A8 · Lesson 31 · Periodic inputs and Fourier series
A square wave is a sum of sines, and a linear circuit answers each one separately
Lesson 30's phasors answer a single sine. Real drives are rarely single sines: a microcontroller's PWM output is a square wave, a rectifier delivers half-sine humps, a switching converter's node is a trapezoid. Each of these repeats, and every repeating waveform is a sum of sines at multiples of its frequency, its Fourier series. Because the circuit's equation is linear, the response to the sum is the sum of the responses, each harmonic multiplied by the circuit's gain at its own frequency. That's how a low-pass smooths a PWM signal, and how a tuned circuit can pull a pure sine out of a square wave.
- A ±1 V, 1 kHz square wave (time in milliseconds) drives an RC low-pass with its corner at kHz. The curve is the steady-state output built from the odd harmonics up to (at most 15), each through the filter's gain at its frequency.
- With a few harmonics the output already looks right; the corner frequency decides how much of the square's sharp edges survive.
Predict
A ±1 V, 1 kHz square wave drives a series RLC tuned to 3 kHz with a high Q, and you look at the voltage across the resistor. What comes out?
Mostly a 3 kHz sine. A square wave contains every odd harmonic: 1, 3, 5 kHz and up, with amplitudes volts. The tuned circuit passes the one at its resonance, 3 kHz with amplitude = 0.42 V, and strongly rejects the others. That's how frequency multipliers and harmonic-tuned oscillators pick a harmonic out of a distorted wave.
Name it
Fourier series
A waveform that repeats every seconds, with , can be written
Three to know:
| Waveform | Harmonics |
|---|---|
| Square wave, | odd only, |
| Triangle wave, | odd only, amplitude |
| Sawtooth, | every , amplitude |
A jump in the waveform makes the harmonics fall as ; a kink with no jump makes them fall as . Smoother waveforms have weaker high harmonics.
The response, harmonic by harmonic
For a linear circuit with frequency response , each harmonic comes out multiplied by and shifted by :
That's the steady state, after the starting transient (lesson 14) has died away.
Power and RMS
Harmonics at different frequencies don't interfere on average, so their powers add (Parseval):
The total harmonic distortion compares everything but the fundamental with the fundamental: .
Worked example
A ±1 V, 1 kHz square wave drives an RC low-pass whose corner is also 1 kHz. Find the output's first three harmonics.
Show the solution
- Gain at each harmonic. The filter's gain at harmonic is , since .
- Scale each input harmonic. The square wave's harmonic has amplitude :
| In: | Gain | Out | |
|---|---|---|---|
| 1 | 1.273 V | 0.707 | 0.900 V |
| 3 | 0.424 V | 0.316 | 0.134 V |
| 5 | 0.255 V | 0.196 | 0.050 V |
- How the harmonics fall. The output harmonics now fall as , like a triangle's: the filter has rounded the square's corners into exponential ramps.
- The full waveform. Adding up enough harmonics reproduces the exact steady state, a pair of exponential segments with peak-to-peak = 1.834 V.
Answer the first three output harmonics are 0.900 V at 1 kHz, 0.134 V at 3 kHz and 0.050 V at 5 kHz.
Worked example
The same square wave drives a series RLC bandpass at 3 kHz with = 10 (output across the resistor). Find the output's harmonics and its THD.
Show the solution
- The bandpass gain. A series RLC's gain at frequency is
- Apply it to each harmonic. With = 3 kHz and = 10:
| Gain | Out | |
|---|---|---|
| 1 | 0.0375 | 0.048 V |
| 3 | 1 | 0.424 V |
| 5 | 0.093 | 0.024 V |
| 7 | 0.052 | 0.010 V |
- The result. The output is a 0.424 V, 3 kHz sine with a THD of 12.9%, almost all of it from the leftover fundamental.
- Why the fundamental leaks through. A higher Q would clean it further; with = 10 the fundamental is only rejected by a factor of 27, because 1 kHz is just a factor of 3 below resonance.
Answer the output is mostly a 0.424 V, 3 kHz sine, with 0.048 V at 1 kHz, 0.024 V at 5 kHz and 0.010 V at 7 kHz, for a THD of 12.9%.
Worked example
Check the low-pass result without harmonics: what is the exact steady-state peak-to-peak output of the RC low-pass ( = 0.159 ms) driven by the ±1 V, 1 kHz square wave?
Show the solution
- The steady-state cycle. In the steady state the capacitor charges toward +1 V for half a period, then toward −1 V for the other half, ending each half where it started the previous one with the sign flipped.
- Write the first half. With swing ,
- Solve for .
- Put in the numbers. With , and the peak-to-peak is 1.834 V.
- Compare with the Fourier sum. Summing the Fourier series with a thousand harmonics gives the same 1.834 V, so the two methods agree. The Fourier view explains which frequencies remain; the time-domain view gives the waveform directly.
Answer the output swings 1.834 V peak to peak, between −0.917 V and +0.917 V.
Check
What is the amplitude of harmonic 3 of a square wave that switches between +2.5 and −2.5 V?
Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.
Check
A ±1 V square wave at frequency drives an RC low-pass whose corner is . What is the amplitude of harmonic 3 at the output?
Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.
Check
A ±1 V square wave at drives a series RLC bandpass tuned to harmonic 3 () with = 10.
(a)
What is the bandpass's gain at the fundamental?
(b)
What is the output's amplitude at harmonic 3?
Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.
Check
A ±A V, 1 kHz square wave drives an RC low-pass with corner fc = 1 kHz. Build its steady-state output from the odd harmonics , each through the filter's complex gain , at 4000 times across one period. Set pp_fourier to the peak-to-peak of the sum and pp_exact to with .
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
A ±1 V square wave drives a series RLC bandpass tuned to harmonic m = 3 with Q = 10. Set amps to a list of the output amplitudes of harmonics 1, 3, 5, …, 99, and thd to the output's total harmonic distortion relative to harmonic m.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Which waveform's harmonics fall off fastest with ?
Check
Find the coefficient of for a square wave that is for the first half period and for the second, with .
Step 1
. By the waveform's symmetry this is twice the integral over the first half. What is it?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What does it equal for odd , where ?
Explain why
Why can a circuit's response to a square wave be found one harmonic at a time?
The circuit's differential equation is linear: if gives and gives , then gives . A square wave is a sum of sines, its Fourier series, so the response is the sum of the responses to each sine. Each of those is a steady-state sine at the same frequency, found with phasors by multiplying by . The method fails only when the circuit isn't linear, for instance a diode or a saturating amplifier, which creates new frequencies instead of just reweighting the old ones.
Practice
Keep practicing
7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.