Servos typically require around a 50 Hz PWM signal (some variation around 50 Hz is okay, but we'll stick with 50 Hz as this is the common reference point), and a pulse width between 1.0 milliseconds and 2.0 milliseconds that determines the angle of rotation. The relation between pulse widths, duty cycles, and angle is illustrated in Figure 10.4. Don't worry if all this does not sink in just yet. It should become more clear as we see our servo in action and review our servo-related code in the next section:
Figure 10.4 – Servo's pulse width, duty cycle, and angles
We have not covered pulse width in relation to our earlier coverage of PWM; however, it's just another way of describing the duty cycle.
Here is an example:
- If we have a PWM signal at 50 Hz (that is, 50 cycles per second), then this means that 1 PWM cycle takes 1 / 50 = 0.02 seconds, or 20 ms.
- Thus, a pulse width of 1.5 ms expressed as a duty cycle is 1.5 ms...