Actual Zumo Motor Resolution?

The ZumoMotors lib uses a range of 0 to 400 for speed control.

Assuming we are using Timer1 and the 20Khz PWM, what does this translate to at the motor driver end of things? Is the effective voltage really divided up into 400 distinct levels? I’d assume there is some degree of slop and fluctuation inherent in the system.

Just curious, what is the practical resolution of the seed control?


In order to achieve an ultrasonic (20 kHz) PWM frequency, Timer 1 is configured to overflow at a count of 400, and the speed you set determines at which count the timer compare match generates the falling edge of the PWM duty cycle. So yes, the voltage is divided into 400 distinct levels (or 401, if you count 0). You can see the code that accomplishes this here: … Motors.cpp

I am not really sure how to address your “practical resolution” comment, though. You should be able to relatively smoothly vary the voltage on the motors, and how they respond will depend on the particulars of the motor and the chassis, and even current state of the system can have an effect (e.g. setting the motors to speed 100 from rest might not be enough to get them started, but you might be able to achieve speed 100 once the robot is moving). In general, you should not be surprised to see the performance of DC motors vary from unit to unit (e.g. putting the same voltage on both motors probably won’t result the robot driving straight; usually that requires calibration or closed-loop feedback).

- Ben

I was guessing it’s a question without a specific answer.

The reason I’m curious is that I’m tuning a PID controller and was wondering how effective adjusting a motor by 1/400th was really going to be. Not that that matters with PID as it is a feedback loop but I was wondering when the error gets down to adjusting the motors by only a few units (say between 1 and 5) then are those adjustments going to be lost in the noise?

I guess the noise will become apparent as I collect data from the system. At first blush the noise looks minimal but I’ve only done a few runs so far.

It sounds like you are mostly just wondering if ~9-bit speed resolution is overkill, and it probably is. The main reason for having 400 speed levels is that it results in a 20 kHz PWM frequency when using Timer 1 on the Arduino; having more speeds would decrease the frequency and make it potentially audible without contributing much while having fewer speeds would make the frequency higher, which is also not desirable since that increases switching losses and makes the H-bridge MOSFET dead time more costly. I suspect you would not perceive a difference in performance between a robot with 9-bit speed resolution and one with 7-bit speed resolution (that doesn’t mean there isn’t a real difference, it just means it’s too small for you to notice just by watching and it might very well get lost in the noise if you were to try to measure it without an appropriate filter).

- Ben