notesonly.in

One notebook for every subject — open it anywhere.

Log in

Digital Filters: FIR Design and Windowing For students.

A Finite Impulse Response filter, or FIR filter, is a digital filter whose output is a weighted sum of the current input sample and a fixed number of past samples. Each weight is called a tap, and the list of taps is the filter's impulse response, finite in length, hence the name.

FIR filters matter because they can achieve perfectly linear phase: every frequency is delayed by exactly the same amount, so the signal's shape is never distorted. They are also unconditionally stable, using no feedback. That combination makes them the first choice for audio, communications and biomedical signals, where phase distortion would corrupt the result.

Key Concepts

  • Tap weights h[k]: the M coefficients of an order M−1 filter; the output is the sum of h[k]·x[n−k].
  • Linear phase: achieved when coefficients are symmetric around the centre tap; the phase response is then a straight line.
  • Ideal lowpass response: passes everything below cutoff and blocks everything above, but needs infinitely many taps, so we truncate it.
  • Truncation ringing: cutting the ideal response short creates ripples (Gibbs phenomenon) in the frequency response.
  • Window function: a smooth taper such as Hamming, multiplied onto the truncated taps to shrink the ripples.
  • Main lobe vs side lobes: the window's wide central lobe sets the transition width; its smaller side lobes set the ripple level.

Formulas

  • Filter equation: y[n] = sum of h[k]·x[n−k] for k = 0 to M−1.
  • Windowed design: h[n] = h_ideal[n]·w[n], the truncated ideal response times the window.
  • Hamming window: w[n] = 0.54 − 0.46·cos(2πn/(M−1)) for n = 0 to M−1.
  • Ideal lowpass taps: h_ideal[n] = sin(ωc·(n − (M−1)/2)) / (π·(n − (M−1)/2)), with the centre tap equal to ωc/π and ωc in radians per sample.
  • Trade-off: narrower transition needs more taps; lower ripples need a stronger window.

Worked Example

Design a 5-tap lowpass FIR with cutoff ωc = π/2 using a Hamming window. Window values for M = 5: w[0] = 0.54 − 0.46·cos(0) = 0.08, w[1] = 0.54 − 0.46·cos(π/2) = 0.54, w[2] = 0.54 − 0.46·cos(π) = 1.0, and by symmetry w[3] = 0.54, w[4] = 0.08.

Ideal taps centred at n = 2: h_ideal[2] = ωc/π = 0.5; h_ideal[1] = sin(−π/2)/(−π) = 1/π ≈ 0.3183; h_ideal[0] = sin(−π)/(−2π) = 0. Multiplying: h = [0, 0.1719, 0.5, 0.1719, 0]. The taps are symmetric, so phase is linear, and the window has tamed the truncation ripples.

Common Misconceptions

  • More taps are always better. More taps sharpen the cutoff but increase delay and multiplications per sample. Real designs balance sharpness against cost.
  • Windowing removes all ripples. It reduces them greatly, but the price is a wider transition band. Ripple level trades against transition width.
  • Every FIR filter has linear phase. Only symmetric or antisymmetric coefficient sets do; arbitrary taps give arbitrary phase.

Real-World Applications

  • Audio equalizers and speaker crossovers use FIR filters so bass and treble stay time-aligned.
  • Anti-aliasing filters before downsampling in software radio rely on FIR linear phase to keep symbol timing intact.
  • ECG machines clean heartbeat signals with FIR filters that preserve the shape doctors read.

FIR design is a clean recipe: start from the ideal response, truncate it, then window it. The result is just multiply-and-add, which maps beautifully onto DSP hardware.