Understanding FFTs
and Windowing
Overview
Learn about the time and frequency domain, fast Fourier transforms (FFTs), and
windowing as well as how you can use them to improve your understanding of
a signal. This tutorial is part of the Instrument Fundamentals series.
Contents
ww Understanding the Time Domain, Frequency Domain, and FFT
a. All Signals Are the Sum of Sines
b. Deconstructing Signals Using the FFT
ww Windowing
a. What Is Windowing
b. Windowing Functions
ww Summary
Next
ni.com/instrument-fundamentals
Understanding the Time Domain, Frequency Domain, and FFT
The Fourier transform can be powerful in understanding everyday signals and troubleshooting
errors in signals. Although the Fourier transform is a complicated mathematical function, it
isn’t a complicated concept to understand and relate to your measured signals. Essentially, it
takes a signal and breaks it down into sine waves of different amplitudes and
frequencies. Let’s take a deeper look at what this means and why it is useful.
a. All Signals Are the Sum of Sines
When looking at real-world signals, you usually view them as a voltage changing over time.
This is referred to as the time domain. Fourier’s theorem states that any waveform in the
time domain can be represented by the weighted sum of sines and cosines. For example,
take two sine waves, where one is three times as fast as the other–or the frequency is 1/3
the first signal. When you add them, you can see you get a different signal.
Figure 1. When you add two signals, you get a new signal.
Now imagine if that second wave was also 1/3 the amplitude. This time, just the peaks
are affected.
TOC
Back
Next
ni.com/instrument-fundamentals
2
Understanding FFTs and Windowing
Figure 2. Adjusting the amplitude when adding signals affects the peaks.
Imagine you added a third signal that was 1/5 the amplitude and frequency of the original
signal. If you continued in this fashion until you hit the noise floor, you might recognize the
resulting waveform.
Figure 3. A square wave is the sum of sines.
TOC
Back
Next
ni.com/instrument-fundamentals
3
Understanding FFTs and Windowing
You have now created a square wave. In this way, all signals in the time domain can be
represented by a series of sines.
Although it is pretty neat that you can construct signals in this fashion, why do you actually
care? Because if you can construct a signal using sines, you can also deconstruct signals into
sines. Once a signal is deconstructed, you can then see and analyze the different frequencies
that are present in the original signal. Take a look at a few examples where being able to
deconstruct a signal has proven useful:
■■
■■
■■
■■
If you deconstruct radio waves, you can choose which particular frequency–or station–you
want to listen to.
If you deconstruct audio waves into different frequencies such as bass and treble, you can
alter the tones or frequencies to boost certain sounds to remove unwanted noise.
If you deconstruct earthquake vibrations of varying speeds and strengths, you can optimize
building designs to avoid the strongest vibrations.
If you deconstruct computer data, you can ignore the least important frequencies and lead
to more compact representations in memory, otherwise known as file compression.
b. Deconstructing Signals Using the FFT
The Fourier transform deconstructs a time domain representation of a signal into the
frequency domain representation. The frequency domain shows the voltages present at
varying frequencies. It is a different way to look at the same signal.
A digitizer samples a waveform and transforms it into discrete values. Because of this
transformation, the Fourier transform will not work on this data. Instead, the discrete Fourier
transform (DFT) is used, which produces as its result the frequency domain components in
discrete values, or bins. The fast Fourier (FFT) is an optimized implementation of a DFT that
takes less computation to perform but essentially just deconstructs a signal.
Take a look at the signal from Figure 1 above. There are two signals at two different
frequencies; in this case, the signal has two spikes in the frequency domain–one at each of
the two frequencies of the sines that composed the signal in the first place.
TOC
Back
Next
ni.com/instrument-fundamentals
4
Understanding FFTs and Windowing
Figure 4. When two sine waves of equal amplitude are added, they result in two
spikes in the frequency domain.
The amplitude of the original signal is represented on the vertical axis. If you look at the
signal from Figure 2 above where there are two different signals at different amplitudes, you
can see that the most prominent spike corresponds to the frequency of the highest voltage
sine signal. Looking at a signal in the time domain, you can get a good idea of the original
signal by knowing at what frequencies the largest voltage signals occur.
Figure 5. The highest spike is the frequency of the largest amplitude.
TOC
Back
Next
ni.com/instrument-fundamentals
5
Understanding FFTs and Windowing
It can also be helpful to look at the shape of the signal in the frequency domain. For instance,
let’s take a look at the square wave in the frequency domain. We created the square wave
using many sine waves at varying frequencies; as such, you would expect many spikes in the
signal in the frequency domain—one for each signal added. If you see a nice ramp in the
frequency domain, you know the original signal was a square wave.
Figure 6. The frequency domain of a sine wave looks like a ramp.
So what does this look like in the real world? Many mixed-signal oscilloscopes (MSO) have an
FFT function. Below, you can see what an FFT of a square wave looks like on a mixed-signal
graph. If you zoom in, you can actually see the individual spikes in the frequency domain.
A
B
Figure 7. The original sine wave and its corresponding FFT are displayed in A, while B is a
zoomed in portion of the FFT where you can see the individual spikes.
TOC
Back
Next
ni.com/instrument-fundamentals
6
Understanding FFTs and Windowing
Looking at signals in the frequency domain can help when validating and troubleshooting
signals. For instance, say you have a circuit that is supposed to output a sine wave. You can
view the output signal on the oscilloscope in the time domain in Figure 8 below. It looks
pretty good!
Figure 8. If these two waves were added, they would look like a perfect sine wave
because they are so similar.
However, when you view the signal in the frequency domain, you expect only one spike
because you are expecting to output a single sine wave at only one frequency. However, you
can see that there is a smaller spike at a higher frequency; this is telling you that the sine
wave isn’t as good as you thought. You can work with the circuit to eliminate the cause of the
noise added at that particular frequency. The frequency domain is great at showing if a clean
signal in the time domain actually contains cross talk, noise, or jitter.
Figure 9. Looking at the seemingly perfect sine wave from Figure 8, you can see
here that there is actually a glitch.
TOC
Back
Next
ni.com/instrument-fundamentals
7
Understanding FFTs and Windowing
Windowing
Although performing an FFT on a signal can provide great insight, it is important to know the
limitations of the FFT and how to improve the signal clarity using windowing.
a. What Is Windowing
When you use the FFT to measure the frequency component of a signal, you are basing the
analysis on a finite set of data. The actual FFT transform assumes that it is a finite data set, a
continuous spectrum that is one period of a periodic signal. For the FFT, both the time domain
and the frequency domain are circular topologies, so the two endpoints of the time waveform
are interpreted as though they were connected together. When the measured signal is periodic
and an integer number of periods fill the acquisition time interval, the FFT turns out fine as it
matches this assumption.
A
B
Figure 10. Measuring an integer number of periods (A) gives an ideal FFT (B).
TOC
Back
Next
ni.com/instrument-fundamentals
8
Understanding FFTs and Windowing