Servo.stop_servo sometimes moves servo when turning it off
markfickett opened this issue · 1 comments
A simplified version of my program is:
import time
import RPIO
import RPIO.PWM
servo = RPIO.PWM.Servo()
while True:
servo.set_servo(17, 940)
time.sleep(1.0)
servo.set_servo(17, 2060)
time.sleep(0.5)
servo.stop_servo() # line at issue
time.sleep(0.5)
The problem is that if I call stop_servo()
, then some of the time (maybe 1/20 or 1/100), the servo jerks back to a different position before the signal turns off. (I'm using a Tower Hobbies micro servo, metal geared.) Is it maybe cutting out mid-signal so it looks like a shorter pulse than it is?
The overall goal is to move a tub with a die in it back and forth, to roll the die. My servo motor sometimes shakes (I think this is a problem with the servo motor, not the Pi or RPIO, since it started happening recently). So I'd like to turn off the signal and leave the servo motor steady when I'm not moving it, instead of having a constant signal. But when I call stop_servo()
it sometimes jerks, up to 20º maybe, which is worse than twitching a little bit, the problem the servo motor has on its own. (This is the full program though currently I haven't pushed a version with the stop_servo
call since it's not working well for me.)
On another note: Thanks very much for making RPIO. It's been very easy to use (and to install), and has generally worked great.
did not have a look at the actual code stopping DMA writes.
but from the general idea how the lib works it is possible that it stops the DMA (at the end the "signal") in the "middle" instead of finishing a complete cycle.
if this is the case a workaround would be: only turn of in a multiple of cycle length.
edit:
I think this is exactly what happens:
source/c_pwm/pwm.c : clear_channel_gpio : 443+