You are on page 1of 2

How Does the LMS Adaptive Filter for DSP Work? - National Instruments http://digital.ni.com/public.nsf/allkb/728BFFD44E6F421986256FF50...

Improve your ni.com experience. Login or Create a user profile.

18 ratings: 2.88 out of 5 Rate this Document

How Does the LMS Adaptive Filter for DSP Work?


Primary Software:
Primary Software Version: 1.0
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem: The DSP LMS Adaptive Filter has either a DSP primitive or a greyed Windows version that
uses a function node. How Does this filter work?

Solution: First, let us consider how the filtering takes place, then we will consider how it adapts, and
what it adapts to. An FIR filter is Finite Impulse Response, which means in the time domain that the
output signal of the filter is not fed back into the input. From a sound perspective, this means the input
audio is filtered but does not have the characteristics of reverb, or the echo that you hear when you are
whistling in a marble room.

The FIR Filter is implemented in the time domain by creating several delayed versions of the input
signal. Each of these delayed versions of the signal is referred to as a "tap" in filter lexicon. This number
of taps also determines the "order" of the filter. Each of these delayed versions of the signal is added to
the original signal, with some weighting factor. That is, each delayed version is multiplied by a number
between 0 and 1. The characteristics of these weighting factors and the number of taps determine the
response of the filter. The higher the number of taps, the greater the quality of the filter for eliminating
unwanted frequencies, and the sharper the edge is between the passband (desired frequencies) and
the stopband (undesired frequencies). For a bandpass filter, the band will be narrower for a higher-order
filter. The higher the order the filter, the more computational resources are necessary, since each filter
requires a multiply and combine operation.

The total time delay in seconds for N taps is given by:

delay = (N-1)/(2 * Fs)

Where Fs is the sampling frequency.

How do you know which coefficients to use to weight the output of the different taps? This is not an
easy question to answer, since each application requires different filter characteristics. There are some
basic things to know about the coefficients. First, if the filter is to preserve the phase relationship of all
the frequencies that make up the input signal, then the coefficients need to be symmetric about a center
coefficient. For example, if you have a 7-tap filter, then coefficient 1 and 7 should be the same, 2 and 6
should be the same, 3 and 5 the same, and 4 is the "center" coefficient.

To get the coefficients out of an unknown filter, you can use the impulse response. This is done by
sending an impulse signal (the perfect impulse is a one in array element 0 followed by all 0's in the rest
of the input array). Since the number 1 is passed through each tao and multiplied by the coefficient, the
resulting output will be an array of filter coefficients. The reverb of a room can be modeled by using an
impulse (say a clap of the hands) into the room. The output of the room will be the fitler coefficients.
Since reflections are traveling around the room and you can hear the sound long after your hands are at
rest, this is not an FIR but an IIR filter. Still an interesting real-world example that is used in music
software to model the characteristics of different performance spaces.

Since the ideal array of filter coefficients can be hard to identify, wouldn't it be nice if I could compare my
input signal with a desirable output signal, and automatically create a filter to get the input as close to
the output as possible? This is the function of the LMS Adaptive Filter.

The filter starts out with a coefficient of zero for each tap of the N taps, and calculates the difference on
an element-by-element basis of the Input signal and the Reference Signal. The square of the sum of
these errors it what we will set out to minimize.

The gradient of the error is calculated (an N-dimensional vector for N taps), and used to determine
which direction the coefficients should go. There is a factor in front of the gradient to determine how
extreme the reaction is. This is the filter convergence factor.

The steps are repeated until the Input signal and the Reference signal are within some acceptable error
of one another. The effect of the convergence factor should be familiar to those who have used PID
control. If the convergence factor is high, the filter may converge more quickly. However, it is possible to
reach overshoot and indeed diverging conditions so tune the filter with care. Depending on the
coefficients found during the adaptation process, the filter may become resonant and levels may quickly
exceed reasonable ones for the system.

1 of 2 03.08.2010 16:21
How Does the LMS Adaptive Filter for DSP Work? - National Instruments http://digital.ni.com/public.nsf/allkb/728BFFD44E6F421986256FF50...

My Profile | RSS | Privacy | Legal | Contact NI


© 2010 National Instruments Corporation. All rights reserved.
| E-Mail this Page

2 of 2 03.08.2010 16:21

You might also like