3pi 3pi+ 32U4 motor speed difference

Hi,

The two motors of my Pololu 3pi operate at different speeds in spite of being set to the same speed.

I’m using a sketch that sets both wheel speeds to 50, and every 5 milliseconds reports the number of rotations per motor. The rotation counts start the same, but the difference between the rotation counts increases over time.

Sample rotation count differences are:

After 1 second - 58
After 2 seconds - 116
After 3 seconds - 174
After 4 seconds - 225
After 5 seconds - 279
After 20 seconds - 787

The vehicle is upside down, so the wheels are essentially spinning freely. When the vehicle is right-side-up, it veers to the right.

Is the difference between motor speeds likely to be a hardware issue? I didn’t assemble the robot, and I know next to nothing about electronics, so I might be overlooking something obvious.

I’m going to try coding so it accounts for the speed difference, but that’s obviously not ideal. Any guidance on how to handle this would be appreciated.

Thanks.

Hello.

I moved your post to the “Robots” section of our forum.

It is common for brushed DC motors to have unit-to-unit variation of ±10% or so. There are a couple ways to account for this. For example, if you are using the 3pi+, you could use the encoders to control the rate each motor spins with closed-loop feedback. Additionally, you could use the onboard IMU (gyro, accelerometer, and compass) to help. You could also try to hard-code an offset (which might be your only option other robot platforms without encoders or an IMU, like the original 3pi), but that might take some trial and error.

Brandon

Hi Brandon,

Thank you for moving the post, and for the information.

I have the 3pi+, so I will look into the closed-loop feedback option. I’ve had limited success adjusting the slower motor speed based on the number of rotations relative to the faster motor speed. The difference doesn’t seem to be linear, so I’m going to change it to dynamically calculate adjustments based on how much impact previous adjustments have. For example, if increasing the slower engine speed by 10% results in the slower motor rotating faster than the faster motor, the next attempt will be by something less than 10%. Is that the kind of thing you’re referring to when you say closed loop feedback? I’ll also look into using the other sensors to compensate.

Thanks!

It sounds like you are describing more of a trial and error approach. By closed-loop, I meant that you could use the encoders to measure the speed of the motors directly, so instead of trying to guess how much you need to adjust the duty cycle to make them turn at the same rate, you could use an algorithm that monitors the speed and adjusts the speeds programmatically. A PID controller is a typical approach for these kinds of applications.

If you are new to PID control, I have seen people recommend the Arduino PID library, so you might consider checking that out, although I have not used it myself as I typically prefer the control of writing my own.

Brandon

Thanks for the information. I will dig into the PID library and see how far I can do. It’s good to know that this can be solved.

David

1 Like