Skip to content

Signals & Wireless (RF)

How to convert a square wave to a sine wave

A square wave is secretly a sum of sine waves: one at its own frequency, the fundamental, plus odd harmonics at three, five, seven times the frequency, each smaller than the last. To turn a square into a sine, filter the harmonics out. A coil and capacitor in series, tuned to the fundamental, pass it whole and block the rest.

What's inside a square

Joseph Fourier showed in 1822 that any repeating wave is a sum of sines. For a square of height 1:

square = (4 ÷ π) × (sin x + sin 3x ÷ 3 + sin 5x ÷ 5 + …)

So a 10 kHz square holds:

HarmonicFrequencySize
1st, the fundamental10 kHz100 %
3rd30 kHz33 %
5th50 kHz20 %
7th70 kHz14 %

There's nothing at 20 or 40 kHz: a symmetric square has no even harmonics.

Tune an LC to the fundamental

A series LC is a short at its resonance and a growing wall either side of it:

C = 1 ÷ (4π² × f² × L)

For 10 kHz with a 10 mH coil, C = 25.3 nF. At 30 kHz the same coil is 1.9 kΩ and the capacitor 210 Ω, leaving about 1.7 kΩ in the way of a 50 Ω load: the third harmonic is cut to 3 % of what was sent. The fifth is cut to under 2 %.

A clean sine

Combine the two. The third harmonic started at a third of the fundamental and keeps 3 % of that, so it ends up at about 1 % of the output. The fifth ends near 0.3 %. A square goes in; a sine you'd be hard pressed to fault on a scope comes out.

Live experiment

Filter the harmonics out

A 10 kHz square wave goes through a 10 mH coil and a capacitor in series into a 50 Ω load. Bars show each harmonic, sent and received. Pick C1: 25.3 nF passes 10 kHz whole and cuts 30 kHz to 3 %, a clean sine; 100 nF tunes to 5 kHz; 2.81 nF picks out the third harmonic.

Try it yourself: free lesson

“Square to sine” is lesson 5 of 6 in Oscillator Outcrop, Signals & Wireless (RF) World 2. Free with an account. Lessons unlock in order, so you’ll do the 11 before it first.

Pick the wrong capacitor

With 100 nF the LC resonates at 5 kHz, below every component of the square, and even the fundamental is cut to 11 %. With 2.81 nF it resonates at 30 kHz and picks out the third harmonic instead: a smaller sine at three times the frequency. Radio designers use exactly that trick to multiply a frequency.

Why bother

A transmitter fed a square wave would broadcast on its harmonics too, landing on other people's frequencies, so the law requires them filtered. Audio test oscillators, inverters that power mains appliances, and sensors that need a clean drive signal all shape squares into sines this way, or with active filters when coils would be too big.

Free lesson

Now build it yourself

Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.

Try it yourself: free lesson

“Square to sine” is lesson 5 of 6 in Oscillator Outcrop, Signals & Wireless (RF) World 2. Free with an account. Lessons unlock in order, so you’ll do the 11 before it first.

Or start from the very first lesson, no account needed

Practice questions

Three quick questions from the lessons. Pick an answer to check it.

  1. Question 1 of 3A square wave at 10 kHz contains sines at…
    Show the answer

    Answer: 10, 30, 50, 70 kHz and on, each smaller. The odd harmonics, at a third, a fifth, a seventh of the fundamental's size. No even ones for a symmetric square.

    • Why not “Every frequency equally”? Its content sits only at odd multiples of 10 kHz, and each is smaller: a third, a fifth, a seventh.
    • Why not “10, 20, 30, 40 kHz”? A symmetric square has no even harmonics, so 20 and 40 kHz are missing.
    • Why not “10 kHz only”? Only a sine has a single frequency. A square's sharp corners need extra sines at odd multiples.
  2. Question 2 of 3C1 is 2.81 nF, tuning the LC to 30 kHz. What comes out?
    Show the answer

    Answer: A sine at 30 kHz: the third harmonic passes and the fundamental is cut to 1 %. The band-pass keeps whatever it's tuned to. At 30 kHz that's the square's third harmonic, a third of its size, so a smaller sine three times too high comes out.

    • Why not “A sine at 10 kHz”? The band-pass passes what it's tuned to. At 30 kHz tuning, the 10 kHz fundamental is far off resonance and cut to about 1 %.
    • Why not “The square, unchanged”? A narrow band-pass can't keep a square's corners: it passes one harmonic and cuts the rest.
    • Why not “Nothing at all”? The square really contains a 30 kHz harmonic, a third of the fundamental's size, and that passes.
  3. Question 3 of 3The capacitor is put across the load instead of in series with the coil. The circuit becomes…
    Show the answer

    Answer: A low-pass that cuts the fundamental too. Coil in series and capacitor across the load is Carrier Cove's harmonic low-pass, but 10 mH in front of 50 Ω puts its corner below 1 kHz: the fundamental is cut to under a tenth.

    • Why not “An open circuit”? The coil still connects the source to the load, so signal gets through, just filtered.
    • Why not “The same band-pass”? Moving the capacitor across the load changes the filter type. Only both parts in series make the band-pass.
    • Why not “A high-pass”? A series coil with a capacitor across the load blocks high frequencies, so it's a low-pass, not a high-pass.
Keep practising: free lesson

“Square to sine” is lesson 5 of 6 in Oscillator Outcrop, Signals & Wireless (RF) World 2. Free with an account. Lessons unlock in order, so you’ll do the 11 before it first.

Questions people ask

What harmonics does a square wave contain?

A symmetric square wave, high and low for equal times, contains only odd harmonics: 3, 5, 7 times its frequency and on, with sizes a third, a fifth and a seventh of the fundamental. A square that isn't 50 % duty has even harmonics too.

Can an RC filter turn a square wave into a sine wave?

Roughly. A single RC with its corner at the fundamental leaves the third harmonic at about 15 % of the fundamental, so the result is a rounded wave, not a clean sine. Several RC stages in a row, or an LC filter, do much better.

How big is the sine inside a square wave?

The fundamental's peak is 4 ÷ π, about 1.27, times the square's peak. A square swinging ±1 V contains a 1.27 V-peak sine, bigger than the square itself, with the harmonics cutting its peaks back down.

Every topic