servo motor notes

Q: Servo motor behaves odd

Kungbjuchahello 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…


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.
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. 😦
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/….
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).
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
Thank you for that answer, I will look into it

@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?
(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, …
(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?
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.
There you are, my first love! imgur.com/gallery/fA7mmId.
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.
Now I am using a cheapie “servo adjuster” to calibrate, test, and reproduce the odd behaviour of the OP’s servo, namely, shaking, and signing: imgur.com/gallery/OmtHf0P. The OP does not mention which servo he is playing with. Anyway, I will use TowerPro MG996R, TowerPro Micro Servo 9g as testing samples. I am applying the same PWM signal to both servos, so to compare and contrast their characteristics.
The servo adjuster’s pulse width range is disappointing, only from 1000uS to 2000 uS, ie, 1mS to 2mS, and the servo motor only turns a range of about 80 degrees. I am not surprised of this narrow adjustment range, because I still remember the shopkeeper guy selling me this thing, telling me that it is used to adjust the middle position, not to calibrate the span angle. Anyway, a disappointing test. Nee to find another tool.
The cheapie server adjuster cannot set the PWM pulse width to a wider range of duty cycle corresponding to more than 80 degrees. So I am thinking a using my other signal generator, and also a variable voltage regulator with current meter: “How can Rpi4B python UART talk to XY PWM Signal Generators?” raspberrypi.stackexchange.com/questions/104779/…. Now I adjust the duty cycle from less than 2% to over 14%, and found the following results: / to continue, …
(1) Within 3~12%, everything OK. But when approach limits 2% and 12%, servo starts shaking, and also making a sound, which I guess is of the same shaking frequency. So I am happy to have reproduced the odd behaviour of the OP servo, when he changed the duty cycle of 3% to “other value” he did not specify. (2) Another surprising result is the following: if DC is within 2% to 12%, the servo moves to a fixed position, and the current is small when motor is not moving, current is small BUT WHEN MOTOR STARTS TO TREMBLE, AND MAKING A NOISE, CURRENT JUMPS TO 1.5A! I need to google to confirm.
Conclusions: (1) If duty cycle is set out of range (2% < 12%) motor might stake, and the current would jump to 1.5A (Note 1), beyond Rpi 5V rail’s limit. In other words, Rpi 5V rail should NOT be used to power servo, (2) 50Hz signal is found OK, not causing any resonance or vibration. The 50Hz signal either from servo adjuster or XY sign gen is clear and sharp, good for FPV drone applications. imgur.com/gallery/QrjInyD. Note 1 – I think when the servo trembles, the shaft peg is actually repeatedly hitting the stopper post, drawing big start and stall motor current, of average 1.5A.
The last message was posted 6 days ago.

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.