I am using PCA9685 to drive a MG995 servo motor. I am using the following code to control the servo motor.

import time,Adafruit_PCA9685

def elbow():
    pwm = Adafruit_PCA9685.PCA9685()

    for i in range(up,down,1):
    for i in range(down,up,-1):

if __name__=='__main__':

The above code works fine but the servo motor rotates very slowly. I have double checked the power requirements of the PCA9685 driver. I am supplying 5V,2A to the V+ pin of the driver and 3.3V( from the Raspberry Pi ) to the Vcc pin of the driver as specified. I have plugged in the servo motor in the Pin number 3 of the PCA driver. Inspite of the correct voltage supply, the motor rotates very slowly. I have tried to change the value of the frequency, pwm.set_pwm_freq(50) between the range 10 to 60, but it did not work. Beyond 60, the servo motor does not respond at all.

Please help me figure out a way to increase the speed of the servo motor. Thank you.

  • Could you explain in words what each line of the for loop is doing? This seems to be a general Python question.
    – joan
    Apr 3 '18 at 7:56
  • So, basically the servo motor rotates between 2 end points i.e up and down (variables). To change its position I need to give different PWM durations. So, 545 to 145 are those pwm durations for which I get different servo motor positions. The code works , but the servo motor rotates very slowly. Youtube videos show the same motor rotating very quickly Apr 3 '18 at 8:38
  • How many different PWM positions are you giving and how quickly?
    – joan
    Apr 3 '18 at 10:04
  • 420 pwm positions (i.e 565-145) and they are being applied at an interval of 0.001 seconds Apr 3 '18 at 10:55
  • Doesn't that answer your question? A servo moves to the commanded position. There is no need to ask it to go to 420 intermediate positions.
    – joan
    Apr 3 '18 at 11:25

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.