LAB #7: Digital Signal Processing Equipment: Pentium PC with NI PCI-MIO-16E-4 data-acquisition board NI BNC 2120 Accessory Box VirtualBench Instrument Library version 2.6 Function Generator (Tektronix CFG250) Reference: PCI-MIO-16E-4 product information from National Instruments website (www.ni.com). Objectives: The objectives of this experiment are: 1. To introduce you to several fundamental concepts in digital signal processing: periodic signals, Fourier Transform, time domain, frequency domain, spectrum, sampling frequency, leakage and aliasing. 2. To introduce you to the Dynamic Signal Analyzer virtual instrument VI (also called a Digital Spectrum Analyzer). We have discussed the idea of periodic and transient signals and Fourier analysis (both Fourier series representation and Fourier transforms). We have also discussed issues related to sampling: number of samples, rate of sampling, and aliasing. The Virtual Bench Dynamic Signal Analyzer provides the tools necessary to explore digital signal processing: it can acquire an analog voltage signal and display the amplitude of the signal as a function of time. The sampling rate and the number of samples can be set. More importantly, it can perform the Fast Fourier Transform (FFT) on the signal, transforming the signal from the time domain to the frequency domain. Now is the time to use the VB- DSA to play with these ideas. Dynamic Signal Analyzer The front panel of the DSA looks similar to the VB-Virtual Oscilloscope. The Online Help is quite useful if you run into problems. Input Settings, Frequency Settings and Markers can be found under the Edit menu. Display two graphs; on both of these, select channel 0. On the top graph, display the Time Waveform and on the bottom graph display the Amplitude Spectrum. For Display 1 set it to display the real part. Input Settings: Ch 0, DC coupled, no averaging, window -- none, analog trigger, level = 0, trigger channel A Frequency Settings: Baseband Span: f bs = 40000 Hz This is the frequency bandwidth, i.e. the highest frequency that will be displayed. It is roughly 2.5 times smaller than the sampling frequency (in this case f s =102.4 khz). If you change f bs this also changes your sampling frequency. 1
Number of lines: 400 This is the number of discrete frequencies that you can resolve. It is approximately N/2.5, where N=1024 is the block size (number of samples). If you don t see 400 as a choice then change the alias free range to classic. Q: What is the sampling time interval t = 1/f s? Q: What is the sampling time period T = N t? Q: What is the frequency resolution f = f s /N = 2.5 f bs /N? Markers: top graph on Dual, bottom graph on Harmonic (this should be changed on the display-menu not from the top-menu). Run the VB-DSA. Connect a BNC-BNC cable between the Function Generator and Ch 0 input of the BNC-2120 accessory box. Set the function generator to supply a sinusoidal output of amplitude 2 V peak-peak and frequency ~100 Hz. You should see the time signal of the sine wave on the top graph and the amplitude spectrum in the bottom graph. Now vary the frequency of the input signal and use the cursor to verify that the DSA is giving you approximately the correct frequency. You can change the baseband span by clicking on the x-axis label at the lower right corner of the spectrum. Changing this changes the frequency resolution of the spectrum. Play around with these settings some to see what happens. 1 Pure Sine-Wave Input: Leakage The objective of this section is to illustrate the fact that spectrum analyzers treat input signals as periodic signals. You will compare the spectrum of a sine wave that exactly fits in the time window with a signal that does not. A signal that is periodic in the sampling window is shown below (left), where one cycle of the wave fits exactly within the sampling time period T. This is to be contrasted with the waveform at right that does not exactly fit the time window. When you compare the spectra of these two waveforms, you will see the effects of leakage for the case where the signal is not periodic in the sampling window. Periodic in sampling window Not periodic in sampling window V(t) T V(t) T t t 2
1.1. Spectrum of a Signal that is Periodic in the Window 1.1.1 Set the frequency back to 100 Hz (as close as possible), and set the amplitude knob fully clockwise (i.e., so the output sine wave will be approximately 2 V peak-topeak). Set the baseband span back to 40 khz. 1.1.2 Try to get one complete period of the 100-Hz sine wave displayed on Display 1. If the period of the wave does not appear to exactly correspond to the 0.01-sec time window (i.e., sampling period of 0.01 sec), adjust the function generator until the sine wave has the correct 0.01 sec period. If the sine wave appears to have some DC bias (i.e., the sine wave is not centered vertically about 0 V), try to adjust the function generator s DC bias knob (pull knob and then turn) until the sine wave does appear to be centered vertically on the graph. 1.1.3 When you have a good 100-Hz input signal, turn your attention to the spectrum of the signal, which is displayed on Display 2. Your display should look like the figure shown. If your graphs are correct, SAVE both displays to a file. (Be sure the spectrum is on the Linear magnitude setting.) 3
1.2 Spectrum of a Sine Wave that is not Periodic in the Window 1.2.1 Now dial the frequency back-and-forth from 100 Hz to about 200 Hz and note what happens to the spectrum. Now, change the frequency of the input signal to 150 Hz so that 1.5 periods of this 150-Hz sine wave are displayed on Display 1 (adjust the function generator until this is the case). If necessary, adjust the DC bias until the 150- Hz signal is centered vertically. If your graphs are correct, save both displays to a file. (Ask you lab instructor to look at the graphs if you re not sure that they are correct.) 2 Square and Sawtooth Waves 2.1.1 Switch the function generator from sine-wave generation to square-wave generation, keeping the frequency at 100 Hz. Change the baseband span (by clicking on the x-axis label at the lower right) to 2 khz. This gives you improved frequency resolution. Your screen should look something like that below. Q: What is your frequency resolution now? (recall f = 2.5 f bs /N) For your lab report you will want to determine the values of the peaks and of the corresponding frequencies at which the peaks occur. These will be used to compare with theoretical Fourier series components of an ideal square wave. SAVE both displays to a file. 4
2.1.2 Repeat section 2.1.1 for a saw-tooth wave at 100 Hz. 3 Sampling; Aliasing; Nyquist Sampling Theorem The objective of this section is to illustrate the fact that digital oscilloscopes, digital spectrum analyzers, and similar instruments all sample continuous input signals at discrete times and store only limited quantities of the digitized data. The following digital signal analysis concepts are illustrated by the experiments in this section: sampling frequency, aliasing, and Nyquist sampling frequency. 3.1. Effect of Sampling Frequency on Input Signals 3.1.1 Reset the baseband span to 40 khz. Now you are going to supply input signals of progressively increasing frequency. 3.1.2 Go to the Input Settings under the Edit menu and set the Trigger to NONE. 3.1.3 Press the 100 khz button on the function generator. Starting with the dial fully clockwise, gradually increase the frequency from effectively zero to above 100 khz. 3.1.4 As you increase the frequency you should notice two things: first, as the frequency is increased, errors in the time domain signal become evident. Second, as the frequency increases, the spectrum becomes broader and some false peaks appear. The false peaks are called aliased frequencies and occur when the input frequency is larger than the Nyquist frequency (f nyq =f s /2). Save waveforms (both time and frequency domain) for frequencies below and above f nyq. For example, you can save files for input frequencies of 20 khz and 100 khz. 5