Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Clarification of Maestro speed control and acceleration control

#1

I apologize if these questions have been answered, but I could not find answers in the forum (tho one from 2008 came close).

I have a Maestro Micro. The User’s Guide says “The speed limit is given in units of (0.25 μs)/(10 ms)”. I extrapolate to assume that the Maestro changes the target every 10 ms. True?

If this is true, with the speed is set to N, every 10 ms, the Maestro adds N x 0.25μs to the target. True?

With my servo, 0 degrees is 815 μs and 180 degrees is 2125 μs (it is designed to travel 270 degrees). That means for the servo, there are 7.278 μs/degree, which equates to 29.111 0.25μs units per degree.

I wish to move 0.5 degree and then stop, do something (sample a LIDAR device), and repeat. 0.5 degree is 14.556 (0.25μs) units. Round the target delta to 15 units. If I set the speed = 1. I think it will take 14 10ms periods to move to the desired target (assume the initial target is (current position + 1) is at time 0. Using the same logic, if the speed = 2, I think it will take 7 periods. If the speed = 4, I think it will take 3 periods. If the speed = 5,6,7, I think it will take 2 periods. If the speed = 8-14, I think it will take 1 periods. If the speed >= 15 I think it will take zero periods, since the new target is (current position + speed > = new target).

Does this make any sense based on the true operation of the device?

The User’s Guide says “The acceleration limit is a value from 0 to 255 in units of (0.25 μs)/(10 ms)/(80 ms)”. I infer that the speed can change only every 80 ms. Is this true?

In my 0.5 degree use case above, the time to reach the target is only greater than 80 ms when the speed is 1. That seems to suggest that acceleration either fails or does nothing for speeds 2-14. Have I got that right?

Thanks for any illumination on these subjects.

#2

That is not correct. The Micro Maestro does update the position variable for each servo every 10 ms. The target is not changed regularly; it represents the final value that you want the position to move towards over time. One way to change the target is to send a “Set Target” command to the Maestro via USB or TTL serial.

If the speed of your servo channel is N, then the Micro Maestro will generally increase or decrease the position of the servo by N quarter microseconds every 10 ms while the servo is moving, but the actual change in position also depends on many other factors, including the acceleration limit, the current velocity, the current position, the target, and the configured minimum and maximum values for the channel.

Your numbers for how long the those movements will take are basically correct. The number of updates needed to move 15 units is simply 15 divided by the speed, rounded up.

If you have enabled an acceleration limit for your servo channel, then its velocity can only change every 80 ms. If the acceleration limit is set to 0, then the acceleration limit is disabled, and the velocity can change every 10 ms.

The acceleration limit does not “fail” or “do nothing” if you have enabled it. If the entire movement takes less than 80 ms, it will happen at a constant speed since the Maestro does not have a chance to further increase the speed.

If you need to look at the timing with this level of detail, there are some more things to keep in mind: The servo position and velocity updates happen on their own schedule that is not affected by the timing of your commands to the Maestro. The Maestro’s “Period” setting determines how often pulses are actually sent to the servos, and it is 20 ms by default. Also, there is no guarantee that your servo can actually move fast enough to keep up with the pulses that the Maestro sends.

I also recommend that you take a look at the Maestro Movement Calculator, which you can find in the “Resources tab” on the Micro Maestro product page.

–David

#3

Thanks. An extremely helpful response. It does, however, raise other questions. Some of these may not belong in the domain of support; feel free to ignore such.

First, I ran the calculator for a fixed ‘current position’ and ‘new target’. As you suggested, it produces numbers that were related to mine with zero acceleration. Each time was 20 ms longer than my calculations. I believe this is because the calculator assumes a 20 ms period, which is what I am using.

I infer from this that the servo electronics can only sample the incoming PWM signal once per period (must wait for the falling edge to know the width of the pulse, and then must wait for the rising edge to begin a new sample). Thus even when both speed and acceleration are 0, the approximate movement time is 20 ms. True?

The previous assumption makes me wonder why the Maestro changes the pulse width every 10 ms. If the period is 20 ms, the change happens faster than the servo can react. I am probably missing something obvious. Can you elaborate?

The above “real world” aspects of servo control and response made me consider the “dead band”. In my perhaps overly simplified thinking, if the actual position reported (to the servo electronics) by the potentiometer differs from the target defined by the pulse width by plus or minus 1/2 of the dead band, the motor gets driven to reduce the error. My servo has a dead band of 3 μs. Thus if the difference between the target pulse and the reported position is less than 1.5 μs (6 0.25 μs units), the servo won’t move at all. Thus a speed less than 6 seems questionable (tho since changes occur in 10 ms, maybe not). Does this make sense?

Thanks.

#4

The details of how the Maestro Movement Calculator program works are not related to how your servo reads pulses, and it is only an approximate calculation anyway. I do not know the details of how your servos process the pulses from the Maestro or how long it would take them to respond.

Our blog has a series of articles about servos and their control protocol that you might find useful.

Regarding your second question: the Maestro sends pulses every 20 ms by default, but that is a configurable setting that you can change if you want.

What questions do you have about speeds less than 6?

–David

#5

I think I mixed up two different but related subjects, and also did not really explain anything well. I will try to do better below. BTW, I found the blog quite informative.

Instead of talking about the Maestro target and position, let me talk about the control signal the Maestro generates to drive a servo. The Maestro by default uses a control signal period of 20 ms. The control pulse width is generally between 1000 μs and 2000 μs. In part based on material in the blog, I feel pretty confident that any servo can only determine the control pulse width once per control signal period. This is because the servo electronics must see a rising edge (start the pulse) and then a falling edge (end the pulse) to be able to determine the pulse width.

The Maestro, when doing speed control, “logically” changes the pulse width every 10 ms. I say logically because the actual pulse of the control signal can only change every 20 ms (with the default period). I think that means that the “logical” pulse width changes twice as fast as the physical pulse width. Thus, with the default 20 ms pulse period, when doing speed control with a speed of N units, each physical control pulse is 2xN units more or less than the pulse in the previous period.

To test this assertion, I connected an oscilloscope to one of the Maestro channel outputs. I used the default 20 ms pulse period. I set the speed to 50 and acceleration to 0. Using the Control Center, I requested the channel to move from roughly 1000 μs to 2000 μs and captured a subset (6) of the control pulses during movement. I determined the pulse period was 20 ms. I measured the first pulse width at 1512 μs and the last pulse width at 1640 μs, with the difference of 128 μs. That means the change in pulse width is about 25 μs per pulse period. By my calculations, a speed of 50 means that the Maestro changes the pulse width by 12.5 μs every 10 ms, or 25 μs every 20 ms. The difference between 125 and 128 is certainly within a reasonable measurement error. I measured some of the other pulse widths and they too were within measurement error of 25 μs different than adjacent pulses. I think this confirms my assertion.

The question about speeds less than 6 is really only relevant for my specific servo in a specific situation. And I think I’ve answered it myself now. Feel free to skip the rest of the post. That said … Since my servo has a dead band of 3 μs, any change is the control pulse width has to be greater than 1.5 μs (or 6 0.25 μs units) to force a movement by the servo. Per the above, however, a speed=6 means that the physical pulse width changes by 12 units (3 μs) every period; that is sufficient to cause movement. So really, it is a speed of 3 that is a bit problematic, as then the change would be 1.5 μs per period, which might or might not cause movement.