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.
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
First consider the output during the time interval T1 which we will call yhigh(t). The voltage starts at y1 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 T2 which we will call ylow(t). With this modified time origin, the voltage starts at y2 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 ylow(t) and yhigh(t) in terms of ymin and ymax, but we don't yet know ymin and ymax. 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=T1+T2) 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 T1, so we will write it as a function of T1.
\[ 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 T1, so we need to find the value of T1 that maximizes the ripple. There is no ripple when T1=0, or T1=T. The ripple is symmetric about T1/T=0.5 (if the output is high 40% of the time and low 60%, the values of ymin and ymax are just switched from the case when the output is high 60% of the time), it is reasonable to assume the peak occurs at T1/T=0.5.
Just to make sure this is correct, we can prove it by differentiating our expression for yripple(T1) with respect to T1 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 T1/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 ylow(t), we integrate from 0 to T2, instead of T1 to 1. The rest of the derivation is some straightforward calculus and algebra.
\[\begin{aligned} PWM\;output\;average &= \frac{1}{T}\left( {\int\limits_0^{{T_1}} {{y_{high}}\left( t \right)dt} + \int\limits_0^{{T_2}} {{y_{low}}\left( t \right)dt} } \right) = \frac{1}{T}\left( {\int\limits_0^{{T_1}} {\left( {1 + \left( {\frac{{{e^{ - T/\tau }}{e^{{T_1}/\tau }} - 1}}{{1 - {e^{ - T/\tau }}}}} \right){e^{ - t/\tau }}} \right)dt} + \int\limits_0^{{T_2}} {\frac{{1 - {e^{ - {T_1}/\tau }}}}{{1 - {e^{ - T/\tau }}}}{e^{ - t/\tau }}dt} } \right) \\ &= \frac{1}{T}\left( {\frac{{\tau {\mkern 1mu} \left( {{e^{{T_1}/\tau }} + {e^{\frac{{T - {T_1}}}{\tau }}} - {e^{T/\tau }} - 1} \right)}}{{{\text{1}} - {e^{T/\tau }}}} + \frac{{{T_1} + \tau - {T_1}{\mkern 1mu} {e^{T/\tau }} + \tau {\mkern 1mu} {e^{T/\tau }} - \tau {\mkern 1mu} {e^{{T_1}/\tau }} - \tau {\mkern 1mu} {e^{\frac{{T - {T_1}}}{\tau }}}}}{{{\text{1}} - {e^{T/\tau }}}}} \right) \\ &= \frac{{\tau {e^{{T_1}/\tau }} + \tau {e^{\frac{{T - {T_1}}}{\tau }}} - \tau {e^{T/\tau }} - \tau + {T_1} + \tau - {T_1}{\mkern 1mu} {e^{T/\tau }} + \tau {\mkern 1mu} {e^{T/\tau }} - \tau {\mkern 1mu} {e^{{T_1}/\tau }} - \tau {\mkern 1mu} {e^{\frac{{T - {T_1}}}{\tau }}}}}{{T\left( {{\text{1}} - {e^{T/\tau }}} \right)}} \\ &= \frac{{{T_1}}}{T} \\ &= PWM\;input\;average \\ \end{aligned} \]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 T1 and yavg.
so the average of the PWM output is equal to the average of the PWM input and is equal to T1/T.
We can easily find the ripple by solving for Δyrising or -Δyfalling (since they are equal).
\[{y_{\max }} - {y_{\min }} = - \Delta_{falling} = {y_{ripple}} = {y_{mid}}\frac{{{T_2}}}{\tau } = \frac{{{T_1}}}{T}\frac{{{T_2}}}{\tau } = \frac{{{T_1}\left( {T - {T_1}} \right)}}{{T \cdot \tau }}\]The ripple depends on the value of T1, so we need to find the value of T1 that maximizes the ripple. There is no ripple when T1=0, or T1=T. The ripple is symmetric about T1/T=0.5 (if the output is high 40% of the time and low 60%, the values of ymin and ymax are just switched from the case when the output is high 60% of the time), it is reasonable to assume the peak occurs at T1/T=0.5. Just to make sure this is correct, we can prove it by differentiating our expression for yripple(T1) with respect to T1 and setting it to zero
\[y_{ripple}\left( T_1 \right) = \frac{{{T_1}\left( {T - {T_1}} \right)}}{{T \cdot \tau }}\]\[\frac{{\partial {y_{ripple}}\left( {{T_1}} \right)}}{{\partial {T_1}}} = \frac{{T - 2{T_1}}}{{T \cdot \tau }} = 0\]which shows that the peak is at T1/T=0.5, as we expected, and the worst case ripple is
\[{y_{ripple,\max }} = \frac{{\frac{T}{2}\left( {T - \frac{T}{2}} \right)}}{{T \cdot \tau }} = \frac{T}{{4\tau }}\]
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, Hsys(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 T1/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
\[x(t) = {a_0} + \sum\limits_{n = 1}^\infty {{a_n}\cos \left( {n{\omega _{pwm}}t} \right)} \]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, a0. Let's examine how that works.
Consider the case when T1/T=0.6. The first five values of an are given below, along with the frequency of oscillation, and (to the right) a graph showing the amplitudes (i.e., an) at these frequencies.
n | an | ω |
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
\[{H_{sys}}(s) = \frac{1}{{1 + \frac{s}{{{\omega _{low}}}}}}\]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, Hsys(s), is
\[A \cdot \cos \left( {\omega t} \right)\]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 a0 term).
\[x(t) = {a_0} + \sum\limits_{n = 1}^\infty {{a_n}\cos \left( {n{\omega _{pwm}}t} \right)} \]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 an·|Hsys(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 |Hsys(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 an terms) by a factor of |Hsys(j·n·ωpwm|, except for a0 (which represents the constant,or average, part of the PWM input). Since
n | an | ω | |Hsys(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 an at various frequencies (this was shown previously, above). The next graph shows the magnitude of the transfer function (|Hsys(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 (a0) term of the input is equal to the constant (α0) term of the output because α0=|H(j0)|·an.
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.
\[y_{ripple} = \frac{{\frac{4}{\pi }\sin \left( {\pi \frac{T}{{{T_1}}}} \right)}}{{\sqrt {1 + {{\left( {2\pi \frac{\tau }{T}} \right)}^2}} }}\]The worst case ripple happens when the sinusoidal term in the expression for the ripple is equal to 1, or when T1=T/2, in which case
\[{y_{ripple,\max }} = \frac{{\frac{4}{\pi }}}{{\sqrt {1 + {{\left( {\frac{{{\omega _{pwm}}}}{{{\omega _{low}}}}} \right)}^2}} }} = \frac{{\frac{4}{\pi }}}{{\sqrt {1 + {{\left( {2\pi \frac{\tau }{T}} \right)}^2}} }}\]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 a0 and a1 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).