If we come across a project on Hackaday or on the Instructables portal, the most likely thing is that one of the components used is a servomotor. The great advantage that servomotors have over classic motors is that they can adopt a specific position and hold it, which (usually) translates into a high level of precision. Now, the question is: How do they achieve that?.
How Servomotors Work
There is a wide range of servomotors on the market, and some models are so advanced that they become prohibitive, but common designs are more than enough to study the basic mechanism, composed of an electronic circuit, a DC motor, a gearbox that “links” the motor to an “output shaft”, and a potentiometer at the bottom of the shaft, which at the same time connects to the circuit.
The job of the potentiometer is to feed back the position of the shaft, while the gears are responsible for reducing the number of revolutions (60 RPM is a typical value) and increasing the torque (I know the term might raise some eyebrows from language purists, but please bear with me).
A conventional servomotor can rotate up to 180 degrees, but that is not a limitation that affects its most popular applications, such as steering systems in model aircraft and small robots. The servomotor is controlled through a signal modulated by pulse width or PWM.
Most models use signals with a frequency of 50 Hz, limiting the time between one pulse and another to 20 milliseconds. The duration itself of the pulse is what determines the angular position of the servo, with extremely short intervals.
The final numbers can vary from one model to another, but in general, 1 millisecond (or 0.5) for an angle of 0 degrees, 1.5 milliseconds for 90 degrees, and 2 milliseconds (or 2.5) for 180 degrees.
The control circuit compares the voltage of the potentiometer with the voltage of the signal, and if necessary, activates an integrated H-bridge to modify the direction of rotation, until the difference between both signals is zero. The second part of the video that accompanies us focuses on controlling servomotors with the help of an Arduino module, and what the main restrictions are, starting with an external power supply (the Arduino does not have enough firepower to serve the servomotor in the example). The rest is reduced to loading the code (available in the source below) specifying the control pin that will be connected to the servo.