Servo motor notes

Raspberry Pi Servo Motor control


If the Servo Misbehaves by Simon Monk
Your servo may behave erratically, … because the servo draws quite a lot of power, especially as the motor is starting up, and this sudden high demand can be enough to drop the voltage on the … board, so that it resets itself. You you can usually cure it by adding a high value capacitor (470uF or greater) between GND and 5V … The capacitor acts as a reservoir of electricity for the motor to use, so that when it starts, it takes charge from the capacitor as well as the [Rpi] supply.

Servo motor behaves odd

Active today
Viewed 50 times

hello I Connected a servo motor to my Raspberry pi Zero W

and used the example from raspberrypi.org: granpa scarer:

Grandpa Scarer

and the servo worked however after changing the value for: p.ChangeDutyCycle(3) to an other value the servo stopped working it makes a sound like it trying to move but can’t.

I changed it back to it’s original value but the problem remains I switched to an other servo that I had and that one worked, so I switched back to the first one (a smaller one) and now it worked.

But after playing around with it for a couple of times, the issue came back

Has anybody else experience this?

  • Hi @Kungbjucha, You remind me the first time I played with the servo motor. I followed the tutorial, ran the program, and the servo moved to different positions as I changed the duty cycle, ie, the width of the pulses input to the signal pin of the servo. So I was happy to have learned what is the meaning of PWM (Pulse Width Modulation) control of a motor. – tlfong01 yesterday
  • Then I tried different duty cycle values, and was happy to see the servo moved further as I increased the pulse width, and moved backward when I decreased the pulse width. So I thought that I learned all the tricks, and tried one more width, but this last time the servo did not move, and started trembling, and drifting away, and as it was going to fall off the desktop, I used a finger to hold it. Then I found one thing weird – the servo was very hot! I immediately pulled the plug, but it was too late. I found the servo seemed dead, never moved again even when I tried the old widths. 😦 – tlfong01 yesterday
  • Thank you for reading my boring, long, and sad story of how I fired the motor, the first one I played. These are the opening paragraphs of my answer to your question. You need to read more of my boring paragraphs to understand my answer: “How can Rpi move a servo motor using a GPIO pin in PWM mode?” raspberrypi.stackexchange.com/questions/98467/…. – tlfong01 yesterday
  • A servo under load will do this if there is not enough current. If you are powering them via a 5V pin, use an external source instead (but make sure to add a common ground). – goldilocks yesterday
  • In case you have already bored to death, and just want a quick reply, here is a hint to the root cause of the odd behaviour of your servo motor: “Servo Position vs Pulse Width (duty Cycle)”: imgur.com/gallery/Q7ruJkJ – tlfong01 yesterday
In case you have already bored to death, and just want a quick reply, here is a hint to the root cause of the odd behaviour of your servo motor: “Servo Position vs Pulse Width (duty Cycle)”: imgur.com/gallery/Q7ruJkJ – tlfong01 yesterday   
  • Thank you for that answer, I will look into it – Kungbjucha yesterday
  • @Kungbjucha, it was only after frying my first servo, then I started reading the friendly user guide. I found there were too many things that I did not know that I did know, including the following: (1) The user guide said something about a “DEAD BAND”. Was it sort of “Bermuda Triangle”, or servo black hole, that the ignorant servo moved into? (2) What was “motor stall” current? Was this huge current that heated up the motor and fried my expensive small toy? – tlfong01 4 hours ago   
  • (3) There is actually inside the servo, an Amtel MCU, reading the motor shaft geared analog potentiometer’s analog value, converts it to digital, and uses it as feedback to control motor moving CW and CCW. And (4) Is this continuous CW/CCW movement that trembles violently my first love motor and fries it? / to continue, … – tlfong01 4 hours ago   
  • (5) Actually at that time I was only a servo newbie (now a ninja, of course! :), sitting by my servo (my first love), RPI, drafting a postmortem. I still remember a couple of wild guesses of the cause of death, I made then, including the following: (a) I am sending PWM pulses every 20 mS, which means 50Hz. Is this 50Hz signal in “resonance” with my home mains 200V AC, also 50Hz, and makes the servo shaking and singing? But how come the American Lady Ada servo tutorial I am reading, does not have such an problem? is it because her mains frequency is 110V AC 60Hz, not 220VAC, 50Hz, like mine? – tlfong01 3 hours ago   
  • It only after looking “Dead Zone” (Dead Band) in Cambridge Dictionary (a place where a mobile phone does not work because there is no signal; a place or time in which nothing happens), then I understood why my motor is shaking. Eg using MG995 whose dead band is 5uS, meaning input pulse width has TOLERANCE of 5uS. Suppose the servo is now at mid position after 1500uS wide pulse, any further change of width less than 5uS will not move motor. If dead band is 5uS, and repeating pulse fluctuating more than 5uS, motor will move CW and CCW, shaking. So DB is sort of RESOLUTION or ERROR MAGNITUDE. – tlfong01 2 hours ago   
  • There you are, my first love! imgur.com/gallery/fA7mmId. – tlfong01 1 hour ago   
  • I am googling “servo weird behaviour” and how to solve problem, like this: “If Servo Misbehaves by Simon Monk”: learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors … servo behaves erratically, … because draws a lot of power, especially as motor start up, sudden high demand can be enough to drop the voltage on the … board, You you can usually cure it by adding a high value capacitor 470+uF between GND and 5V … capacitor acts as a reservoir of electricity for the motor to use, when it starts, it takes charge from the capacitor as well as the [Rpi] supply. – tlfong01 7 mins ago   

2 Answers


This is an old resource, and due for an update. Can I recommend that you have a look at using the gpiozero module to interface with a servo.

from gpiozero import Servo
from time import sleep

servo = Servo(17)

while True:
 New contributor

That is a dreadful tutorial. It really should be deleted or updated.

You need to understand how servos are controlled to use them properly – that tutorial confuses the issue.

A hobby servo is commanded by a series of pulses expected about 50 times per second (50 Hz). The length of the pulse determines the angle of the attached horn. The pulse length is generally given in microseconds.

The centre angle is specified by a pulse length of 1500 µs. Shorter pulses move the horn counterclockwise. Longer pulses move the horn clockwise. Values between 1000 and 2000 µs are safe for most servos. The small 9g servos often respond to pulses in the range 500 to 2500 µs. However every servo is different. If you command it to a position outside its range you can strip the gears and destroy the servo. So be careful and check the safe pulse lengths by experiment.

At 50 Hz PWM each pulse is a maximum of 20000 µs. A 50% dutycycle means the pulse is high for 10000 µs and low for 10000 µs. A 3% dutycycle means the pulse is high for 600 µs and low for 19400 µs. The pulse length is the high part so 3% equates to 600 µs. This may or may not work for your servo.

You need to convert between dutycycles at 50 Hz and the resulting pulse length. You need to establish safe limits for your servos.

  • ah ok, when you first read about them, they seems simple to use. I will investigate what are the limits for my servo. – Kungbjucha yesterday

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: