Determining
the Frequency Components in a Square Wave Signal + Sine and Triangle
In this laboratory you will determine the frequency components in a square
wave signal. You need to do the following.
Getting
Started
-
Connect a function generator
to the HP5460X oscilloscope.
-
Set the function generator
initially, to produce a sine wave.
-
Set the function generator
to a frequency between 1 KHz and 1.5 KHz.
-
Get exactly one cycle
of the sine - or as close as you can get to that.
-
Set the 1 KHz signal to
5 v amplitude. That would mean the sincewave reaches +5 volts on
the positive part of the signal, and -5 volts on the negative part of the
signal.
-
Next, you need to "acquire"
the data. You do that by running a program that transfers the data
from the oscilloscope (the data on the screen) to the computer. Actually,
you want the data to be put into a data file. Do that using whatever
program is available on the computer you are using.
-
Check that the file is
OK by importing it into Excel and graphing the data. In Excel you
will see that there is some header information as well. Strip off
the header information in Excel by removing those rows and save the data
as a *.txt file with another name.
-
Import the data from the
file into Matlab. Use dlmread.
Assuming that the file you put the data into is called "Signal1.txt", you
would use the following code.
-
FileData = dlmread('Signal1.txt','\t');
-
Compute the FFT of the
data using the FFT function in Matlab. (It is also in Mathcad.)
-
SigFFT = fft(FileData);
-
plot(abs(SigFFT))
-
Plot the absolute value
(a complex function!) of the FFT array.
-
From the plot you can
determine where the harmonics are in the signal, and the magnitude of those
harmonics. You will need to read the note at
this link.
-
Applying the algorithm
in the note linked in the previous step, determine the fundamental frequency
of the sinusoidal signal you used. That result should be close to
the frequency of the sinusoidal signal you used.
-
Then, you need to check
the amplitude of the signal. The FFT algorithm computes two parts
(a real and a complex). Treating that as a complex number, the amplitude
should be the magnitude of the complex number (an + jbn)
at the frequency found in the previous step.
Getting
the Data you need.
-
Using the process above,
get the following data sets. Get data in a format readable in Excel,
but you should also probably get data in "picture" format. Be sure
to save each data set using a name that is descriptive. If you don't
do that, there is a good chance that you will write a new data file over
one you wanted to keep.
-
Use a signal with 5v amplitude
in each case.
-
Use a signal around 1
KHz. to start and increase the frequency to:
-
Get square wave data with
1 cycle, 2 cycles and 2.5 cycles on the screen.
-
Get triangle wave data
with 1 cycle, 2 cycles and 2.5 cycles on the screen.
-
Get sine wave data with
1 cycle, 2 cycles and 2.5 cycles on the screen.
-
Using the FFT algorithm,
plot the spectrum for all nine signals above.
-
Determine the frequency
components for every signal.
-
Determine whether the
frequency components were what you expected, and explain any discrepancies.