Sie sind auf Seite 1von 7

Physics 405 Lab 6 LabVIEW DSP

Page 1/7

Physics Department, UIUC

University of Illinois at Urbana-Champaign Digital Electronics Laboratory

Physics Department Physics 405 Laboratory

Experiment 6:

Digital Signal Processing

LabVIEW has extensive signal processing capabilities, including fast Fourier transformation and digital filtering VI's. For the first series of exercises we will just have LabVIEW generate signals as arrays of data rather than importing them from an external instrument. Once we have gained familiarity with the filters, we can apply the techniques to real waveforms, using the acquisition methods learned in the previous lab. Exercise #1. Fourier Analysis Use LabVIEW to generate an array containing the slit-diffraction function, sin( 0 t)/( 0 t) and find its Fourier transform (power spectrum). Place the frequency control on the front panel so you can access it. Label it angular frequency to avoid confusion later on. As you can show by elementary calculus, this transform should be a box function with abrupt edges. LabVIEW has a selection of FFTs under its Functions > Analysis menu. You may use either the Real FFT or Power Spectrum version.

Figure 1. LabVIEW diagram to plot the Fourier transform of a function. You should try to use a power of two as the number of points because the Fast Fourier transform (FFT) function is more efficient that way. Remember to use a range of positive and negative times. Since the FFTs output is complex, you need to convert it to an amplitude. Then use an XY chart to make a plot of Fourier coefficient versus frequency. Your diagram might look something like the one shown in Figure 1 above. Describe what you see carefully in your report. Make sure you understand what happens when you change the value of 0 , for example.
Revised October, 2004. Copyright 2000-2004 The Board of Trustees of the University of Illinois. All rights reserved.

Physics 405 Lab 6 LabVIEW DSP

Page 2/7

Physics Department, UIUC

Next use your LabVIEW program to look at the Fourier transform of a pure sine wave, sin( 0 t) where t is the (integer) index value of the array. An easy way to do this is to right-click the existing function and Replace it with a different one. The transform should of course be a single sharp peak at frequency 0 , but there will be two if you have both positive and negative frequencies present. 1. Make sure you understand the conversion of units that determines how the frequency axis of the FFT is calibrated. You may have to refer to the definition of the Discrete Fourier Transform, yj = xk exp(2 ijk / N ) .
k =0 N 1

2. Vary the sine-wave frequency 0 over a wide range. Notice especially what happens at values of (angular) frequency near to 3. What is special about this value, called the Nyquist frequency N ? Why does the spectrum look the same for frequencies an equal amount above and below N ? What happens to the wave in each of these cases? This effect is called "Aliasing". 3. Now consider the case of a frequency which is an exact power-of-two submultiple of , such as /16. Look closely at the shape of the peak by using the XY display's control palette to make the individual points visible and to zoom the X-axis. Then change the frequency slightly, say to /15, /15.9 or /17. Sketch what happens in your report and try to explain it? This effect is called "leakage" and can be cured by filtering, as we will see later. See Essick's book pp 261-278. Now convert your LabVIEW program to generate a sum of three signals: two sinusoidal signals with independent frequencies and amplitudes, and some Gaussian noise. Design the front panel so you can vary the amplitudes and frequencies of the sine wave components as well as the amount of noise. The front panel should have two XY displays, as before, one for the signal and one for the spectrum. You will use this to prepare test signals for later parts of the lab, so save your signal generator as a VI file. Now use the Real FFT function to examine the real and imaginary parts of the Fourier spectrum (rather than its amplitude as you did before). Consider the following: 4. Vary the frequency of one sine wave component to demonstrate aliasing: make it larger than the Nyquist frequency and see where this ends up in the Fourier transform. 5. Change the total length of the array to demonstrate how to increase frequency resolution.

Revised October, 2004. Copyright 2000-2004 The Board of Trustees of the University of Illinois. All rights reserved.

Physics 405 Lab 6 LabVIEW DSP

Page 3/7

Physics Department, UIUC

6. Compare the individual real and imaginary parts with the power spectrum. Do you understand why some frequency components are zero, while others are negative? 7. Where does the noise show up in the spectrum? 8. Demonstrate that you can invert the real and imaginary parts of the transform to reconstruct the original time signal exactly. You may need to use the array operations to move those components of the discrete Fourier transform that lie higher than the Nyquist frequency, down to negative frequencies. Exercise #2. Digital Filtering LabVIEW has an extensive library of digital filters in its signal processing "suite" of virtual instruments. You can find them all in the Functions > Analysis > Filters section. These programs accept an array of input data (often a time series) and output a filtered array. The Help section has some informative discussions. For any of the filter VI functions, you must specify several filter characteristics as inputs to its icon: (1) You must specify low-pass, high-pass, bandpass, or bandstop (sometimes called a notch filter). (2) Specify the order of the filter, which is the number of poles. The standard RC low pass filter has 1 pole, rolls off at 6dB/octave, and has order = 1. A second order low pass filter will eventually roll off at 12dB/octave, since it has two poles, etc. (3) You must specify the sampling frequency, fsample. This is the same as the external clock frequency of the real digital filter. Your incoming data might be an array of data sampled every t seconds. In that case the sampling frequency is fsample = 1/t. (4) You must specify the characteristic frequency as a low cutoff frequency; the high cutoff frequency is left unspecified even for a low-pass filter. This is rather confusing, admittedly. The implementations are all digital filters. As an example, recall the simple recursive filter, yn = a yn-1 + b xn, where a and b are the filter coefficients. xn are the input data at time tn = n t. yn are the filtered data (output) at time tn. The low frequency cutoff for this filter is given by fcutoff b / ( a t ) = (b /a) fsample. The filter coefficients are simply determined by the ratio of the cutoff frequency and the sampling frequency. You can see that in LabVIEW. The
Revised October, 2004. Copyright 2000-2004 The Board of Trustees of the University of Illinois. All rights reserved.

Physics 405 Lab 6 LabVIEW DSP

Page 4/7

Physics Department, UIUC

output will be the same no matter whether fcutoff = 0.2 and fsample = 1 or fcutoff = 3 and fsample = 15. But, you can't set the cutoff higher than the Nyquist frequency = fsample / 2. If you try to set fcutoff = 0.6 and fsample = 1 the LabVIEW filter VI will return a blank array of numbers. LabVIEW allows you to choose from a large selection of different kinds of filters, such as Butterworth, Chebyshev, Bessel. The Help sections are useful to read on this score. The world of digital filters is divided into what are called IIR (Infinite Impulse Response) and FIR (Finite Impulse Response) filters. IIR filters are what we've been calling recursive filters. If you put in a sharp pulse (a delta function, ideally) then the output of a recursive filter can, in principle, last forever. You can see that in the above equation if a = 1, for example. IIR or recursive filters are good for filtering out noise and cleaning things up in the frequency domain, but they don't have such great time-domain characteristics. They are said to be not phase-linear. form: FIR (Finite Impulse Response) filters are nonrecursive. They take the

yn = aoxn + a1xn-1 + a2xn-2 + a3xn-3 + ... + aNxn-N Looking at this expression, you can see that the response to an impulse will not last forever because a finite number of inputs are used and no outputs are fed back. Both kinds of filters are causal, meaning that they only look at inputs after they arrive. FIR filters have better time domain characteristics but are more complicated to design for specific characteristics. IIR filters are simpler to program and use less memory than FIR filters. They are used primarily if you are worried about the frequency response but don't care much about the phase response. The common filter VI's in LabVIEW such as Butterworth, Chebyshev, Bessel, are all IIR filters. For FIR filters, LabVIEW has a "design" facility that figures out the coefficients you need according to your specifications. This is all contained in the Advanced FIR section but is a bit beyond what we need for this lab. You should carry out the following experiments: A. Frequency domain filtering Let's suppose that the desired signal is a sinewave of unit amplitude and frequency fsignal and there is an interfering signal, which is another sinewave of amplitude A and frequency fint. For simplicity we'll let fint > fsignal. We want to use a digital filter to suppress the interference. Use your earlier LabVIEW program to generate a signal array containing the sum of both sine-waves. It would be a good idea to take the number of samples as a power of 2 so that the FFT algorithm works efficiently. 1024 samples might be reasonable. Set fsignal = 19Hz and fint =
Revised October, 2004. Copyright 2000-2004 The Board of Trustees of the University of Illinois. All rights reserved.

Physics 405 Lab 6 LabVIEW DSP

Page 5/7

Physics Department, UIUC

60Hz (line frequency). Send the combined waveform through a Butterworth filter with its cutoff frequency set between fint and fsignal. 1. Measure the power spectrum of the filtered signal and watch how the attenuation of the two frequency components changes as you increase the order of the filter. 2. Next, try the same thing with the Chebyshev filter. In this case, you'll also need to specify the ripple in decibels. With the same order and cutoff frequency, compare the attenuation of the two filters. 3. Suppose you set and demand that the interference be attenuated by at least 1000 relative to the signal. Compare the filter order required using a Butterworth as opposed to a Chebyshev and a Bessel filter. 4. Explore the result of using a high-order filter with the cutoff frequency set to 40Hz, acting on a square wave of 19Hz. An important thing to realize is that higher order filters simply require a bit more computer time to implement digitally. To make a high order analog filter is quite difficult since many stable, accurate components are required. B. Time domain response In the time domain, we care about the shape of the signal. In this case, the more appropriate test signal is a square pulse, which is a pair of stepfunctions. Use the Signal Processing section to find the VI which generates a square pulse of duration W. Connect this to the filter, but now examine the time-response on a chart. 1. Send this pulse through low-pass Butterworth, Chebyshev, and Bessel filters and plot the filtered pulse shapes. Remember that you can access the Replace function with the right mouse button. Try, for example, using the same cutoff frequency as above, with fcutoff / fsampling = 0.04. 2. Plot out the transmitted pulse as you increase the order of the filter from 1 to 10. For the same order filter and cut-off frequency, which filter distorts the signal shape the least? 3. Using a second order Butterworth filter, change the filter cutoff all the way up to the Nyquist frequency. Plot the transmitted pulses on top of each other to show how the rise time changes. 4. Set fcutoff / fsampling = 0.04 and change the order of the filter from 1 to 10 and plot the transmitted pulses to show how this parameter changes the settling time. See Horowitz and Hill, p. 268-270 for additional discussion.

Revised October, 2004. Copyright 2000-2004 The Board of Trustees of the University of Illinois. All rights reserved.

Physics 405 Lab 6 LabVIEW DSP

Page 6/7

Physics Department, UIUC

5. The more realistic situation is one in which the signal is contaminated with noise. You can do this in LabVIEW by adding Gaussian noise to the pulse. Give the signal unit amplitude and the noise a standard deviation of 0.5 so that the pulse is just on the verge of visibility in the noise. Send it through a Bessel filter and change both cutoff frequency and filter order to do the best job that you can do to transmit the pulse faithfully while still filtering out the noise. C. Autocorrelation From the preceding example it should be clear that, even with a lot of filtering, once the noise level becomes comparable in size, the incoming waveform will be rather difficult to see. Another way to extract a signal from noise is called autocorrelation. You can consult the Help section to find out how the Autocorrelation VI in LabVIEW works. Note, for example, that the autocorrelation function is defined for both positive and negative times. Suppose you consider a single pulse that begins at array index (time) 100, is 50 units long, and has a total of 256 samples. The autocorrelation function should be a triangle with its base 100 units wide, extending from time 50 to +50. The LabVIEW autocorrelation VI will produce an array with 512 elements. The ones from 0 to 255 are considered negative time and the ones from 256 to 511 are considered positive time. 1. Verify the example above, by producing the triangular autocorrelation function of the square pulse described. 2. Now start adding noise. How large can the noise be before the autocorrelation function of the pulse disappears? Even when you add lots more noise there is still a sharp spike in the autocorrelation function. Where does that come from? 3. Finally, make a more complicated time-series by combining multiple pulses with the same shape, or by using combinations of positive and negative pulses delayed relative to each other. Plot their autocorrelation functions. Now add noise to these new shapes in order to see whether the signal/noise for the autocorrelation function is better than for the simple square pulse. Exercise #3. Filtering of real signals In Lab 5, we used the Data Acquisition VIs to acquire sampled waveforms into arrays and to replay them to a DAC to produce an output voltage. The effect of sampling was seen as discrete steps in the waveform. We will now apply our knowledge of filters to see what we can achieve with these real signals.
Revised October, 2004. Copyright 2000-2004 The Board of Trustees of the University of Illinois. All rights reserved.

Physics 405 Lab 6 LabVIEW DSP

Page 7/7

Physics Department, UIUC

Recall the file containing the AI Sample Waveform VI from you previous lab or create it again quickly. Apply its acquired data to either the Real FFT or Power Spectrum functions to calculate the spectrum of a signal from the Wavetek generator. You may need to adjust the number of samples input and the sampling rate to get an accurate spectrum. Try the following tests: 1. Check that the calibration of your frequency axis agrees with the value measured with the HP meter used as a frequency counter. 2. Compare the spectra of sine, triangle and square waves. How accurately do these spectral amplitudes agree with your expectations from calculus? 3. Vary the frequency of the real sine wave over a small range to look for the leakage effects you saw in Exercise #1. Do you get the same result for a square wave? Now connect one of the pre-packaged low-pass filter VIs between the AI Sample Waveform VI and the AO Generate Waveform VI to make a genuine filter. Retain the For Loop structure used last time to process waveforms multiple times. Then you can watch the results on the oscilloscope. Try the following tests: 4. Estimate the computational delay associated with the filtering by looking at the time delay between repetitions. How does this change with the kind of filter and its number of poles? 5. Examine the frequency response by comparing the input and output amplitudes as a function of frequency of a sine-wave. 6. Verify that a low-pass-filtered square wave looks like a sine-wave. 7. While applying a low frequency square-wave input, which can be considered to be a series of step functions, compare the settling times of the different kinds of filter and different numbers of poles. As a final exercise, construct an ideal low-pass filter based on FFTs. Calculate the FFT of an acquired input signal. Set the amplitudes above a certain cutoff frequency to zero. Then calculate the inverse FFT to produce the output signal. Evaluate it in your report using similar criteria to those used above.

Revised October, 2004. Copyright 2000-2004 The Board of Trustees of the University of Illinois. All rights reserved.

Das könnte Ihnen auch gefallen