How to program a gear ratio into a six motor drive?

We are having problems with programming a gear ratio into our code. Can we get some explanation on how to do it on the way our drivetrain is made? We have a 72 tooth to 48 tooth gear ratio. Our drivetrain code:

const int wheelTravel = 320;
const int trackWidth = 381;
const int wheelBase = 330;
motor_group driveL (LF, LM, LB);
motor_group driveR (RF, RM, RB);
drivetrain myDrivetrain(driveL, driveR, wheelTravel, trackWidth, wheelBase, mm);

We had found this way of a drivetrain on the forum and we believe it is intended for direct drive.
We are newer to Vexcode V5 Pro and we are the only team in our organization that uses this type of drivetrain, so we need the forums help.

1 Like

There is an overload on the drivetrain constructor that allows for a gear ratio (just after distance units).

distanceUnits units = distanceUnits::in;  //Imperial measurements - inches.
double wheelTravel = 4 * M_PI;  //Circumference of the drive wheels (4" x PI)
double trackWidth = 18;         //Distance between the left and right center of wheel. 
double wheelBase = 15;          //Distince between the center of the front and back axle. 
double gearRatio = 1;           //Ratio of motor rotations to wheel rotations if using gears.

//Use the following Drivetrain code if NOT using an Inertial Sensor
drivetrain myDrivetrain(LeftDriveGroup, RightDriveGroup, wheelTravel, trackWidth, wheelBase, distanceUnits::in, gearRatio );
4 Likes

Could you explain a little more about exactly how to find the ratio of motor rotations to wheel rotations please?

That’s just the external gear ratio you described above. So if you have a 72 tooth gear on the motor meshing with a 48 tooth gear on the wheel, the gear ratio is 72/48 = 3/2 = 1.5.

2 Likes

So is that what I would put in that slot?

It’s easier if you start simple. If you have a 24 tooth gear on the motor and a 12 tooth gear touching it, how many times will the 12 tooth gear spin when you spin the 24 tooth once? Answer: two times. After 12 teeth on the 24 tooth gear have gone past the contact point, so have 12 on the 12 tooth gear: 1 rotation. The next 12 teeth on the 24 tooth gear go past the contact point, and so do 12 on the 12 tooth gear: another rotation. So the gear ratio is 2, because each rotation of the motor will spin the driven gear 2 times. Now, how to you derive that from 24 and 12? Answer: 24/12 = 2. So the number of times the driven gear will spin = driver gear teeth/driven gear teeth. And I think this is the number VEXcode wants.

4 Likes

Ok thank you so much I really appreciate it.

So would I put it in as 3/2 since I cannot put it as 1.5?

const int wheelTravel = 305;
const int trackWidth = 381;
const int wheelBase = 330;
const int gearRatio = 3/2;
motor_group driveL (LF, LM, LB);
motor_group driveR (RF, RM, RB);
drivetrain myDrivetrain(driveL, driveR, wheelTravel, trackWidth, wheelBase, mm, gearRatio);

1 Like

gearRatio should be a double, so that line should read:

const double gearRatio = 1.5;
4 Likes

THANK YOU SO MUCH
(20char)