D25 of 9
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

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 (2V/nπ)|sin⁡(nπD)|.
  • 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?

Name it

PWM

A pulse train of height V, frequency fs and duty cycle D has

  • a DC term DV;
  • harmonics at nfs with amplitudes 2Vnπ|sin⁡(nπD)|.

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 fs passes the DC term (and slow changes of D) and attenuates the harmonics.

  • RC (one pole): attenuation grows at 20 dB/decade. For RC ≫ 1/fs, the ripple is about VD(1−D)RCfs 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 f0=1/(2πLC), so the switching harmonic is reduced by about (f0/fs)2, or 40log10⁡(fs/f0) 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
  1. Filter corner. f0=12π1mH×10µF=1592Hz
  2. Attenuation at 20 kHz. About (1592/20000)2=0.0063 or 44 dB.
  3. 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
  1. DC term. The duty cycle times the amplitude: 0.25×12=3V
  2. First harmonic. a1=2×12πsin⁡(π/4)=5.40V
  3. Third harmonic. a3=2×123π|sin⁡(3π/4)|=1.80V

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
  1. Fundamental. 2×12/π=7.64V
  2. Attenuation needed. Reducing it to 0.12 V needs 7.64/0.12=63.7 about 64 times attenuation.
  3. Corner. A first-order filter well above its corner attenuates by f/fc, so fc=10kHz/63.7=157Hz
  4. 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?

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.