Uncategorized

Active yesterday
Viewed 52 times

# What is the relationship between angle and servo motor duty cycle? How do I implement this?

I am unsure of the relationship between duty cycle and angle. I see lots of tutorials online with many different equations to calculate duty cycle for a given angle. I have a 50Hz servo motor that ranges between a 2%-12% duty cycle for 0-180 degrees.

The equation I’ve seen is (angle/18 + 2). This works but I do not understand why and virtually all resources just give the equation with no explanation where the numbers come from.

Can someone please explain why I am dividing by 18 and add 2 to my duty cycle?

New contributor

Servos are controlled by pulse width, the pulse width determines the horn angle.

A typical servo responds to pulse widths in the range 1000 to 2000 µs.

A pulse width of 1500 µs moves the servo to angle 0. Each 10 µs increase in pulse width typically moves the servo 1 degree more clockwise. Each 10 µs decrease in pulse width typically moves the servo 1 degree more anticlockwise.

Small 9g servos typically have an extended range and may respond to pulse widths in the range 500 to 2500 µs.

Why do people think servos are controlled by duty cycle? Because servos are typically given 50 pulses per second (50 Hz). So each pulse is potentially a maximum of 20000 µs (1 million divided by 50). A duty cycle is the percentage on time. 100% will be a 20000 µs pulse, way outside the range accepted by a servo.

Do some calculations at 50 Hz for sample pulse widths.

`````` 500 / 20000 = 0.025 or  2.5 % dutycycle
1000 / 20000 = 0.05  or  5.0 % dutycycle
1500 / 20000 = 0.075 or  7.5 % dutycycle
2000 / 20000 = 0.1   or 10.0 % dutycycle
2500 / 20000 = 0.125 or 12.5 % dutycycle
``````

Don’t use dutycycles, if possible use pulse widths, and think in pulse widths. If you send pulses at 60 Hz by duty cycle the servo will go to the wrong position.

.END

Categories: Uncategorized

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