Skip to content Skip to navigation

OpenStax-CNX

You are here: Home » Content » DSP Laboratory: FIR Filter Design

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • NSF Partnership display tagshide tags

    This module is included inLens: NSF Partnership in Signal Processing
    By: Sidney BurrusAs a part of collection: "Fundamentals of Digital Signal Processing Lab"

    Click the "NSF Partnership" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

  • National Instruments display tagshide tags

    This module is included in aLens by: National InstrumentsAs a part of collection: "Fundamentals of Digital Signal Processing Lab"

    Comments:

    "The purpose of this course, EE 453 at Penn State University, is to familiarize students with DSP development by examining sampling, analysis, and reconstruction of continuous-time signals. […]"

    Click the "National Instruments" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Also in these lenses

  • Lens for Engineering

    This module is included inLens: Lens for Engineering
    By: Sidney Burrus

    Click the "Lens for Engineering" link to see all content selected in this lens.

  • NI Signal Processing display tagshide tags

    This module is included inLens: Digital Signal Processing with NI LabVIEW and the National Instruments Platform
    By: Sam ShearmanAs a part of collection: "Fundamentals of Digital Signal Processing Lab"

    Comments:

    "Lab material that explores signal processing concepts using National Instruments LabVIEW DSP."

    Click the "NI Signal Processing" link to see all content selected in this lens.

    Click the tag icon tag icon to display tags associated with this content.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

DSP Laboratory: FIR Filter Design

Module by: Erik Luther. E-mail the author

Summary: The purpose of this lab is to examine FIR filter design/implementation using LabVIEW Digital Filter Design Toolkit and LabVIEW DSP Module. In this lab, it is assumed that the student is already familiar with the basic operation of LabVIEW.

FIR Filter Design

The purpose of this lab is to examine FIR filter design/implementation using LabVIEW Digital Filter Design Toolkit and LabVIEW DSP Module. In this lab, it is assumed that the student is already familiar with the basic operation of LabVIEW.

Configure Sound Output on the Computer

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

Create a VI for Plotting Time and Frequency Domain Data

  1. Start LabVIEW Embedded Edition and change the target to the SPEEDY-33 board.
    Figure 1
    Figure 1 (Graphic1)
  2. Create a New Blank VI.
  3. Open the Front Panel and place two All Controls»Graphs»Waveform Graphs
  4. Label them Time Domain and Frequency Domain.
  5. Open the Block Diagram and place the following objects in it.
    • All Functions»Elemental I/O»Analog Input node.
    • All Functions»Elemental I/O»Analog Output node.
    • All Functions»Numeric»Add function.
    • All Functions»Signal Processing»Frequency Domain»Spectral Measurements.

    Note:

    When you place the Analog Input node, it will display only one channel. It is after you configure it that the right and left channels will be shown.
  6. Double click the Analog Input node and change the Resource under the General Tab to be 2 channel multiple samples.
    Figure 2
    Figure 2 (Graphic2)
  7. Go to the Configuration Tab and set the Sample Rate to 8000 Hz and the Framesize to 256.
    Figure 3
    Figure 3 (Graphic3)
  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 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 4
    Figure 4 (Graphic4)
  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 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.
  14. Once you have verified that everything is working properly, stop the CD, then stop the LabVIEW VI. (Do not exit LabVIEW)
  15. Save this VI by selecting File»Save As. Make sure to save the file in your personal directory - - Desktop \ee 453\<folder name>. You can give the file any name you want (such as lab3setup), but use the default extension of .vi

FIR Filter Design

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

  1. Open LabVIEW (not the Embedded Edition) and create a New Blank VI.
  2. In the block diagram, place the All Functions»Digital Filter Design»Filter Design»DFD Classical Filter Design Express VI.
  3. Double click in the VI and configure a lowpass FIR filter with the following settings:
    • Type: Lowpass
    • Passband edge frequency: 400 Hz
    • Stopband edge frequency: 800 Hz
    • Passband ripple: 1dB (doesn’t matter because stopband specs will determine passband ripple)
    • Minimum stopband attenuation: 40 dB
    • Sampling Frequency: 8000 Hz.
    • Design Method: Kaiser Window
    Figure 5
    Figure 5 (Graphic5)
  4. Once you have all the parameters set correctly, press OK.
  5. Place the DFD Save to File VI found in All Functions»Digital Filter Design»Utilities.
  6. Wire the filter out to the filter in of the DFD Save to File function. Wire the error clusters.
  7. Save the VI in Desktop \ ee 453 \<folder name> using some meaningful title such as Filter Design.vi.
    Figure 6
    Figure 6 (Graphic6)
  8. Run the VI and when prompted save the Filter Coefficients into the same folder with a meaningful name such as LPFIR400.fds. Make sure to use the default extension (fds) when saving this coefficient file.

    Exercise 1

    Determine the predicted filter length M using the Kaiser-window design equation:

    Figure 7: Kaiser-window Design Equation
    Figure 7 (eq1.png)

    Recall that alpha is the desired stopband attenuation and delta-omega is the transition region width (in radians/sample). (Show your work.)

    Exercise 2

    Write down the filter 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 Domain–Filtered and Frequency Domain-Filtered.
  11. Add to the DFD Filter VI (All Functions»Signal Processing»Filters) to the Block Diagram after the Add function. Wire the output of the Add function to the DFD filter. Wire the output of the DFD filter to the Analog Output node. Wire the output of the DFD filter to the Time Domain – Filtered terminal.
  12. Make a copy of the Spectral Measurements Express VI. Wire the output of the Add function to the copy of the Spectral Measurements. Then wire the output of the Power Spectrum to the Frequency Domain – Filtered terminal.
    Figure 8
    Figure 8 (Graphic7)
  13. Double click on the DFD Filter VI and select the path to the Coefficient File. As soon as you load the file, you will see the magnitude, impulse and phase response graphs update.
    Figure 9
    Figure 9 (Graphic8)
  14. Save the VI. Start the CD Player and then Run the VI. You should here a heavily lowpass filtered version of your music through the headphones. You can also see the effect of the filtering by looking at the appropriate indicators.
  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 3

    What happens when the sampling frequency used to operate the filter is changed from Fs = 8000 Hz (the Fs used to design the filter) to Fs = 16000 Hz.? Explain

  16. Stop the VI and disconnect the Analog Input node and the Add function. Replace these objects with the Simulate Signal Express VI (Functions»Embedded Signal Generator). Double click to bring up the properties page and configure it to generate a 200 Hz sine wave with amplitude 10000. Set the framesize to 256. Make sure that the sampling frequency is 8000 Hz. Save the VI with a different name. Run the VI and observe the filtered output. Use the Time-Domain plot to carefully measure the amplitude of the output signal.
    Figure 10
    Figure 10 (Graphic9)
  17. Repeat step 16 without changing the name of the file for the following frequencies: 400 Hz, 600 Hz, 800 Hz.

    Exercise 4

    Complete the following table based on your measured data:

    Figure 11: Table for collecting data
    Figure 11 (table1.png)

    Exercise 5

    Does this filter yield the gains that you expected at the frequencies above? Why or why not? Specifically comment on the gain at 400 Hz, 600 Hz and 800 Hz.

  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 filter, the output of the filter will look like the input, except for a time delay. Carefully measure and record the time (in milliseconds) of the first zero crossing in the input signal and the corresponding zero crossing in the output signal.

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

FIR Filter Bank – Graphic Equalizer

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

  1. Open LabVIEW (not Embedded Edition) and open the Filter Design VI built in Section II.
  2. Design a bandpass FIR filter to meet the following specifications:
    • Type: bandpass
    • Design Method: Kaiser Window
    • Stop Edge Frequency: 400Hz / 2000Hz
    • Passband Edge Frequency: 800Hz / 1600Hz
    • Passband ripple: 1 dB (doesn’t matter because stopband specs will determine passband ripple)
    • Minimum stopband attenuation: 40 dB
    • Sampling Frequency : 8000 Hz
  3. After entering the parameters, press OK. Run the VI and save the filter coefficients as BPFIR800_1600.fds.

    Exercise 7

    The filter length for this BP filter was the same as for the LP filter. Why did this happen?

  4. Design a highpass FIR filter to meet the following specifications:
    • Type: Highpass
    • Design Method: Kaiser Window
    • Stopband Edge Frequency: 1600 Hz
    • Passband Edge Frequnecy: 2000 Hz
    • Passband ripple: 1 dB (doesn’t matter because stopband specs will determine passband ripple)
    • Minimum stopband attenuation: 40dB
    • Sampling Frequency: 8000 Hz
  5. Run the VI and save the coefficient file as HPFIR2000.fds

    Exercise 8

    You should have noticed that all 3 filters had (nearly) identical filter lengths. For an FIR-based filter bank, this is a very important feature to have. Why? Hint: Think about the phase responses of FIR filters.

    Exercise 9

    You should have noticed that the length of the highpass filter was slightly different than the other filters. What is the reason for this? Hint: Think about the 4 basic types of FIR filters (Type I – Type IV).

  6. Open the lab3setup VI and change the filter coefficient’s file in the DFD filter VI to the bandpass filter file. Save the VI with a different name such as lab3filters.vi. Run the VI and make sure it works fine.
  7. Change again the filter file for the highpass filter file. Do not change the name of the file. Save it and run it.
  8. Once you have verified that your 2 additional FIR filters work, add two more DFD Filter VIs to the block diagram and two Add functions.
  9. Wire the output of the Add function that adds the Analog Input node to the two new DFD filters. Configure the three DFD Filter VIs with the Lowpass, Highpass and Bandpass filter files.
  10. Put three Multiply functions and wire the output of the filters to them. Place three numeric controls in the Front Panel and set them to 1.
  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 filter.
  12. Wire the output of the Multiply functions to the Add functions to add the three multiplications or gain sets. Wire the output of the last Add to the Analog Output node and the signal input of the Spectral Measurements Express VI.
    Figure 12
    Figure 12 (Graphic10)
  13. The resulting configuration is a 3-band filter bank that covers frequencies in the range DC-4000 Hz. Note that the frequency ranges of these 3 filters were selected so that the transition regions overlap perfectly (i.e. the edge of the passband of one filter is the edge of the stopband of the prior filter). This type of overlap yields the best frequency coverage and provides a nearly constant gain in each transition region. (i.e. As one filter starts attenuating, the next filter starts amplifying).
  14. Start your CD. Save and Run the VI. You should hear the music basically unfiltered, since all frequencies in the range 0-4000 Hz are passed with a gain of 1. Start playing with the individual Gains now to boost/attenuate the various frequency ranges by selecting gains <1 and >1. Don’t select gains too large (greater than 3 or 4) or else you may start clipping the output signal. Call your TA over to verify that you have completed this part of the lab.

Note:

When you are done with this lab, exit LabVIEW and LabVIEW Embedded Edition and log off the computer. Unplug the SPEEDY-33 board and turn off the headphone volume booster. Turn in your completed worksheet to the lab TA.

Content actions

Download module as:

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks