Programming two motors to run simultaneously


#1

Hi,
In graphical RobotC, can someone please explain how to programme two motors (one reversed) which will simultaneously raise and lower an arm.

I assume I must use the command ‘setMultipleMotors’, and then 'stopMultipleMotors? But what command do I use in between? I’ve tried using ‘waitUntil’, but this only allows me to select a value for one of the motors.

Should I use a second gyro sensor and attach it to the side of the robot? Then, I could raise and lower the arm using degrees instead of rotations.

Thanks
Mike

Screenshot 2019-01-30 17.46.20.jpg


#2

Reset the motor encoder on, say Motor 7, then do Multiple motor start and WaitUntil the motor 7 encoder reaches a desired value, then execute multiple Motor stop. Since both are operating the same shaft/axle sensing one should be good enough for both.


#3

Thanks. So should it look like this? Do you know what value 3 is? Is it degrees or rotations?


Screenshot 2019-01-30 19.48.35.jpg


#4

I’m assuming armmotor is motor7. the number is degrees. Try 90. Looks good to me.


#5

Thanks for the help.
We seem to have hit another problem. Commands 10-13 move the robot forward (If we use the ‘forward’ command on its own, the robot moves forward but the arm raises too).
For commands 18-21 we want to move the robot backwards, but we can’t get it to. (If we use the ‘backward’ command on its own, the robot will go backwards but also lowers the arm).
Can anyone see what’s wrong with commands 18-21? We want to move backwards but we don’t want the arm to move.
Thanks



Screenshot 2019-02-01 21.04.56.jpg


#6

I think that the the waitUntil(getMotorEncoder(leftMotor) >= -50 should be <=.

If you had just reset the encoder it is zero which is already greater than -50, so it stops immediately.

Also, shouldn’t the prior setMultipleMotors be -35 to move it backwards?