adafruit / Adafruit_CircuitPython_Motor

Helpers for controlling PWM based motors and servos
MIT License
63 stars 39 forks source link

Servo motors are not disabling/releasing after setting angle to None #65

Open scprotz opened 1 year ago

scprotz commented 1 year ago

I'm using a Raspberry Pi 4 to control the PCA9685. I have generic MG996R-style servos connected (2 different brands). When I set the servo.angle = None, the servos just hold their current position without releasing.

I'm using servokit 1.3.13, pca9685 3.4.6, and motor 3.4.5

(I do have a version on a different raspberry pi that is running servokit 1.3.6, pca9685 3.39 and motor 3.3.2 that does work correctly, though it uses a different brand of servo).

I am not quite sure if this is due to a regression or certain brands of servos not recognizing the angle = None.

Any insight would be appreciated. I may try to upgrade the second raspberry pi and see if those servos get the issue. That would help narrow down if this is a per-servo-brand bug or a regression.

Recelis commented 1 year ago

I have the same issue too. My micro servo motors are disabling correctly but it seems like the bigger servos 1501MG https://www.pololu.com/product/1057 aren't being disabled.

ladyada commented 1 year ago

do you know that the motors will 'release' when not receiving a 50hz signal because thats the only way to release motors - if your servo doesnt do that, it has nothing to do with this firmware

scprotz commented 1 year ago

How can we programmatically tell it not to send the 50hz signal then. I would have thought setting angle = None should do something like that. Is there another command?

scprotz commented 1 year ago

So just a note. It appears I can set the duty_cycle to nothing and it turns off this type of servo.

There are two ways (which are effectively the same based on the source code in github):

either kit.servo[0]._pwm_out.duty_cycle = 0

or kit.servo[0].fraction = None

Both of these turn off duty cycle 'release' the motor.

scprotz commented 1 year ago

I misspoke. This does not release the motor. It just stops the duty cycle. I'll play around and see if there is another way to cut power completely to the servo.

arnaudbore commented 1 year ago

@scprotz do you have any update on this? It feels like you've been working with this for quite some time. If you have some time can you answer #73 ? Thank you in advance

scprotz commented 1 year ago

Just wanted to add another comment. I have tried a number of things and still certain brands of motors will not disconnect/release when I set fraction = None, nor Angle = None. It appears there is a way to turn off the servo pins on the PCA9685. On this page: https://learn.adafruit.com/16-channel-pwm-servo-driver/library-reference It states that (using an Arduino), I can setPWM(1, 0, 4096) to disable the servo pins (and I hope turn off the servo).

Is there a way to do the same with CircuitPython_Motor (or one of the lower level APIs)?

scprotz commented 1 year ago

Extra notes: https://forums.adafruit.com/viewtopic.php?f=22&t=178641 says that setting the PWM duty_cycle to 0 should shut off the PCA9685 pins, but again, this does not seem to be the case as some servos continue to 'hold' even after setting the duty cycle to 0 for those servo's pins.