You are on page 1of 75

Fundamentals of Digital Signal Processing

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

Rice University, Houston, Texas


This selection and arrangement of content as a collection is copyrighted by Erik Luther. It is licensed under the
Creative Commons Attribution 2.0 license (http://creativecommons.org/licenses/by/2.0/).
Collection structure revised: January 3, 2006
PDF generated: October 25, 2012
For copyright and attribution information for the modules contained in this collection, see p. 67.
Table of Contents
1 DSP Laboratory: Introduction, Hardware and Software Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 DSP Laboratory: Analog to Digital and Digital to Analog Conversion . . . . . . . . . . . . . . . . . . . . . . 7
3 DSP Laboratory: Time and Frequency Displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4 DSP Laboratory: Aliasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5 Interactive Digital Filter Design - Online Tool for IIR Filter and FIR Filter
Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6 DSP Laboratory: IIR Notch Filter Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
7 DSP Laboratory: IIR Filter Design via the Bilinear Transformation . . . . . . . . . . . . . . . . . . . . . . . 41
8 DSP Laboratory: FIR Filter Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Attributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
iv

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


Chapter 1

DSP Laboratory: Introduction,


1
Hardware and Software Setup

1.1 DSP Workstation Hardware List & Setup


1.1.1 Hardware: Dell Dimension 4550 PC with a Pentium 4 microprocessor
• · Runs software to design/implement digital lters
· Controls data acquisition and analysis
· Communicates with the DSP board and/or soundcard
· Edits/assembles/downloads code for the DSP chip on the DSP board

1.1.1.1 National Instruments SPEEDY-33

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.

• Specications of the NI SPEEDY-33


2 are as follows:

· Bundled with LabVIEW DSP


3 programming environment
· Includes a Texas Instruments VC33 oating point DSP processor
· 13-ns Instruction Cycle Time
· 150 Million Floating-Point Operations Per Second (MFLOPS)
· 75 Million Instructions Per Second (MIPS)
· USB interface used for connection to the PC
· 16-bit stereo audio codec with two on-board microphones
· Software-controlled adjustable sampling rate (8, 18, 24, 36, 44.1, and 48 kHz)
· Eight memory-mapped LED's and eight memory-mapped general purpose switch inputs
· Serial Port, CompactFlash interface

1 This content is available online at <http://cnx.org/content/m13036/1.2/>.


2 http://digital.ni.com/express.nsf/bycode/ex3wxw
3 http://digital.ni.com/express.nsf/bycode/ex3wxw

Available for free at Connexions <http://cnx.org/content/col10303/1.5>

1
CHAPTER 1. DSP LABORATORY: INTRODUCTION, HARDWARE AND
2
SOFTWARE SETUP

Figure 1.1: National Instruments Speedy 33

1.1.1.1.1 Condenser Microphone.

1.1.1.1.2 Personal Headphone set with individual volume control.

1.1.1.1.3 Black 3 prong headphone booster.

1.1.1.1.4 Audio Cable to go from the computer sound card to the microphone.

1.1.1.1.5 Male to male adapter cable.

Alternative option to NI Speedy 33:

1.1.1.2 Texas Instruments 6711 DSK

• Digital Signal Processing Board with PCM3003 Audio Daughter Card

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.

• Specications of the DSP board and daughter card are as follows:

· TI TMS320C6711 oating point DSP processor


· Software-controlled adjustable sampling rate (8, 9.6, 12, 16, 24, and 48 kHz)
· 16-bit stereo audio codec with two on-board microphones. A lowpass anti-aliasing lter at the
input channel with a xed cuto frequency = 24 kHz

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


3

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.

1.1.3 Test Equipment:


1. Wavetek 270 Function Generator
2. Tektronix 2213A Oscilloscope

1.2 System Set-up


Before beginning the lab, you need to make sure that the system is set up correctly. Follow the instructions
below to setup the station.

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

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 1. DSP LABORATORY: INTRODUCTION, HARDWARE AND
4
SOFTWARE SETUP

1.2.1 Hardware Setup


1.2.1.1 NI SPEEDY-33 Setup Instructions

NI SPEEDY-33 DSP Board

Figure 1.2: NI SPEEDY-33 Installation Guide Part #: 371581A-01, 324158A-01

• Log on to the computer


• Connect a USB cable between the PC USB Port of the SPEEDY-33 (Figure 2 #7) and the USB port
of your PC. The SPEEDY-33 is powered by the USB port. Once you connect the cable, the green
Power LED (Figure 2 #2) on the SPEEDY-33 will light.
• Conrm that the Power LED on the SPEEDY-33 is lit.
• If the New Hardware Found Wizard starts, follow the instructions to congure the drivers.
• Connect your headphones to the black 3-pronged headphone booster and connect this booster to the
Audio Stereo Output Port (Figure 2 #4) on the SPEEDY-33. 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 Audio Stereo
Input Port (Figure 2 #3) of the SPEEDY-33. The soundcard output (either CD audio or microphone)
will be the input to the DSP board for most of this lab.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


5

• 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).

1.2.1.2 TI 6711 DSK Setup Instructions

• 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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 1. DSP LABORATORY: INTRODUCTION, HARDWARE AND
6
SOFTWARE SETUP

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


Chapter 2

DSP Laboratory: Analog to Digital and


1
Digital to Analog Conversion

2.1 A/D and D/A Conversion


NI LabVIEW DSP is a block diagram-based DSP development platform that allows the user to quickly set
up complex DSP algorithms. The true power of LabVIEW lies in its ability to interface with external DSP
devices and/or internal sound cards that are installed on the PC. The developed algorithms are downloaded
to the DSP board, which then runs the algorithm in a real-time environment. In this lab, we will only
scratch the surface regarding LabVIEW DSP's capabilities. For starters, we will look at how LabVIEW
DSP interfaces with the A/D and D/A operations of the DSP board. Specically, we will simply connect
the A/D converter to the D/A converter so that the DSP system plays back audio signal sent to it.

2.1.1 Simple Sampling/Reconstruction System


1. Keeping the Surround Mixer open, start LabVIEW Embedded Edition. On the startup screen from
the Execution Target dropdown menu select your hardware device. Refer to Figure 2 below for details.
Execution target determines where your application will execute when you run it.
2. Note: All the screenshots of LabVIEW windows are taken with the SPEEDY-33 selected as the exe-
cution target. However, the instructions still apply for any other target unless otherwise specied.

1 This content is available online at <http://cnx.org/content/m13035/1.1/>.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>

7
CHAPTER 2. DSP LABORATORY: ANALOG TO DIGITAL AND DIGITAL
8
TO ANALOG CONVERSION

Figure 2.1: Switch Execution Target to your DSP hardware device

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


9

2.1.1.1 Start With a New Blank LabVIEW VI

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 2. DSP LABORATORY: ANALOG TO DIGITAL AND DIGITAL
10
TO ANALOG CONVERSION

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

5. Click OK when done.

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

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


11

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 2. DSP LABORATORY: ANALOG TO DIGITAL AND DIGITAL
12
TO ANALOG CONVERSION

Figure 2.5: Completed 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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


13

2.1.1.2 Run LabVIEW Code On The DSP

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.

Figure 2.6: LabVIEW DSP Module Status Monitor

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.

2.1.2 Answer These Questions


Exercise 2.1
Describe how sampling frequency seems to aect the sound quality for both speech and music.
Based on your observations, which seems to be most aected by sampling frequency, music or
speech?

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 2. DSP LABORATORY: ANALOG TO DIGITAL AND DIGITAL
14
TO ANALOG CONVERSION

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


Chapter 3

DSP Laboratory: Time and Frequency


1
Displays

3.1 Time and Frequency Displays


LabVIEW DSP gives you the ability to view the data in time domain or take its Fourier Transform and view
its frequency content. In this section of the lab, we'll learn how to set up and interpret these views. In the
later labs, you will need to set up these displays on a regular basis, so you may want to refer to this part of
the lab in the future.

3.1.1 Time Domain


Whenever an analog signal is passed through an A/D converter, its samples are stored as a number (usually
as an integer). If we have a 16-bit system, there are 216 = 65,536 possible values that can be stored. These
stored values can be displayed either as discrete samples or as a smooth line connecting the samples. The
instructions below outline how to set up a basic time-domain display using a Waveform Chart.
Switch over to the Front Panel and right click on the Front panel window anywhere to bring out the
Controls palette. From the Graph palette bring out the Waveform Chart and place it on the Front Panel, as
shown in step 1 of Figure 1. Right click on the Waveform Chart and select Properties from the popup menu
as shown in step 2 of Figure 6. In the Chart Properties window on the Appearance tab change the Label to
Left Channel Time Domain. Specify the settings as shown in step 4 of Figure 1. Deselecting Autoscale will
ensure that the Y-axis of the chart does not change with the data values. Minimum and Maximum values
of -32000 and 32000 will cover all the values for a 16-bit A/D channel.

1 This content is available online at <http://cnx.org/content/m13037/1.1/>.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>

15
16 CHAPTER 3. DSP LABORATORY: TIME AND FREQUENCY DISPLAYS

Figure 3.1: Waveform Chart Properties

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


17

Figure 3.2: Chart Time Domain Data

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

Time Range = Chart History Length/Sample Frequency


Example 3.1
Using the default settings, the displayed time range is 1024/48000 = 0.02133 = 21.33 msec.

3.1.2 Frequency Domain Magnitude Display


1. To display the frequency content of the audio signal we will take a Fast Fourier Transform (FFT) of
the data and display it in a Waveform Chart. Add a second Waveform Chart Display to the Front
Panel (as described in step 1 on page 7). Change the label of this Chart to Left Channel Frequency
Domain and enable Autoscale for the Y-axis by checking the box in the Waveform Chart Properties
window on the Scales Tab. On the Scales Tab switch over to the X axis properties by selecting it in
the dropdown menu and change the X-axis range to 0-255.
2. Switch over to the Block Diagram and resize the while loop as shown in Figure 8. Place the Spectral
Measurements Express VI from the FunctionsSignal ProcessingFrequency Domain Sub-Palette.
Refer to Figure 8 for details.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


18 CHAPTER 3. DSP LABORATORY: TIME AND FREQUENCY DISPLAYS

Figure 3.3: FFT of the Audio Input

3. Wire the Block Diagram as in Figure 3.

Figure 3.4: Frequency Domain Block Diagram

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

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


19

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.

3.1.2.1 Answer These Questions

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.

3.1.2.2 Answer These Questions

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 __________

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


20 CHAPTER 3. DSP LABORATORY: TIME AND FREQUENCY DISPLAYS

• Now change the amplitude of the sine wave to 1 V and observe the resulting frequency spectrum. Is
this expected?

3.1.2.3 Answer These Questions

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


Chapter 4
1
DSP Laboratory: Aliasing

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.

4.1.1 SPEEDY-33 Instructions:


We will now look at aliasing and its eect on the sampled signal. As you know, aliasing exists whenever
signal frequencies greater than Fs/2 are sampled using a sampling frequency of Fs. To eliminate aliasing,
most sound cards and DSP boards have some sort of built-in analog anti-aliasing lter that removes all input
signals greater than a certain frequency prior to sampling. It is important to remember that anti-aliasing
lters must do the ltering prior to sampling  otherwise, the high-frequency signals would have already
aliased to lower frequencies by the sampling process.
Some boards (and most Soundcards) have anti-aliasing lters with variable cuto frequencies that remove
all frequencies > Fs/2. As Fs changes, the cuto frequency of the anti-aliasing lter changes as well. If a
board has a variable frequency anti-aliasing lter that is always set to Fs/2, there will never be aliasing
(at least in theory). Although this type of operation is ideal from a performance point of view, it doesn't
allow the user to examine the eect of aliasing. The SPEEDY-33 does not have an anti-aliasing lter. Any
frequency greater than 24kHz can cause aliasing if the sampling frequency is set to 48kHz.

• 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.

4.1.1.1 Answer These Questions

Exercise 4.1
Describe what you hear and see (especially the frequency spectrum) when you sweep the sinusoid

1 This content is available online at <http://cnx.org/content/m13034/1.2/>.


Available for free at Connexions <http://cnx.org/content/col10303/1.5>

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.

4.1.1.2 Answer These Questions

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.

4.1.1.3 Answer These Questions

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?

4.1.2 6711 DSK Instructions:


We will now look at aliasing and the operation of the anti-aliasing lter on the DSP board. As you know,
aliasing exists whenever signal frequencies greater than Fs/2 are sampled using a sampling frequency of
Fs. To eliminate aliasing, most sound cards and DSP boards have some sort of built-in analog anti-aliasing
lter that removes all input signals greater than a certain frequency prior to sampling. It is important to
remember that anti-aliasing lters must do the ltering prior to sampling  otherwise, the high-frequency
signals would have already aliased to lower frequencies by the sampling process.
Some boards (and most Soundcards) have anti-aliasing lters with variable cuto frequencies that remove
all frequencies > Fs/2. As Fs changes, the cuto frequency of the anti-aliasing lter changes as well. If a
board has a variable frequency anti-aliasing lter that is always set to Fs/2, there will never be aliasing (at
least in theory). Although this type of operation is ideal from a performance point of view, it doesn't allow
the user to examine the eect of aliasing. Fortunately for us, our particular DSP board (or more precisely,
the Audio Daughter Card attached to the DSP board) has a xed-frequency anti-aliasing lter with a cuto
frequency of 24 kHz. If Fs = 48 kHz, this lter will prevent aliasing completely. However, if Fs is chosen to
be some value < 48 kHz, the anti-aliasing lter won't remove all frequencies > Fs/2, so some aliasing will
result. The fact that our anti-aliasing lter is xed rather than variable allows us to examine what happens
when we have aliasing. We will examine this now.

• 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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


23

• Pay particular attention to the amplitude and sound of the reconstructed signal for input frequencies
> 24 kHz.

4.1.2.1 Answer These Questions

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.

4.1.2.2 Answer These Questions

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.

4.1.2.3 Answer These Questions

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


24 CHAPTER 4. DSP LABORATORY: ALIASING

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


Chapter 5

Interactive Digital Filter Design - Online


1
Tool for IIR Filter and FIR Filter Design

5.1 Digital Filter Design

1 This content is available online at <http://cnx.org/content/m13115/1.10/>.


Available for free at Connexions <http://cnx.org/content/col10303/1.5>

25
CHAPTER 5. INTERACTIVE DIGITAL FILTER DESIGN - ONLINE TOOL
26
FOR IIR FILTER AND FIR FILTER DESIGN

5.1.1 Introduction to Digital Filter Design in LabVIEW


The Interactive Digital Filter Design Utility is a compiled LabVIEW applicaiton that allows you to inter-
actively specify and design oating point digital IIR lters and FIR lters online. This utility was created
with LabVIEW 8
2 and the LabVIEW Digital Filter Design Toolkit3 to provide an interacive tool for digital
lter design. Only a portion of the functionality available in the LabVIEW Digital Filter Design Toolkit is
used in this utility. The full toolkit contains a complete set of lter design tools for designing a wide range of
oating point and xed point digital lters. Once the LabVIEW plug-in has been installed, the Interactive
Digital Filter Design utility will run within the box below.

This is an unsupported media type. To view, please see


http://cnx.org/content/m13115/latest/DFD_Utility.llb

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.

5.2 How to Use the Digital Filter Design Utility


The Digital Filter Design Utility provides two lter design tools for either classical design or design by
pole-zero placement.
Classical design mode allows you to specify a FIR or IIR lter design by setting design parameters
such as lter type, sampling frequency, passband/stopband edge frequencies, passband and stopband ripple
levels, and stopband attenuation. You can select from design methods that include Butterworth, Chebyshev,
Inverse Chebyshev, Elliptic, Kaiser Window, Dolph-Chebyshev, and Equi-Ripple. LabVIEW will then use
the design parameters to suggest a lter meeting as many of those specications as possible. You are then
free to optimize the design to meet your needs.
The pole-zero placement interface allows you specify the location of multiple poles and zero either by
entering the coordinate locations directly or graphically by clicking on the z-plane. The resulting lter is
then displayed using the Bode Plot.
The resulting lter coecients can then be saved to a text le to facilitate deploying your design on real
hardware or for further analysis.

5.3 Getting Started


To start a design, you rst choose from one of the two available interactive design tools by making a selection
from the tree control on the left side of the interface. Select Classical Design to design a lter based on
specications such as passband / stopband edge frequencies, passband ripple, and stopband attenuation.

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

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


27

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.4 Classical Filter Design


This tool allows you to design multiple digital lter types by adjusting the lter specications manually or
by interactively changing the passband and stopband cursors in the magnitude vs. frequency graph. As the
cursors move, the pole/zero plot and the text based interface change dynamically to set the values for the
desired lter.

Digital Filter Design Utility

Figure 5.1: The Classical Filter Design Interface

5.4.1 Classical Filter Parameter Descriptions


• Filter Type: Species the type of lter you want. The default is a lowpass lter type. You also can
select a highpass, bandpass, or bandstop lter type.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 5. INTERACTIVE DIGITAL FILTER DESIGN - ONLINE TOOL
28
FOR IIR FILTER AND FIR FILTER DESIGN

5.4.2 Filter Specication


• Sampling Frequency [Hz]: Species the sampling frequency of the lter in hertz
• Passband Edge Frequency [Hz]: Species the rst passband edge frequency of the lter in hertz.
• Passband Edge Frequency [Hz]: Species the second passband edge frequency of the lter in hertz.
This option does not appear for lowpass or highpass lters.
• Passband Ripple: Species the passband ripple of the lter in units determined by the Magnitude
in dB option.
• Stopband Edge Frequency [Hz]: Species the rst stopband edge frequency of the lter in hertz.
• Stopband Edge Frequency [Hz]: Species the second stopband edge frequency of the lter in hertz.
This option does not appear for lowpass or highpass lters.
• Stopband Attenuation: Species the stopband attenuation of the lter in units determined by the
Magnitude in dB option.
• Design Method: Species the method of lter design. The default is Elliptic. You also can select
Butterworth, Chebyshev, Inverse Chebyshev, Kaiser Window, Dolph Chebyshev Window, and Equi
Ripple FIR lter designs. Elliptic, Butterworth, Chebyshev, and Inverse Chebyshev designs are IIR
lter designs. Kaiser Window, Dolph Chebyshev Window, and Equi Ripple FIR designs are FIR lter
designs.

5.4.3 Design Feedback


• Filter Order: Returns the order of the designed lter. For FIR lters, order +1 equals the number
of coecients or lter taps.
• Error Message: Contains details about errors that occur during lter creation.
• Magnitude in dB: Species whether the VI uses decibels or a linear scale to express the magnitude
response and for entry of the Passband and Stopband Attenuation input parameters. If checked, the
VI converts linear magnitude response to decibels.
• Passband: Species the color of the lines in the magnitude plot that represent the passband response
and the passband frequencies. The default is blue. Click the color box next to the parameter name to
select a dierent color.
• Stopband: Species the color of the lines in the magnitude plot that represent the stopband atten-
uation and the stopband frequencies. The default is red. Click the color box next to the parameter
name to select a dierent color.
• Magnitude: Contains the plot of the magnitude response. You can drag the cursors in the plot to
change the specications. The color you specify in passband represents the passband response and the
passband frequencies. The color you specify in stopband represents the stopband attenuation and the
stopband frequencies. The green vertical line in the graph represents the half sampling frequency, also
known as the Nyquist frequency.
• Z Plane: Contains the plot of the zeroes and poles of the lter in the Z plane.

5.5 Pole/Zero Placement Design


The Pole-Zero Placement Option allows you to interactively place and move poles and zeros on the
z-plane. To do so, you can enter complex value coordinates to specify exact values or click on a graph of the
complex half plane to move or place them with the mouse. The magnitude response of the resulting lter
updates immediately as you place or move poles / zeros.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


29

Digital Filter Design Utility

Figure 5.2: The Pole-Zero Placement Filter Design Interface

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:

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 5. INTERACTIVE DIGITAL FILTER DESIGN - ONLINE TOOL
30
FOR IIR FILTER AND FIR FILTER DESIGN

• 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.3 Filter Settings


• Gain: Sets the gain of the lter manually. You can use this control only if you remove the checkmark
from the Normalized Gain checkbox.
• Normalized Gain: Species whether the VI automatically adjusts the gain of the lter. The default
contains a checkmark in the checkbox, in which the VI adjusts the gain so the maximum response is 1.0
(0 dB). Remove the checkmark from the checkbox to adjust the gain manually with the Gain control.
• fs [Hz]: Species the sampling frequency in hertz. The input must contain a value greater than zero.
• Coordinates: Species whether the VI displays poles and zeroes in rectangular or polar coordinates.
The default is rectangular coordinates.
• Load Filter from File: Opens a le dialog you can use to select a le of a lter that loads into the
Express VI.
• Zero: Species the color of the zeroes in the Z Plane plot. The default is blue. Click the color box
next to the parameter name to select a dierent color.
• Pole: Species the color of the poles in the Z Plane plot. The default is red. Click the color box next
to the parameter name to select a dierent color.
• Delete selected: Deletes the selected pole or zero from the lter.
• Add Zero: Adds a zero to the lter.
• Add Pole: Adds a pole to the lter.
• Z Plane: Plots the number and location of poles and zeroes.
• Magnitude: Plots the lter magnitude response.
• Magnitude in dB: Species whether the VI uses decibels or a linear scale in the magnitude plot. If
a checkmark is in the checkbox, the VI converts linear magnitude response to decibels.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


31

5.6 LabVIEW Resources


To simplify working in LabVIEW with the lters that you design with the interactive utility on this page,
we have posted several utility VIs for LabVIEW that allow you to import and export the designs that you
save or load using the "Save Filter Spec" or "Load Filter Spec" buttons from the utility. You can download
a zip le containing these utilities here
6 .

6 http://cnx.org/content/m13115/latest/DigitalFilterDesignUtils.zip

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 5. INTERACTIVE DIGITAL FILTER DESIGN - ONLINE TOOL
32
FOR IIR FILTER AND FIR FILTER DESIGN

5.7 What is LabVIEW?


LabVIEW is a graphical programming & mathematics environment for designing, prototyping, and deploying
systems. The Interactive Digital Filter Design Utility included on this site was built using LabVIEW 8 and
the LabVIEW Digital Filter Design Toolkit.
The LabVIEW Digital Filter Design Toolkit
7 is a software add-on for LabVIEW that facilitates speci-
cation, design, analysis, and implementation of digital lters. Without prior knowledge about programming
in LabVIEW, you can use the Digital Filter Design Toolkit Express VIs to interact graphically with lter
specications to design digital lters. For more information on the LabVIEW Digital Filter Design toolkit,
view the online web event Designing Digital Filters with NI LabVIEW and the Digital Filter Design Toolkit
8
.
The LabVIEW Digital Filter Design Toolkit
9 provides VIs that you can use to design a digital IIR or
FIR lter, analyze the characteristics of the digital lter, change the implementation structure of the digital
lter, and process data with the digital lter. Besides the oating point support, the LabVIEW Digital
Filter Design Toolkit provides a set of VIs that you can use to generate a xed point digital lter model,
analyze the characteristics of the xed point digital lter, simulate the performance of the xed point digital
lter, and generate integer C or LabVIEW code for a specic xed point target. In addition to tools that
help you create conventional digital lters, the LabVIEW Digital Filter Design Toolkit includes tools for
multirate digital lter design.
Visit ni.com
10 for more information about the LabVIEW Digital Filter Design Toolkit11 and other NI
products and resources.

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

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


Chapter 6

DSP Laboratory: IIR Notch Filter


1
Design

6.1 Notch IIR Filter Design


The purpose of this lab is to examine IIR lter design/implementation using LabVIEW DSP. Particular
attention is drawn to the comparison between theoretical lter characteristics and actual lter performance.
In this lab, it is assumed that the student is already familiar with the basic operation of LabVIEW DSP.

6.1.1 Create a VI for Plotting Time and Frequency Domain Data


1. Open Surround Mixer, a program which controls the input/output operation of the sound card. Make
sure that the Wave/mp3 and Line-in volumes are set to approximately 75%. 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 and Line-in) throughout the lab.
2. Start LabVIEW Embedded Edition (StartAll ProgramsLabVIEW Embedded Edition) and open a
blank VI (Virtual Instrument).

1 This content is available online at <http://cnx.org/content/m13038/1.2/>.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>

33
34 CHAPTER 6. DSP LABORATORY: IIR NOTCH FILTER DESIGN

Figure 6.1: Pass-Through VI

3. We will build the VI whose Block Diagram is shown in Figure

• 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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


35

Figure 6.2: Elemental I/O sub palette

• 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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


36 CHAPTER 6. DSP LABORATORY: IIR NOTCH FILTER DESIGN

Figure 6.3: Spectral Measurements 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.

Figure 6.4: VI Front Panel

• 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).

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


37

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).

6.1.2 Notch Filter


Now we're going to add some noise to the music and then lter it out. The rst type of noise we're going
to add is a single frequency sinusoidal noise. As you know from class, the best lter to use for this type of
lter is a simple notch lter.

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


38 CHAPTER 6. DSP LABORATORY: IIR NOTCH FILTER DESIGN

Figure 6.5: Modied Block Diagram with the Biquad VI

6.1.2.1 Answer These Questions

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

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


39

from the music?

• 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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


40 CHAPTER 6. DSP LABORATORY: IIR NOTCH FILTER DESIGN

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


Chapter 7

DSP Laboratory: IIR Filter Design via


1
the Bilinear Transformation

7.1 IIR Filter Design via the Bilinear Transformation


The purpose of this lab is to examine IIR lter design/implementation using LabVIEW DSP. Particular
attention is drawn to the comparison between theoretical lter characteristics and actual lter performance.
In this lab, it is assumed that the student is already familiar with the basic operation of LabVIEW DSP.

7.1.1 Create a VI for Plotting Time and Frequency Domain Data


1. Open Surround Mixer, a program which controls the input/output operation of the sound card. Make
sure that the Wave/mp3 and Line-in volumes are set to approximately 75%. 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 and Line-in) throughout the lab.
2. Start LabVIEW Embedded Edition (StartAll ProgramsLabVIEW Embedded Edition) and open a
blank VI (Virtual Instrument).

1 This content is available online at <http://cnx.org/content/m13039/1.1/>.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>

41
CHAPTER 7. DSP LABORATORY: IIR FILTER DESIGN VIA THE
42
BILINEAR TRANSFORMATION

Figure 7.1: Pass-Through VI

3. We will build the VI whose Block Diagram is shown in Figure

• 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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


43

Figure 7.2: Elemental I/O sub palette

• 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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 7. DSP LABORATORY: IIR FILTER DESIGN VIA THE
44
BILINEAR TRANSFORMATION

Figure 7.3: Spectral Measurements 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.

Figure 7.4: VI Front Panel

• 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).

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


45

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).

7.1.2 IIR Filter Design via the Bilinear Transformation


LabVIEW DSP allows the user to implement standard IIR digital lters designed using a lter design
supplemental program, called Digital Filter Design Toolkit. The DFD toolkit is an add-on module to
LabVIEW (not LabVIEW Embedded). This module allows the user to design complex lters, save them
and implement them using LabVIEW DSP.

Figure 7.5: New Block Diagram with DFD Filter

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).

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 7. DSP LABORATORY: IIR FILTER DESIGN VIA THE
46
BILINEAR TRANSFORMATION

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:

• Filter Type: Lowpass


• Sampling Frequency: 16000 Hz
• Passband Edge Frequency: 1000 Hz
• Passband ripple: 3 dB (standard for Butterworth lters)
• Stopband Edge Frequency: 1500 Hz
• Minimum stopband attenuation 20 dB
• Design Method: Butterworth

note: Leave the other settings to their default values.

Figure 7.6: DFD Classical Filter Design Conguration Window

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


47

• 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.

Figure 7.7: Filter Design

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 7. DSP LABORATORY: IIR FILTER DESIGN VIA THE
48
BILINEAR TRANSFORMATION

7.1.2.1 Answer These Questions

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.

7.1.3.1 Answer These Questions

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


49

Figure 7.8: Table for recording Problem 3 Results.

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.

7.1.4.1 Answer These Questions

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 7. DSP LABORATORY: IIR FILTER DESIGN VIA THE
50
BILINEAR TRANSFORMATION

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).

7.1.5.1 Answer These Questions

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


51

Figure 7.9: Program with Noise Generator

7.1.6.1 Answer These Questions

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

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


CHAPTER 7. DSP LABORATORY: IIR FILTER DESIGN VIA THE
52
BILINEAR TRANSFORMATION

• Save the lter to your folder (giving it a descriptive name like bpcheby1500-3500) and examine the
various tabs in the lter design program.

7.1.7.1 Answer These Questions

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


Chapter 8
1
DSP Laboratory: FIR Filter Design

8.1 FIR Filter Design


The purpose of this lab is to examine FIR lter 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.

8.1.1 Congure Sound Output on the Computer


1. Keep the Surround Mixer open throughout the lab. You will be selecting various inputs (wave, micro-
phone, and line-in) throughout the lab.
2. 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/o. When checked, the
corresponding sound source is deactivated. Make sure that all source buttons are muted for now.

8.1.2 Create a VI for Plotting Time and Frequency Domain Data


1. Start LabVIEW Embedded Edition and change the target to the SPEEDY-33 board.

1 This content is available online at <http://cnx.org/content/m13040/1.1/>.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>

53
54 CHAPTER 8. DSP LABORATORY: FIR FILTER DESIGN

Figure 8.1

2. Create a New Blank VI.


3. Open the Front Panel and place two All ControlsGraphsWaveform Graphs
4. Label them Time Domain and Frequency Domain.
5. Open the Block Diagram and place the following objects in it.

• All FunctionsElemental I/OAnalog Input node.


• All FunctionsElemental I/OAnalog Output node.
• All FunctionsNumericAdd function.
• All FunctionsSignal ProcessingFrequency DomainSpectral Measurements.

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


55

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

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


56 CHAPTER 8. DSP LABORATORY: FIR FILTER DESIGN

makes it easier to connect them together.


11. 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.
12. Place a while loop around the objects in the Block Diagram to execute this functions continuously.

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

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


57

8.1.3 FIR Filter Design


Now we will design an FIR lter using the same LabVIEW DFD toolkit used for the IIR lters. This
LabVIEW DFD toolkit designs 3 dierent types of FIR lters: Kaiser-Window lters, Equi-Ripple lters
and Dolph-Chevyshev Windows lters. We will focus on the Kaiser-Window FIR lters.

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


58 CHAPTER 8. DSP LABORATORY: FIR FILTER DESIGN

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:

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


59

Figure 8.7: 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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


60 CHAPTER 8. DSP LABORATORY: FIR FILTER DESIGN

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


61

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


62 CHAPTER 8. DSP LABORATORY: FIR FILTER DESIGN

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:

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


63

Figure 8.11: Table for collecting 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.

8.1.4 FIR Filter Bank  Graphic Equalizer


Now you are going to add two more FIR lters that cover the rest of the frequency range DC  Fs/2 and then
combine these FIR lters into a lter bank that will allow you to selectively boost/attenuate the various
frequency ranges. A lter bank is nothing more than a parallel combination of dierent lters. This is
basically what a graphic equalizer does on a typical stereo system, except that many equalizers are analog
lters, rather than digital lters.

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?

4. Design a highpass FIR lter to meet the following specications:

• Type: Highpass

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


64 CHAPTER 8. DSP LABORATORY: FIR FILTER DESIGN

• 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

5. Run the VI and save the coecient le as HPFIR2000.fds

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


65

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.

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


66 INDEX

Index of Keywords and Terms


Keywords are listed by the section with that keyword (page numbers are in parentheses). Keywords
do not necessarily appear in the text of the page. They are merely associated with that section. Ex.
apples, Ÿ 1.1 (1) Terms are referenced by the page they appear on. Ex. apples, 1

6 6711, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15), Ÿ 4(21), Ÿ 6(33), Ÿ 7(41), Ÿ 8(53)


Ÿ 7(41), Ÿ 8(53)
P Processing, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15), Ÿ 4(21),
D Digital, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15), Ÿ 4(21), Ÿ 6(33), Ÿ 6(33), Ÿ 7(41), Ÿ 8(53)
Ÿ 7(41), Ÿ 8(53)
Digital Signal Processing, Ÿ 5(25)
S Signal, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15), Ÿ 4(21), Ÿ 6(33),
Ÿ 7(41), Ÿ 8(53)
dsk, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15), Ÿ 4(21), Ÿ 6(33),
Signal Processing, Ÿ 5(25)
Ÿ 7(41), Ÿ 8(53)
SP, Ÿ 5(25)
DSP, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15), Ÿ 4(21), Ÿ 5(25),
speedy, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15), Ÿ 4(21), Ÿ 6(33),
Ÿ 6(33), Ÿ 7(41), Ÿ 8(53)
Ÿ 7(41), Ÿ 8(53)
F Filter Design, Ÿ 5(25) speedy 33, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15), Ÿ 4(21),
FIR Filter, Ÿ 5(25) Ÿ 6(33), Ÿ 7(41), Ÿ 8(53)
Free, Ÿ 5(25)
T texas instruments, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15),
I IIR Filter, Ÿ 5(25) Ÿ 4(21), Ÿ 6(33), Ÿ 7(41), Ÿ 8(53)
ti, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15), Ÿ 4(21), Ÿ 6(33),
L labview, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15), Ÿ 4(21),
Ÿ 7(41), Ÿ 8(53)
Ÿ 5(25), Ÿ 6(33), Ÿ 7(41), Ÿ 8(53)
tidsk, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15), Ÿ 4(21), Ÿ 6(33),
LabVIEW DSP, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15),
Ÿ 7(41), Ÿ 8(53)
Ÿ 4(21), Ÿ 6(33), Ÿ 7(41), Ÿ 8(53)
lv, Ÿ 1(1), Ÿ 2(7), Ÿ 3(15), Ÿ 4(21), Ÿ 6(33), U Utility, Ÿ 5(25)

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


ATTRIBUTIONS 67

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: "DSP Laboratory: Introduction, Hardware and Software Setup"


By: Erik Luther
URL: http://cnx.org/content/m13036/1.2/
Pages: 1-5
Copyright: Erik Luther
License: http://creativecommons.org/licenses/by/2.0/

Module: "DSP Laboratory: Analog to Digital and Digital to Analog Conversion"


By: Erik Luther
URL: http://cnx.org/content/m13035/1.1/
Pages: 7-14
Copyright: Erik Luther
License: http://creativecommons.org/licenses/by/2.0/

Module: "DSP Laboratory: Time and Frequency Displays"


By: Erik Luther
URL: http://cnx.org/content/m13037/1.1/
Pages: 15-20
Copyright: Erik Luther
License: http://creativecommons.org/licenses/by/2.0/

Module: "DSP Laboratory: Aliasing"


By: Erik Luther
URL: http://cnx.org/content/m13034/1.2/
Pages: 21-23
Copyright: Erik Luther
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 Notch Filter Design"


By: Erik Luther
URL: http://cnx.org/content/m13038/1.2/
Pages: 33-39
Copyright: Erik Luther
License: http://creativecommons.org/licenses/by/2.0/

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


68 ATTRIBUTIONS

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/

Module: "DSP Laboratory: FIR Filter Design"


By: Erik Luther
URL: http://cnx.org/content/m13040/1.1/
Pages: 53-65
Copyright: Erik Luther
License: http://creativecommons.org/licenses/by/2.0/

Available for free at Connexions <http://cnx.org/content/col10303/1.5>


Fundamentals of Digital Signal Processing Lab
The purpose of this lab is to familiarize students with the DSP development workstation in the signal
processing lab by examining sampling, analysis, and reconstruction of continuous-time signals. Specically,
we will rst look at sampling/reconstruction of continuous-time signals. We will then examine time- and
frequency-domain displays. Finally, we will examine the importance of sampling frequency and its eects on
aliasing.

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.

You might also like