Programming Issue

Hello,

I use RobotC, and had a theory; is there possibly a way to push a button on the controller, and have the arm go to that height. Also say if we wanted two heights(preferably) and two pots. On each arm. Could this be done in Driver control?
Thanks a lot

Sorry, if so some code would be dearly appreciated
Cheers,

Take a look at this post.

https://vexforum.com/showpost.php?p=332277&postcount=1

You could also wade through the 90+ posts in this thread from last year.

https://vexforum.com/t/team-323z-code-help/22504/1

I’m sure we must have covered arm control in that one as well.

How to keep 2 arms synchronized with a pot on each:
https://vexforum.com/t/help-with-running-two-motors-in-sync/25119/1

We have these two methods that we use to control the arm to a certain level. This is kinda pseudocode; sorry that I don’t have the actual code with me.

void waitScissorPot( int direction, int height )
{
   if( direction is up )
   {
      while( sensorvalue of left and right potentiometers are less than specified height )
      {
         wait a reallllyyy small time
      }
   }
   else //down
   {
      while(  sensorvalue of left and right potentiometers are more than specified height )
      {
         wait a reallllyyy small time
      }
   }
   stop lift motors
}

void lift_to_pot( int direction, int speed, int potVal )
{
   set all lift motors to specified direction and speed
   waitScissorPot( direction, potVal );
}

As for controlling arm levels during driver control, I would assume that you could just assign your joystick buttons to lift actions in your operator control, implementing the above methods. For example:

if( vexRT[Btn5UXmtr2] == 1 )
{
   set lift motors/powers
}
else if( vexRT[Btn5DXmtr2] == 1 )
{
   set lift motors/powers
}
else if( whateverbuttonyouwannause == 1)
{
   lift_to_pot( up, 127, 3000 )
}
else
{
   stop lift motors
}

If I’m wrong or my code has obvious flaws in logic, please correct me. I’ve heard that doing “smart buttons” may be problematic in that you don’t have a cancel button. So like if you’re under the 12-inch bar and accidentally press the button, your lift will continuously try to go up even with that barrier. But I’m sure there are ways around that using timers and such.

Anyways, I don’t know if what I said makes any sense, but I wish you the best of luck.

Thanks, this actually helps a lot

This reminds me of another post in the ROBOTC programming tips thread that may be of interest.

Handling errors and boundary conditions

The post talks about using timeouts, detecting lack of movement and keeping track of battery voltage so that an arm on a power expander does not go out of control.