Digital Signal Processing
IIR Filters
In 2018, a medical ultrasound device was recalled after IIR filters in its signal chain began oscillating intermittently during cold boot. The root cause: a Chebyshev filter designed in Matlab (float64) was deployed on a fixed-point ASIC. At cold temperatures, resistor tolerance shifts moved the pole positions just outside the unit circle. The engineers had tested stability in simulation - they had not verified stability under coefficient quantization. IIR filter theory is not academic: it determines whether life-critical medical equipment works reliably.
- **Qualcomm Snapdragon** audio DSP uses 2nd-order IIR biquad sections (SOS form) for real-time EQ in Bluetooth headphones, processing 48 kHz audio with 4th-order Butterworth crossover filters consuming under 0.1% CPU at 32-bit fixed-point - compared to a 100-tap FIR equivalent that would use 30x more compute.
- **Siemens Healthineers** MRI scanners use elliptic IIR filters with 60 dB stopband rejection to suppress gradient switching artifacts at 5 kHz from the 10 MHz RF signal. The elliptic design achieves this in 5 poles where Butterworth would need 20, critical for real-time reconstruction in the scanner's embedded processor.
- **Tesla Autopilot** uses Butterworth low-pass IIR filters in the sensor fusion stack to smooth LIDAR point cloud data at 10 Hz cutoff (vehicle dynamics bandwidth). The flat passband avoids distorting the vehicle motion estimate that the neural network processes for object detection.
Butterworth - Maximally Flat Filter
The Butterworth filter is the 'maximally flat' IIR design: |H(jw)|^2 = 1 / (1 + (w/wc)^(2N)) where N is the filter order and wc is the -3 dB cutoff. The response is flat (no ripple) in the passband - the first 2N-1 derivatives of |H|^2 are zero at w=0. The trade-off is a gradual roll-off: the transition band is wider than Chebyshev or elliptic designs of the same order. Butterworth poles lie on a circle of radius wc in the s-plane, equally spaced in angle.
**SOS (Second-Order Sections)** representation is critical for numerical stability. Representing a high-order IIR as a single transfer function H(z) = B(z)/A(z) causes catastrophic cancellation in floating-point when poles are close together. SOS chains multiple 2nd-order biquad stages, each with poles far from numerical precision issues. Always use output='sos' in scipy and sosfilt() - never use signal.lfilter() with high-order ba coefficients.
A 6th-order Butterworth and a 6th-order Chebyshev Type I filter are both designed with the same -3 dB cutoff and sample rate. Which statement is true?
Chebyshev and Elliptic Filters
Chebyshev Type I filters have equiripple in the passband and monotonic stopband roll-off. |H(jw)|^2 = 1 / (1 + epsilon^2 * C_N^2(w/wc)) where C_N is the Nth-order Chebyshev polynomial and epsilon controls ripple. For the same passband ripple spec, Chebyshev achieves a steeper roll-off than Butterworth with fewer poles. Chebyshev Type II (inverse Chebyshev) has a monotonic passband and equiripple stopband. Elliptic (Cauer) filters have equiripple in both bands - they are the optimal IIR design achieving maximum roll-off for given order, passband ripple, and stopband attenuation.
| Filter | Passband | Stopband | Roll-off for same order | Phase nonlinearity |
|---|---|---|---|---|
| Butterworth | Flat (monotonic) | Monotonic | Lowest | Moderate |
| Chebyshev I | Equiripple | Monotonic | Medium | High |
| Chebyshev II | Monotonic | Equiripple | Medium | Moderate |
| Elliptic (Cauer) | Equiripple | Equiripple | Highest | Very high |
For an anti-aliasing filter in an ADC running at 96 kHz requiring 80 dB rejection above 40 kHz, which filter choice minimizes analog component count?
Bilinear Transform
The bilinear transform converts analog prototype filters (in the s-domain) to digital filters (in the z-domain) via the substitution s = 2*fs * (z-1)/(z+1). This maps the entire j*Omega axis of the s-plane to the unit circle of the z-plane, preserving stability: the left half of the s-plane maps to the interior of the unit circle. The mapping introduces frequency warping: a desired digital frequency w_d corresponds to analog prototype frequency Omega = 2*fs * tan(w_d/2). Pre-warping the critical frequencies before applying the bilinear transform ensures the digital filter meets specifications exactly at those frequencies.
**Why bilinear transform instead of impulse invariance?** Impulse invariance maps an analog filter's poles by s_k -> e^{s_k*T}, which allows aliasing: multiple s-plane poles can map to the same z-plane location. For low-pass and bandpass designs, aliasing is negligible, but for highpass and bandstop filters it causes severe distortion. Bilinear transform maps all of the jOmega axis to the unit circle without aliasing, making it the universal standard for IIR digital filter design from analog prototypes.
Why must critical frequencies be pre-warped before applying the bilinear transform?
IIR Stability and Fixed-Point Considerations
An IIR filter is stable in BIBO (Bounded-Input Bounded-Output) sense if and only if all poles of H(z) lie strictly inside the unit circle: |z_k| < 1 for all poles z_k. In floating-point, bilinear-transform-designed IIR filters maintain this property. In fixed-point implementation, coefficient quantization rounds exact pole positions, potentially moving them outside the unit circle. For a 16-bit fixed-point system, poles placed near z = 1 (low cutoff frequencies) are most vulnerable because small coefficient errors correspond to large pole position errors.
**Direct Form II is numerically dangerous for high-order IIR.** Direct Form II shares delay elements between numerator and denominator, which causes internal overflow before the cancellation in the final output. Use Direct Form II Transposed (scipy's default in lfilter) or, better, always use SOS (second-order sections) with sosfilt(). For fixed-point DSP, limit each SOS section to a 16-bit coefficient range and verify stability after quantization using the pole-check above.
An IIR filter that is stable with double-precision floating-point coefficients will remain stable when implemented in fixed-point with quantized coefficients.
Fixed-point coefficient quantization can move poles outside the unit circle, turning a stable design into an unstable one. This is especially dangerous for low-cutoff filters where poles cluster near z=1, and for high-order filters in direct form.
A 6th-order Butterworth at 100 Hz (fs=8000) has poles at complex positions like 0.9812 ± 0.0523j. The exact pole radius is 0.9826. With 16-bit coefficient quantization (LSB = 2^-15 ≈ 0.00003), the rounded coefficients can place the pole at radius 1.0003 - unstable by 0.01%. This does not matter in simulation but causes the DSP implementation to slowly diverge into oscillation. The fix is to use SOS form (each biquad section has poles closer to the origin, far from the precision boundary) and verify stability post-quantization.
A 6th-order Butterworth IIR is stable in float64 simulation but oscillates when deployed on a 16-bit fixed-point DSP at 10 Hz cutoff (fs=1000 Hz). What is the most likely cause?
Key Ideas
- **Butterworth** (maximally flat) achieves the gentlest possible passband ripple but the widest transition band. **Chebyshev** trades passband (Type I) or stopband (Type II) ripple for steeper roll-off. **Elliptic** achieves the steepest roll-off of any IIR with equiripple in both bands - optimal when filter order must be minimized.
- **Bilinear transform** converts analog prototypes to digital by s = 2*fs*(z-1)/(z+1), mapping all stable s-plane poles to the interior of the unit circle. Pre-warping critical frequencies ensures the digital filter meets its spec exactly at those points.
- **Fixed-point stability** is the critical deployment concern for IIR filters: quantized coefficients can move poles outside the unit circle. Always use SOS form, verify stability post-quantization by checking |pole| < 1, and place higher-Q (closer-to-unit-circle) sections at the end of the SOS chain.
Related Topics
IIR filters extend analog filter theory into the digital domain:
- FIR Filters — FIR and IIR are complementary: FIR is always stable with guaranteed linear phase but needs more taps. IIR achieves the same magnitude response with far fewer coefficients but has non-linear phase and potential stability issues under quantization.
- Z-Transform and Poles — The z-transform is the theoretical foundation for IIR analysis. Filter stability (|poles| < 1), frequency response (H(e^jw) from H(z) on the unit circle), and direct-form implementations all derive directly from z-transform theory.
Вопросы для размышления
- A Butterworth filter of order 8 is implemented in Direct Form II on a fixed-point DSP and oscillates. Redesigning it as 4 cascaded 2nd-order SOS sections stops the oscillation. Why does SOS form solve the stability problem that direct form could not handle for the same filter order?
- An elliptic filter achieves 80 dB stopband attenuation with N=5 poles where Butterworth needs N=16. In a real-time embedded system at 10 kHz sample rate, what is the relative compute cost of each? At what sample rate does the compute advantage of the elliptic filter become critical?
- The bilinear transform introduces frequency warping that grows worse near Nyquist. For a highpass filter with passband edge at 0.9 * Nyquist, how severe is the warping, and how does pre-warping correct it? Show the calculation for fs=1000 Hz and f_pass=450 Hz.