Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8621

Troubleshooting • Re: Cannot control a servo motor precisely

$
0
0
Hi,
this is my first time working on RPIs and GPIO. I've successfully connected a servo motor (this one) to my RPI5 and made it move. However, I'm unable to control it accurately. This is the code I'm using:

Code:

from gpiozero import Servofrom time import sleepmaxPW = 0.0024minPW = 0.0004servo = Servo(4, min_pulse_width=minPW, max_pulse_width=maxPW)servo.value = -0.5sleep(1)print(servo.value)servo.value = 0.5sleep(1)print(servo.value)
when I print the servo value I get -0.6 and 0.4 respectively. I also tried using AngularServo but it has the same problem.
To power the servo I'm using the PI's 5V, I know I'm not supposed to do that (it's just temporary) but I don't think it would impact the precision of the movement (?). Is this behaviour expected? If not, what could be the root problem of this? Maybe a low quality servo, the software PWM?
Thanks for the help


My principle suggestion would be to ask the developers of gpiozero via their Issues page, here - https://github.com/gpiozero/gpiozero/issues



But I would observe that the documentation for gpiozero.Servo at https://gpiozero.readthedocs.io/en/stab ... html#servo only refers to the use of Servo.value to SET a value. Maybe attempting to use it to GET a value is not an expected usage and returns an unreliable result?
I also thought that it wasn't a reliable way to tell where the servo is "located" but examples all over the internet used it in that manner.

Statistics: Posted by _FranK_ — Tue Jan 30, 2024 12:43 pm



Viewing all articles
Browse latest Browse all 8621

Trending Articles