Back to top

Voltage Response of a Low Pass Filter Applied to a Square Wave

A common technique to generate an adjustable fixed voltage from a microcontroller is to low pass filter a pulse width modulated signal. It's common knowledge that a rough estimate of the generated voltage will be \frac{{\Delta{t}_{{h}}}}{{\Delta{t}_{{h}}+\Delta{t}_{{l}}}}{V} . Here, I will prove this approximation correct and also derive other interesting properties of the resulting voltage, like the rate at which the transient response dies out, and an equivalent approximation in the case that the charging and discharging resistors are unequal. In fact, this case is a generalization of the single resistor case, so let's consider the double resistor case first.
Figure 1. Square wave generated by a voltage reference. A relais is used as a model of a perfect transistor.
Figure 2. Single resistor, or {R}_{{1}}={0} case of figure 1.
Let's say the capacitor voltage is {V}_{{n}} right after the nth high pulse. During the next low pulse the voltage will drop exponentially with time constant \tau={R}_{{2}}{C} . So right after the low pulse the capacitor voltage is: {V}_{{n}}'={V}_{{n}}{e}^{{-\frac{{\Delta{t}_{{l}}}}{{{R}_{{2}}{C}}}}} Subsequently the input voltage will go high again, and this time the difference between the driving voltage and the capacitor voltage will drop off exponentially with the time constant \tau={\left({R}_{{1}}+{R}_{{2}}\right)}{C}={R}{C} . {V}_{{{n}+{1}}}={V}+{\left({V}_{{n}}'-{V}\right)}{e}^{{-\frac{{\Delta{t}_{{h}}}}{{{R}{C}}}}} Substituting {V}_{{n}}' we have now found a recurrence relation for the capacitor voltage after every high voltage pulse. To simplify further analysis we introduce the time independent variables {A} and {B} . {V}_{{{n}+{1}}}={V}+{\left({V}_{{n}}{e}^{{-\frac{{\Delta{t}_{{l}}}}{{{R}_{{2}}{C}}}}}-{V}\right)}{e}^{{-\frac{{\Delta{t}_{{h}}}}{{{R}{C}}}}}=\underbrace{{{\left({1}-{e}^{{-\frac{{\Delta{t}_{{h}}}}{{{R}{C}}}}}\right)}{V}}}_{{\text{A}}}+{V}_{{n}}\underbrace{{{e}^{{-\frac{{\Delta{t}_{{l}}}}{{{R}_{{2}}{C}}}-\frac{{\Delta{t}_{{h}}}}{{{R}{C}}}}}}}_{{\text{B}}} We now try to solve this recurrence relation. Starting with a uncharged capacitor {V}_{{1}}={0} we calculate the first few voltages. \begin{aligned} V_1 &= 0 \\ V_2 &= A + V_1 B = A \\ V_3 &= A + (A) B = A + AB \\ V_4 &= A + (A + AB) B = A + AB + AB^2 \\ V_5 &= A + AB + AB^2 + AB^3\end{aligned} This seems just to be a geometric series. For which we know the general formula. {V}_{{n}}={A}+{A}{B}+{A}{B}^{{2}}+\cdots+{A}{B}^{{{n}-{1}}}+{A}{B}^{{{n}-{2}}} {V}_{{n}}={A}\frac{{{1}-{B}^{{{n}-{1}}}}}{{{1}-{B}}} Now {B}={e}^{{-\frac{{\Delta{t}_{{l}}}}{{{R}_{{2}}{C}}}-\frac{{\Delta{t}_{{h}}}}{{{R}{C}}}}} is an exponential function with a negative exponent, so {0}<{B}<{1} . The transient response will die out, and we can find the steady state capacitor voltage as. \lim_{{{n}\to\infty}}{V}_{{n}}=\frac{{A}}{{{1}-{B}}}=\frac{{{1}-{e}^{{-\frac{{\Delta{t}_{{h}}}}{{{R}{C}}}}}}}{{{1}-{e}^{{-\frac{{\Delta{t}_{{l}}}}{{{R}_{{2}}{C}}}-\frac{{\Delta{t}_{{h}}}}{{{R}{C}}}}}}}{V}=\frac{{{e}^{{\frac{{\Delta{t}_{{h}}}}{{{R}{C}}}}}-{1}}}{{{e}^{{\frac{{\Delta{t}_{{h}}}}{{{R}{C}}}}}-{e}^{{-\frac{{\Delta{t}_{{l}}}}{{{R}_{{2}}{C}}}}}}}{V}
Figure 3. For the simulated voltage the values {V}_{{{r}{e}{f}}}={5}\text{V} , {R}_{{1}}={2500}\Omega , {R}_{{2}}={5000}\Omega , {C}={50}\text{μF} were used. The horizontal line is the voltage given by the expression immediately preceding the figure.
This is as far as we can go in the general case. But if we use a high frequency signal the pulse times \Delta{t}_{{h}} and \Delta{t}_{{l}} will be very small which invites a taylor expansion. {e}^{{\frac{{\Delta{t}_{{h}}}}{{{R}{C}}}}}\approx{1}+\frac{{\Delta{t}_{{h}}}}{{{R}{C}}}\qquad\qquad{e}^{{-\frac{{\Delta{t}_{{l}}}}{{{R}{C}}}}}\approx{1}-\frac{{\Delta{t}_{{l}}}}{{{R}{C}}} Working this out gives: \lim_{{{n}\to\infty}}{V}_{{n}}\approx\frac{{R}_{{2}}}{{{R}\frac{{\Delta{t}_{{l}}}}{{\Delta{t}_{{h}}}}+{R}_{{2}}}}{V}
Figure 4. The simulated voltage from figure 1 is repeated here on a different time scale. The Taylor approximated voltage is given by the expression immediately preceding the figure.
If we now write {R}={R}_{{1}}+{R}_{{2}}=\alpha{R}_{{2}} for a suitable constant \alpha we find \lim_{{{n}\to\infty}}{V}_{{n}}\approx\frac{{\Delta{t}_{{h}}}}{{\Delta{t}_{{h}}+\alpha\Delta{t}_{{l}}}}{V} Going back to the the one resistor case we recover the familiar rule of thumb. {R}_{{1}}={0}\quad\Rightarrow\quad\alpha={1}\quad\Rightarrow\quad\lim_{{{n}\to\infty}}{V}_{{n}}=\frac{{\Delta{t}_{{h}}}}{{\Delta{t}_{{h}}+\Delta{t}_{{l}}}}{V}