ELEC 320, Fall 2006
Profs. Wismer & Kozick

## Laboratory 6 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, before leaving lab today, you must demonstrate to the lab instructor that you can use the FFT on the oscilloscope and perform A/D and D/A conversion.

### 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.

We can display the sine wave in the "frequency domain" using the FFT function on the oscilloscope. Instructions will be provided in lab. Familiarize yourself with the various items that can be specified for the FFT display, such as the scaling of the horizontal axis (frequency), and the format of the vertical axis (linear or logarithmic = dB). For the WINDOW option, please choose "Hanning." 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.

Please do the following exercises.

• Understand the effects of each setting in the FFT menu. See what happens if you change these settings to other values.
• Check that the "spike" in the FFT display occurs at the proper frequency, and compare the amplitude of the spike with the amplitude on the function generator (be careful with peak-to-peak and rms!). Measure the sine wave amplitude using both the linear and dB scales in the FFT.
• 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).
• 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 in class? What are the approximate amplitudes of the various sine wave components?
• Verify that the amplitudes of the harmonics for the square wave decay at (1/n), where n is the harmonic number. We will derive this relationship in class next week.
• 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.

 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 (some of the other EE labs have similar cards). We 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