Help applying gear ratios to motor speeds

Hey, I’m having trouble figuring out if there is a proper way to apply gear ratios to the speed of motors in the code.

Specifically I’m wanting to know if there is a way to apply gear ratios to the speed mathematically in such a way that the motors will always be running at the maximum possible speed without causing problems among the other motors.

For example, say I have three motors attached to a single wheel, and each one has a different gear ratio between it and the wheel. Is there a way that I could apply all of the ratios to the speeds of the motors in order to ensure that the speed of one does not force a different speed on another motor.

Any help would be greatly appreciated. I know it seems to be an obscure problem but there is a practical reason for it. Thanks in advance!

I guess theoretically you could.

I’m not sure if this is what your asking, but;
Take the fastest ratio, set that as 127, and then all the other ratios can be proportional to that.
For example, you could have a 5:1, 3:1, and 1:1, set the 5:1 as 127, 3:1 as 76.2, and 1:1 as 25.4. But I don’t think thats how motor really work, PWM output from 0-127 doesn’t directly correlate with RPM. I guess I’m missing the practicality of this. Can they not all have the same gear ratio?

They can, but I’m working on a program that helps users with their autonomous, so I am simply trying to account for edge cases like this, just so that I have to do as little updating as possible later. This is actually the last bit of the program that I need to finish, but I just don’t have the knowledge necessary myself to be able to figure this part out.

Oh, and one last thing. I am hoping that there is a way to make this work no matter how many motors are attached to a wheel.

That’s it. I just need to figure this out, and my program will be done. Like I said, any help is welcome.

This is not really an edge case that you want to account for. Best practice is (obviously) to just not have different gear ratios to the same axle.

Solving this is also quite sketchy, since scaling the motor power by the ratio won’t really always be perfectly proportional to the velocity.

Motor speed does not increase linearly, instead it is more logarithmic. Here is a good post detailing this and how to (sort of) fix it.

However, I agree with the rest of the commenters that there really isn’t a point in making different ratios unless you have some crazy transmission or something- you’re always limited to, at most, the speed of the slowest motor. The rest of the motors would be artificially slowed, which just means less torque with absolutely no speed gain at all. If you really want to account for this edge case, use trueSpeed and the method @jack202020 explained. Just keep in mind that even this will not be entirely perfect, especially if you’re making a library that will be used on multiple robots, and realistically nobody should be making a chassis like that anyway.

Well, don’t forget that with the smarter V5 motors you can set a speed instead of a related value we used with the 393s. I don’t think the OP said what motors are being used. @KoalaKing , what motors are you using? If they’re V5’s, you’re in luck.

Now, assuming they are V5’s, you can do roughly what was suggested by @jack202020 , but don’t use 127. You want a number that is divisible by all the gear ratio values you will be using. For example, using the 5:3:1 example, multiply that 5:3:1 all by the same integer, whatever it is so long as 5 times that integer doesn’t exceed the maximum integer you can functionally use. So, for example, 100:60:20 would work.

But I really don’t recommend this in general. It’s likely the same type of motor is being used, so I would expect a goal of more evenly distributing the torques between the motors so they can all function more efficiently.

My program would (or at least, I was hoping it would) be able to ask the user what type of motor is being used: 393 or v5. Unfortunately, based on what I am seeing, there does not appear to be a right way to do this, but fortunately, again based on what I’m seeing, it’s not something I need to take into account anyways. That makes things easier, so thank you to everyone who responded. I’ll just write a note to go with the program saying that if they are doing that for whatever reason, that they need to figure that out themselves.