Uncategorized

Servo motor notes

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? shareeditflag  edited 43 secs ago

  • 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. – tlfong01yesterday
  • 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. 😦 – tlfong01yesterday
  • 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/…. – tlfong01yesterday
  • 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). – goldilocksyesterday
  • 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 – tlfong01yesterday
  • Thank you for that answer, I will look into it – Kungbjuchayesterday
  • @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? – tlfong0113 mins 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, … – tlfong016 mins ago   Edit   
1

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:
    servo.min()
    sleep(1)
    servo.mid()
    sleep(1)
    servo.max()
    sleep(1)

 

 New contributor
0

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
.END

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

%d bloggers like this: