Tools › Electrical and Controls › Signal Processing › Signal Analysis (FFT and PSD) › Example

Square wave: odd harmonics falling as 1/n, read exactly with the rectangular window

ToolSignal Analysis (FFT and PSD)
SourceOriginal case (a ±1 V square wave of ten whole cycles in 1,000 samples), checked against the closed form of the sampled square wave, (4 / N) / sin(π n / 100) with N = 100 samples per cycle, and against numpy.fft in test_signal_analysis.php.
LevelUndergraduate

Problem

A 10 Hz square wave between +1 V and −1 V is sampled 1,000 times a second for exactly one second. Find the amplitudes of its harmonics and compare them with the Fourier series 4 / (π n) for odd n.

Inputs to Enter

  • 1,000 values in V (500 samples at +1 and 500 at −1 in each of ten cycles of 100 samples), sample rate 1,000 Hz
  • Window rectangular; show the amplitude spectrum
Open the Signal Analysis (FFT and PSD) tool

Answers

  • Resolution Δf = 1,000 / 1,000 = 1 Hz: every harmonic falls exactly on a line, so nothing leaks
  • Harmonics 1, 3, 5, 7, 9 at 10, 30, 50, 70, 90 Hz: 1.2734, 0.4250, 0.2557, 0.1834, 0.1434 V
  • Fourier series 4 / (π n): 1.2732, 0.4244, 0.2546, 0.1819, 0.1415 V; the sampled wave reads slightly high because 100 samples per cycle fold the highest harmonics back
  • Even harmonics (20, 40, 60 Hz) are zero
  • rms = 1 V, crest factor 1, kurtosis 1; the rms recovered from the spectrum is 1.0000 V (Parseval's check is exact with the rectangular window)

Notes

Open this case in the tool: /analysis-tools/electrical/signals/signal-analysis/?try=square-wave. With a whole number of cycles in the record the rectangular window is the right one; a Hann window would spread each harmonic over three lines.

More Examples for This Tool