Section 9.5 Pulse-Width Modulation (PWM)
Pulse-width modulation (PWM) is used to generate digital signals with varying average voltage levels. Instead of outputting an analog value, which is not possible without a digital to analog converter (DAC), a digital pulse with varying frequency and duty cycle is generated.
Subsection 9.5.1 Duty Cycle
The duty cycle (\(D\)) of a square wave is the fraction of time that a signal is HIGH (\(T_{HIGH}\)) compared to the total period of the wave (\(T\)). The duty cycle can be calculated as defined in (9.5.1).
\begin{equation}
D = \frac{T_{HIGH}}{T}\tag{9.5.1}
\end{equation}
Duty cycle is typically expressed as a percentage. A square wave that is LOW all the time has a duty cycle of 0%, and a square wave that is HIGH all the time has a duty cycle of 100%. Equal HIGH and LOW intervals would result in a duty cycle of 50%.
Subsection 9.5.2 Average Voltage
Modifying the duty cycle of a square wave changes the signalโs average voltage (\(\overline{V}\)). This average voltage can be calculated as defined in (9.5.2), where \(V_{MAX}\) is the maximum signal voltage (usually VCC), and \(V_{MIN}\) is the minimum signal voltage (usually 0ย V).
\begin{equation}
\overline{V} = D \times V_{MAX} + (1 - D) \times V_{MIN}\tag{9.5.2}
\end{equation}
Figureย 9.5.1 shows five PWM waveforms, all with a period of 20ย ms (frequency of 50ย Hz). Each of the waveforms in Figureย 9.5.1 is described below.
-
Waveform A has a duty cycle of 0% and average voltage of 0ย V.
-
Waveform B has a duty cycle of 25% and average voltage of 1.25ย V.
-
Waveform C has a duty cycle of 50% and average voltage of 2.5ย V.
-
Waveform D has a duty cycle of 75% and average voltage of 3.75ย V.
-
Waveform E has a duty cycle of 100% and average voltage of 5ย V.
Subsection 9.5.3 Frequency
The frequency of a PWM wave is equal to the number of complete cycles that occur per unit of time. It is independent of the waveform duty cycle. Figureย 9.5.2 shows waveforms, all with 25% duty cycles, with different frequencies. The frequency of each waveform shown in Figureย 9.5.2 is described below.
-
Waveform A has a frequency of 200ย Hz.
-
Waveform B has a frequency of 100ย Hz.
-
Waveform C has a frequency of 50ย Hz.
-
Waveform D has a frequency of 20ย Hz.
