Learn & build · Electronics · Chapter 8

Filters

A microphone picks up your voice, a 60 Hz hum from the wiring, and a hiss. A radio antenna picks up every station at once. A filter keeps the frequencies you want and turns down the rest. You've met the simplest one already, a resistor and a capacitor; this chapter makes filters you can design: how sharp, where, and what they do to the signal's timing.

In plain words: any signal is a sum of sine waves of different frequencies (that's what a spectrum shows). A filter is a circuit that turns each frequency up or down by its own amount. Because circuits of R, L, C and op-amps are linear, each frequency goes through independently, and the output is the sum of what comes out.

1. Separating a hum from a whistle

The input (yellow) is a 60 Hz hum plus a 3 kHz whistle. Choose a low-pass or high-pass RC filter and slide its cutoff. The output (blue) is each tone passed through on its own, then added back up.

🎯 Challenge: keep the whistle and remove at least 95% of the hum.

Filters move signals by factors of a hundred or a thousand, so filter people count gain in decibels (dB): every ×10 in voltage is 20 dB. Letting 10% through is −20 dB, 1% is −40 dB, and the cutoff's 71% is −3 dB. Draw frequency on a scale where each step is ×10 and gain in dB, and an RC filter's curve turns into nearly straight lines: that's a Bode plot, the middle graph above. It's flat in the passband, then falls 20 dB for every ×10 in frequency (a decade).

The math, step by step

From chapter 6, the RC low-pass passes \(|H(f)| = 1/\sqrt{1 + (f/f_c)^2}\); swapping R and C (high-pass) gives \(|H(f)| = (f/f_c)/\sqrt{1 + (f/f_c)^2}\). Filter people measure gain in decibels:

\[ G_{dB} = 20 \log_{10} |H| \]

−3 dB is 71% (the cutoff), −20 dB is 10%, −40 dB is 1%. A log scale for both frequency and gain (a Bode plot, the middle graph above) turns the curve into nearly straight lines: flat in the passband, falling 20 dB per decade (per 10× in frequency) beyond the cutoff.

How many decibels is a gain of 1% (0.01)?

\(20 \log_{10} 0.01 = 20 \times (-2) = -40\) dB.

A first-order low-pass at 600 Hz. Roughly how much of a 6 kHz tone gets through?

One decade above \(f_c\): \(1/\sqrt{1 + 100} \approx 0.1\).

2. Sharper filters: stacking stages

One RC stage falls 20 dB per decade, gently. Stack \(n\) stages (each buffered by an op-amp so they don't load each other) and the fall gets \(n\) times steeper. Compare orders on the Bode plot.

A third-order filter, a decade above its cutoff. About how many dB down?

Each order adds about −20 dB per decade: \(3 \times (-20) = -60\) dB, a thousandth of the voltage. (Stacked identical RC stages are a little softer near the cutoff; designed filters like Butterworth keep the corner sharp.)

3. Keep one band: band-pass and Q

A coil and a capacitor (chapter 3) resonate at \(f_0 = 1/(2\pi\sqrt{LC})\); in series with a resistor they pass a band around \(f_0\). The width of that band, relative to \(f_0\), is set by \(Q\): high \(Q\) is a sharp peak (tuning one radio station), low \(Q\) a broad hump.

The math

\[ H(f) = \frac{1}{1 + jQ\left(\dfrac{f}{f_0} - \dfrac{f_0}{f}\right)}, \qquad \text{bandwidth (−3 dB)} = \frac{f_0}{Q}, \qquad Q = \frac{1}{R}\sqrt{\frac{L}{C}} \]

At \(f = f_0\) the coil's and capacitor's impedances cancel (\(j\omega L = -1/(j\omega C)\)), leaving only R: full signal through. Away from \(f_0\), whichever reactance wins grows quickly.

A band-pass at 1 MHz with Q = 100. How wide is its passband?

\(f_0/Q = 1\text{ MHz}/100 = 10\) kHz: about the width of one AM broadcast station.

4. Active filters: op-amps instead of coils

Coils are bulky and imperfect at audio frequencies. An op-amp with two resistors and two capacitors, the Sallen-Key circuit, makes a second-order filter with any \(Q\) you like. The value of Q decides the shape: below 0.5 it's droopy, 0.707 (Butterworth) is the flattest possible passband, and higher values add a peak just before the cutoff.

🎯 Challenge: find the Q that's as flat as possible without any peak (Butterworth).

The math, step by step

For the unity-gain Sallen-Key low-pass:

\[ H(f) = \frac{1}{1 - (f/f_0)^2 + j\,(f/f_0)/Q}, \qquad f_0 = \frac{1}{2\pi\sqrt{R_1 R_2 C_1 C_2}}, \qquad Q = \frac{\sqrt{R_1 R_2 C_1 C_2}}{C_2 (R_1 + R_2)} \]

At \(f = f_0\) the real part vanishes and \(|H| = Q\): a Q of 2 means the filter boosts its cutoff frequency twice. To design one: pick \(R_1 = R_2 = R\), then \(C_1 = 2Q/(2\pi f_0 R)\) and \(C_2 = 1/(2Q \cdot 2\pi f_0 R)\) give exactly the \(f_0\) and \(Q\) you want. In time (the right-hand graph, the output after the input jumps from 0 to 1), a high Q rings and overshoots; Butterworth overshoots about 4%; Q = 0.5 creeps up without overshoot. Choosing Q is choosing between a sharp corner and a calm response.

A Sallen-Key low-pass with Q = 2. What's its gain exactly at \(f_0\)?

\(|H(f_0)| = Q = 2\), a +6 dB bump. Fine for a synthesizer's resonant filter; bad for a measurement.

A filter's order sets how steeply it falls, 20 dB per decade for each order, and its Q sets the shape of the corner: sharp and ringing, or flat and calm.

Filters are everywhere: the anti-aliasing filter in front of every ADC (the radio course explains why), the crossover in a speaker, the tuned circuits in a radio, the smoothing after a PWM output. The radio course's chapter 6 builds the same filters in software, with numbers instead of capacitors.

Next: oscillators and timers, circuits that tick.

Previous: Op-amps · All chapters: Learn & build.

Last updated