MIE 402: WORKSHOP ON DATA ACQUISITION AND SIGNAL PROCESSING Spring 2003 OBJECTIVE To become familiar with state-of-the-art digital data acquisition hardware and software. To explore common data acquisition pitfalls and possible remedies. BACKGROUND REQUIRED Theory related to data acquisition, signal sampling, and spectral analysis (Chapters 4-5) Understand the range and measurement precision of the I/O board to be used for the lab. EQUIPMENT PC National Instrument data acquisition (I/O) board Lab View 4.1 data acquisition/analysis software Function generator Noise generator Frequency counter Digital oscilloscope Bring in your text book! PRE-LAB ASSIGNMENT Review textbook Chapters 4-5 DESCRIPTION The data acquisition system being used consists of three main components - computer, I/O board, and supporting peripherals: The I/O board accepts up to eight analog input signals, multiplexes them to one A/D converter which converts each signal level (voltage) to a number the computer can read; The computer does the actual number crunching and then displays the results; The software controls the number crunching and associated display options (via user selectable parameters). While digital signal capture and processing offers significant advantages over conventional analog techniques, the method is not without potential pitfalls and limitations. To use digital signal processing (DSP) instrumentation and analysis techniques to full advantage, it is mandatory that these limitations be clearly understood 1. 1 Note that although we use the term FFT, DSP hardware actually performs DFT (Discrete Fourier Transform)! Y. Chait 1 Spring 2003
PROCEDURE Setup the equipment as shown in Figure 1 below. Set the function generator to produce a sin(20πt) signal and no DC offset. Use 100 ms/div and 0.5 volts/div settings for the oscilloscope. Figure 1. Setup of the data acquisition hardware Start the Lab View program. In this lab, we will work with *.vi (virtual instrument) files which have been pre-programmed to do the required tasks. Open the file scope.vi (in the sub-directory \labview\mie402). This file simulates a physical oscilloscope. Familiarize yourself with the various options. Data Acquisition. Note the scope-like parameters on the scope.vi as shown in Figure 2, such as the channel and trigger settings. These, and other vi parameters can be modified via doubleclicking of the mouse on the number in the window of interest, typing over a new number and then Enter. For example, to change the scale of the signal graph, double click on the max. or min. values on the axis, and type in the desired new values. The sampling options on the vi are: Number of Samples, Sample Rate (Hz) and A/D Range (high and low limits with ±10 volts implying 1:1 scaling. Figure 2. User interface of the virtual instrument Y. Chait 2 Spring 2003
Using a Sample Rate of 500 Hz, select the correct number of samples to produce the same picture seen on the oscilloscope (to initiate data acquisition, use the run icon on the upper left corner of the control bar). If you do not get a trigger (timeout button becomes red), play with the hysteresis level until you get one. Note that the vi screen refreshing is occurring much slower than on the oscilloscope, and that triggering is not as accurate as on a properly adjusted oscilloscope. To freeze the view, use the stop button, or run the vi in the single sweep mode. If you get the same figure, familiarize yourself with the zoom options (cursor driven or re-defining axis min/max values). Print the screen by going to File\Print Window. Aliasing. Reduce the sampling rate to 27 Hz (modify number of samples to maintain the same period of data acquisition, T= (N-1)/f s )). What happened to the image appearing on the vi display? Has the same happened in the oscilloscope display? Further reduce the sampling rate to 12 Hz while maintaining the same data acquisition period) and observe the result. Freeze the plot. Note that the picture you are seeing is the sampled points connected via lines. To illustrate that click on the plot 0 option (top right-hand side menu), point to style, and then select one of the point styles other than none. Now select a sampling rate of 10 Hz (maintain same period of data acquisition) and slightly increase or decrease the signal frequency using the dial on the function generator. Note what happens to the sampled signal (almost looks like a DC signal?). Based on the present A/D settings and the vi display, write down your prediction for the frequency of the displayed sampled signal for all the above signals. Again, freeze the plot. This and the previous are examples of what is called aliasing. It occurs here because the sample rate is less than the Nyquist rate or Shannon requirement and approximately equal to the frequency of the wave we are viewing. Obviously, aliasing errors can cause very serious problems. To avoid aliasing errors you should always: Compare the displayed sampled signal against that shown on the oscilloscope. Trust the oscilloscope (what would be the reason for this statement?). Use a sampling rate 10 times the highest frequency contained in the signal (not the highest frequency that you are interested in!). The theoretical Nyquist sampling rate is two times as fast as the highest frequency, but to be safe use 10 times as fast (which is common practice). Some data acquisition packages provide operator selectable low pass analog filtering at the input amplifier to eliminate unwanted high frequency components. However, our hardware does not have this option. Note also that any such filtering must be analog filtering, digital filtering will not solve the aliasing problem. Y. Chait 3 Spring 2003
Amplitude Ambiguity. Change the generator's frequency to 100 Hz. Set the oscilloscope sweep rate to 2.5 ms/div to display >2 cycles. Using 11 samples, select the sampling frequency to match the oscilloscope 's 25 ms total period. What do you see? The software connects data points with straight lines, and there are not enough points in the period to produce smooth curve. This is a resolution error in the horizontal (time) direction. Print the (zoomed) screen. Now increase the sampling rate to 4,000 Hz (and modify the number of samples to maintain the same total period). Is the picture looking any better? Why? Resolution Error. Now change the output of the function generator to 20dB (this causes the output to decrease by a factor of 10) by pulling out the AMPL knob. Also push the ATT 20dB button for additional attenuation. Reduce the signal amplitude to 20 mv. Increase the sampling frequency to 40 khz and take sufficient data to capture 2 periods. Note what happens to the signal on the oscilloscope screen (make sure you change the scope s sensitivity to see the signal). Do the same to the displayed sampled signal using the zoom options. Note that the waveform displayed is no longer smooth. In this case, the vertical axis has poor resolution, resulting in a staircase effect at the peaks of the wave. Print the (zoomed) screen. Although the zoom factor helps view the signal, it does nothing to improve the actual resolution of the sampled signal. This resolution is fixed by the input limits setting of the 12 bit A/D converter. The zoom setting just expands the vertical axis of the display, somewhat like putting a magnifying glass in front of the scope screen. Estimate the resolution (i.e. the height of a stair in the "staircase") and compare it to the theoretical value (see attachment). Now enter the appropriate A/D range, based on the oscilloscope, and note that the sampled signal display appears to be smooth. What is the theoretical resolution for this configuration? (hint: use Table 3.2 at the end of this handout). Finally, modify A/D limits to minimize this error. Analysis of Data. Now open the file analysis.vi. This program will compute and display the spectrum, RMS and mean of the sampled signal. Set the function generator to produce a 100 Hz sinusoid with a DC component (don t forget to switch off the two 20dB setting!) v(t) = 2 + 2sin(200πt) Run the analysis.vi program with appropriate settings for sample rate, number of samples, and A/D range. Do you agree with the computed mean and RMS values? Back up your answer with appropriate calculations. Y. Chait 4 Spring 2003
FFT Analysis. Remove the DC offset from the generator's output. Reproduce the three time and amplitude spectra as shown in the class handout (Figure 7.4), print all relevant screens. Note that the software FFT s frequency resolution is δf = 1 N' δt where N = 2 x, with the integer x chosen so that N N (e.g., if N = 100, x = 6 yielding N' = 64). Do you see any leakage effects? Noise Filtering Demo. To illustrate the effectiveness of FFT in identifying important signals imbedded in noise, let us now produce a noise-added sinusoid. Adjust the noise amplitude to approximately 0.5 volts, then add a 0.05sin(200πt) sinusoid signal by connecting the output of the function generator to the input of the noise generator, which is already connected for this lab. Note that the noise generator needs an external ±15V power supply (series mode on the dual power supply). Also note that the knob on the noise generator is a 15-turn potentiometer that needs to be turned quite a number of times before seeing appreciable changes of the noise voltage amplitude. Then connect noise+input of the noise generator to the A/D channel 0, as well as to the oscilloscope. Can you distinguish this sinusoid from the combined signal (when viewed by the oscilloscope or scope.vi)? Now run an FFT on the combined signal session (with an appropriate sampling settings). Explain the picture. Next, filter the noise with an RC low pass filter (R = 10 kω and C = 0.1 µf). Do you see any difference in the signal and its spectrum? Y. Chait 5 Spring 2003
Y. Chait 6 Spring 2003