0

I modified two Futaba S3003 servos for continuous rotation according to this instruction: http://terrencejpiman.blogspot.com/2015/04/continuous-rotation-futaba-s3003-servo.html?m=1.

It seems to work pretty good (forward and backward), but I can't get them stop.

My code is like this:

import RPi.GPIO as GPIO
import time

servoPIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(servoPIN, GPIO.OUT)

p = GPIO.PWM(servoPIN, 50) # GPIO 17 als PWM mit 50Hz
p.start(2.5) # Initialisierung
try:
  while True:
    p.ChangeDutyCycle(5)
    time.sleep(0.5)
    p.ChangeDutyCycle(7.5) # 90 deg: this should be the stop position
    time.sleep(0.5)
    p.ChangeDutyCycle(10)
    time.sleep(0.5)
    p.ChangeDutyCycle(12.5)
    time.sleep(0.5)
    p.ChangeDutyCycle(10)
    time.sleep(0.5)
    p.ChangeDutyCycle(7.5)
    time.sleep(0.5)
    p.ChangeDutyCycle(5)
    time.sleep(0.5)
    p.ChangeDutyCycle(2.5)
    time.sleep(0.5)
except KeyboardInterrupt:
  p.stop()
  GPIO.cleanup()

On 90 degree the motors are still turning. When I use something around 7.1 instead of 7.5 like p.ChangeDutyCycle(7.1), the motors seem to stop. But every few seconds they rotate a bit. I tried already other values but none of them hold the motors for more than 10 seconds.

Is there a way to fix this?

0

Probably. You really shouldn't use software PWM to control servos. The timing jitter will make them fidget causing them to overheat and wear our prematurely.

Use one of the many modules (software or hardware) which provide hardware timed PWM.

1
  • Thank you for your answer, my problem is now solved. It is working now with the pigpio library and a value of around 1490. Mar 3 '21 at 12:25

Your Answer

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

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