1 kHz3 kHz5 kHz7 kHzADD0.00 V1import numpy as np2t = np.arange(1000) * 1e-63w = 2 * np.pi * 10004x = 05for k in range(1, 50, 2):6 x += 4/(np.pi*k)*np.sin(k*w*t)
00.511.52-101t (ms)volts (V)TIME±1 V · T0 = 1 ms1 sine · y(0.25) = 1.27 V2 sines · y(0.25) = 0.85 V4 sines · y(0.25) = 0.92 Vx·sin(3ω0t): mean 0.21225 sines · y(0.25) = 1.01 V25 sines · peak 1.18 V1357911131500.511.5f (kHz)amplitude b_k (V)SPECTRUMb_k = 4/(πk), odd k
Coloured parts: what the current step is about; everything else rests in whiteBlocks: four oscillators (1, 3, 5, 7 kHz) with switches, an adder, a voltmeter and a Python code cardPlots: the time picture (target square and the sum so far) and the line spectrumEach dial's arm turns k times per period; its length is that harmonic's amplitude (slow motion)A 1 kHz square wave of ±1 V is built from sines at 1, 3, 5 and 7 kHz with amplitudes 4/(πk). The oscillators and the adder stand for an additive synthesizer. In a real circuit the adder is a summing amplifier (an op-amp with one resistor per input).

The goal

  1. We want the output to be a square wave: +1 V for half a millisecond, then −1 V, over and over. It repeats every T0 = 1 ms, so its frequency is f0 = 1/T0 = 1 kHz. Can smooth sines make sharp corners?

Adding sines

Finding the amplitudes

Many sines

The working

# step 1/10 · square

target x(t), one period T0 = 1 ms:
  +1 V  for 0   <= t < 0.5 ms
  −1 V  for 0.5 <= t < 1   ms
then it repeats: x(t + T0) = x(t)

f0 = 1 / T0 = 1 / 0.001 s = 1000 Hz = 1 kHz

Fourier's claim: a periodic signal is a sum
of sines at f0, 2·f0, 3·f0 ... (harmonics)

The square wave (±1 V, 1 kHz) is a chosen example. Every amplitude, curve and value in the figure is computed from the coefficient integrals in this model; the closed form b_k = 4/(πk) is used only to check them. The motion is slowed down a great deal: a real 1 kHz oscillator turns its phasor a thousand times a second.