The purpose of this lab is to examine FIR
filter design/implementation using LabVIEW Digital Filter Design
Toolkit and LabVIEW DSP Module. In this lab, it is assumed that the
student is already familiar with the basic operation of LabVIEW.
- Keep the Surround Mixer open throughout the lab. You will be
selecting various inputs (wave, microphone, and line-in) throughout
the lab.
- Select and activate Surround Mixer, a program which controls
the input/output operation of the sound card. Beneath each of the
volume bars is a mute box that can be toggled on/off. When checked,
the corresponding sound source is deactivated. Make sure that all
source buttons are muted for now.
- Start LabVIEW Embedded Edition and change the target to the
SPEEDY-33 board.
- Create a New Blank VI.
- Open the Front Panel and place two All
Controls»Graphs»Waveform Graphs
- Label them Time Domain and Frequency Domain.
- Open the Block Diagram and place the following objects in it.
- All Functions»Elemental I/O»Analog Input node.
- All Functions»Elemental I/O»Analog Output node.
- All Functions»Numeric»Add function.
- All Functions»Signal Processing»Frequency Domain»Spectral
Measurements.
When you place the Analog Input node, it will display only one channel. It is after you configure it that the right and left channels will be shown.
- Double click the Analog Input node and change the Resource
under the General Tab to be 2 channel multiple samples.
- Go to the Configuration Tab and set the Sample Rate to 8000
Hz and the Framesize to 256.
- Double click on the Analog Output node and change the
resource to 2 channel multiple samples and check that the Sample
Rate is set to 8000 Hz.
- Double click in the Spectral Measurements Express VI and
select Power Spectrum from the type of Measurement.
- Rearrange the objects in the Block Diagram so that you have
plenty of space between them. This makes it easier to connect them
together.
- Connect the 2 outputs of the Analog Input node (Left and
Right channels) to the 2 inputs of the Add function. Connect the
output of the Add function to both inputs of the Analog Output
node. What you are doing here is converting the stereo signal into
a mono signal. Then, connect the output of the Add function to the
Time Domain Waveform graph indicator and to the Signals Input of
the Spectral Measurements. Finally, connect the Power Spectrum
output to the Frequency Domain Graph.
- Place a while loop around the objects in the Block Diagram to
execute this functions continuously.
- In the Surround Mixer activate the Wave/mp3 source and put a
CD into the computer’s CD-ROM drive. Run the Windows Media Player
program in the EE 453 folder to start the CD. Finally, press the
Run button in LabVIEW. You should hear your music through the
headphones. If there is distortion/clipping (due to the volume
being too high), adjust the CD volume on the Surround Mixer to
lower the volume until the clipping stops.
- Once you have verified that everything is working properly,
stop the CD, then stop the LabVIEW VI. (Do not exit LabVIEW)
- Save this VI by selecting File»Save As. Make sure to save the
file in your personal directory - - Desktop \ee 453\<folder
name>. You can give the file any name you want (such as
lab3setup), but use the default extension of .vi
Now we will design an FIR filter using the
same LabVIEW DFD toolkit used for the IIR filters. This LabVIEW DFD
toolkit designs 3 different types of FIR filters: Kaiser-Window
filters, Equi-Ripple filters and Dolph-Chevyshev Windows filters.
We will focus on the Kaiser-Window FIR filters.
- Open LabVIEW (not the Embedded Edition) and create a New
Blank VI.
- In the block diagram, place the All Functions»Digital Filter
Design»Filter Design»DFD Classical Filter Design Express VI.
- Double click in the VI and configure a lowpass FIR filter
with the following settings:
- Type: Lowpass
- Passband edge frequency: 400 Hz
- Stopband edge frequency: 800 Hz
- Passband ripple: 1dB (doesn’t matter because stopband specs
will determine passband ripple)
- Minimum stopband attenuation: 40 dB
- Sampling Frequency: 8000 Hz.
- Design Method: Kaiser Window
- Once you have all the parameters set
correctly, press OK.
- Place the DFD Save to File VI found in All Functions»Digital
Filter Design»Utilities.
- Wire the filter out to the filter in of the DFD Save to File
function. Wire the error clusters.
- Save the VI in Desktop \ ee 453 \<folder name> using
some meaningful title such as Filter Design.vi.
- Run the VI and when prompted save the Filter Coefficients
into the same folder with a meaningful name such as LPFIR400.fds.
Make sure to use the default extension (fds) when saving this
coefficient file.
Determine the predicted filter length M using the Kaiser-window design equation:
Recall that alpha is the desired stopband attenuation and delta-omega is the transition region width (in radians/sample). (Show your work.)
Write down the filter length as calculated by Hypersignal. Does it agree (or come close to) the value predicted above?
- Close LabVIEW and open LabVIEW Embedded Edition. Target the
SPEEDY-33 and open the VI we built in the System Setup section of
this Lab (lab3setup.vi).
- Add two more Waveform Graphs on the Front Panel and label
them as Time Domain–Filtered and Frequency Domain-Filtered.
- Add to the DFD Filter VI (All Functions»Signal
Processing»Filters) to the Block Diagram after the Add function.
Wire the output of the Add function to the DFD filter. Wire the
output of the DFD filter to the Analog Output node. Wire the output
of the DFD filter to the Time Domain – Filtered terminal.
- Make a copy of the Spectral Measurements Express VI. Wire the
output of the Add function to the copy of the Spectral
Measurements. Then wire the output of the Power Spectrum to the
Frequency Domain – Filtered terminal.
- Double click on the DFD Filter VI and select the path to the
Coefficient File. As soon as you load the file, you will see the
magnitude, impulse and phase response graphs update.
- Save the VI. Start the CD Player and then Run the VI. You
should here a heavily lowpass filtered version of your music
through the headphones. You can also see the effect of the
filtering by looking at the appropriate indicators.
- Stop the VI and, without changing anything else, change the
Sample Rate in the Analog Input node to 18000 Hz. Save and Run the
VI and listen to the output now. When done, change the Sample Rate
back to 8000 Hz. Save the VI.
What happens when the sampling frequency used to operate the filter is changed from Fs = 8000 Hz (the Fs used to design the filter) to Fs = 16000 Hz.? Explain
- Stop the VI and disconnect the Analog Input node and the Add
function. Replace these objects with the Simulate Signal Express VI
(Functions»Embedded Signal Generator). Double click to bring up the
properties page and configure it to generate a 200 Hz sine wave
with amplitude 10000. Set the framesize to 256. Make sure that the
sampling frequency is 8000 Hz. Save the VI with a different name.
Run the VI and observe the filtered output. Use the Time-Domain
plot to carefully measure the amplitude of the output
signal.
- Repeat step 16 without changing the name of the file for the
following frequencies: 400 Hz, 600 Hz, 800 Hz.
Complete the following table based on your measured data:
Does this filter yield the gains that you expected at the frequencies above? Why or why not? Specifically comment on the gain at 400 Hz, 600 Hz and 800 Hz.
- Set the Simulate Signal back to 200 Hz. Now run the VI and
stop it. Because the 200 Hz is in the passband of the filter, the
output of the filter will look like the input, except for a time
delay. Carefully measure and record the time (in milliseconds) of
the first zero crossing in the input signal and the corresponding
zero crossing in the output signal.
Record the time delay (in milliseconds) between the input and output signal. Convert this to a sample delay (by multiplying time delay by Fs) and compare it to the theoretically expected answer. Discuss.
Now you are going to add two more FIR filters
that cover the rest of the frequency range DC – Fs/2 and then
combine these FIR filters into a filter bank that will allow you to
selectively boost/attenuate the various frequency ranges. A filter
bank is nothing more than a parallel combination of different
filters. This is basically what a graphic equalizer does on a
typical stereo system, except that many equalizers are analog
filters, rather than digital filters.
- Open LabVIEW (not Embedded Edition) and open the Filter
Design VI built in Section II.
- Design a bandpass FIR filter to meet the following
specifications:
- Type: bandpass
- Design Method: Kaiser Window
- Stop Edge Frequency: 400Hz / 2000Hz
- Passband Edge Frequency: 800Hz / 1600Hz
- Passband ripple: 1 dB (doesn’t matter because stopband specs
will determine passband ripple)
- Minimum stopband attenuation: 40 dB
- Sampling Frequency : 8000 Hz
- After entering the parameters, press OK. Run the VI and save
the filter coefficients as BPFIR800_1600.fds.
The filter length for this BP filter was the same as for the LP filter. Why did this happen?
- Design a highpass FIR filter to meet the
following specifications:
- Type: Highpass
- Design Method: Kaiser Window
- Stopband Edge Frequency: 1600 Hz
- Passband Edge Frequnecy: 2000 Hz
- Passband ripple: 1 dB (doesn’t matter because stopband specs
will determine passband ripple)
- Minimum stopband attenuation: 40dB
- Sampling Frequency: 8000 Hz
- Run the VI and save the coefficient file as
HPFIR2000.fds
You should have noticed that all 3 filters had (nearly) identical filter lengths. For an FIR-based filter bank, this is a very important feature to have. Why? Hint: Think about the phase responses of FIR filters.
You should have noticed that the length of the highpass filter was slightly different than the other filters. What is the reason for this? Hint: Think about the 4 basic types of FIR filters (Type I – Type IV).
- Open the lab3setup VI and change the filter coefficient’s
file in the DFD filter VI to the bandpass filter file. Save the VI
with a different name such as lab3filters.vi. Run the VI and make
sure it works fine.
- Change again the filter file for the highpass filter file. Do
not change the name of the file. Save it and run it.
- Once you have verified that your 2 additional FIR filters
work, add two more DFD Filter VIs to the block diagram and two Add
functions.
- Wire the output of the Add function that adds the Analog
Input node to the two new DFD filters. Configure the three DFD
Filter VIs with the Lowpass, Highpass and Bandpass filter
files.
- Put three Multiply functions and wire the output of the
filters to them. Place three numeric controls in the Front Panel
and set them to 1.
- Wire a numeric control to the other input of the Multiply
functions. Do this for each of the DFD Filter VIs. With this we are
going to control the gain for that filter.
- Wire the output of the Multiply functions to the Add
functions to add the three multiplications or gain sets. Wire the
output of the last Add to the Analog Output node and the signal
input of the Spectral Measurements Express VI.
- The resulting configuration is a 3-band filter bank that
covers frequencies in the range DC-4000 Hz. Note that the frequency
ranges of these 3 filters were selected so that the transition
regions overlap perfectly (i.e. the edge of the passband of one
filter is the edge of the stopband of the prior filter). This type
of overlap yields the best frequency coverage and provides a nearly
constant gain in each transition region. (i.e. As one filter starts
attenuating, the next filter starts amplifying).
- Start your CD. Save and Run the VI. You should hear the music
basically unfiltered, since all frequencies in the range 0-4000 Hz
are passed with a gain of 1. Start playing with the individual
Gains now to boost/attenuate the various frequency ranges by
selecting gains <1 and >1. Don’t select gains too large
(greater than 3 or 4) or else you may start clipping the output
signal. Call your TA over to verify that you have completed this
part of the lab.
When you are done with this lab, exit LabVIEW and LabVIEW Embedded Edition and log off the computer. Unplug the SPEEDY-33 board and turn off the headphone volume booster. Turn in your completed worksheet to the lab TA.
"The purpose of this course, EE 453 at Penn State University, is to familiarize students with DSP development by examining sampling, analysis, and reconstruction of continuous-time signals. […]"