E E 2 7 5 Lab
October 6, 2007
Lab 6a. Adaptive Filters 1
Here are some examples where Adaptive filters are used.
We do the experiments in Sections 2 and 3.
Noise Cancellation (or Interference Cancellation) In noise cancellation, adaptive filters let you remove noise from a signal in real time. Here, the desired signal d(n) the one to clean up, combines noise and desired information. To remove the noise, feed a signal n’(n) to the adaptive filter that represents noise that is correlated to the noise to remove from the desired signal.
s(n) + n(n) d(n) y(n) Adaptive Filter
n‘(n)
e(n)
Figure 1: Adaptive Noise Canceller So long as the input noise to the filter remains correlated to the unwanted noise accompanying the desired signal, the adaptive filter adjusts its coefficients to reduce the value of the difference between y(n) and d(n), removing the noise and resulting in a clean signal in e(n). Notice that in this application, the error signal actually converges to the input data signal, rather than converging to zero.
Inverse System By placing the unknown system in series with your adaptive filter, your filter adapts to become the inverse of the unknown system as e(k) becomes very small. As shown in the figure the process requires a delay inserted in the desired signal d(k) path to keep the data at the summation synchronized. Adding the delay keeps the system causal. Plain old telephone systems (POTS) commonly use inverse system identification to compensate for the copper transmission medium. When you send data or voice over telephone lines, the copper wires behave like a filter, having a response that rolls off at higher frequencies (or data rates) and having other anomalies as well.
Delay d(n) e(n)
y(n) s(n)
Adaptive Filter
Unknown System x(n)
Figure 2: Identifying Unknown System Adding an adaptive filter that has a response that is the inverse of the wire response, and configuring the filter to adapt in real time, lets the filter compensate for the rolloff and anomalies, increasing the available frequency output range and data rate for the telephone system.
System Identification One common adaptive filter application is to use adaptive filters to identify an unknown system, such as the response of an unknown communications channel or the frequency response of an auditorium, to pick fairly divergent applications. Other applications include echo cancellation and channel identification. Unknown System d(n)
y(n) Adaptive Filter
e(n)
x(n)
Figure 3: Identifying Unknown System In the figure, the unknown system is placed in parallel with the adaptive filter. This layout represents just one of many possible structures. Clearly, when e(n) is very small, the adaptive filter response is close to the response of the unknown system. In this case the same input feeds both the adaptive filter and the unknown. If, for example, the unknown system is a modem, the input often represents white noise, and is a part of the sound you hear from your modem when you log in to your Internet service provider.
2
Experiment 1: Use of Adaptive Filters with the LMS Algorithms for Signal Enhancement
We will run one adaptive filter demo. Go to MATLAB Help. Highlight Demos. Go to Toolboxes and look at the drop down menu. Go to Filter Design and look at the drop down menu. Go to Adaptive Filters and look at the drop drown menu. Highlight Getting Started with Adaptive Filters (ADAPTFILT) Objects and look at the material on the right-hand side. You will run all the pieces of code contained therein, starting from code contained in Desired Signal and ending with code contained in Theoretical Learning Curves. Note: You can run any code on the right-hand side by highlighting it with your mouse, going to Go in the menu, and invoking Evaluate Selection. The corresponding code will automatically run in MATLAB. (You don’t have to manually copy the code into the Command Window and run it from there). We will use a very simple signal enhancement application as an illustration. While we demonstrate with two algorithms only, there are about 30 different adaptive filtering algorithms included with MATLAB’s Filter Design Toolbox.
x(n)
y(n) Adaptive
Filter
v2(n)
e(n) = x(n) - y(n)
Figure 4: Signal Enhancement Do the following: 1.
Generate the 1000 points of signal s(n). Generate the 1000 points of an “autoregressive process” v1(n). Describe why it is called an AR process? Now generate the noise corrupted sine wave x(n).
2. Check to see if s(n) and v1(n) are correlated. You don’t want them to be. You can use xcorr. What should xcorr give you if the two signals were correlated? (Applying xcorr on x(n) and x(n) will show what xcorr gives for correlated signals). 3. Now since you are trying to remove noise (the AR process) from the sine, and since you are using this type of adaptive filter, you need another signal that is correlated with the noise. This is called the reference signal v2(n). Generate the MA process v2(n). Is it correlated with v1(n)? (You are looking for a correlated signal to make this work). 4. Generate the 7-tap LMS filter hlms and the normalized 7-tap LMS filter hnlms. (We will see afterwards what these are. They are simply 7-tap FIR filters whose weights change as per some algorithm which depends on the error e(n).
5. Choose the two step sizes. (We will see this later on). 6. Now we are all set. As per Figure 4, we can run the adaptive filters with inputs v2(n) and x(n) and let them adapt their weights so that the error e(n) becomes minimum (in some sense). 7. For comparing how well this filter does, a 7-tap Wiener filter is generated to remove the noise. Do it. 8. Plot the results as MATLAB does. Compare the filter coefficients. 9. Plot the MSE for 25 simulations and see how well and how fast the filter converges. 10. Plot the theoretical MSE curve.
3 1.
4
Experiment 2 Under Demos, Filter Design, Adaptive Filters → run the code contained in either Adaptive Line Enhancer or Adaptive Noise Cancelling applied to Fetal Electrocardiography.
The LMS or Widrow-Hoff Algorithm
You can see the LMS algorithm if under Help, you search for “LMS Algorithm (learnwh). (The material in this lab handout derives mostly from MATLAB’s Help documentation )
c 2006GM