Maestro Arduino Programming - setSpeed command

mqtt_try_1_w.o._wifi_cred.ino (3.7 KB)
Hi support,
When talking arduino to maestro via serial and the Pololu Maestro Servo Controller library for Arduino, I have working code that will manipulate a servo using the Micromaestro; however, I’m having trouble with the maestro.setSpeed(0,1) command; I’ve tried adding it to my setup() as well as just prior to my setTarget command. Neither code string slows the servo and it does not change as I manipulate the speed variable up or down. The speed, regardless of what is used in the setSpeed command, corresponds to full servo speed (i.e., 1, 2, 10, 10 speed are all the same as speed 0). Changing the speed does work as intended when controlling in the Maestro software. Any thoughts?
Arduino code attached for reference. The program generally is talking software serial to MQTT to homeassistant.

It looks like every time you move the servo, you follow it up by disabling the output on that channel (i.e. setting a target position of 0). Please note that speed and acceleration limits cannot be applied to the first movement after startup or after a channel is disabled.

To apply a speed or acceleration limit, the Maestro breaks up the commanded movement into many smaller movements. This means it needs to know where the servo current is in order to calculate the next movement. After a channel is disabled (or the Maestro is first powered up), the Maestro has no way of determining what position they are in. More information about this can be found in the last FAQ under the “FAQs” tab of the Maestro product pages.

You might be able to get around this (if you don’t expect the servo to move after being disabled) by storing the target position it was in before the channel was disabled, then when you want to move the servo again, first send the stored target position, followed by your desired speed/acceleration limit, and then the next position you want it to go to.

Brandon

BrandonM,
I didn’t catch that disabling the servo caused the controller to lose track of its position. My intent is to allow movement in case it’s required, but under normal circumstances the servo will not be moved. I will store the target position. Thanks for the quick response!
Ben

1 Like