An IIR (Infinite Impulse Response) filter is a discrete-time filter whose output depends on both current and past input samples and on past output samples, making it a recursive structure. Because feedback is present, its impulse response theoretically extends infinitely in time.
In practice
IIR filters are widely used in embedded signal processing when computational efficiency matters. For a given filter order, an IIR design typically achieves a much steeper frequency response than an equivalent FIR filter, meaning fewer multiply-accumulate operations per output sample. This makes IIR filters attractive on resource-constrained MCUs and DSPs where cycle budgets or RAM are tight.
The most common embedded implementation is a cascade of second-order sections, called biquads. Each biquad has two poles and two zeros and is described by five coefficients. Cascading biquads is numerically more stable than implementing a high-order filter as a single Direct Form I or II structure, because coefficient quantization errors are isolated to each section. The blog post "Design IIR Filters Using Cascaded Biquads" covers this structure in detail. Common classical designs -- Butterworth, Chebyshev, elliptic -- are routinely realized this way; "Design IIR Butterworth Filters Using 12 Lines of Code" walks through the Butterworth case.
A critical practical concern is stability. Because IIR filters feed output samples back into the computation, poles can move outside the unit circle under fixed-point arithmetic, causing the filter to become unstable and produce a runaway or oscillating output. This risk is highest with narrow-bandwidth or high-order designs and with low word widths (e.g., 16-bit fixed-point). Careful coefficient scaling, selection of the correct Direct Form, and, where possible, use of 32-bit or floating-point arithmetic all help maintain stability. "Improved Narrowband Lowpass IIR Filters" specifically addresses this challenge for narrowband cases.
A first-order IIR lowpass -- sometimes called an exponential moving average -- is one of the most frequently used constructs in embedded firmware. It requires only one multiply, one add, and one state variable, making it practical even on 8-bit MCUs. It is commonly applied to ADC readings, sensor fusion outputs, and control loop signals. "The First-Order IIR Filter -- More than Meets the Eye" explores its behavior and limitations in depth.
Discussed on DSPRelated
Frequently asked
What is the difference between an IIR filter and an FIR filter?
An
FIR (Finite
Impulse Response) filter uses only past and present input samples -- no feedback -- so its impulse response is finite and it is unconditionally stable. An IIR filter feeds past output samples back into the computation, which makes it recursive and potentially unstable, but allows it to achieve a given frequency-selectivity specification with a much lower order (fewer coefficients and operations) than a comparable FIR design.
Can IIR filters become unstable on embedded hardware?
Yes. Stability requires that all poles remain inside the unit circle. In
floating-point arithmetic this is rarely a practical problem for reasonable designs, but in fixed-point implementations, coefficient quantization can shift poles outside the unit circle, especially for high-order filters or very narrow passbands. Biquad cascade structures, careful coefficient scaling, and sufficient word length (32-bit fixed-point or floating-point is common in practice) all reduce this risk.
Do IIR filters introduce phase distortion?
Yes, in general. Classical IIR designs (Butterworth, Chebyshev, elliptic) have nonlinear
phase responses, meaning different frequency components are delayed by different amounts. This matters in applications sensitive to waveform shape or relative timing across frequencies, such as some communications and biomedical systems.
FIR filters can be designed with
linear phase; if phase linearity is a hard requirement, an IIR filter may not be appropriate.
What is a biquad, and why is it the preferred implementation structure?
A biquad is a second-order IIR section with two poles and two zeros, described by five coefficients (b0, b1, b2, a1, a2). Higher-order IIR filters are built by cascading multiple biquads. This structure is preferred because quantization errors in one section do not interact with those in others, making the cascade numerically better-conditioned than a single high-order direct-form implementation. Most DSP libraries for Cortex-M parts (including CMSIS-DSP) provide optimized biquad cascade routines.
How do I design IIR filter coefficients for an embedded target?
Coefficients are almost always computed offline using a tool such as
MATLAB, Python (
scipy.signal), or Octave, then hard-coded into firmware as constant arrays. You specify the filter type (Butterworth, Chebyshev, etc.), the
sample rate, and the cutoff or passband frequencies, and the tool produces the biquad coefficients. For fixed-point targets, the coefficients must then be scaled and quantized to fit the available word length. The posts 'Design IIR Butterworth Filters Using 12 Lines of Code' and 'An Efficient
Lowpass Filter in Octave' demonstrate this workflow.
Differentiators vs similar concepts
IIR filters are most often contrasted with
FIR (Finite
Impulse Response) filters. The key distinctions are: IIR filters are recursive (use feedback) while FIR filters are non-recursive; IIR filters can match a given frequency-selectivity target with a lower order than FIR, reducing computation; FIR filters are unconditionally stable and can be designed with
linear phase, while IIR filters are conditionally stable and generally have nonlinear
phase. In embedded work the trade-off is typically computational cost and memory (favoring IIR) versus stability guarantees and phase linearity (favoring FIR).