4 Motor Programming

Hi, we are new to the vex forums. We were wondering how to program a 4 motor drive in Vex CTT. We just want to know how to run 4 motors at the same speed at the same time. Thank you for any help!

I’m assuming you mean Vex C++? With VCS? With controls?

A simple code for running all motors at the same power in VCS would be:


Motor1.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
Motor2.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
Motor2.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
Motor2.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);

If you want a drive program, use this as a page on it: https://help.vex.com/article/111-vcs-example-program-with-controller-c-tank-drive

If you want to add additional drive motors to a drive, do something like this:


FrontLeft.spin(vex::directionType::fwd, Controller1.Axis3.value(), vex::velocityUnits::pct);
BackLeft.spin(vex::directionType::fwd, Controller1.Axis3.value(), vex::velocityUnits::pct);
FrontRight.spin(vex::directionType::fwd, Controller1.Axis2.value(), vex::velocityUnits::pct);
FrontRight.spin(vex::directionType::fwd, Controller1.Axis2.value(), vex::velocityUnits::pct);

Also keep in mind the motors will need reversed on one of the side of the drive in the configuration.

@jack202020 gave some good instructions. But also keep in mind that if you want to code the motors to rotate using the encoders, there is an optional boolean at the end of certain commands. So if you use these

rotateTo(double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)
rotateFor(double rotation, rotationUnits units, double velocity, velocityUnits units_v, bool waitForCompletion=true)

you’ll want to include that optional boolean to make sure only the last of the motors you set actually waits for completion. Or you could use these instead:

startRotateTo(double rotation, rotationUnits units, double velocity, velocityUnits units_v)
startRotateFor(double rotation, rotationUnits units, double velocity, velocityUnits units_v)

What about a 4 or 2 motor drive in autonomous. Like in Easy C there was a multimotor time Control box. What would the code for that be?

You can also use rotateFor() for time.