RobotC Problems

Hello,

For the past few days I have been noticing something unusual going on with our robot in our autonomous. This is the code that drives forward and then lifts the arm (in natural language):

motor[leftdrive] = 127;
motor[rightdrive] = 127;
wait1Msec(4000);

motor[leftlift] = 127;
motor[rightlift] = 127;
wait1Msec(500);

The driving forward works perfectly, however, when it lifts the arm, it lifts it too high (we want only a partial lift or a 45 degree angle). We tried reducing the time. We even reduced it to 1 millisecond, but the arm still lifts too high, it lifts at a 90 degree angle instead of 45. All the ports in the program are correct. Can anyone help me sort out this issue? Is this a problem with RobotC or is it me?

Do you know how to set the actual distance the arm is moving? That would be much more accurate. I think you want something like this:

setServoTarget(leftlift, target);

or

moveMotorTarget(leftlift, target, speed);

Hope that helps
Steve

A few other things:

  1. VEX IQ uses the newer style of ROBOTC commands with the “get” and “set” prefixes. So instead of using “motor[leftdrive]”, we recommend you use setMotorSpeed(leftdrive, 100);
  2. The VEX IQ motors are a percentage based value, not a byte value. Speeds are between -100 to +100.

As for Steve’s comment - what you’re doing right now is simply setting the motor to run at a specific speed (maximum speed, at that) - and not utilizing the encoders that are built into the motors. Try out the following code - it will move the two “lift” motors one rotation and then come to a stop automatically.

moveMotorTarget(leftlift, 360, 50); //this will move the motor for 1 rotation (360 degrees)
moveMotorTarget(rightlift, 360, 50); //this will move the motor for 1 rotation (360 degrees)
waitUntilMotorStop(leftlift);
waitUntilMotorStop(rightlift);

Thank you very much, I will try using moveMotorTarget in order to achieve what I want to achieve. You both have been a lot of help. Thank you again!