Zumo PID Clarification

Hey -

Pololu describes PID behavior in the example application RotationResist for the Zumo32U4 - it looked like this:

// Calculate the motor turn speed using proportional and
// derivative PID terms. Here we are a using a proportional
// constant of 56 and a derivative constant of 1/20.
int32_t turnSpeed = -(int32_t)turnAngle / (turnAngle1 / 56)
- turnRate / 20;

I was wondering if you could do a little more to describe how PID behavior works. For example, for the Zumo robots, speed is set to +/- 400 which I think assumes a 75:1 motor gear ratio. I don’t thing there is any concern with using these max speeds with what I have - a 100:1 gear ratio, but 100:1 gear ratio may be better suited with a +/- 320 max speed setting (based on wheel rpm); however I notices that +/- 400 is just the speed ratio and could be used for all other gear ratios. Unlike your excellent work on the gyro system which only requires one set of reference variables, the motor system changes with gear ratio, so I’m looking for more insight on that.

Other info that should probably be added to the Micro Metal Gearmotor table that may be useful:

51.45 x 12 = 617.4 CPR (wheel)
75.81 x 12 = 909.72 909.7 CPR (wheel)
100.31 x 12 = 1204.44 CPR (wheel)

40/(625/60) = 3.84 inches per wheel revolution
25/(400/60) = 3.75 inches per wheel revolution
20/(320/60) = 3.75 inches per wheel revolution

3.84/617.4 = 0.0062 inches per count
3.75/ 909.72 = 0.0041 inches per count
3.75/1204.44 = 0.0031 inches per count

1/0.0062 = 161.2903 counts make an inch
1/0.0041 = 243.9024 counts make an inch
1/0.0031 = 322.5806 counts make an inch

Let me know what you think.

I am not sure I understand what you are asking. If you are asking for more information on how PID control works, you might find the “PID controller” entry on Wikipedia helpful. In general, you should not need to change the max speed if you are using a different gear ratio, but you will likely need to re-tune your PID coefficients.

Thank you for your suggestion; we will keep it in mind. By the way, I am a little confused about your calculation for inches per wheel revolution. This spec should essentially be the circumference of the wheel (or the equivalent for a tracked robot like the Zumo 32U4). The gear ratio should have no affect on the inches traveled per wheel revolution.


Hey Brandon - thank you for your response.

It would be great if a tutorial could be created to boiled PID control for the hobbyist and apply it to the Zumo robot. I’ll leave that for you at Pololu to decide, but the little bit of time your engineers spend on this effort will go a long way in the robotics community.

Gears to inches was just a step to get from quadrature encoders to inches. Encoders to inches is probably something that should be added to the motor table.

Thanks again -