Trouble with micro servos.
-
I'm trying to run a micro servo from a PWM connection on my Duex 5, but I don't seem to be able to get it to move at all with what I think are the correct settings. I can get some movement if I change the PWM frequency to much higher than it should be, but it never moves to where I think it should.
The servo is an MG90S. I have tried swapping it (I bought a pack of 3), but no change. It is connected to PWM_5 on my Duex.
I'm running:
- Duet 2 WiFi with Duex 5
- RRF 3.3
I have separate 5V power connected to the Duex's 5V Aux In and the jumper changed to select this.
According to the internet, the servo expects a 50Hz PWN frequency, and a 1ms pulse should put it to the minimum position, a 1.5 ms pulse should put it to the middle and a 2ms pulse should put it to the maximum position.
I think I should configure the servo with:
M950 S0 C"!duex.pwm5" Q50
and then set its position with, ie:
M280 P0 S1000 M280 P0 S1500 M280 P0 S2000
for the positions mentioned above.
This does nothing, except turn on the LED next to the heater 7 output (I have nothing connected to any of the duex heaters).
If I instead do:
M950 S0 C"!duex.pwm5" Q500
then the position commands do cause movement, just very small amounts, definitely not going to the correct positions.
Different values of Q give different results, 250 gives some big movements, but I'm fairly sure I shouldn't be changing that number at all.
Please help me, I have no idea what I'm doing.
-
@ernst-blofeld
AFAIK, for servos you don't set any Q-value.
Make sure you have sufficient current to move the servo (external 5V perhaps) -
@ernst-blofeld use:
M950 S0 C"duex.pwm5"
Don't invert the pin, and there is no need to specify the frequency.
-
@dc42 said in Trouble with micro servos.:
@ernst-blofeld use:
M950 S0 C"duex.pwm5"
Don't invert the pin, and there is no need to specify the frequency.
Thanks Dave, my servo is now moving, but only 90 degrees between min and max, where I expected 180 degrees. Any ideas on that?
-
@ernst-blofeld what commands are you sending to move it to the ends of its range?
-
@dc42 said in Trouble with micro servos.:
@ernst-blofeld what commands are you sending to move it to the ends of its range?
M280 P0 S1000
to send to minimumand
M280 P0 S2000
to send to maximumExperimentally, I can get 180 degrees by using S600 for min and S2400 for max. I don't know what that means. Values below 600 seem to cause it to spin round to the other extreme and values over 2400 seem to be ignored.
-
The docs for M280:
From the docs for M280:
S values below 544 are treated as angles, and 544 or greater as the pulse width in microseconds.
-
@fcwilt said in Trouble with micro servos.:
The docs for M280:
From the docs for M280:
S values below 544 are treated as angles, and 544 or greater as the pulse width in microseconds.
Yes! I'd become fixated on using the pulse width. S0 through S180 seem to work as expected.