





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






University of Rhode Island Department of Electrical and Computer Engineering ELE 436: Communication Systems
This lab will provide an introduction to the Analog Devices EZ-KIT LITE DSP board: a few simple demos on the board will be covered, and implementation of different kinds of FIR filters such as low pass, high pass, band pass, and band stop will be done. A brief explanation of FIR filters will be given. These filters will be designed using the Remez exchange algorithm function available in the MATLAB signal processing toolbox. The filter coefficients generated by the MATLAB file will written to a separate file. This output file in turn will be inserted into a C program which will be compiled and downloaded the DSP board. Audio signals and signals generated by a function generator will be filtered through the board and the output will be sent to a speaker and observed on a spectrum analyzer.
The DSP board has a SHARC processor manufactured by Analog Devices and can sample up to 48 kHz. The following steps will guide you through the setup and testing of the board.
One class of filters that do not use output feedback are nonrecursive and hence have a finite impulse response (FIR). One form of FIR structure is obtained by implementation of the discrete convolution: y(n) =
∑^ ∞ m=−∞
h(m)x(n − m). (1)
where x(n) is the input signal, and h(n) is the FIR filter impulse response. If the impulse response h(m) = 0 for m < 0 and m ≥ N, then equation (1) becomes
y(n) =
N∑ − 1 m=
h(m)x(n − m). (2)
This is a difference equation, but it is nonrecursive as y(n-m) does not appear on the right. The Z transform of equation (2) has all its poles at the origin; so it must be a stable system. The length of the impulse response is N samples. The Z transform of any filter has the form
H(z) = B A((zz)). (3)
For an FIR filter, A(z) = 1, since it does not have poles in the Z-plane other than at the origin. However it has N-1 zeros. So the equation for the Z transform of the impulse response can be written as
y(n) =
N∑ − 1 m=
h(m)z−m. (4)
We can design the FIR filter such that H(z) is a lowpass, highpass, bandpass, or bandstop filter.
The required MATLAB file is already written for you. It is in C:\EZ-KIT\EZSHARC\tt. The name of the file is dsp filter.m. Open the file and read the program. As you will see, the first line of the program is function dsp filter(N,F,A,file name). When you are in MATLAB under C:\EZ-KIT\EZSHARC\tt, call the function by typing dsp filter(...). The information in the parentheses has to be entered by you.
[ 0, start of tr band1, stop of tr band1, start of tr band2, stop of tr band2, 1 ] As you know, the band pass filter has two transition bands. The four start and stop frequencies are entered as fractions of the Nyquist. For example, entering [0 .2 .3 .7 .8 1] will produce the first transition band from 20% to 30% of the Nyquist, and the second transition band from 70% to 80% of the Nyquist.
After the function has been called, the program will compile and two plots will appear. One will have the magnitude of the filter in dB and linear scale. The other shows the coefficients of the impulse response of the filter. Study these plots carefully. Look at the coefficients of the impulse response of the low pass filter. What is the shape of the impulse response? Can you see the relationship between the filter and impulse response? Are the impulses centered around the origin? If yes or no, why do you think this is? Re-run the MATLAB function for any kind of filter, but make the transition bands finer. For example, for a low pass filter, enter [0 .5 .55 1] as the F array instead of [0 .5 .6 1]. Do you notice a change in the magnitude plots? Why do you think this happens? How can you fix this problem?
After running the MATLAB function, make sure an output file with a ’.h’ extension of the filename that you denoted in the function call has been created in the directory. You can view this file in Notepad, and you will see a list of numbers created. These are the required coefficients of your filter that are going to be used by the C program. Close this file without modifying anything. This is very important. If you do modify something by mistake, make sure you do not save changes as you will have to re-run your MATLAB function dsp filter. Under the same directory, open the file tt.c. After scrolling down a little you will come to the section where you will see the following text
#define NUM TAPS 129
float pm coeffs[NUM TAPS] = { #include ”lpf.h” };
float dm state[NUM TAPS+1];
Change ”lpf.h” to ”filename.h”. So basically change the code to include the name of your filename that you denoted in the function call in MATLAB instead of lpf.h. Also change the NUM TAPS to 51. The NUM TAPS is defining the number of coefficients and it always has to be one more than the order you defined in the MATLAB function. Why? Save the file tt.c and close it. In C:...\tt, you will see a file called Mk.bat. Double click on this file. This will invoke a DOS window and compile the tt.c file. Close the DOS window after it has finished compiling. Now, just go to the EZ-KIT Lite Host window. Go to File and then Demos. Choose the talkthru demo. You should hear the filtered sound from your audio source. You can play around with different values of the sample rate and filter gain and listen to the difference in the sound with different sampling rates. The filter gain will just increase the amplitude of the sound. After you have done the procedure with a certain type of filter, go back and re-run the MATLAB function with a different filter with different characteristics. Make sure you change the filename every time. Go through the rest of the steps mentioned above and you will hear distinct differences in the sound with the different types of filters.
Design and implement a filter (on the DSP board) that will pass only the third harmonic of a 1kHz square wave (i.e. the harmonic at 3kHz). Justify your choices for the sampling rate, filter order, pass band, transition band, and stop band. Include all relevant Matlab plots and data from tests.
(^00) 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
1
1.4^ lowpass
Frequency
Magnitude
50% of Nyquist
60% of Nyquist (^) Nyquist
Figure 1: Low Pass Filter
(^00) 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
1
1.4^ highpass
Frequency
Magnitude
Nyquist
60% of Nyquist
50% of Nyquist
Figure 2: High Pass Filter