Escolar Documentos
Profissional Documentos
Cultura Documentos
Lab
Collection Editor:
Erik Luther
Fundamentals of Digital Signal Processing
Lab
Collection Editor:
Erik Luther
Authors:
Jim Cahow
Erik Luther
Online:
< http://cnx.org/content/col10303/1.5/ >
CONNEXIONS
A self-contained, high-performance, programmable DSP board for signal processing applications. The
SPEEDY-33 comes equipped with a Texas Instruments DSP for high speed DSP calculations and Analog to
Digital (A/D) and Digital to Analog (D/A) converters for interaction with the outside world.
1
CHAPTER 1. DSP LABORATORY: INTRODUCTION, HARDWARE AND
2
SOFTWARE SETUP
1.1.1.1.4 Audio Cable to go from the computer sound card to the microphone.
The DSP board is responsible for the high-speed DSP calculations and the daughter card controls the A/D
and D/A conversion between the DSP board and the outside world.
1.1.2 Software:
The software used in the lab is National Instruments LabVIEW DSP Module
4 ; a block diagram-based graph-
ical programming package for digital signal processing that will be used for: data acquisition, time domain
data display, frequency domain calculation and display, lter implementation, convolution and correlation
calculations, speech/signal modeling, and real-time ltering. Using LabVIEW DSP Module in conjunction
with the LabVIEW Digital Filter Design Toolkit, the DSP board and the rest of the lab equipment will not
only allow students to perform data acquisition, analysis, and ltering, it will also give them the ability to
listen to the ltered output.
note: Instructions are included for both the SPEEDY-33 and TI 6711 DSK, follow instructions
appropriate to the hardware on your station.
4 http://digital.ni.com/express.nsf/bycode/ex3wxw
• Switch the Jumpers on the SPEEDY-33 to the Line position. Refer to Figure 1 for the location of the
Line/Microphone Jumpers (Figure 2 #9).
• Plug the A/C adapter into the DSP board and make sure that the power LED is lit.
• Connect your headphones to the black 3-pronged headphone booster and connect this booster to the
OUT jack on the audio daughter card attached to the DSP board. Do not use the OUT jack directly
on the DSP board. Turn on the headphone volume booster.
• Connect the light gray cable coming out of the computer (which is the audio output from the computer
sound card) to the short gray male-male adapter cable and connect this, in turn, to the IN jack of the
audio daughter card. Do not use the IN jack directly on the DSP board. The soundcard output (either
CD audio or microphone) will be the input to the DSP board for most of this lab.
• Log on to the computer.
• Once you log on, a DSK Init window should appear on the task bar. Click on it to open up the window
and then press ENTER as often as needed to complete the initialization. This congures the parallel
port of the computer to communicate with the DSP board. Note: If you forgot to supply power to the
DSP board prior to this step, the initialization will fail. In which case, you will have to log o, power
up the DSP board, and then log on again and run the initialization routine again.
• Select the EE 453 folder and create a folder within this folder to store your lab les. Use some
descriptive name to identify your lab group. The path for this folder will be Desktop\ee 453\<folder
name>
• Activate Surround Mixer, a program which controls the input/output operation of the sound card.
The Surround Mixer control panel is a mixer consisting of numerous volume bars, each controlling a
dierent aspect of the sound card. The far left volume bar controls the master volume. Make sure that
the master volume is set to 100%. The volume bars in the middle control the various types of sound
sources that the sound card can play (wave les, microphone input, MIDI input, music CD input, etc).
Make sure that the wav/mp3, microphone, and line-in volumes are set to 100%.
• Beneath each of the volume bars is a mute box that can be toggled on/o. When checked, the
corresponding sound source is deactivated. Make sure that all source buttons are muted for now.
• Keep the Surround Mixer open throughout the lab. You will be selecting various inputs (wave, micro-
phone, and line-in) throughout the lab.
note: When you are nished with each lab, exit LabVIEW, log o the computer, turn o the
function generator and the headphone volume booster, and unplug the DSP board from the A/C
adapter. Turn in Answered Questions to the TA.
7
CHAPTER 2. DSP LABORATORY: ANALOG TO DIGITAL AND DIGITAL
8
TO ANALOG CONVERSION
1. Select FileNew VI to start a new LabVIEW application. (Note: A LabVIEW application is called
Virtual Instrument or VI). Any LabVIEW VI consists of two windows; a Front Panel where you will
design your user interface and a Block Diagram where you will add various block components or VIs
and wire them together to design your DSP system. On starting a new VI you will see the Front Panel
and Block Diagram windows for your application appear on the screen.
2. Switch over to the Block Diagram window by left clicking on it and start developing your application.
You will now develop a simple VI to read in an analog input from the A/D channel and play it back
using the D/A channel. From the menu select WindowShow Functions Palette. The Functions pallet
contains functions or VIs that you will wire together to develop the application. Click on the Elemental
I/O palette and bring out the Analog Input Elemental I/O node and place it on the block diagram.
This node is used to read in analog input from the A/D channel. Similarly place the Analog Output
Elemental I/O node on the block diagram. Refer to Figure 3 below for details.
Figure 2.2: Analog Input and Analog Output Elemental I/O nodes.
3. The Analog Input and Output nodes control the input/output ow of sound waves/data between the
analog input channels and the DSP. The Analog Input node controls the A/D converter, which converts
the analog input signal (from the microphone, function generator, or any other analog sound source)
to a sequence of numbers (digital data) and passes the data on to the DSP. The analog Output node
controls the D/A converter, which takes the digital data from the DSP and converts it back to an
analog signal.
4. Now we need to congure the Analog Input and Analog Output nodes. Double click on the Analog
Input node to bring up its conguration dialog. In this dialog specify the following setting:
• General Tab:
• Resource: 2 channel multiple samples
• Conguration Tab
• Sample Rate in Hz: 48000
• Framesize: 256
Figure 2.3
6. Double click on the Analog Output node. On its Conguration dialog specify the parameters as follows:
• General Tab:
• Resource: 2 channel multiple samples
• Conguration Tab
• Sample Rate in Hz: 48000
Figure 2.4
7. Before running any DSP algorithm, the Analog Input and Output nodes need to be wired together.
Hover your mouse over the Left channel output of the Analog Input node, the mouse curser will change
to a wire spindle. Left click and drag the wire to the Left channel input of the Analog Output node.
8. We will now place a While Loop so that the process can be run in a loop. Bring out a While Loop
from the FunctionsStructures Palette. Place the While Loop around the two nodes by left clicking
on the top left corner and dragging it to the bottom right. The nal application will look like Figure
4. Notice a stop button appears which is wired to the conditional terminal of the loop. You will also
see a stop button on the front panel. Once the application is run you will press this button to stop the
application.
9. Save your VI by selecting FileSave As and storing it in the directory you created earlier. You can
give the le any name you want (such as lab1setup), but use the default extension of vi.
10. Now you need to prepare an audio input for your system. First, go to the Surround Mixer and activate
the Wave/mp3 input. Place a CD in the CD player in the PC, select the Windows Media Player
program, and press play. (Note: The program may automatically start when you insert the CD).
You should not hear anything yet, because you haven't compiled and downloaded the simple playback
program to the DSP yet.
1. You're nally ready to run this very simple DSP system. (If using the SPEEDY-33 make sure that the
Jumpers are in the Line position). To run the application left click on the run arrow on the toolbar
as shown in Figure 4. Notice on the LabVIEW DSP Module Status Monitor window comes up and
displays the Status as the application is compiled and downloaded onto the DSP. The Memory Usage
bar at the bottom displays the amount of memory being used. Once Status displays Running on Target
you should hear the music through the headphones.
2. To use the microphone input instead of the CD Audio input, simply mute the Wave input button on
the Surround Mixer and activate the Microphone input instead. Give it a try. You can very quickly
toggle between (or even combine) dierent inputs by using the Surround Mixer.
3. Stop the program by pressing the Stop button on the Front Panel.
4. Eects of Sampling Frequency on Sound Quality
5. Now we'll briey examine the eects of sampling frequency on the sound quality of both music and
voice signals.
6. Run the program again with CD audio input (using the original sampling frequency of 48000 Hz.) and
note the sound quality.
7. Stop the program and change the sampling frequency (in both the Audio Input and Audio Output
nodes) to 18000 Hz. Run the program again and listen to the sound quality. Repeat with a sampling
frequency of 8000 Hz.
8. Repeat steps 1-2 but use the microphone input instead of the CD input.
15
16 CHAPTER 3. DSP LABORATORY: TIME AND FREQUENCY DISPLAYS
The Waveform Chart maintains a buer of values that are plotted on it, the number of points that are
stored can be adjusted by Right Clicking on the Chart and selecting Chart History Length. . . from the popup
menu. By default the chart history length is 1024. Right Click on Waveform Chart from the Visible Items
sub menu and select X Scrollbar to show the toolbar for the X-axis. From the same sub menu (Visible Items)
select Graph Palette. This palette gives you the ability to zoom in on the data.
1. Wire the Left output of the Analog Input Node to the Waveform Chart as shown in Figure 1 below.
2. Un-mute the microphone Input, run the program and speak into the microphone. You should be able
to see your voice, in addition to hearing it. Play around with the properties of the Waveform Chart
(Right Click and select Properties form the menu) and become familiar with the dierent options. Also
use the zoom tools on the Graph Palette and become familiar with it.
3. If you stop the program the currently displayed data will freeze on the Waveform Chart.
4. Often, you'll nd it necessary to display less (or more) of the signal in the time-domain display. This is
done by changing the Chart History Length from the popup menu of the Waveform Chart. The time
range that will be displayed will always be
note: The frequency-domain Waveform Chart will display the magnitude response in the range
0 (DC) to Fs /2.
1. With the CD Audio input selected, run the program and examine the spectrum of the music signal.
Now change the input to microphone and examine the frequency spectrum of your voice as well. Stop
the program when done.
2. The frequency spectrum is always displayed from 0 Hz. (DC) to Fs/2. For voice signals, which have
most of the energy < 2000 Hz, the voice frequencies only cover a small portion of the display (assuming
Fs = 48000 Hz.). To get a more detailed view of your voice spectrum, change the sampling frequency
to 8000 Hz. (making sure to change both the Anaog Input and Analog Output nodes). Now, your
voice spectrum will cover a wider range of the display. Run the VI.
3. Speak into the microphone using a single held-out note (like AHHHHHHHHHH or EEEEEEEEEEE).
Examine both the time-domain and frequency domain displays. If necessary, change the Chart History
Length so that about 4-5 periods of the signal are on the time-domain display. Because a note like this
is periodic, you should notice a fairly steady time signal as well as a well-dened frequency spectrum
consisting of large peaks at your note's fundamental frequency and its harmonics. Change the frequency
(pitch) of this note and examine how it aects the frequency spectrum. Also try experimenting with
various notes. Once you get a fairly steady display in both the time- and frequency-domains, hold
your note and stop the program to freeze the displays. You can now zoom into various parts of the
spectrum to examine it closely.
Exercise 3.1
From your time-domain plot, determine the fundamental period of your voice note (AHHHHHH,
EEEEEEEE, etc.). Remember that the time base is in milliseconds. Measure the period as accu-
rately as possible and record the period below. From your frequency-domain plot, determine the
frequency of the 1st harmonic (fundamental frequency) and record it below as well. Do these results
concur with each other? Why or why not?
Exercise 3.2
Fundamental Period of signal __________ Fundamental Frequency of signal
__________
• We are now ready to use the third input the function generator. Begin by going to the Surround
Mixer and changing the active playback device to Line-in. Make sure that the volume is set to 100%.
Locate the black cable (with an RCA-type connector on the end) coming out of the computer this
cable is connected to the Line-in port of the sound card. Connect the other end of this cable to the Func
Out port of the function generator using the RCA to BNC adapter. Turn on the function generator
and set the following parameters. You need to press EXEC after setting each one.
· FREQ: 400 Hz
· AMPL: 0.2 V
· OFST: 0 V (DC oset)
· MODE: CONTINUOUS (use the [U+F0AD][U+F0AF] keys to cycle through the options if needed)
· FUNC: SINE (use the [U+F0AD][U+F0AF] keys to cycle through the options if needed)
• After all of these are set, press the OUT/ON button (bottom middle) and use the [U+F0AD][U+F0AF]
keys to select OUTPUT ON. If you now run your VI again, you should hear a 400 Hz tone. You should
also see the sine wave in the time- and frequency-domain Charts on your Front Panel. Use the Zoom
tools to view the signals in detail.
Exercise 3.3
From the time-domain plot, measure the period of the sine wave and record it below. From the
frequency-domain plot, measure the frequency of the sine wave and record it as well. Discuss
whether these results concur with each other.
Exercise 3.4
Period of the sine wave __________ Frequency of the sine wave __________
• Now change the amplitude of the sine wave to 1 V and observe the resulting frequency spectrum. Is
this expected?
Exercise 3.5
Explain in detail what is happening to your frequency spectrum when you increase the amplitude
of the sine wave to 1 V. Why is this happening?
• When you're done, stop the program and save the VI.
4.1 Aliasing
note: This section has dierent instructions for the Speedy 33 and the 6711. Please select the
section of the SPEEDY-33 or the 6711 based on the hardware setup on your station.
• Set the sampling frequency to 48000 Hz (in both the Analog Input and Analog Output nodes).
• Set the function generator to a 0.2 V, 100 Hz, sinusoid.
• Move the [U+F0AC][U+F0AE] arrows on the function generator so that the hundreds-digit on the
frequency display is ashing.
• You can now easily increase the frequency in steps of 100 Hz. by pressing the [U+F0AD][U+F0AF]
buttons.
• Run the program and observe the frequency display, time display, and sound as you sweep the signal
frequency from 100 Hz. to 50 kHz.
• Pay particular attention to the amplitude and sound of the reconstructed signal for input frequencies
> 24 kHz.
Exercise 4.1
Describe what you hear and see (especially the frequency spectrum) when you sweep the sinusoid
21
22 CHAPTER 4. DSP LABORATORY: ALIASING
frequency from 100 Hz. to 50 kHz. Take special note of what happens to both the amplitude and
frequency of the reconstructed sinusoid once you get past 24 kHz.
• Repeat the experiment above, but set the sampling frequency to Fs = 8000 Hz. Here, pay special
attention to what happens once you get above 4 kHz.
Exercise 4.2
What happens to the amplitude of the reconstructed signal once the input signal frequency hits
24 kHz? Explain.
• To really see the eects of aliasing, change the input signal to a square wave (square [2] on the function
generator) and sweep from 100 Hz. to 50 kHz (keeping the sampling frequency at 8000 Hz.). Carefully
examine the frequency-domain graph as you sweep the signal through its frequency ranges.
Exercise 4.3
Describe what you observe in the frequency domain when you sweep a square wave from 100 Hz.
to 50 kHz. Is this expected?
• Set the sampling frequency to 48000 Hz (in both the Analog Input and Analog Output nodes).
• Set the function generator to a 0.2 V, 100 Hz, sinusoid. Move the [U+F0AC][U+F0AE] arrows on the
function generator so that the hundreds-digit on the frequency display is ashing.
• You can now easily increase the frequency in steps of 100 Hz. by pressing the [U+F0AD][U+F0AF]
buttons.
• Run the program and observe the frequency display, time display, and sound as you sweep the signal
frequency from 100 Hz. to 50 kHz.
• Pay particular attention to the amplitude and sound of the reconstructed signal for input frequencies
> 24 kHz.
Exercise 4.4
Describe what you hear and see (especially the frequency spectrum) when you sweep the sinusoid
frequency from 100 Hz. to 50 kHz. Take special note of what happens to both the amplitude and
frequency of the reconstructed sinusoid once you get past 24 kHz.
• Repeat the experiment above, but set the sampling frequency to Fs = 8000 Hz. Here, pay special
attention to what happens once you get above 4 kHz and again once you get above 24 kHz.
Exercise 4.5
Explain the dierence in the results of the experiment when we change the sampling frequency
from 48000 Hz to 8000 Hz. Pay particular attention to what happens once the signal hits 4000 Hz.
and when it hits 24000 Hz.
Exercise 4.6
What happens to the amplitude of the reconstructed signal once the input signal frequency hits
24 kHz? Explain.
• To really see the eects of aliasing, change the input signal to a square wave (square [2] on the function
generator) and sweep from 100 Hz. to 50 kHz. (keeping the sampling frequency at 8000 Hz.). Carefully
examine the frequency-domain graph as you sweep the signal through its frequency ranges.
Exercise 4.7
Describe what you observe in the frequency domain when you sweep a square wave from 100 Hz.
to 50 kHz. Is this expected?
4.1.3 Conclusion
When you are done with each lab, exit LabVIEW, log o the computer, turn o the function generator
and the headphone volume booster, and unplug the DSP board from the A/C adapter. Turn in Answered
Questions to the TA.
25
CHAPTER 5. INTERACTIVE DIGITAL FILTER DESIGN - ONLINE TOOL
26
FOR IIR FILTER AND FIR FILTER DESIGN
Download the full source code for the LabVIEW Interactive Digital Filter Design Utility here
4 . This
allows you to run the same Interactive Digital Filter Design Utility from your Windows PC without being
connected to the web.
5.1.2 Requirements
The Digital Filter Design Utility can be run on Windows OS within this web page or downloaded for oine
use. You will need to download and install the free LabVIEW Runtime Engine and enable the browser
plug-in for local execution. Visit the following link for instructions on installing the LabVIEW Runtime
Engine and conguring the browser plug-in
5 to enable the Interactive Digital Filter Design Utility and other
online web based LabVIEW applications.
2 http://digital.ni.com/express.nsf/bycode/exnymx
3 http://digital.ni.com/express.nsf/bycode/ex6d3j
4 http://digital.ni.com/demo.nsf/websearch/61a1e8001e5b0ccd86256ab90075c1b5
5 http://digital.ni.com/express.nsf/bycode/exwgjq
Select Pole-Zero Placement to design a lter by specifying the locations of poles and zeros on the complex
plane.
The following sections detail how to work with each alternative.
5.5.1 Zeroes
• Real: Species the real part value if coordinates are rectangular, or the radius value if coordinates are
polar.
• Imag: Species the imaginary part value if coordinates are rectangular, or the angle value if coordinates
are polar.
• Is Real?: Makes the specied pole or zero point real if you place a checkmark in the checkbox.
• Is Linear Phase Pair?: Makes the specied pole or zero a linear phase pair if you place a checkmark
in the checkbox.
• On Unit Circle?: Places the pole or zero point on the unit circle if you place a checkmark in the
checkbox.
• Order: Species the order of the pole or zero.
5.5.2 Poles
• Species the properties for each pole in the lter. Contains the following options:
• Real: Species the real part value if coordinates are rectangular, or the radius value if coordinates are
polar.
• Imag: Species the imaginary part value if coordinates are rectangular, or the angle value if coordinates
are polar.
• Is Real?: Makes the specied pole or zero point real if you place a checkmark in the checkbox.
• Is Linear Phase Pair?: Makes the specied pole or zero a linear phase pair if you place a checkmark
in the checkbox.
• On Unit Circle?: Places the pole or zero point on the unit circle if you place a checkmark in the
checkbox.
• Order: Species the order of the pole or zero.
6 http://cnx.org/content/m13115/latest/DigitalFilterDesignUtils.zip
7 http://digital.ni.com/express.nsf/bycode/ex6d3j
8 http://sine.ni.com/apps/we/nievn.ni?action=display_oerings_by_event&event_id=17399&event_subtype=WEB_EVENT_DEMAND&si
9 http://digital.ni.com/express.nsf/bycode/ex6d3j
10 http://digital.ni.com/express.nsf/bycode/exyx3d
11 http://digital.ni.com/express.nsf/bycode/ex6d3j
33
34 CHAPTER 6. DSP LABORATORY: IIR NOTCH FILTER DESIGN
• Switch execution target to your hardware by going to OperateSwitch Execution Target in Lab-
VIEW Embedded.
• Go to the Block Diagram of the blank VI, navigate the function palette to the Analog Input, click
and drop an analog input element on the Block Diagram. It is located under FunctionsElemental
IOAnalog Input. See Figure 2.
• Double-click on the Analog Input elemental I/O for conguration. In the conguration window,
select the General tab. Click on the drop down under resource and select 2 channel Multiple
Samples. On the Conguration tab, set the Sampling Rate to 16000 Hz and the Framesize to 256.
Click OK to close the window.
• Drop an Add function located on the Numeric sub palette of the Functions palette: Func-
tionsNumericAdd.
• Drop an Analog Output elemental I/O. FunctionsElemental I/OAnalog Output. Double click
on the Analog Output you just dropped on the Block Diagram and set the Sample Rate to 16000
Hz on the Conguration tab. Click OK to close.
• Drop a Spectral Measurement Express VI on the block diagram. FunctionsSignal Process-
ingFrequency DomainSpectral Measurements. This VI will allow us to build the power spec-
trum of the sound signal. Double click on the Spectral Measurements Express VI to open its
conguration window. In the window, select Power Spectrum for Spectral Measurements and dB
for results (See Figure)
• Click OK to validate the conguration.
• Now let's switch to the Front Panel (WindowsShow Front Panel) and drop two Waveform Graphs.
The Waveform Graph is located on the Graph Sub palette: ControlsGraphsWaveform Graph.
Name one Time Domain and the other Power Spectrum. Do not add the stop button yet.
• Let's switch back to the Block Diagram and wire everything already on the diagram as shown in
Figure 1.
• Select the while loop from FunctionsStructuresWhile Loop, click and drag to enclose everything
on the Block Diagram within the loop. You Block Diagram should now be similar to the one in
Figure 1 and the Front Panel similar to the one in Figure 4.
note: This setup is similar to that found in the DSP Laboratory: Time and Frequency
Displays Module except that the Left and Right channels are being combined into a single
channel.
4. In 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
icon and 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. Now adjust the two displays to make one a time-domain display and the other a
frequency-domain display. Remember how to set/unset the automatic scaling on the displays. It is
usually best to use Auto scaling on the frequency-domain display but not the time-domain display.
5. Once you have veried that everything is working properly, stop the CD, then stop the LabVIEW
program (but don't exit LabVIEW).
6. 11. Save the VI by selecting FileSave As. Make sure to save the le in your personal directory
Desktop\ee 453\<folder name>. You can give the le any name you want (such as lab2setup).
1. Using the BNC to RCA adapter, connect the long black cable coming from the computer soundcard
(the line-in cable) to the FUNC OUT output of the function generator.
2. Turn on the function generator and set it up to generate a 1000 Hz, 0.2 V sine wave. Don't forget to
activate the signal by pressing the OUT/ON button on the function generator, setting its value to 1,
and then pressing the EXEC button.
3. In Surround Mixer, activate the Line-in input. Run the program in LabVIEW and you should hear
an annoying 1000 Hz. tone. Adjust the volume of the Line-in source in Surround Mixer so that the
output sine wave amplitude is close to 5000 units.
4. Now restart the CD. You should hear the music, but it will be corrupted with a very annoying sinusoidal
tone. (Depending on your music selection, you may possibly need to increase the amplitude of the
sinusoidal noise so that it can be heard over the music). Examine both the time- and frequency-domain
displays of the signal + noise. Stop the program before the noise drives you crazy.
5. Add a Biquad VI from FunctionsSignal ProcessingFiltersBiquad.vi . This block allows you to
specify the coecients of a generic 2nd-order digital lter. A biquad is just a particular conguration
for a 2nd-order digital lter.
6. Determine the transfer function of the notch lter needed to remove the 1000 Hz. noise. Use a value
of alpha = 0.9.
7. Double click on the Biquad VI and enter the coecient values. Insert the Biquad VI between the
output of the Add function and the inputs to the Analog Output elemental I/O (see Figure 5 for the
modied Block Diagram). (You'll need to break the existing connections rst).
8. Re-run the program and take notice of whether the lter eectively removes the noise without removing
too much of the music signal. Take special note of the frequency spectrum of the ltered signal + noise.
Exercise 6.1
Calculate the transfer function of the notch lter needed to remove the sinusoidal noise. Show
your work.
Exercise 6.2
Does this lter seem to remove much of the music signal along with the noise? Explain why or
why not.
• To see how sensitive this lter is, increase the frequency of the sinusoidal noise in increments of 10
Hz until the lter no longer seems to be removing the sinusoidal noise adequately. This is somewhat
subjective and may also depend on the music that you're combining with the sinusoidal noise.
6.1.3
6.1.3.1 Answer These Questions
Exercise 6.3
At what sinusoidal noise frequency does this lter no longer eectively remove the sinusoidal tone
• Now turn o the music so that you only have the sinusoidal noise going through the system. Sweep
the sine wave frequency through a range from about 500-3000 Hz. and note how the tone cuts out in
the vicinity of 1000 Hz. Next determine the smallest frequency > 1000 Hz. at which the output signal
appears to be at full amplitude.
6.1.4
6.1.4.1 Answer These Questions
Exercise 6.4
At what sinusoidal noise frequency does the lter no longer attenuate the sine wave at all?
• Using alpha = 0.5, repeat from step Don't forget to turn your music back on and to reset your sinusoid
to 1000 Hz. before starting the test. Also, use the same music as you did before. Otherwise, you may
not be able to compare the 2 dierent lters accurately.
6.1.5
6.1.5.1 Answer These Questions
Exercise 6.5
Using this new alpha vaue, calculate the transfer function of the notch lter needed to remove the
sinusoidal noise. Show your work below.
Exercise 6.6
What eect did decreasing alpha have on the quality of the remaining music? Explain.
Exercise 6.7
Using this new alpha, at what sinusoidal noise frequency did the lter stop removing the sinusoidal
tone from the music?
Exercise 6.8
At what sinusoidal noise frequency does the lter no longer attenuate the sine wave at all?
Exercise 6.9
Based on your observation, does decreasing [U+F061] seem to make the lter remove a larger or
smaller range of sinusoidal frequencies? Explain why this is so.
6.1.6
When done with this part of the lab, stop the program, remove the notch lter block, and save the VI. This
VI is used in other labs.
41
CHAPTER 7. DSP LABORATORY: IIR FILTER DESIGN VIA THE
42
BILINEAR TRANSFORMATION
• Switch execution target to your hardware by going to OperateSwitch Execution Target in Lab-
VIEW Embedded.
• Go to the Block Diagram of the blank VI, navigate the function palette to the Analog Input, click
and drop an analog input element on the Block Diagram. It is located under FunctionsElemental
IOAnalog Input. See Figure 2.
• Double-click on the Analog Input elemental I/O for conguration. In the conguration window,
select the General tab. Click on the drop down under resource and select 2 channel Multiple
Samples. On the Conguration tab, set the Sampling Rate to 16000 Hz and the Framesize to 256.
Click OK to close the window.
• Drop an Add function located on the Numeric sub palette of the Functions palette: Func-
tionsNumericAdd.
• Drop an Analog Output elemental I/O. FunctionsElemental I/OAnalog Output. Double click
on the Analog Output you just dropped on the Block Diagram and set the Sample Rate to 16000
Hz on the Conguration tab. Click OK to close.
• Drop a Spectral Measurement Express VI on the block diagram. FunctionsSignal Process-
ingFrequency DomainSpectral Measurements. This VI will allow us to build the power spec-
trum of the sound signal. Double click on the Spectral Measurements Express VI to open its
conguration window. In the window, select Power Spectrum for Spectral Measurements and dB
for results (See Figure)
• Click OK to validate the conguration.
• Now let's switch to the Front Panel (WindowsShow Front Panel) and drop two Waveform Graphs.
The Waveform Graph is located on the Graph Sub palette: ControlsGraphsWaveform Graph.
Name one Time Domain and the other Power Spectrum. Do not add the stop button yet.
• Let's switch back to the Block Diagram and wire everything already on the diagram as shown in
Figure 1.
• Select the while loop from FunctionsStructuresWhile Loop, click and drag to enclose everything
on the Block Diagram within the loop. You Block Diagram should now be similar to the one in
Figure 1 and the Front Panel similar to the one in Figure 4.
note: This setup is similar to that found in the DSP Laboratory: Time and Frequency
Displays Module except that the Left and Right channels are being combined into a single
channel.
4. In 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
icon and 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. Now adjust the two displays to make one a time-domain display and the other a
frequency-domain display. Remember how to set/unset the automatic scaling on the displays. It is
usually best to use Auto scaling on the frequency-domain display but not the time-domain display.
5. Once you have veried that everything is working properly, stop the CD, then stop the LabVIEW
program (but don't exit LabVIEW).
6. 11. Save the VI by selecting FileSave As. Make sure to save the le in your personal directory
Desktop\ee 453\<folder name>. You can give the le any name you want (such as lab2setup).
1. Go to the Functions palette and add the DFD Filter Express VI to your existing Block Diagram:
FunctionsSignal ProcessingFiltersDFD Filter
2. Wire the Express VI as shown in Figure 6. The output of the Add function is the input Signal of the
Express VI and the Filtered Signal goes into the Analog Output. Set the function generator's signal
to a frequency of 500 Hz.
3. Follow the steps below to implement a lowpass lter that will be implemented on the DSP. Launch
LabVIEW by going to StartAll ProgramsNational InstrumentsLabVIEW 7.1LabVIEW. Let's try
to understand what is happening. We rst launched LabVIEW Embedded Edition which allowed us
to target the DSP hardware and run our program. Now, we are launching LabVIEW, not LabVIEW
Embedded Edition. The program you built earlier should still be open. We will use the Digital Filter
Design Toolkit available in the LabVIEW environment to design the lter.
4. Create a blank VI (NewBlank VI).
5. Switch to the Block Diagram and drop a DFD Classical Filter Design on the Block Diagram: It is in
FunctionsAll FunctionsDigital Filter DesignFilter DesignDFD Classical Filter Design.
6. In the DFD Classical Filter Design Express VI, enter the following settings:
7. Check the graph to the left to make sure the lter response appears as expected and click OK to set
the congurations.
8. Some lter parameters are described below:
• Sampling Frequency self-explanatory. Make sure to set it to the sampling frequency that you
plan on using!
• Center Frequency (not used for lowpass lters). Set this to the middle frequency of the passband
for Bandpass/Highpass lters or the middle frequency of the stopband for Bandstop lters.
• Bandwidth Set this to the frequency width of the passband (stopband for Bandstop lters).
Recall that Lowpass lters have a lower passband frequency of 0 Hz and that Highpass lters has
an upper passband frequency of Fs/2.
• Stopband Attenuation Set this to the desired attenuation in dB at the edge of the stopband. For
Bandstop lters, this parameter must be negative (because the stopband is really the passband).
For all other lter types, this parameter must be positive.
• Passband Ripple Set this to the desired attenuation (in dB) at the edge of the Passband. For
Butterworth lters, the standard (but not required) value to use is 3 dB.
• Filter Order N Set this to the desired lter order. However, after you press the Apply button,
the program calculates which lter order you need to meet the given specs. For most applications,
then, you can put any number here and then change it to the necessary value when instructed.
There may be some situations, however, when you want to force the lter order to be some set
value. In this case, the desired specications may not be met.
note: Regarding calculation of lter order N: This program uses the same design equations
that we use in EE 453. For IIR lters, the program automatically does prewarping.
9. Build the following Block Diagram to save the lter settings: Drop a DFD Save to File VI on the
Block Diagram. This VI is located at FunctionsAll FunctionsDigital Filter DesignUtilitiesDFD
Save to File. Wire the Block Diagram as shown in Figure 6.
10. Run the lter design VI you just built. When prompted to save your design, navigate to your folder
and save your lter under any chosen name. Save and close this VI.
Exercise 7.1
Calculate, by hand, the predicted lter order needed to meet the specications of the lowpass lter.
Show your work below.
Exercise 7.2
Does your predicted lter order agree with the lter order suggested by LabVIEW DSP? YES /
NO
7.1.3
1. Let's now go back to the original DSP program and add the newly designed lter. Switch to the Block
Diagram and Double-click on the DFD Filter Express VI you added on the Block Diagram in step 1.
In Path section of the Congure Filter prompt, click the Browse button and navigate to the lter
design you saved earlier, click OK to accept. Run the program.
2. Because the signal frequency is signicantly lower than the passband cuto frequency, the signal should
pass through the lter with very little attenuation. Change the frequency plot to manual scale. Sweep
the input signal frequency through the range 500 Hz. 3000 Hz. and note the resulting time-domain
and frequency-domain plots.
3. Set the input sine wave to the following frequencies: 1000 Hz, 1200 Hz, 1500 Hz, 2000 Hz, and 3000
Hz. For each frequency input, observe the corresponding lter output (both displays as well as the
actual sound) and measure/record the exact amplitude of the output signal for each frequency. The
easiest way to measure the amplitudes is to stop the simulation and then place your mouse pointer at
the appropriate position on the graph. Note: You will need to change the scale of the graphs to read
accurately. Call your lab assistant for help on how to change the scale.
Exercise 7.3
Record the amplitude and corresponding attenuation (in dB) of the ltered sinusoid for each of
the frequencies below.
The equation for attenuation is: attenuation = -20log(output amplitude/(maximum
amplitude.
Exercise 7.4
Take special note of the attenuations at 1000 Hz and 1500 Hz. What do you expect these values
to be theoretically? (show work) How do your actual values compare to the theoretical values?
7.1.4
• Put the input frequency to 800 Hz and run the program again. Without changing anything else,
change the sampling frequency in the Analog Input and Analog Output elements to 8000 Hz and run
the program. Observe what happens to the output signal. When done, set all sampling frequencies
back to 16000 Hz.
Exercise 7.5
Explain what happens to the lter's performance when the sampling frequency is changed from Fs
= 16000 Hz to 8000 Hz. Specically, what happens to the 800 Hz signal when it is passed through
the lter now? Explain what this implies about the importance of operating a digital lter using
the same sampling frequency that you used to design it.
7.1.5
• Now deactivate the Line-In input in Surround Mixer and run the program again using your CD input
instead. Listen to and observe the output of the lter (in both the time and frequency domain).
Exercise 7.6
Discuss the eect of the lowpass lter on the music signal.
7.1.6
1. To really see the eect of the lter more graphically, remove the Analog Input element and Add func-
tion from the Block Diagram and add a EMB Uniform White Noise Waveform node instead (Func-
tionsEmbedded Signal GenerationEMB Uniform White Noise Waveform.vi). This block generates
white noise. White noise has energy spread equally across the frequency spectrum. For this reason, a
white noise generator is often a good test of a lter's performance. Connect this block to the input of
the IIR Filter. Double click on the Noise block and set the Amplitude = 10000, save and close it.
2. Run the program and observe the sound of the noise and take note of both its spectrum and time-
domain shape. Now remove the lowpass lter block completely from the worksheet and connect the
output of the Noise block directly to the Analog Output element. Re-run the program and observe the
signal again. This is what unltered white noise looks/sounds like.
Exercise 7.7
Discuss how the shape of the white noise signal changes when it is passed through the lowpass
lter. Also, describe how the sound changes.
7.1.7
• Now follow steps 4 to 7 to design a bandpass lter to meet the following specications:
· Type: Chebyshev I
· FSTL: 1000 Hz
· FPL: 1500 Hz
· FPU: 3500 Hz
· FSTU: 4000 Hz
· Passband ripple: 1 dB
· Minimum stopband attenuation: 40 dB
· Sampling Frequency: 16000 Hz
• Save the lter to your folder (giving it a descriptive name like bpcheby1500-3500) and examine the
various tabs in the lter design program.
Exercise 7.8
What is the IIR lter order needed to meet the bandpass lter specications given? (You do not
have to verify this value, just state what it is).
1. Re-add an IIR lter block back into your system and connect it to the system the same way you did
the previous IIR block. Load your new lter coecient le into the IIR lter block. Keeping the Noise
Generator as your input signal, run the program again and note the dierence between how the noise
gets ltered by the bandpass and lowpass lters.
2. Remove the Noise block and re-add the Analog Input node and the Add Function. Connect these to
the rest of the system as you did earlier and run the system using your CD input. Observe the output
signal.
3. Add a second IIR lter block to your system in parallel with the rst block. Load the original lowpass
lter coecient le into this block. Double-click on the Analog Output Element and select 2 channels
multiple samples. Now send the output of one lter to one of the channels of the Analog Output
element and the output of the other lter to the other channel. (Note: Only one of the lter outputs
can be connected to the displays. It doesn't matter which one you have connected). Run the program
using your CD input, and listen to the ltered output. You should hear a dierent signal in each ear.
4. As a nal experiment, break the parallel lter connections and connect the 2 lter blocks in cascade
rather than parallel by passing the output of one lter through the other lter and sending the output
of the 2nd lter to the Analog Output element. Run the program using your CD input.
7.1.8
7.1.8.1 Answer These Questions
Exercise 7.9
When the lowpass and bandpass lters are cascaded together, what happens to the output signal?
Why?
7.1.9
note: Call your TA over to verify that you have completed this last part of the lab. If time
permits, feel free to design a few other types of IIR lters and connecting them in various ways.
53
54 CHAPTER 8. DSP LABORATORY: FIR FILTER DESIGN
Figure 8.1
note: When you place the Analog Input node, it will display only one channel. It is after
you congure it that the right and left channels will be shown.
6. Double click the Analog Input node and change the Resource under the General Tab to be 2 channel
multiple samples.
Figure 8.2
7. Go to the Conguration Tab and set the Sample Rate to 8000 Hz and the Framesize to 256.
Figure 8.3
8. 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.
9. Double click in the Spectral Measurements Express VI and select Power Spectrum from the type of
Measurement.
10. Rearrange the objects in the Block Diagram so that you have plenty of space between them. This
Figure 8.4
13. 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 dis-
tortion/clipping (due to the volume being too high), adjust the CD volume on the Surround Mixer to
lower the volume until the clipping stops.
14. Once you have veried that everything is working properly, stop the CD, then stop the LabVIEW VI.
(Do not exit LabVIEW)
15. Save this VI by selecting FileSave As. Make sure to save the le in your personal directory - - Desktop
\ee 453\<folder name>. You can give the le any name you want (such as lab3setup), but use the
default extension of .vi
1. Open LabVIEW (not the Embedded Edition) and create a New Blank VI.
2. In the block diagram, place the All FunctionsDigital Filter DesignFilter DesignDFD Classical Filter
Design Express VI.
3. Double click in the VI and congure a lowpass FIR lter 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
Figure 8.5
4. Once you have all the parameters set correctly, press OK.
5. Place the DFD Save to File VI found in All FunctionsDigital Filter DesignUtilities.
6. Wire the lter out to the lter in of the DFD Save to File function. Wire the error clusters.
7. Save the VI in Desktop \ ee 453 \<folder name> using some meaningful title such as Filter Design.vi.
Figure 8.6
8. Run the VI and when prompted save the Filter Coecients into the same folder with a meaningful
name such as LPFIR400.fds. Make sure to use the default extension (fds) when saving this coecient
le.
Exercise 8.1
Determine the predicted lter 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.)
Exercise 8.2
Write down the lter length as calculated by Hypersignal. Does it agree (or come close to)
the value predicted above?
9. 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).
10. Add two more Waveform Graphs on the Front Panel and label them as Time DomainFiltered and
Frequency Domain-Filtered.
11. Add to the DFD Filter VI (All FunctionsSignal ProcessingFilters) to the Block Diagram after the
Add function. Wire the output of the Add function to the DFD lter. Wire the output of the DFD
lter to the Analog Output node. Wire the output of the DFD lter to the Time Domain Filtered
terminal.
12. 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.
Figure 8.8
13. Double click on the DFD Filter VI and select the path to the Coecient File. As soon as you load the
le, you will see the magnitude, impulse and phase response graphs update.
Figure 8.9
14. Save the VI. Start the CD Player and then Run the VI. You should here a heavily lowpass ltered
version of your music through the headphones. You can also see the eect of the ltering by looking
at the appropriate indicators.
15. 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.
Exercise 8.3
What happens when the sampling frequency used to operate the lter is changed from Fs =
8000 Hz (the Fs used to design the lter) to Fs = 16000 Hz.? Explain
16. Stop the VI and disconnect the Analog Input node and the Add function. Replace these objects with
the Simulate Signal Express VI (FunctionsEmbedded Signal Generator). Double click to bring up
the properties page and congure 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 dierent
name. Run the VI and observe the ltered output. Use the Time-Domain plot to carefully measure
the amplitude of the output signal.
Figure 8.10
17. Repeat step 16 without changing the name of the le for the following frequencies: 400 Hz, 600 Hz,
800 Hz.
Exercise 8.4
Complete the following table based on your measured data:
Exercise 8.5
Does this lter yield the gains that you expected at the frequencies above? Why or why not?
Specically comment on the gain at 400 Hz, 600 Hz and 800 Hz.
18. 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 lter, the output of the lter will look like the input, except for a time delay. Carefully
measure and record the time (in milliseconds) of the rst zero crossing in the input signal and the
corresponding zero crossing in the output signal.
Exercise 8.6
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.
1. Open LabVIEW (not Embedded Edition) and open the Filter Design VI built in Section II.
2. Design a bandpass FIR lter to meet the following specications:
• 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
3. After entering the parameters, press OK. Run the VI and save the lter coecients as BP-
FIR800_1600.fds.
Exercise 8.7
The lter length for this BP lter was the same as for the LP lter. Why did this happen?
• Type: Highpass
Exercise 8.8
You should have noticed that all 3 lters had (nearly) identical lter lengths. For an FIR-
based lter bank, this is a very important feature to have. Why? Hint: Think about the
phase responses of FIR lters.
Exercise 8.9
You should have noticed that the length of the highpass lter was slightly dierent than the
other lters. What is the reason for this? Hint: Think about the 4 basic types of FIR lters
(Type I Type IV).
6. Open the lab3setup VI and change the lter coecient's le in the DFD lter VI to the bandpass lter
le. Save the VI with a dierent name such as lab3lters.vi. Run the VI and make sure it works ne.
7. Change again the lter le for the highpass lter le. Do not change the name of the le. Save it and
run it.
8. Once you have veried that your 2 additional FIR lters work, add two more DFD Filter VIs to the
block diagram and two Add functions.
9. Wire the output of the Add function that adds the Analog Input node to the two new DFD lters.
Congure the three DFD Filter VIs with the Lowpass, Highpass and Bandpass lter les.
10. Put three Multiply functions and wire the output of the lters to them. Place three numeric controls
in the Front Panel and set them to 1.
11. 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 lter.
12. 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.
Figure 8.12
13. The resulting conguration is a 3-band lter bank that covers frequencies in the range DC-4000 Hz.
Note that the frequency ranges of these 3 lters were selected so that the transition regions overlap
perfectly (i.e. the edge of the passband of one lter is the edge of the stopband of the prior lter).
This type of overlap yields the best frequency coverage and provides a nearly constant gain in each
transition region. (i.e. As one lter starts attenuating, the next lter starts amplifying).
14. Start your CD. Save and Run the VI. You should hear the music basically unltered, 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.
note: When you are done with this lab, exit LabVIEW and LabVIEW Embedded Edition and
log o the computer. Unplug the SPEEDY-33 board and turn o the headphone volume booster.
Turn in your completed worksheet to the lab TA.
Attributions
Collection: Fundamentals of Digital Signal Processing Lab
Edited by: Erik Luther
URL: http://cnx.org/content/col10303/1.5/
License: http://creativecommons.org/licenses/by/2.0/
Module: "Interactive Digital Filter Design - Online Tool for IIR Filter and FIR Filter Design"
By: Erik Luther, Jim Cahow
URL: http://cnx.org/content/m13115/1.10/
Pages: 25-32
Copyright: Erik Luther, Jim Cahow
License: http://creativecommons.org/licenses/by/2.0/
Module: "DSP Laboratory: IIR Filter Design via the Bilinear Transformation"
By: Erik Luther
URL: http://cnx.org/content/m13039/1.1/
Pages: 41-52
Copyright: Erik Luther
License: http://creativecommons.org/licenses/by/2.0/
About Connexions
Since 1999, Connexions has been pioneering a global system where anyone can create course materials and
make them fully accessible and easily reusable free of charge. We are a Web-based authoring, teaching and
learning environment open to anyone interested in education, including students, teachers, professors and
lifelong learners. We connect ideas and facilitate educational communities.
Connexions's modular, interactive courses are in use worldwide by universities, community colleges, K-12
schools, distance learners, and lifelong learners. Connexions materials are in many languages, including
English, Spanish, Chinese, Japanese, Italian, Vietnamese, French, Portuguese, and Thai. Connexions is part
of an exciting new information distribution system that allows for Print on Demand Books. Connexions
has partnered with innovative on-demand publisher QOOP to accelerate the delivery of printed course
materials and textbooks into classrooms worldwide at lower prices than traditional academic publishers.