Foundations to Frontier
Tests
A. Mathematical Foundations › A10 Signal Processing

Filters: FIR, IIR, Low-, High- and Band-Pass

Filters keep the frequencies you want and remove the rest: smoothing a noisy accelerometer, removing motor vibration, isolating a radio channel. This topic covers specifications (passband, stopband, transition band, ripple), FIR design by windowed sinc with exactly linear phase, IIR design by the bilinear transform with Butterworth biquads, the trade-offs between them (taps, delay, phase, stability), and how to turn a low-pass into high-pass and band-pass filters. In the research exercise you compare FIR and IIR filters for an IMU and build a complementary filter that fuses gyro and accelerometer into a tilt estimate better than either alone.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Sieves for signals

A kitchen sieve lets fine flour through and keeps the lumps. A filter does the same for signals. A low-pass filter keeps slow changes and removes fast jitter. A high-pass keeps quick changes and removes slow drift. A band-pass keeps one range, like tuning a radio to one station. Every robot and spacecraft cleans its sensor signals with filters before trusting them.

Filter designer (fs = 1 kHz)
order
0-20-40-60-80Hz (0–500) · dBgroup delay (ms), max shown 16
input 5 + 120 + 300 Hz (grey) → output
gain at 5 Hz 0.0 dB · 120 Hz -39.5 dB · 300 Hz -83.2 dB
FIR filters use only past inputs: always stable, exactly linear phase when symmetric (every frequency delayed by (N−1)/2 samples), but sharp cutoffs need many taps and long delay. IIR filters feed back past outputs: a 4th-order Butterworth achieves a steep roll-off with a few multiplies and little delay, at the cost of non-constant group delay (it peaks near the cutoff) and possible instability if poorly designed.
Why engineers care

Motor and propeller vibration contaminates accelerometers; gyros drift slowly; radio receivers must isolate one channel among many. The filter choice sets how much noise remains and how much delay is added. Delay matters, because a control loop fed late data can go unstable.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A low-pass filter keeps…
  2. 2. To remove slow drift, use a…
  3. 3. Filtering usually adds…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Specifications

A filter is specified by its passband (gain ≈ 1, with allowed ripple), stopband (attenuation of at least A dB) and the transition band between them. The −3 dB point is the cutoff.

FIR vs IIR

  • FIR: y[n]=∑k=0N−1bkx[n−k]y[n] = \sum_{k=0}^{N-1}b_kx[n - k]. Always stable. With symmetric taps it has exactly linear phase: every frequency is delayed by (N−1)/2(N - 1)/2 samples, with no shape distortion.
  • IIR: y[n]=∑bkx[n−k]−∑k≥1aky[n−k]y[n] = \sum b_kx[n - k] - \sum_{k\ge1}a_ky[n - k]. Feedback gives steep responses with few coefficients and low delay, but the phase is nonlinear, stability must be checked (poles inside the unit circle), and quantization effects matter.

Simple examples

  • A moving average of N samples is a crude FIR low-pass.
  • y[n]=ay[n−1]+(1−a)x[n]y[n] = ay[n - 1] + (1 - a)x[n] is a first-order IIR low-pass, the “exponential smoother”.
📝 Quick check (Level 1)
0/3 answered
  1. 1. A 101-tap symmetric FIR delays every frequency by…
  2. 2. Which filter type can be unstable?
  3. 3. The cutoff frequency is usually where the gain is…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

FIR by windowed sinc

The ideal low-pass impulse response is h[n]=2fcfssinc⁡(2fcfsn)h[n] = 2\frac{f_c}{f_s}\operatorname{sinc}(2\frac{f_c}{f_s}n): infinite and non-causal. Truncate it to N taps, centre it, and multiply by a window to control the sidelobes. Hamming gives about −53 dB stopband, and the transition width is about 3.3fs/N3.3f_s/N.

  • High-pass: spectral inversion, hhp=δ−hlph_{hp} = \delta - h_{lp}.
  • Band-pass: a difference of two low-passes.

IIR by the bilinear transform

Start from an analog prototype such as the Butterworth (maximally flat, ∣H∣2=1/(1+(f/fc)2n)\lvert H\rvert^2 = 1/(1 + (f/f_c)^{2n})). Map s→2T1−z−11+z−1s\to\frac2T\frac{1 - z^{-1}}{1 + z^{-1}} and prewarp the cutoff: K=tan⁡(πfc/fs)K = \tan(\pi f_c/f_s). Implement as cascaded second-order sections (biquads) for numerical robustness. A 2nd-order Butterworth low-pass is

b=(K2,2K2,K2)K2+2K+1,a=(1, 2(K2−1)K2+2K+1, K2−2K+1K2+2K+1)b = \tfrac{(K^2, 2K^2, K^2)}{K^2 + \sqrt2K + 1},\quad a = \big(1,\ \tfrac{2(K^2 - 1)}{K^2 + \sqrt2K + 1},\ \tfrac{K^2 - \sqrt2K + 1}{K^2 + \sqrt2K + 1}\big)
🐍 Exercise 1: designing FIR and IIR filters
Design a windowed-sinc FIR low-pass and check its passband, stopband and constant 50-sample group delay. Derive high-pass and band-pass versions. Design a bilinear Butterworth biquad, check its −3 dB point and pole stability, and filter a two-tone signal with it.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Windowing the truncated sinc mainly reduces…
  2. 2. Bilinear-transform prewarping ensures…
  3. 3. High-order IIR filters are implemented as…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Linear phase of symmetric FIR

With h[k]=h[N−1−k]h[k] = h[N - 1 - k], pair the terms: H(ejω)=e−jω(N−1)/2∑kh[k]cos⁡(ω((N−1)/2−k))H(e^{j\omega}) = e^{-j\omega(N-1)/2}\sum_kh[k]\cos(\omega((N - 1)/2 - k)), i.e. a real amplitude times a linear-phase factor. The group delay −d∠H/dω=(N−1)/2-d\angle H/d\omega = (N - 1)/2. ∎

Bilinear transform maps stability

z=1+sT/21−sT/2z = \frac{1 + sT/2}{1 - sT/2} maps the left half s-plane inside the unit circle, so stable analog filters stay stable. Frequency warps as ωa=2Ttan⁡(ωdT/2)\omega_a = \frac2T\tan(\omega_dT/2), which prewarping compensates. ∎

Complementary filtering

A low-pass L(s)=1τs+1L(s) = \frac1{\tau s + 1} and a high-pass 1−L=τsτs+11 - L = \frac{\tau s}{\tau s + 1} sum to 1. Feeding the accelerometer angle through L and the integrated gyro through 1−L1 - L therefore reproduces the true angle (all-pass) while rejecting each sensor’s bad band. In discrete form: θ←α(θ+ωΔt)+(1−α)θacc\theta\leftarrow\alpha(\theta + \omega\Delta t) + (1 - \alpha)\theta_{acc} with α=τ/(τ+Δt)\alpha = \tau/(\tau + \Delta t).

Exercise 3.1: prewarped K for f_c = 10 Hz at f_s = 1 kHz

K=tan⁡(0.01π)≈0.031426K = \tan(0.01\pi)\approx0.031426, slightly more than πfc/fs=0.031416\pi f_c/f_s = 0.031416. Warping matters only near Nyquist.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The bilinear transform maps the left half s-plane to…
  2. 2. In a complementary filter, L + (1 − L) =
  3. 3. Group delay of a symmetric FIR is…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Filtering an IMU on a drone

An accelerometer picks up 80 Hz motor vibration. A 151-tap FIR low-pass at 10 Hz (fs = 500 Hz) removes it by 81 dB but delays everything by 150 ms, far too much inside a stabilization loop. A single Butterworth biquad gives −38 dB with only about 23 ms delay at 2 Hz. For attitude, a complementary filter (τ = 0.5 s) blends the integrated gyro (good at high frequency, but drifting) with accelerometer tilt (unbiased, but noisy and vibrating). Its pitch error is about 11× smaller than the accelerometer alone and 20× smaller than the integrated gyro. That’s how most small drones and phones estimate tilt (Mahony, Hamel and Pflimlin, 2008).

🐍 Exercise 2 (research): FIR vs IIR for an IMU, and a complementary filter
Compare a 151-tap FIR and a Butterworth biquad on vibration attenuation and delay. Simulate a biased gyro and a vibrating accelerometer, and fuse them with a complementary filter. Compare its pitch error with each sensor alone.

Filters in AI, robotics and aerospace

  • Flight controllers: biquad low-pass and notch filters on gyro and D-term paths (PX4, ArduPilot); dynamic notches track motor RPM.
  • Attitude estimation: complementary and Mahony/Madgwick filters on MCUs; the Kalman filter is the optimal generalization (a10-8).
  • Communications: channel selection, matched and raised-cosine pulse-shaping filters.
  • Learning: 1-D convolutional layers are learned FIR filters; anti-aliasing blur before downsampling.

References

  1. A. Oppenheim, R. Schafer (2010). Discrete-Time Signal Processing, 3rd ed. Pearson. Ch. 7.
  2. S. W. Smith (1997). The Scientist and Engineer’s Guide to Digital Signal Processing. California Technical Publishing. Ch. 14–20.
  3. R. Lyons (2010). Understanding Digital Signal Processing, 3rd ed. Prentice Hall.
  4. R. Mahony, T. Hamel, J.-M. Pflimlin (2008). “Nonlinear complementary filters on the special orthogonal group.” IEEE TAC, 53(5).
  5. S. Madgwick, A. Harrison, R. Vaidyanathan (2011). “Estimation of IMU and MARG orientation using a gradient descent algorithm.” IEEE ICORR.
  6. R. Bristow-Johnson. “Cookbook formulae for audio EQ biquad filter coefficients” (Audio EQ Cookbook; W3C note, 2021).
  7. L. Meier et al. (2015). “PX4: a node-based multithreaded open source robotics framework for deeply embedded platforms.” ICRA.