Multiple Drivetrains in VexCode Program

Right now, my team and I are creating a robot with an intake. We are using the drivetrain aspect of the code on the two motors being used for intake, so that they can move simultaneously. But we need another drivetrain-type aspect so that we can move the motors connected to the wheels at the same time. As far as I know, there is no way to have two drivetrain’s on Vex V5 Text. This is our first year doing any form of VEX and we are all new to coding.

Is there any way to create two drivetrain’s or have two motors move at the same time otherwise?

1 Like

no, you can’t have more than one drivetrain.

spin two at a time:

motor.spin(direction, power, units);
motor2.spin(direction, power, units);

//using blocking commands
motor.spincommand(params, false);
motor2.spincommand(params, true);

using motor groups

motor_group name(motor,motor2);

To be more precise, the graphical configuration wizard won’t let you configure more than one drivetrain. As far as I’m aware there’s nothing stopping you from initializing multiple drivetrains manually. But if you are new to c++ its probably not recommended to do this without some additional experience/practice.


How do I configure multiple drivetrains without the graphical interface? Do you have some example code? Thanks.

you would have to go into robot-config.cpp and manually add the new drivetrains as well as adding them to robot-config.h. (You can use the automatically configured one as an example)

I do want to point out that drivetrains are meant to make the code for newer teams simpler. If you are going to go through the effort of adding more drivetrains I would think that it would be better to just outright not use them since it might only make things more confusing when you apply drivetrain terminology to something that isn’t a drivetrain.


Agreed. The motor_group seems like a much more reasonable abstraction to a 2-motor intake system than a drivetrain. See: VEXcode, motor groups and drivetrain example


We are using motor groups to move our robot forward. (We are using drivetrain for intake.)

We have 4 motors attached to the 4 wheels.
The two left wheels motors are in one motor group and the two right wheels motors are in another motor group.

The issue we are facing is that in autonomous programming we cannot find a way make the motor move a set number of rotations and at a set speed.

motor_group wheelsLeftMain(motor1,motor4);
motor_group wheelsRightMain(motor3,motor5);

We tried-
Here the robot moves forward but does not stop at the set rotation.

We tried-
Here the motors move separately instead of together.

Please let me know what I am doing wrong.

you already asked this in a different thread and I answered it there:

You can pass the wheelsLeftMain and wheelsRightMain motor_groups into the drivetrain class constructor. Or, there is now a 4-motor drivetrain available from the graphical interface that will do this for you.

As far as using motor_groups to spin for a certain amount of rotations:

bool vex::motor_group::rotateFor	(	double 	rotation,
rotationUnits 	units,
double 	velocity,
velocityUnits 	units_v,
bool 	waitForCompletion = true 

So you should be able to do (since both rotateFor and spinFor do the same thing):

wheelLeftMain.spinFor(360, deg, 40, pct, false);  // The false here says not to wait for the motor group to move the 360 degrees.
wheelRightMain.spinFor(360, deg, 40, pct, true); // The true here says to wait for the motor group to move the 360 degrees. This assumes that the Left motor group will finish spinning at nearly the same time. This assumption may not always be true

I’ve not actually tested this code to see if it works or compiles, but it should be close enough.

If you were to use the drivetrain class, you would be able to use:

bool vex::drivetrain::driveFor	(	double 	distance,
distanceUnits 	units,
bool 	waitForCompletion = true 

Here, you should be able to specify how far, in inches, to move:

dt.driveFor(12, distanceUnits::inches);