Subsection 13.4.1 The Command Pulse
A hobby servo is commanded by a pulse repeated about every 20 ms (50 Hz). The width of the HIGH pulse is the position command, and the servo holds the position only as long as the pulses keep coming; with no signal there is no power on the motor. The convention:
| Pulse width | Position |
|---|---|
| 1 ms | −90°, one end of the travel |
| 1.5 ms | 0°, the middle |
| 2 ms | +90°, the other end of the travel |
The endpoints are the convention, and a given servo does not necessarily reach them; the SG90 datasheet says approximately 180° of rotation. Pulse widths outside 1 ms to 2 ms can drive the servo against its own stops, which is why the program limits every value it computes to
SERVO_MIN through SERVO_MAX before writing CCR1. The initialization is the one exception: tim14_pa7_pwm_init() parks CCR1 at 0, so until the first potentiometer reading arrives there is no pulse at all and the servo is not commanded anywhere. The SG92R’s dead band width is 1 µs: a change in pulse width smaller than that has no effect. Its other specs, from the datasheet: stall torque 2.5 kgf-cm at 4.8 V, operating speed 0.1 s per 60°, operating voltage 4.8 V, POM and carbon-fiber gears. It draws about 250 mA while moving, and much more when it is stalled.
