ELEC 320, Fall 2004
Prof. Rich Kozick

## Laboratory 5 Using the FFT on the Oscilloscopes, A/D and D/A Procedures, and Design Project

One objective in this lab is to learn how to use the Fast Fourier Transform (FFT) capabilities of the oscilloscope to analyze the frequency content of signals. The other objective is to learn how to use the A/D and D/A capabilities in the labs. Finally, the design project for this course will be introduced.

A formal report is not required for this lab. However, there are some calculations related to FFT measurements that I would like you to submit before you leave lab today. I would expect the calculations to take approximately one page per group.

### 1. Using the FFT on the Oscilloscope

Begin by connecting the function generator to the oscilloscope. Set the function generator to produce a sine wave with amplitude 100 mV and frequency 1 kHz. Display the sine wave on the oscilloscope, and save this "time-domain" view of the signal as setup 1 using the SETUP key on the scope.

Now we can display the sine wave in the "frequency domain" using the FFT as follows. First, press the 1 key and turn the time-domain display of the sine wave OFF. Press the +/- key, then turn FUNCTION 2 to ON, then choose the FFT operation. (Note that the scope will also perform differentiation and integration operations.) Familiarize yourself with the various items that can be specified for the FFT display. Settings that work for the 100 mV, 1 kHz sine wave are as follows: 10 dB Units/div, 10 dBV Reference Level, and on the FFT MENU: Hanning Window, Frequency Span 9.766 kHz (change with Time/Div knob and the knob next to SETUP button), and Move 0 Hz to left. Save this "frequency-domain" view of the signal as setup 2. Now you can view signals in the time-domain by recalling setup 1, and setup 2 will produce a frequency-domain view of the signal.

• Understand the effects of each setting in the FFT menu. See what happens if you change these settings to other values.
• Change the amplitude of the sine wave (try 50 mV and 200 mV). What happens to the FFT display? Does something unusual happen as the sine wave amplitude is increased further?
• Change the frequency of the sine wave (try 500 Hz, 2 kHz, and other values). What happens to the FFT display? Be sure that you can interpret the scale along the horizontal axis (in hertz).
• SUBMIT A SOLUTION FOR THE FOLLOWING:
Determine how to convert the vertical axis of the FFT display to an amplitude in volts. The "Reference Level" of 10dBV is the RMS sine wave amplitude relative to a sine wave with 1 volt RMS amplitude, and this level is at the top of the oscilloscope display.
• Change the function generator to generate a square wave. View the square wave on the scope in both the time-domain (setup 1) and the frequency domain (setup 2). Can you relate the FFT of the square wave to our discussion of the Fourier series? What are the amplitudes of the various sine wave components?
• SUBMIT A SOLUTION FOR THE FOLLOWING:
Verify that the amplitudes of the harmonics for the square wave decay at (1/n), where n is the harmonic number, as we derived in class.
• Look at the FFT for other signal shapes, such as triangle, ramp, noise, and "sinc". What is different about the FFTs of these signals? Can you relate the properties of the FFT to the shape of the signals in the time domain?
• Connect a microphone to the scope, and analyze the frequency content of speech, whistling, music, and any other signals that you would like.
• Use the FFT to determine the frequencies that are used in telephone touch-tones. The touch-tone signals are called dual-tone, multi-frequency (DTMF) signals. Can you see why this name is appropriate? You should be able to verify the following table.
** SKIP THIS ON OCTOBER 18-19 **

 Frequency (Hz) 1209 1336 1477 697 1 2 3 770 4 5 6 852 7 8 9 941 * 0 #

The FFT is an important and useful tool to analyze the frequency content of signals. You should now be able to use the oscilloscope to perform the FFT operation.

Note: The DTMF code is for wireline phones. You may want to test your cell phone to see what tones are used when you dial.

### 2. A/D and D/A Procedures in Dana 307

Analog-to-digital (A/D) and digital-to-analog (D/A) conversion circuits are important in the analysis of signals and systems. The computers in Dana 307 contain Keithley A/D and D/A cards (Dana 303 and CC 4 also have similar cards). I would like you to know how to use these cards with Matlab in case you need them for your design project in this course.

The following procedure is used for the Keithley cards.

1. Use the function generator to apply a sine wave with frequency 1 kHz and amplitude 3 V to channel 1 of the A/D card. Input channel 1 is pin 32 (+) and pin 14 (-). This is a differential input, so pin 17 (ground) should be connected to pin 14. The card has a total of 8 input channels, and you can use the other channels for your project.

2. The Matlab commands to access channel 1 of the A/D card are as follows.
>> set(ai,'SampleRate',fs)
>> set(ai,'SamplesPerTrigger',NS)
>> start(ai)
>> data=getdata(ai);
>> point=getsample(ai);
>> stop(ai)
>> delete(ai)
The getsample command will get one sample. The getdata command will get a vector of NS samples. It is usually not necessary to use both commands.

The following Matlab function conveniently combines these commands:

get_sig.m
To run this function, save the get_sig.m file in your folder. Then from the Matlab command window, you can type, for example,
>> x = get_sig(2000, 4000);
This will get 4,000 samples from the A/D card with sampling rate 2,000 samples per second.

3. Collect some samples of the sine wave in Matlab, and produce a plot of the samples versus time, labeled in units of seconds. Make sure your sampling rate is greater than 2,000 samples/sec (why?)! Change the amplitude and frequency of the sine wave, and check the calibration of the A/D card.

4. The Matlab commands to access channel 1 of the D/A card are as follows. Pin 35 is the output from D/A channel 1. You can connect pin 35 to the oscilloscope (and connect ground).
>>ao=analogoutput('keithley')
>>set(ao,'SampleRate',Fs)
>>putsample(ao,level)
>>putdata(ao,data)
>>start(ao)
The putsample command will set the output to a constant value of level volts. The putdata command will output the data vector. It is usually not necessary to use both commands.

5. Generate constant signals with 2.5 V, 5.0 V, and 10 V, and observe them on the oscilloscope. (Use the putsample command.) Also, use the D/A to output the sine wave samples that you obtained from the A/D in step 3. (Use the putdata command.)

You can also use the soundcard on the PC to sample and output signals. These are most convenient for audio signals. You can access the soundcard from Matlab with the commands