0

I brought a new SG90 servo and I tried to control it using my Raspberry Pi's pin 17 writing the following code on the terminal's python

>>>import RPi.GPIO as GPIO
>>>import time

>>>GPIO.setmode(GPIO.BCM)
>>>GPIO.setwarnings(False)

>>>GPIO.setup(17, GPIO.OUT)
>>>servo=GPIO.PWM(17, 50)
>>>servo.start(5)
>>>servo.ChangeDutyCycle(2)

When the last command is executed, the servo performs its job but it vibrates a lot and it heats up. Please help me solve this.

2
  • 1
    Did you try other value for ChangeDutyCycle? 2 seems really low (rpi.science.uoit.ca/lab/servo) – Félicien Feb 26 '18 at 16:27
  • @Félicien if that (2) is 400 µs that will probably be beyond the end stops, that will destroy the servo pretty fast and generate heat. – joan Feb 26 '18 at 16:50
1

It is inadvisable to use software timed PWM to drive servos. The pulse width determines the desired position of the servo. With software PWM the pulse width is erratic so the servo is continually trying to adjust its position. This results in heat and the servo quickly wearing out.

Use hardware timed pulses using one of the following methods.

  1. You can use an external pulse width generator
  2. or one of the modules which uses DMA to time the pulses (e.g. servoblaster, (my) pigpio, etc.).
  3. Alternatively use software which supports the hardware PWM pins on the Pi (e.g. pigpio).

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.