DSPRelated.com

Adaptive Filter

Category: Adaptive

An adaptive filter is primarily a digital filter (analog implementations exist but are far less common) whose coefficients are automatically adjusted over time to optimize a performance criterion, typically minimizing the error between the filter's output and a desired reference signal. Unlike fixed filters, adaptive filters can track changes in signal statistics without requiring prior knowledge of the signal or noise characteristics.

In practice

Adaptive filters appear in embedded systems wherever the signal environment is unknown, nonstationary, or both. Common applications include acoustic echo cancellation in hands-free audio devices, active noise control, channel equalization in modems, and system identification. On resource-constrained MCUs, the Least Mean Squares (LMS) algorithm is the most widely used adaptation rule because its per-sample computation scales as O(N) in the filter order N and requires no matrix operations, making it practical on Cortex-M4/M7 cores with DSP instructions and even on some 16-bit DSCs.

The core update equation for LMS is w(n+1) = w(n) + 2*mu*e(n)*x(n), where w is the coefficient vector, mu is the step size, e(n) is the error signal, and x(n) is the input vector. Choosing mu involves a tradeoff: too large and the filter diverges or exhibits excess steady-state error (misadjustment); too small and convergence is slow. The stability bound for LMS is typically cited as mu < 1 / (N * Px), where Px is the input signal power, though the exact bound depends on the LMS variant and the input correlation structure. Normalized LMS (NLMS) divides mu by the instantaneous input power, making the effective step size more robust to power variations and reducing the need to manually retune mu when input levels change, though some tuning may still be needed for convergence speed and misadjustment.

A practical concern in embedded implementations is numerical precision. Fixed-point LMS on a 16-bit DSP can suffer from coefficient stalling, where quantization prevents small gradient updates from accumulating. Using a 32-bit or 40-bit accumulator for the coefficient update, as supported by many DSP-oriented cores such as the TI C28x or Microchip dsPIC, mitigates this. Recursive Least Squares (RLS) converges faster than LMS but in its standard form requires O(N^2) operations per sample and O(N^2) state storage, though some optimized or specialized variants can reduce practical cost; this generally limits its use to lower filter orders or processors with significant compute headroom such as Cortex-A class SoCs.

Adaptive filters are distinct from time-varying filters whose schedules are predetermined. An adaptive filter reacts to measured data at runtime. When the environment is stationary and the filter has converged, it behaves identically to a fixed FIR or IIR filter, which can be a useful debugging checkpoint: freeze the coefficients after convergence and verify the steady-state frequency response matches expectations using a tool like the one discussed in "An Astounding Digital Filter Design Application".

Discussed on DSPRelated

Frequently asked

What is the difference between an adaptive filter and a fixed digital filter?
A fixed filter has coefficients determined at design time and does not change during operation. An adaptive filter updates its own coefficients at runtime using a feedback signal, allowing it to track changes in signal or noise statistics without redesign or reprogramming.
Which adaptation algorithms are most practical for embedded MCUs and DSPs?
LMS and its normalized variant NLMS are by far the most common in embedded work due to their O(N) per-sample complexity and simple implementation. RLS converges faster but costs O(N^2) per sample in its standard form and is generally reserved for small filter orders or processors with substantial DSP throughput, such as Cortex-A or dedicated DSP cores. Affine Projection and frequency-domain LMS occupy the middle ground and appear in audio-class DSPs.
How do I choose the step size (mu) for LMS?
For LMS to be stable, mu must satisfy 0 < mu < 1 / (N * Px), where N is the filter length and Px is the average input signal power, though the precise bound depends on the LMS variant and input correlation. In practice, start with mu roughly an order of magnitude below the upper bound, then tune empirically. NLMS normalizes by instantaneous input power, reducing sensitivity to this choice and making it a safer default for embedded use where signal levels may vary.
Can adaptive filters run in real time on small MCUs such as Cortex-M4?
Yes, for moderate filter orders. As a rough example, a Cortex-M4 running at 168 MHz with the DSP extension (SIMD MAC instructions) can handle LMS filters of order 32 to 128 at audio sample rates (8-48 kHz) in real time under favorable conditions, but actual performance depends heavily on implementation details, memory access patterns, word length, interrupt load, and other concurrent tasks. Higher orders, higher sample rates, or RLS adaptation may require a Cortex-M7, a dedicated DSP core, or careful use of CMSIS-DSP library routines to stay within budget.
What is misadjustment, and why does it matter?
Misadjustment is the fractional excess mean-squared error that remains after LMS has converged, caused by the filter continuing to adapt to gradient noise rather than settling to a fixed solution. It is approximately proportional to mu * N. A larger step size speeds convergence but raises steady-state error; a smaller step size reduces steady-state error but slows tracking of non-stationary signals. In noise-canceling or echo-canceling applications, misadjustment directly sets a floor on achievable suppression depth.

Differentiators vs similar concepts

Adaptive filters are sometimes conflated with time-varying or switched-coefficient filters. A time-varying filter changes coefficients on a predetermined schedule (e.g., a filter bank that switches based on a mode flag), whereas a true adaptive filter derives its next coefficient set from observed input/output data at runtime. Adaptive filters are also distinct from Kalman filters: a Kalman filter is a recursive state estimator for a dynamic system model, while an adaptive FIR/IIR filter minimizes an error criterion directly on the filter coefficients without necessarily modeling underlying system dynamics. In practice the two are complementary; a Kalman filter can be viewed as an adaptive filter with a specific model-based adaptation law.