3

I have been working on controlling servos in one direction with PWM control via GPIO ports on my RPi 3. I've worked with motor controllers that use PWM before and it seems that I should be able to provide negative PWM values to indicate the opposite direction, but GPIO seems not to allow that. For my current project, I do need to be able to control one servo in both directions. (Precise positional control would not be necessary, I just need to be able to control direction)

I have found an alternative solution where I can create a jank analog device by hooking up a resistor and capacitor in parallel. If I were to try to achieve positional control of the servo, could I potentially use analog information from this strategy to do so?

11
  • 2
    But you can adjust PWM duty cycle to turn servo motor CW or CCW, normally within a range of about 180 degrees.. PWM duty cycle is defined from 0% to +100%. Negative PWM duty cycle is unthinkable.
    – tlfong01
    Mar 26 '20 at 6:16
  • 3
    Perhaps look at a wiki to understand how servos are controlled. Nothing to do with the Pi.
    – joan
    Mar 26 '20 at 6:32
  • 1
    @tlfong01 Can the direction be switched upon command? I've read about a hardware solution but my project requires automatic control. Mar 26 '20 at 6:32
  • 1
    Yes, I would suggest three methods: (1) using GPIO pin in PWM mode, (2) using L298N DC motor/servo driver, also using GPIO pins in PWM mode. (3) Using PCA9685 PWM Controller. You can search this forum using key words "servo", "PWM", "L298N", PCA9685" to find more details. Lady Ada's tutorial is a good start: adafruit.com/product/815. Good luck and cheers.
    – tlfong01
    Mar 26 '20 at 7:01
  • 1
    Thank you so much! I will look into all of these :) Mar 26 '20 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.