«

»

Mai 11

Robotics 101 : controlling analog servos

Hi all,

In this small tutorial you will learn how to control analog servos !
Since it is a simple application of the PWM we saw before it is more a lab work than a course, so feel free to try yourself without reading the code i’ll give at the end 😉
Most analog servos use the same protocol, they are control with a PWM with a 20ms period, usually at 5V (but 3V works perfectly, even though it shouldn’t).
The neutral position (0°) is achieved when the duty cycle is 1520µs.
The servo moves of 1 degree per 10-11µs of difference with the neutral position.
(If you want a clearer explanation, this website has some good schematics).

Now try to control one yourself !

_______

Here is a sample code to control a servo on PB4 :