Turn a square wave into a sine

Design · 12 min

Plenty of circuits make square waves easily (a microcontroller's pin, a 555 timer) but you want a sine: for a test tone, or to drive a speaker without a buzz. The trick: take a square wave and filter off its harmonics, keeping only the fundamental.

The generator makes a 1 kHz square. The specification: at the output, the third harmonic at least 30 dB below the fundamental. The scope's spectrum shows channel 2, on column 6.

First, a single RC low-pass with its corner far below 1 kHz. Past the corner it falls 20 dB per decade, so from the fundamental to three times its frequency, another 9.5 dB. The square's third starts 9.5 dB down. Where does it end up?

Answer in dB.

Which of these meets −30 dB?

  • One RC low-pass with its corner at 3 kHz
  • Two RC low-passes in a row (about −28 dB, and less with loading)
  • An LC low-pass with its corner near 1 kHz and a light load, so it peaks at the fundamental

Build it with the 10 mH coil, as in the picture. Choose the capacitor to put the corner near 1 kHz, and a load that leaves it a modest peak:

  • the coil from C3 to C6;
  • the capacitor from D6 to D8, a wire A8 to the − rail;
  • the load from B6 to B9, a wire A9 to the − rail.

Press Run and watch the spectrum and the wave.

Filtering a square into a sine:

  • the harmonics are only 3, 5, 7… times the fundamental: close, so the filter must be steep;
  • a first-order filter gets the third to about −19 dB; a second-order one, with its corner at the fundamental, past −30 dB;
  • what's left over is distortion, often given as a percentage: −30 dB is about 3%.

On a real bench this is how many cheap sine-wave inverters and test oscillators work: a square wave, filtered. Audio-quality sine oscillators instead make a sine directly (a Wien bridge oscillator, in topic 08), and reach well under 0.01%.