You are on page 1of 5

FAST Fourier Transform (FFT) and Digital Filtering Using LabVIEW

Wei Lin Department of Biomedical Engineering Stony Brook University

Instructors Portion
Summary
This experiment requires the student to use LabVIEW to perform signal analysis on the acquired analog signals. Students should be familiar with the Fast Fourier Transform (FFT) and digital filtering using LabVIEW

Uses
This lecture applies to all courses of virtual instrumentation.

Equipment List
Computers LabVIEW 8.5 Express NI-ELVIS benchtop workstation

References
Lecture Slides of Data Analysis Using LabVIEW VIs from the project Data Acquisition Using NI-DAQmx

Students Portion
Introduction
The students should learn the basic LabVIEW programming techniques for the FFT and digital filtering. They will modify two VIs developed in the

project Data Acquisition Using NI-DAQmx and add frequency spectrum analysis and digital filter in the two VIs.

Objectives
Perform FFT analysis using LabVIEW Frequency Spectrum Express VI Design and test digital filter using LabVIEW Filter Express VI

Theory
The Fast Fourier Transform (FFT) and the power spectrum are powerful tools for analyzing and measuring signals from plug-in data acquisition (DAQ) devices. It can measure the frequency components within the signal. FFT-based measurement requires digitization of a continuous signal. According to the Nyquist criterion, the sampling frequency, Fs, must be at least twice the maximum frequency component in the signal. If this criterion is violated, a phenomenon known as aliasing occurs. When the Nyquist criterion is violated, frequency components above half the sampling frequency appear as frequency components below half the sampling frequency, resulting in an erroneous representation of the signal. This is called frequency aliasing. Therefore, before a signal is digitized, antialiasing filters are used to attenuate the frequency components at and above half the sampling frequency to a level below the dynamic range of the analog-to-digital converter (ADC). Spectral leakage is another issue in FFT analysis. It is the result of an assumption in the FFT algorithm that the time record is exactly repeated throughout all time and that signals contained in a time record are thus periodic at intervals that correspond to the length of the time record. If the time record has a nonintegral number of cycles, this assumption is violated and spectral leakage occurs. To alleviate the spectrum leakage, a predefine window function is applied to the signals to be analyzed. Filters alter or remove unwanted frequencies from your signal. Depending on the frequency range that they either pass or attenuate, they can be classified into the following types:

A lowpass filter passes low frequencies, but attenuates high frequencies. A highpass filter passes high frequencies, but attenuates low frequencies. A bandpass filter passes a certain band of frequencies. A bandstop filter attenuates a certain band of frequencies.

Digital filters have the following advantages over their analog counterparts:

They are programmable in terms of filter order, cutoff frequencies, and amount of ripple. They are stable and predictable. They do not drift with temperature or humidity and do not require precision components. They have a superior performance-to-cost ratio.

Therefore, it is recommended to use digital filters in instrumentation except for the antialiasing filter. LabVIEW has two express VIs for FFT analysis and digital filtering. They are frequency spectrum express VI and filter express VI.

Lab Procedure
Experiment 1: Create a LabVIEW application of frequency spectrum analysis: 1. Launch LabVIEW. 2. Load finite data acquisition VI. 3. Add the frequency spectrum VI (Express->Signal Analysis>Spectral). Configure the output of the express VI as linear in result section and set window as None. 4. Connect the waveform data from DAQmx read VI to the signal terminal of the frequency spectrum express VI. 5. Add a graph indicator on the front panel and connect the output (FFT-(RMS)) of the frequency spectrum VI (FFT) to the graph. 6. Keep the ELVIS unit off. Connect the output of function generator FUNC OUT to ACH0 using connection wire on the prototype board. 7. Turn ELVIS unit on including the prototype board. 8. Launch ELVIS application and choose function generator. 9. Enter the parameters for the controls of the LabVIEW. Recommended sampling frequency is 1000 Hz and number of samples is 1000. 10. Set the frequency, and function type of the signal generator (recommended function: sine wave, frequency 20 Hz. and run the VI and observe the frequency spectrum. In this case, you should collected integer number of cycles of the signal. Therefore, no spectrum leakage is present. 11. Change the signal frequency or the number of samples so that there is a disconnection at the end of the signal (non integer number of cycles collected) and observe the spectrum leakage. 12. You may need to add write Meas file VI to same the signal and the FFT result for your lab report. 13. Save the VI

Experiment 2, Create a LabVIEW application of digital filter: 1. Use the VI from previous experiment. 2. Add two more graph indictors on the front panel for the filtered signal and the spectrum of the filtered signal. 3. Add a filter express VI (Express->Signal Analysis->Filter) and connect the output from the DAQmx VI to the signal terminal of the filter VI 4. Connect the output of filter to the graph indicator of filtered signal. 5. Add another frequency spectrum express VI (Express->Signal Analysis->Spectral) on the block diagram and connect the filtered signal to its input. 6. Connect the output of the above frequency spectrum express VI to the graph indicator of the filtered signal spectrum. 7. Combine the two dynamic data, the spectrum of the original signal and the spectrum of the filtered signal using signal manipulation VI (Express->Signal Manipulate->merge signals) and connect it to the Write LabVIEW Measurement Data express VI (Express>Output->write meas data). In the wizard, select a. Ask user to choose file b. Ask each iteration c. If a file already exists, overwrite file d. X value columns: one column per channel 8. Run the application and record the results in files. The following are the suggestions for the test of digital filters. a. Use square wave at low frequency, far below the sampling frequency. (20 Hz) b. Change the cutoff frequency of the filter. c. Change the type of filter, e.g. lowpass or highpass. d. Change the order of the filter. (optional) e. Change the topology of the filter. (optional) Experiment 3. (Extra credits): Using FFT to measure the cutoff frequencies of the band pass filter you made in the previous lab. The expected solution will use one or two measurements to estimate the cutoff frequencies instead of using multiple sinusoidal signals.

Lab Report
1. Objective. 2. Theory (What it FFT? Filter?) 3. Data: Demonstrate frequency spectrum of the tested signal and filter effects. 4. Due on 11/14/2008

Reference VIs

FFT VI

Filter VI