D2 · Lesson 5 · PWM and filtering
Pulse-width modulation as a way to set an average with on-off switching, the spectrum of a PWM wave (a DC term plus harmonics of the switching frequency), and the RC and LC filters that remove the harmonics and leave the average
Every converter in this course works the same trick: switch fast, then average. Pulse-width modulation makes the trick explicit. A digital pin that is high 40% of the time has an average of 40% of its supply, and a microcontroller can dim an LED, set a motor's speed or make an analog voltage that way, with nothing but a timer. The price is everything other than the average: a train of harmonics at the switching frequency and its multiples, which a filter, or the inertia of a motor or the persistence of an eye, must remove.
- A 12 V PWM wave at 500 Hz with duty cycle D, and its spectrum.
- The DC term is D × 12 V; the rest is harmonics at multiples of 500 Hz, with amplitudes .
- At 50% duty the even harmonics vanish; at small duty the harmonics fall off slowly, because narrow pulses are rich in high frequencies.
Predict
A 3.3 V microcontroller pin runs PWM at 40% duty into an RC filter whose time constant is much longer than the PWM period. What DC voltage comes out?
The filter keeps the average and removes the rest: 0.4 × 3.3 = 1.32 V. With R = 10 kΩ, C = 1 µF and a 1 kHz PWM, the leftover ripple is about = 3.3 × 0.24/10 = 79 mV peak to peak. A longer time constant cuts the ripple but slows the output's response to a change in duty.
Name it
PWM
A pulse train of height V, frequency and duty cycle D has
- a DC term ;
- harmonics at with amplitudes .
Changing D changes the average linearly, which is why PWM is used for dimming, motor speed, heater power and cheap digital-to-analog conversion.
Filtering
A filter with its corner well below passes the DC term (and slow changes of D) and attenuates the harmonics.
- RC (one pole): attenuation grows at 20 dB/decade. For RC ≫ , the ripple is about peak to peak, worst at D = 0.5.
- LC (two poles, as in a buck converter or an inverter's output filter): attenuation grows at 40 dB/decade above , so the switching harmonic is reduced by about , or dB.
The faster the switching, the easier the filtering, which is the main reason converters switch at hundreds of kilohertz.
Natural filters
A motor's winding inductance filters PWM into a smooth current, and the eye averages an LED flickering faster than about 100 Hz. Audio class-D amplifiers rely on the speaker and an LC filter.
Worked example
An inverter's LC output filter has L = 1 mH and C = 10 µF, and it switches at 20 kHz. How much does the filter reduce the switching harmonic?
Show the solution
- Filter corner.
- Attenuation at 20 kHz. About or 44 dB.
- The fundamental. A 60 Hz fundamental passes almost untouched.
Answer the filter cuts the 20 kHz harmonic by about 44 dB (a factor of 0.0063).
Worked example
A 12 V PWM wave runs at 25% duty. What are the DC term and the first and third harmonics' amplitudes?
Show the solution
- DC term. The duty cycle times the amplitude:
- First harmonic.
- Third harmonic.
Answer the DC term is 3 V, the first harmonic 5.40 V and the third 1.80 V.
Worked example
A 12 V PWM signal at 50% duty and 10 kHz is smoothed by a single RC stage to make an analog voltage. What corner keeps the fundamental's ripple to 1% of 12 V?
Show the solution
- Fundamental.
- Attenuation needed. Reducing it to 0.12 V needs about 64 times attenuation.
- Corner. A first-order filter well above its corner attenuates by , so
- Second order. A second-order filter could keep the corner far higher and respond faster.
Answer a corner of 157 Hz.
Check
A 5 V PWM signal at duty cycle 0.15 goes through a slow low-pass filter. What DC voltage results?
Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.
Check
A 5 V PWM wave has duty cycle 0.1. What's the amplitude of its harmonic number 3?
Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.
Check
A 3.3 V PWM at 1 kHz and duty 0.2 feeds a 10 kΩ, 2.2 µF RC filter. About how much ripple is left, peak to peak?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
Check
An LC filter with L = 1 mH and C = 1 µF follows a 100 kHz switching stage. By about how many decibels does it attenuate the switching frequency?
Check
An inverter's LC filter has L = 1 mH and C = 4.7 µF, switching at 40 kHz.
(a)
What is its corner frequency?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
(b)
Roughly how much does it attenuate the switching frequency?
Check
A 12 V PWM wave runs at 10% duty.
(a)
What is its DC term?
Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.
(b)
What is the amplitude of harmonic 3?
Explain why
Why does switching faster make a PWM signal easier to filter?
A PWM signal is its average plus harmonics at the switching frequency and its multiples. A low-pass filter must pass the average, and any slow changes of it, while attenuating those harmonics, and a filter's attenuation grows with how far above its corner a frequency lies. Raising the switching frequency moves every harmonic further above the corner, so the same filter removes more of them, or a smaller, cheaper filter achieves the same ripple. The limit is that each switching transition costs some energy, so faster switching raises losses.
Practice
Keep practicing
9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.