FFT Example - Done Using Mathcad |
An FFT Example - Done Using
Mathcad
In this note we are going
to analyze a triangle signal using the FFT.
Here is the signal.
- The signal has 4000 samples,
and the length of the record is 2 milliseconds. (It goes from -.001 seconds
to +.001 seconds.)
Since the length of the
record is 2 milliseconds, if we compute the FFT for the entire record (which
we would normally do), then the fundamental frequency in the computed
results is going to be 1/.002 = 500 Hz. We will refer to this as the
fundamental frequency of the data record.
- Within the data record is the
triangle signal, and it has a period of 1 millisecond, so it has a frequency
of 1 KHz.
Now, we need to examine what happens
when we FFT this signal. We will use the
Mathcad file this link takes you to. That file assumes that the data file
has two columns (Time in the first column, data in the second column. Now, if
we look at the plot of the absolute value of the SigFFT array, we get a plot
like the one below.
Now, the fundamental
frequency of the data record is 500 Hz. You need to be able to get from that to
the actual frequency components of the signal. Here is what you need to use.
- The fundamental frequency of
the data record is the reciprocal of the length (in seconds) of the data
record. Since the data record is 2 milliseconds long (i.e. .002 sec), the
fundamental frequency of the data record is 500 Hz.
- In Mathcad, the indices start
from zero. So, ao, is going to be placed in SigFFT0
in our workspace above. Here is a short table of frequencies, indices,
etc. In this table, the indices in the FFT array (SigFFT) are the number of
the harmonics of the fundamental frequency of the data arecord.
Harmonic of the
fundamental frequency of the data record |
The actual
frequency |
0
|
0 Hz (DC)
|
1
|
500 Hz
|
2
|
1000 Hz
(1 KHz) |
3
|
1500 Hz
|
4
|
2000 Hz
|
5
|
2500 Hz
|
6
|
3000 Hz
|
Now, we can get at the
frequencies in the FFT plot. Notice the following.
- The first "spike" in the FFT
plot is at SigFFT2. That corresponds to 1000 Hz which is
the fundamental of the signal. It is not the fundamental of the data
record. It is, however, related to the fact that there are exactly two
cycles of the signal in the length of the data record.
- The second "spike" in the FFT
plot is at SigFFT6. That corresponds to 3000 Hz which is
the third harmonic of the signal.
- and so on. . .
With that, you should be able
to interpret the horizontal scale of the FFT plot - at least the plots that
Matlab produces.
Now, we need to address
the vertical scale. First, you should realize that the vertical plot is the
absolute value of the c's in the Fourier expansion. If you need to understand
what the c's are, check these links.
When we did the calculation,
we found that the third element in the SigFFT array (That's the one that is the
first, large value - somewhere over 8000 on the plot!.) has a value of 8,103.
That's not a number that we would expect from a triangle wave that has an
amplitude of 5 volts.
The explantion for the
seemingly ridiculous value of over 8000 is this:
The calculation
includes a 1/N term. That is off by a factor of 2, since you want 2/N.
You have to compensate for that. In a five volt triangle wave with 4000
data points, the first harmonic of the triangle wave should be 8A/(p2)
(where A = 5 for our signal).
- That works out to be
4.053. The value in the Mathcad workspace is - 2.026j. It's
imaginary because it is the coefficient of a sine - returned in the
imaginary part of the FFT. Multiply by 2 and focus on the absolute
value, and we have what we want.
- Here are some links to
pages with the expressions for the Fourier Series of a triangle wave
signal. That's where we got that amplitude for the first harmonic.
- A
page from
Wolfram Research (the folks who make Mathematica). There is a
lot of information on this one web page. You may want to print it
out.
- A
java-based simulator
- A nice
derivation of the coefficients
What do you conclude
from this?
From the material above,
you should be able to determine the actual Fourier Series components if you have
a signal in a file. You should be able to distinguish between the fundamental
frequency of the data record and the fundamental frequency of the signal
embedded in the data record - if that signal is periodic. And, you should be
able to determine the frequencies present in the signal, as well as the
amplitudes.
What if the signal
doesn't have an integral number of periods in the data record?
Here is an example of a
signal with 2.5 periods in the data record. In this signal, we only have 2000
points, so we have to factor that in.
You can see that there is not an
integral number of periods in the data record. Now, let's see what happens when
we FFT this data record. That's shown below.
Generally, this can only be
described as a mess. There are no clear-cut lines in this FFT spectrum.
However, note the following table.
Harmonic of the
fundamental frequency of the data record |
The actual
frequency |
0
|
0 Hz
|
1
|
500 Hz
|
2
|
1000 Hz
(1 KHz) |
3
|
1500 Hz
|
4
|
2000 Hz
|
5
|
2500 Hz
|
6
|
3000 Hz
|
Now, we can get at the
frequencies in the FFT plot. Notice the following.
- The fundamental frequency of
the signal embedded in the data record is 1250 Hz. That is not a frequency
found in the table. Rather, the harmonics of the fundamental frequency of
the data record are 1000 Hz and 1500 Hz, and they appear at harmonics number
2 and number 3.
- The largest spikes appear at
harmonic number 2 and number 3.
All of that is well and good,
but the third harmonic of the embedded signal is at 3750 Hz and that would
appear between harmonics 7 and 8.
|