Servos

Besides relays, servo motors are one of the most interesting and versatile components that are frequently used on IoT projects. A servo motor can turn itself to a determined angle with high precision. They can be used to steer a robot car, orient a camera, as actuators on a robotic arm, and so on. They are -obviously- controlled using PWM.

Robotic arms and camera brackets rely on servos

Servos use PWM in a particular way. They do not read the duty cycle in the way you would expect; they do check the length of the pulse. That length is not related to a percentage of the period, but an absolute number. A servo expects this value to be sent about every 20 ms, so we will work at 50 Hz. Repeating the signal is important to make the servo return to that position if it was moved -i.e. by brute force- but without an external interaction, the servo will simply stay in the last position.

A servo considers itself to have a neutral position when there is no left or right rotation, and that is indicated by a pulse of 1.5 ms in duration (note that it is nowhere close to a 50% duty cycle at 50 Hz, which is 10 ms).

Servos use PWM in their own particular way.

The maximum and minimum pulse length varies slightly from each brand and even each particular servo, but typically they are around 1 ms for minimum and 2 ms for maximum:

In my experience, most of the mini servos operate on a slightly wider pulse duration range. Do not worry; the servo driver allows us to configure and control its parameters easily, but it is important to understand what they mean. Let's build an example.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.204.208