D5 · Lesson 5 · IIR filters
Filters that feed their own output back, the one-pole smoother with its exponential memory, time constant and corner frequency, why a few feedback coefficients do the work of hundreds of FIR taps, the biquad section, designing from analog prototypes with the bilinear transform, and the stability and phase costs
An FIR filter remembers only its last N inputs. Let a filter also remember its own past outputs and it can remember forever: an impulse sets off a response that decays but never quite ends, so it's called infinite impulse response. The simplest one, "new output = 0.9 × old output + 0.1 × new input", is a digital RC low-pass in one line of code, and it's in every sensor-smoothing routine ever written. Feedback makes IIR filters extraordinarily efficient, but it also brings the analog world's problems back: phase distortion and the possibility of instability.
- The frequency response of the one-pole smoother at a sampling rate of 1 kHz: .
- As a approaches 1 the filter remembers longer and its corner moves down. Its DC gain is always 1.
- It behaves like an RC low-pass with a time constant of samples, until the response flattens near the Nyquist frequency.
Predict
A sensor reading is smoothed by at 1000 samples per second. After a sudden step in the reading, about how long does the output take to cover 63% of the step?
After n samples the remaining error is of the step, which falls to 1/e when n = −1/ln 0.9 = 9.49 samples, 9.5 ms at 1 kHz. The handy approximation = 10 samples is close when a is near 1. Reaching 99% takes ln 0.01/ln 0.9 = 44 samples.
Name it
The IIR filter
The feedback terms give the transfer function poles (lesson 6). A filter is stable only if every pole lies inside the unit circle; quantizing the coefficients can push a pole outside.
The one-pole smoother
has DC gain 1, a time constant of samples, and a −3 dB frequency where
To get a time constant of τ samples, use .
Efficiency
A fourth-order IIR elliptic filter can match the sharpness of a 100-tap FIR filter with about 10 multiplications per sample. In practice, high-order IIR filters are built as cascades of second-order biquad sections, each over , because one big high-order polynomial is too sensitive to coefficient rounding.
Designing from analog prototypes
Butterworth, Chebyshev and elliptic designs (C4) carry over through the bilinear transform , which maps the whole analog frequency axis onto the digital one up to the Nyquist frequency. That squeezes frequencies, so the analog prototype is designed at the prewarped frequency
for each critical digital frequency .
The cost
IIR filters can't have exactly linear phase, so they distort waveform shapes, and their feedback makes them sensitive to rounding (lesson 12).
Worked example
For a = 0.9 at 1 kHz, where's the −3 dB point? What a gives a 100-sample time constant?
Show the solution
- Cosine of the corner. Put in :
- Corner angle.
- Corner in hertz.
- Pole for τ = 100 samples.
Answer the −3 dB point is at 16.8 Hz, and a = 0.99005 gives a 100-sample time constant.
Worked example
A digital low-pass at 8 kHz needs its corner at 1 kHz. At what frequency should the analog prototype be designed?
Show the solution
- Prewarp the corner.
- Check. The bilinear transform's squeeze then lands the corner exactly at 1 kHz.
Answer design the analog prototype with its corner at 1054.8 Hz.
Worked example
A one-pole smoother at 1 kHz should have a 10 ms time constant. What pole a does it need?
Show the solution
- Pole. Each sample should keep this fraction of the previous output:
- Difference equation. The input gets the rest, 0.095:
- Analog equivalent. It's the digital equivalent of an RC filter with RC = 10 ms.
Answer a = 0.905, so .
Check
A one-pole smoother with a = 0.9 runs at 1 kHz. What's its time constant?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
What coefficient a gives a one-pole smoother a time constant of 5 samples?
Check
Where is the −3 dB point of a one-pole smoother with a = 0.9 at 1 kHz?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
A digital filter at 32 kHz needs a critical frequency of 6 kHz. At what frequency should its analog prototype be designed for the bilinear transform?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
Check
A one-pole smoother at 1 kHz should have a 10 ms time constant.
(a)
What pole a?
(b)
What input weight ?
Check
A bilinear-transform low-pass at 8 kHz needs a digital corner at 1 kHz.
(a)
Where should the analog prototype's corner be (prewarped)?
Write units the way you normally would: 1.5 kHz, 1500 Hz and 0.0015 MHz are the same answer.
(b)
How far above the target is that, in percent?
Explain why
How can a few feedback coefficients replace hundreds of FIR taps?
An FIR filter can only shape its output from the inputs within its window, so a sharp transition or a long memory needs a long window and many multiplications. An IIR filter feeds its own past outputs back in, so each output already summarizes the whole history of the input, weighted by an exponentially decaying memory. That recursion lets a handful of coefficients produce resonant peaks and steep slopes, poles in the transfer function, that an FIR filter can only approximate with hundreds of zeros. The price is that the phase response can't be exactly linear and the feedback can turn unstable if a pole is pushed outside the unit circle.
Practice
Keep practicing
8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.