Home » Learning Library » From Time to Frequency, the FFT, Interactive

Learning Library · Frequency domain · 2

From time to frequency: the FFT

Any repeating waveform can be built by adding sine waves at whole-number multiples of its frequency. An oscilloscope shows the sum over time. A fast Fourier transform (FFT) takes the sum apart and shows how much of each sine is in it.

Top: the sum of the harmonics (blue) against the target waveform (grey). Bottom: the spectrum, each harmonic's amplitude in dB relative to the fundamental. Bars beyond the slider are greyed out.

Harmonics in the sum
Highest frequency
3rd harmonic
Shape error (RMS)

What the harmonics tell you

WaveformHarmonics presentAmplitude of harmonic n
SquareOdd only: 1, 3, 5, 7…Falls as 1 ÷ n, so the 3rd is −9.5 dB
TriangleOdd onlyFalls as 1 ÷ n², so the 3rd is −19.1 dB
SawtoothAll: 1, 2, 3, 4…Falls as 1 ÷ n, so the 2nd is −6.0 dB

The sharper the corners, the slower the harmonics fall away, and the more bandwidth the waveform needs. A square wave's vertical edges need harmonics far above its fundamental. A triangle has no vertical edges, so its harmonics fade quickly and a few of them already make a close copy.

Try this

  • Start the square wave at one harmonic. It is a pure sine. Add the 3rd and 5th and the corners start to form.
  • Push to the 49th harmonic. The edges sharpen, but an overshoot of about 9 % of the step stays next to each corner however many harmonics you add. That is the Gibbs phenomenon, and it is why band-limited square waves always ring a little.
  • Switch to triangle. By the 5th harmonic the shape error is under 3 %, and by the 11th it is under 1 %. The square wave at the 49th harmonic is still at 9 %.

FFT on an oscilloscope

A scope's FFT works on the captured record. Three settings decide what you see:

  • Frequency span is half the sample rate. Sample faster to see higher frequencies.
  • Frequency resolution is the sample rate divided by the number of FFT points, which is one divided by the record time. Capture longer to separate close frequencies.
  • The window shapes the ends of the record so a signal that does not fit a whole number of cycles does not smear across the spectrum. Hanning is a good general choice. Flat top gives the most accurate amplitudes. Rectangular gives the sharpest peaks but the most smearing.

An FFT is how you find what a time-domain view hides: switching-supply noise at a specific frequency, mains hum and its harmonics on an audio line, or a clock leaking into a sensitive analog circuit. For low-level signals over a wide frequency range, a spectrum analyzer has far more dynamic range.

See both domains on one screen. Oscilloscopes with built-in FFT analysis.

Shop UNI-T oscilloscopes

UNI-T Learning Library. Design. Debug. Deploy.™