Pulse Width Modulation

Pulse width modulation (PWM) is a useful technique used for efficiently controlling the power delivered to electrical devices by pulsing a digital signal rather of using current limiting resistors. Resistors draw power which is lost in the form of heat, leading to reduced efficiency. PWM can also be used to approximate analog signals; a technique used by the Arduino's analog out pins. Another application for PWM signals is with servos, where the output position is driven by the width of the pulse of a PWM input signal.

What is PWM?

A PWM signal is a digital signal which is pulsed, usually at some regular frequency, as shown in Figure 1. The duration of each pulse determines what is called the duty cycle. The duty cycle is the ratio of the duration of the pulse and the period between each pulse. By modulating the duration of each pulse, one can control the average amount of power passing through a device, or, in the case of servos, control the servo's position.

Figure 1: A plot of a generic pulse width modulation signal identifying the period between pulses, the duration of each pulse and the duty cycle.

PWM for Power Limiting

In general, the devices that benefit from PWM tend to have a slow reaction time to their input signals, such as a motor, a heating element, or an LED (slow reaction of the human eye). By pulsing the current through the device for a short duration (and high frequency), one can effectively limit the applied power because part of the time, no power is applied. Because power is applied during the pulse and not during the off periods, the average the power delivered to the device becomes approximately the duty cycle ratio times the full on power. The higher the duty cycle, the higher the average power applied to the device. Because of the slow reaction times of the device, they generally still operate smoothly even though power is applied to them in pulses instead of continuously.

Figure 2: A plot of a generic pulse width modulation signal with a 20% duty cycle. The effective voltage is 20% of the peak voltage.

PWM for Servo control

A servo is a motor equipped with a potentiometer for position feedback and an electronic circuit to control the output position of the servo arm. The input signal used by servos is a PWM input signal which controls the output position of the servo. The width of the pulse (ms) is what specifically controls the output position of the servo. The servo output is somewhat independent of pulse frequency, however standard servos need at least 3 ms delay between pulses to "reset". Too low frequency and you servo will lose torque.

In general, servos are designed to respond to a PWM signal using a pulse width of 1 to 2 ms pulsed at a frequency of 20 ms. Pulse width of 1 ms would make a servo turn full left, and a pulse width of 2 ms would make a servo turn full right. The pulse frequency can be increased up to 120 Hz for standard servos and even higher with digital servos.

Figure 3: A servo PWM signal with a period of 20 ms and a pulse width between 1 to 2 ms.

Documentation License: