The previous page analyzed the output of a pulse width modulated system with a resistor and a capacitor. This page performs, using three different, an in depth analysis of a first order low pass system applied to a PWM signal. The first method is an exact solution. This derivation is quite involved mathematically, and doesn't provide any insights beyond those obtained with the other two methods; it is included for completeness and for those who would like to see all the mathematical details. The second method is based on a first order (i.e., linear) solution in the time domain and is only valid if the time constant, τ, of the low pass system is much longer than the period, T, of the PWM signal (i.e., τ>>T). The third mased is based on a frequency domain argument, and is also on valid for τ>>T.

The results from all three methods are shown in the graph below along with the PWM input and the average value of the PWM input. Note all three methods yield the same average output, equal to the average of the input, but will have slightly different calculations of the ripple in the output. If you select one of the solutions, it will be highlighted on the graph. Also, the derivation of the specified solution will appear immediately below the graph to make it easier to go back and forth between the graph and the derivation.

Try these things with the sliders next to the graph to get a feel for how the PWM works.

- As the duty cycle is increased the average increases (as does the output of the low pass system). The ripple also decreases and goes to zero as the duty cycle approaches 100%.
- As the duty cycle is decreased the average decreases (as does the output of the low pass system). The ripple also decreases and goes to zero as the duty cycle approaches 0%.
- As τ is decreased the ripple increases (because the low pass system responds quickly). Also note that the approximations become less good because the assumption that τ>>T becomes less good.
- As τ is increased the ripple decreases (because the low pass system cannot respond as quickly). Also note that the approximations become better because the assumption that τ>>T becomes better.

Exact Solution

Approximate Time Domain Solution

Approximate Frequency Domain Solution

Approximate Time Domain Solution

Approximate Frequency Domain Solution

First Order System Review

Two of the solutions below ("Exact" and "Approximate Time Domain") make use of some facts
about the step response of a first order system (more
details here). The step response of a first order system, y_{γ}(t), is
determined by the initial value at t=0+, the final value at t=∞ and the time constant. The response (the
blue line) starts at y_{γ}(0^{+}) and is asymptotic to y_{γ}(∞) as t increases.

\[{y_\gamma }(t) = {y_\gamma }\left( \infty \right) + \left( {{y_\gamma }\left( {{0^ + }} \right) - {y_\gamma }\left( \infty \right)} \right){e^{ - t/\tau }}\]

For t/τ <<1, we can approximate the exponential by a linear function as shown above (the red line). The linear approximation is easily derived by replacing the exponential term with its first order taylor series expansion:

\[\begin{align}

{y_\gamma }(t) &\approx {y_\gamma }\left( \infty \right) + \left( {{y_\gamma }\left( {{0^ + }} \right) -
{y_\gamma }\left( \infty \right)} \right)\left( {1 - \frac{t}{\tau }} \right) \\

&= \frac{{{y_\gamma }\left( {{0^ + }} \right) - {y_\gamma }\left( \infty \right)}}{\tau }t + {y_\gamma
}\left( 0^+ \right) \\

&= \frac{{\Delta y}}{\tau }t + {y_\gamma }\left( 0^+ \right) \\

\end{align} \]

The last equation shows that the line has a slope of Δy/τ and a y-axis
intercept of y_{γ}(0^{+}).

The figure below shows a PWM signal, x(t), with period T=1S and a duty cycle of 0.6 (or 60%) as a solid black line. Also shown is the ouput, y(t), of a system with time constant τ=0.5S as a blue line.

We will find

- an expression for the voltage during T
_{1}, while the input is high, and the output is increasing, - an expression for the output, y(t), during T
_{1}, while the input is low and the output is decreasing, - the values of y
_{max}and y_{min}(the maximum and minimum values of the output, - the "ripple" in the output (i.e., y
_{max}-y_{min}) which depends on T_{1}, - the maximum, or worst case, ripple,
- the average value of y(t).

First consider the output during the time interval T_{1} which we will call y_{high}(t). The
voltage starts at y_{1} and is asymptotic to 1 (as shown by the dotted line)

\[{y_{high}}\left( t \right) = {y_{high}}\left( \infty \right) + \left( {{y_{high}}\left( {{0^ + }} \right) - {y_{high}}\left( \infty \right)} \right){e^{ - t/\tau }} = 1 + \left( {{y_{min}} - 1} \right){e^{ - t/\tau }}\]

To make the math during this section easier, we will redefine the origin of the time axis so that t=0 when the
PWM input falls (in previous graphs, t=0 when PWM input rises). Now consider the output during the time interval
T_{2} which we will call y_{low}(t). With this modified time origin, the voltage starts at
y_{2} and is asymptotic to 0 (as shown by the dotted line)

\[{y_{low}}\left( t \right) = {y_{low}}\left( {0^ + } \right){e^{ - t/\tau }} = y_{max}{e^{ - t/\tau }}\]

We have expressions for y_{low}(t) and y_{high}(t) in terms of y_{min} and
y_{max}, but we don't yet know y_{min} and y_{max}. However, if you examine the graphs
you can see that

\[y_{max} = y_{high} \left( T_1 \right) = 1 + \left( {{y_{min}} - 1} \right){e^{ - T_1/\tau }}\]

and

\[y_{min} = y_{low} \left( T_2 \right) =y_{max} {e^{ - T_2/\tau }}\]

We can solve these equations (using the fact the T=T_{1}+T_{2}) to get

\[{y_{\max }} = \frac{{1 - {e^{ - {T_1}/\tau }}}}{{1 - {e^{ - T/\tau }}}},\quad \quad {y_{\min }} = {y_{\max }}{e^{ - {T_2}/\tau }} = {e^{ - {T_2}/\tau }}\frac{{1 - {e^{ - {T_1}/\tau }}}}{{1 - {e^{ - T/\tau }}}} = \frac{{{e^{ - {T_2}/\tau }} - {e^{ - T/\tau }}}}{{1 - {e^{ - T/\tau }}}}\]

\[\begin{align}

{y_{high}}\left( t \right) &= 1 + \left( {{y_{\min }} - 1} \right){e^{ - t/\tau }} = 1 + \left(
{{e^{ - T/\tau }}\frac{{{e^{{T_1}/\tau }} - 1}}{{1 - {e^{ - T/\tau }}}} - 1} \right){e^{ - t/\tau }} = 1 +
\left( {{e^{ - T/\tau }}\frac{{{e^{{T_1}/\tau }} - 1}}{{1 - {e^{ - T/\tau }}}} -
\frac{{1 - {e^{ - T/\tau }}}}{{1 - {e^{ - T/\tau }}}}} \right){e^{ - t/\tau }} \\

&= 1 + \left( {\frac{{{e^{ - T/\tau }}{e^{{T_1}/\tau }} - 1}}{{1 - {e^{ - T/\tau }}}}} \right){e^{ - t/\tau }}
\\

{y_{low}}\left( t \right) &= {y_{max}}{e^{ - t/\tau }} =
\frac{{1 - {e^{ - {T_1}/\tau }}}}{{1 - {e^{ - T/\tau }}}}{e^{ - t/\tau }} \\

\end{align} \]

The ripple is dependent on the value of T_{1}, so we will write it as a function of T_{1}.

\[ y_{ripple}\left( {{T_1}} \right) = {y_{\max }} - {y_{\min }} = \frac{{1 - {e^{ - {T_1}/\tau }}}}{{1 - {e^{ - T/\tau }}}} - \frac{{{e^{ - T/\tau }}{e^{{T_1}/\tau }} - {e^{ - T/\tau }}}}{{1 - {e^{ - T/\tau }}}} = \frac{{1 - {e^{ - {T_1}/\tau }} - {e^{ - T/\tau }}{e^{{T_1}/\tau }} + {e^{ - T/\tau }}}}{{1 - {e^{ - T/\tau }}}}\]

The ripple depends on the value of T_{1}, so we need to find the value of T_{1} that maximizes
the ripple. There is no ripple when T_{1}=0, or T_{1}=T. The ripple is symmetric about
T_{1}/T=0.5 (if the output is high 40% of the time and low 60%, the values of y_{min} and
y_{max} are just switched from the case when the output is high 60% of the time), it is reasonable to
assume the peak occurs at T_{1}/T=0.5.

Just to make sure this is correct, we can prove it by differentiating our expression for
y_{ripple}(T_{1}) with respect to T_{1} and setting it to zero

\[\begin{align}

\frac{{\partial y_{ripple}\left( {{T_1}} \right)}}{{\partial {T_1}}} &= \frac{{{e^{{T_1}/\tau }}{\mkern 1mu}
{e^{ - T/\tau }} - {e^{ - {T_1}/\tau }}}}{{\tau {\mkern 1mu} \left( {{e^{ - T/\tau }} - 1} \right)}} =
0{\text{,}}\quad {\text{so}} \\

{e^{{T_1}/\tau }}{\mkern 1mu} {e^{ - T/\tau }} - {e^{ - {T_1}/\tau }} &= 0 \\

{e^{{T_1}/\tau }}{\mkern 1mu} {e^{ - T/\tau }} &={e^{ - {T_1}/\tau }},\quad {\text{take the logarithm}} \\

\frac{{{T_1}}}{\tau } - \frac{T}{\tau } &= - \frac{{{T_1}}}{\tau }{\text{,}}\quad {\text{or}} \\

{T_1} &= \frac{T}{2} \\

\end{align} \]

which shows that the peak is at T_{1}/T=0.5, as we expected, and the worst case ripple
is

\[{y_{ripple,\max }} = \frac{{1 - {e^{ - T/(2\tau )}} - {e^{ - T/\tau }}{e^{T/(2\tau )}} + {e^{ - T/\tau }}}}{{1 - {e^{ - T/\tau }}}} = \frac{{1 - 2{e^{ - T/(2\tau )}} + {e^{ - T/\tau }}}}{{1 - {e^{ - T/\tau }}}} = \frac{{{{\left( {1 - {e^{ - T/(2\tau )}}} \right)}^2}}}{{1 - {e^{ - T/\tau }}}}\]

There are several ways to find the average value of the PWM output. Here we will find the average value through integration. This is conceptually easy, but computationally difficult. In the section describing the frequency domain approximation we will use another techniques that is conceptually very simple, but is conceptually more difficult (we will also find it in the discussion of the time domain approximation, which is somewhere between the two both conceptually and computationally). We start with the definition of the average:

\[PWM\;output\;average = \frac{1}{T}\left( {\int\limits_0^T {{y_{PWMout}}\left( t \right)dt} } \right)\]

The notation on the next line is a little tricky. We split the two integral into two parts,
one where the function is rising, and one where it is falling. Recall that when we defined the latter function,
we reset the time origin; this means when we integrate y_{low}(t), we integrate from 0 to T_{2},
instead of T_{1} to 1. The rest of the derivation is some straightforward calculus and algebra.

This is a power result! It states that the output of the PWM output is the same as that of the PWM input. So, for the case described here, since the duty cycle is 0.6, the input average is 0.6, as is the output average.

The exact analysis is very laborious, but we can make an accurate linear model if the pulse width modulated square wave is much faster than the system being driven; in other words if T<<τ. The figure below shows a PWM signal, x(t), with period T=1S and a duty cycle of 0.6 (or 60%) as a solid black line. Also shown is the exact ouput, y(t), of a system with time constant τ=0.5S as a blue line, and a the linear approximation in red. You can see they are quite close:

We want to start by finding a relationship between T_{1} and y_{avg}.

- First consider the plot during the interval
labeled T
_{1}, as the PWM output is rising (see image at right)

Note that the graph at the right has the time axis shifted so t=0 is set to the time when the linear approximation (red) goes through the average PWM output (y_{avg}, shown in magenta).- We want to match the slope of the exponential (shown as dotted red) with the slope of the linear approximation (solid red) as it passes through the average.
- The slope of the linear approximation is (y
_{max}-y_{min})/T_{1}. - The slope of the exponential (see above) is Δy
_{T1}/τ = (1-y_{avg})/τ. (Recall Δy_{T1}is the difference between the asymptotic value (1) of the exponential and the initial value (y_{avg}). - The two slopes are equal so $\frac{{{y_{\max }} - {y_{\min }}}}{{{T_1}}} = \frac{{\Delta {y_{T1}}}}{\tau
} = \frac{{1 - {y_{avg}}}}{\tau }$.

- Now consider the plot during the
interval labeled T
_{2}, as the PWM output is false (see image at right)

Note that the graph at the right has the time axis shifted so t=0 is set to the time when the linear approximation (red) goes through the average PWM output (y_{avg}, shown in magenta).- We want to match the slope of the exponential (shown as dotted red) with the slope of the linear approximation (solid red) as it passes through the average.
- The slope of the linear approximation is (y
_{min}-y_{max})/T_{2}. - The slope of the exponential (see above) is Δy
_{T2}/τ = -y_{avg}/τ. (Recall Δy_{T2}is the difference between the asymptotic value (0) of the exponential and the initial value (y_{avg}). - The two slopes are equal so $\frac{{{y_{\min }} - {y_{\max }}}}{{{T_2}}} = \frac{{\Delta {y_{T2}}}}{\tau } = - \frac{{{y_{avg}}}}{\tau }$.

- We know that the change in PWM output during T
_{1}is just the slope multiplied by T_{1}or ${\Delta _{rising}} = \left( {\frac{{1 - {y_{avg}}}}{\tau }} \right){T_1}$ - Likewise, the change in output during T
_{2}is just the slope multiplied by T_{2}or ${\Delta _{falling}} = \left( { - \frac{{{y_{avg}}}}{\tau }} \right){T_2}$ - During one cycle of the input, the sum of the changes during T
_{1}and T_{2}must add to zero (so the cycle can repeat). We also use the fact that T_{2}=T-T_{1}

\[\begin{align} {\Delta _{rising}} + {\Delta _{falling}} &= 0 = \left( {1 - {y_{avg}}} \right)\frac{{{T_1}}}{\tau } - {y_{avg}}\frac{{{T_2}}}{\tau },\quad \tau {\text{ cancels from equation}} \\ 0 &= \left( {1 - {y_{avg}}} \right){T_1} - {y_{avg}}\left( {T - {T_1}} \right) \\ {y_{avg}} \cdot T &= {T_1} \\ {y_{avg}} &= \frac{{{T_1}}}{T} \\ \end{align} \]

so the average of the PWM output is equal to the average of the PWM input and is equal to
T_{1}/T.

We can easily find the ripple by solving for Δy_{rising} or
-Δy_{falling} (since they are equal).

The ripple depends on the value of T_{1}, so we need to find the value of T_{1} that maximizes
the ripple. There is no ripple when T_{1}=0, or T_{1}=T. The ripple is symmetric about
T_{1}/T=0.5 (if the output is high 40% of the time and low 60%, the values of y_{min} and
y_{max} are just switched from the case when the output is high 60% of the time), it is reasonable to
assume the peak occurs at T_{1}/T=0.5. Just to make sure this is correct, we can prove it by
differentiating our expression for y_{ripple}(T_{1}) with respect to T_{1} and setting
it to zero

which shows that the peak is at T_{1}/T=0.5, as we expected, and the worst case ripple
is

Because this derivation is so much simpler than the exact derivation, and because the results are similarly less complex, this is usually a much more fruitful way of thinking about pulse width modulation.

Understanding Pulse Width Modulation in the context of a frequency domain analysis is in some ways the simplest
(the mathematics is quite simple), and in some ways the most complex (it requires a knowledge of transfer
functions, sinusoidal steady state, and Fourier Series. We assume we have a low pass system, H_{sys}(s),
with and PWM input, x(t), and we want to find the system output, y(t).

To start this analysis consider a PWM input (in this case we have the pulse is symmetric around t=0 because it makes the math easier, but this has no impact on our calculation of the average value of the output, nor on our calculation of the ripple.

The duty cycle is given by T_{1}/T, in this case 0.6. The average is also 0.6 (since
the input has a value of one 60% of the time, and is otherwise equal to 0). The Fourier Series representation
for this waveform is derived here, and is given by

where

\[a_0=average=\frac{T_1}{T}\]and otherwise,

\[{a_n} = {2 \over {n\pi }}\sin \left( {n\pi {{T_1} \over T}} \right)\]In these equations ω_{pwm} is the frequency of the PWM signal so
$\omega_{pwm}=\frac{2\pi}{T}$.

From a frequency domain perspective PWM works by attenuating the time varying parts of the signal (all of the
cosine terms), but not the constant (i.e., average) term, a_{0}. Let's examine how that works.

Consider the case when T_{1}/T=0.6. The first five values of a_{n} are given below, along with
the frequency of oscillation, and (to the right) a graph showing the amplitudes (i.e., a_{n}) at these
frequencies.

n |
a_{n} |
ω |

0 | 0.600 | 0 |

1 | 0.606 | ω_{pwm} |

2 | -0.187 | 2·ω_{pwm} |

3 | -0.125 | 3·ω_{pwm} |

4 | 0.151 | 4·ω_{pwm} |

We have already stated that the system being driven is a low-pass system,
so let's assume a first order system, with a break frequency of ω_{low}, so

Note that ω_{low}=1/τ, where τ is the time constant we used in the time domain analyses on this page.

Recall from sinusoidal steady state analysis that if the input to a system, H_{sys}(s), is

that the output is

\[A \cdot M \cdot \cos \left( {\omega t + \theta } \right)\]where

\[M = \left| {{H_{sys}}(j\omega )} \right| = \left| {\frac{1}{{1 + \frac{{j\omega }}{{{\omega _{kiw}}}}}}} \right| = \frac{1}{{\sqrt {\left( {1 + {{\left( {\frac{\omega }{{{\omega _{kiw}}}}} \right)}^2}} \right)} }},\quad \quad \theta = \angle {H_{sys}}(j\omega ) = - \arctan \left( {\frac{\omega }{{{\omega _{kiw}}}}} \right)\]We will not need to know the angle, θ, if we are only interested in the magnitude of the variations (ripple) in the output. It is value is included here for completeness.

Such a system with sinusoidal input and output is shown below.

Each of the component cosines from the input is at a frequency of n·ω_{pwm} (with a
frequency of 0 (i.e., a constant) associated with the a_{0} term).

These individual component will have their magnitude and phase changed by the system in accordance with the magnitude and phase of the transfer function so that the output is given by:

\[y(t) = {a_0} \cdot {H_{sys}}(j \cdot 0) + \sum\limits_{n = 1}^\infty {{a_n}\left| {{H_{sys}}(jn{\omega _{pwm}})} \right|\cos \left( {n{\omega _{pwm}}t + \angle {H_{sys}}(jn{\omega _{pwm}})} \right)} \]If we call
a_{n}·|H_{sys}(j·n·ω_{pwm})|=α_{n} (and
∠H(j·n·ω_{pwm}) we can rewrite the series as

\[y(t) = {\alpha _0} + \sum\limits_{n = 1}^\infty {{\alpha _n}\cos \left( {n{\omega _{pwm}}t + {\theta _n}} \right)} \]

Note: from here on out weLet's add |H_{sys}(j·n·ω_{pwm})
and α_{n} to our previous table (for the case where
ω_{low}=ω_{pwm}/3). Immediately you see that all of the coefficients of the cosine
terms in the output (the α_{n} terms) are smaller than the corresponding terms in the input (the
a_{n} terms) by a factor of |H_{sys}(j·n·ω_{pwm}|, except for
a_{0} (which represents the constant,or average, part of the PWM input). Since

n |
a_{n} |
ω |
|H_{sys}(j·n·ω_{pwm})| |
α_{n} |

0 | 0.600 | 0 | 1.000 | 0.600 |

1 | 0.606 | ω_{pwm} |
0.316 | 0.191 |

2 | -0.187 | 2·ω_{pwm} |
0.164 | -0.031 |

3 | -0.125 | 3·ω_{pwm} |
0.110 | -0.014 |

4 | 0.151 | 4·ω_{pwm} |
0.083 | 0.013 |

We can also show this visually. There are three graphs below. The first shows the values of a_{n} at
various frequencies (this was shown previously, above). The next graph shows the magnitude of the transfer
function (|H_{sys}(j·n·ω)|) over the same frequency
range. The last graph shows α_{n}, and is simply the product of the first two graphs.

By decreasing ω_{low}, we can attenuate the higher frequency parts of the signal
even more. Here ω_{low}=ω_{pwm}/10.

Clearly, as long as H(j0)=1, the average value of the input is equal to the average value of the output. In
other words, the constant (a_{0}) term of the input is equal to the constant (α_{0}) term
of the output because α_{0}=|H(j0)|·a_{n}.

Since the coefficients of the Fourier Series drop off rapidly as n increases, we create a first order approximation to the output with just the first two terms of the series. In other words we can estimate the output as a constant, plus the lowest frequency (n=1) cosine:

\[y(t) = {\alpha _0} + {\alpha _1}\cos \left( {{\omega _{pwm}}t + {\theta _{_1}}} \right)\] whereWe assume all of the ripple is from this cosine, so the peak to peak ripple is 2·α1.

\[\begin{align} {\alpha _1} &= {a_1}\left| {{H_{sys}}(j{\omega _{pwm}})} \right| \\ &= {a_1}\left| {\frac{1}{{1 + \frac{{j{\omega _{pwm}}}}{{{\omega _{low}}}}}}} \right| = \frac{{{a_1}}}{{\sqrt {1 + {{\left( {\frac{{{\omega _{pwm}}}}{{{\omega _{low}}}}} \right)}^2}} }} = \frac{{\frac{2}{\pi }\sin \left( {\pi \frac{T}{{{T_1}}}} \right)}}{{\sqrt {1 + {{\left( {\frac{{{\omega _{pwm}}}}{{{\omega _{low}}}}} \right)}^2}} }} \\ y_{ripple} &= 2 \cdot {\alpha _1} = \frac{{\frac{4}{\pi }\sin \left( {\pi \frac{T}{{{T_1}}}} \right)}}{{\sqrt {1 + {{\left( {\frac{{{\omega _{pwm}}}}{{{\omega _{low}}}}} \right)}^2}} }} \\ \end{align} \]We can put this in terms of time domain quantities by noting that the time constant of the
system is τ=1/ω_{low}, and the period of the pwm signal is given by
T=2·π/ω_{pwm}.

The worst case ripple happens when the sinusoidal term in the expression for the ripple is equal to 1, or when
T_{1}=T/2, in which case

If we have a PWM input with T=1S (so ω_{pwm}=2·π/T=6.28 rad/S) with a duty cycle of 0.6
(or 60%), pass it through a system with time constant τ=0.5S (so
ω_{low}
=2rad/S), we get the output shown below. The average is a magenta line, the ijnput is black, the exact output is
blue, and the approximate output (with just the a_{0} and a_{1} terms of the Fourier Series) is
green.

Note that the Fourier Series approximation is slightly shifted relative to the pulses. This is because of the angle, θ, of the transfer function (which we have been ignoring because it does not affect the size of the ripple).

Replace