Digital Signal Processing Reference
In-Depth Information
without squaring, averaging, or differentiating, yet it is powerful and efficient. This
equation, as in (7.3), will be used in the following examples.
7.6 PROGRAMMING EXAMPLES FOR NOISE CANCELLATION AND
SYSTEM IDENTIFICATION
The following programming examples illustrate adaptive filtering using the LMS
algorithm. It is instructive to read the first example even though it does not use the
DSK, since it illustrates the steps in the adaptive process.
Example 7.1: Adaptive Filter Using C Code Compiled with
Borland C/C
( Adaptc )
++
This example applies the LMS algorithm using a C-coded program compiled with
Borland C/C
. It illustrates the following steps for the adaptation process using
the adaptive structure in Figure 7.1:
++
1. Obtain a new sample for each, the desired signal d and the reference input to
the adaptive filter x , which represents a noise signal.
2. Calculate the adaptive FIR filter's output y , applying (7.1) as in Chapter 4 with
an FIR filter. In the structure of Figure 7.1, the overall output is the same as
the adaptive filter's output y .
3. Calculate the error signal applying (7.2).
4. Update/replace each coefficient or weight applying (7.3).
5. Update the input data samples for the next time n with the data move scheme
used in Chapter 4. Such a scheme moves the data instead of a pointer.
6. Repeat the entire adaptive process for the next output sample point.
Figure 7.11 shows a listing of the program adaptc.c , which implements the
LMS algorithm for the adaptive filter structure in Figure 7.1. A desired signal is
chosen as 2 cos(2 n
p
f / F s ), and a reference noise input to the adaptive filter is chosen
as sin(2 n
8 kHz. The adaptation rate, filter order, and
number of samples are 0.01, 22, and 40, respectively.
The overall output is the adaptive filter's output y , which adapts or converges to
the desired cosine signal d .
The source file was compiled with Borland's C/C
p
f / F s ), where f is 1 kHz and F s =
compiler. Execute this
program. Figure 7.12 shows a plot of the adaptive filter's output ( y_out ) converg-
ing to the desired cosine signal. Change the adaptation or convergence rate
++
b
to
0.02 and verify a faster rate of adaptation.
Interactive Adaptation
A version of the program adaptc.c in Figure 7.11, with graphics and interactive
capabilities to plot the adaptation process for different values of
b
, is on the accom-
Search WWH ::




Custom Search