0

I'm currently developping (improving) an Octoprint plugin that is used to control servo motors with the pigpio library. I always thought that I had to initialize the servos at the start of the code by sending a pulsewidth of 0 μs, doing pi.set_servo_pulsewidth(pin, 0) on Python http://abyz.me.uk/rpi/pigpio/python.html#set_servo_pulsewidth .

My problem is that I need to read the actual angular position of the servo on start. And after "initializing" it, I would get '0' after settings the pulsewidth to 0 by using pi.get_servo_pulsewidth(pin) on the same GPIO.

After reading the doc, I think that I just don't need at all to initialize the servo, and I could get the actual pulsewidth at the start of the code....

Does anybody could answer me by experience or try it please ? I don't have any Raspberry or servo motor where I am currently.

Thanks

1 Answer 1

0

Servos move to a commanded position when given a valid pulse width. A pulse width of 0 is used to tell pigpio to stop sending servo pulses.

The get_servo_pulsewidth() function tells you the last commanded position. It tells you nothing about the current servo position.

Most hobby servos provide no method of discovering the position. You need a special servo or additional hardware to find a servo's position.

2
  • Never knew such things existed. Just been reading up on the and resistive and Hall effect versions - not cheap to say the least.
    – user115418
    Nov 13, 2020 at 22:55
  • Thank you very much for this answer. I hopefully have the solution to send a "autohome" position on server startup, but this movement will be harsh... After this, I can easily track the current position. Happy day!
    – Franfran
    Nov 14, 2020 at 1:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.