---
title: Class D amplifiers
heading: Switching the output stage, and filtering the switching away
eyebrow: C6 · Lesson 43 · Class D amplifiers
xp: 40
---

::: hook
A class B output stage wastes a third of its power or more, because its transistors carry the load current with a large voltage across them. A class D stage never does: its transistors are either fully on, with almost no voltage across them, or fully off, with no current. The signal is coded as the duty cycle of a fast square wave, and an LC filter recovers it at the speaker. Efficiencies above 90% are routine, which is why phones, laptops and car audio use it.

::: play
- The trace is a pulse-width-modulated wave: a comparator switching between the rails as an audio sine is compared with a fast triangle. The bars are its spectrum.
- The audio tone sits alone at 1 kHz; everything else clusters around the switching frequency and its multiples.
- Raise the switching frequency: the clusters move away from the audio, and a simple filter can remove them. Raise the modulation: the tone grows.
:::
:::

```sim plot
view: spectrum
x: t = 0..4m s
y: v = -1.5..1.5 V
samples: 4096
freq: f = 0..250k Hz
slider: m = 0..0.95 step 0.05 = 0.5
slider: fc = 20k..120k = 50k Hz step 1k
plot: sign(m*sin(2*pi*1000*t) - 2/pi*asin(sin(2*pi*fc*t))) | label: PWM output
marker: f = fc | label: switching frequency
```

::: predict
## A class D stage on ±15 V delivers 10 W to 8 Ω through switches with 0.1 Ω of on-resistance and 0.3 W of switching loss. About what's its efficiency? A class B stage on the same supplies at the same power reaches about 66%.

- [ ] About 66%, the same
- [ ] About 78.5%
- [x] About 96%
- [ ] 100%

::: reveal
About 96%. The load current always flows through one switch or the other, so the conduction loss is $I_\text{rms}^2R_\text{on}$ = 1.25 × 0.1 = 0.125 W; with the 0.3 W of switching loss, 10 W out costs 10.4 W in. The class B stage has its transistors in the active region with volts across them while they carry amps.
:::
:::

::: nameit
## Pulse-width modulation

A comparator compares the audio with a triangle at the switching frequency $f_s$, many times the highest audio frequency. Its output switches the stage between $+V$ and $-V$, with a duty cycle D that follows the audio. The average over a switching period is

$$\bar v = (2D - 1)V.$$

The spectrum holds the audio itself plus clusters at $f_s$, $2f_s$ and so on, which the output filter must remove.

## The output filter

A second-order LC low-pass between the switches and the speaker passes the audio and attenuates the switching clusters at 40 dB per decade. For a Butterworth response with load R and corner $f_c$:

$$L = \frac{\sqrt2R}{2\pi f_c}, \qquad C = \frac{1}{\sqrt2R \cdot 2\pi f_c}.$$

The inductor carries a triangular ripple current on top of the audio; for a stage switching between 0 and $V_S$ at duty D, it's

$$\Delta I = \frac{V_SD(1 - D)}{Lf_s},$$

largest at D = ½.

## Efficiency

The losses are conduction, $I_\text{rms}^2R_\text{on}$, since one switch or the other always carries the load current; switching, from the transitions and the switches' capacitances, rising with $f_s$; and the quiescent power of the modulator and drivers. Switching faster makes the filter smaller and the audio cleaner but costs switching loss. **Dead time**, a short gap when neither switch is on, prevents shoot-through but distorts slightly; feedback around the stage corrects most of it.
:::

::: example
## Compare the efficiency of the predict's class D stage with a class B stage on the same ±15 V, both delivering 10 W into 8 Ω.

::: solution
1. **Output peak.**
   $$\sqrt{2 \times 10 \times 8} = 12.6\ \text{V}$$
2. **Class B.**
   $$\begin{aligned} \eta &= \frac\pi4 \times \frac{12.6}{15} \\ &= 66.2\% \end{aligned}$$
   so it draws 15.1 W and dissipates 5.1 W in its transistors.
3. **Class D.** The conduction loss is
   $$\frac{10}{8} \times 0.1 = 0.125\ \text{W}$$
   plus 0.3 W of switching, for 95.9%.
4. **Compare.** The class B amplifier needs a heat sink for 5 W; the class D one dissipates under half a watt.

**Answer:** class B reaches 66.2% and class D 95.9%.
:::
:::

::: example
## Design a Butterworth LC output filter for an 8 Ω speaker with a 30 kHz corner. How much does it attenuate a 400 kHz switching frequency?

::: solution
1. **Inductor.** With $\omega_c = 2\pi \times 30$ kHz,
   $$\begin{aligned} L &= \frac{\sqrt2 \times 8}{\omega_c} \\ &= 60\ \mu\text{H} \end{aligned}$$
2. **Capacitor.**
   $$\begin{aligned} C &= \frac{1}{\sqrt2 \times 8 \times \omega_c} \\ &= 0.47\ \mu\text{F} \end{aligned}$$
3. **Attenuation at 400 kHz.** More than a decade above the corner, the filter is down about
   $$40\log\frac{400}{30} = 45\ \text{dB}$$
4. **A real speaker.** The filter is tuned to the speaker's nominal resistance; a real speaker's impedance varies, which moves the corner and the response near it.

**Answer:** L = 60 µH and C = 0.47 µF, which attenuate 400 kHz by about 45 dB.
:::
:::

::: example
## The 60 µH inductor sits in a stage switching between 0 and 30 V at 400 kHz. What's its peak-to-peak ripple current with no audio (D = ½)? And what average output does D = 0.75 give in a stage switching between +15 V and −15 V?

::: solution
1. **Ripple current.**
   $$\begin{aligned} \Delta I &= \frac{30 \times 0.5 \times 0.5}{60\ \mu\text{H} \times 400\ \text{kHz}} \\ &= 0.31\ \text{A} \end{aligned}$$
   peak to peak, flowing even with no signal: that's a quiescent loss the designer has to keep small.
2. **Bipolar stage.**
   $$\begin{aligned} \bar v &= (2 \times 0.75 - 1) \times 15 \\ &= 7.5\ \text{V} \end{aligned}$$

**Answer:** the ripple is 0.31 A peak to peak, and D = 0.75 gives an average of 7.5 V.
:::
:::

::: check
kind: parts
given: P = 5 | 20 | 50; R = 4 | 8; Ron = 0.05 | 0.2; Ps = 0.2 | 1

## A class D stage delivers {P} W into {R} Ω through switches with {Ron} Ω on-resistance and {Ps} W of switching loss.

::: part
answer: P/R*Ron
unit: W
tolerance: 0.5%

### What's its conduction loss?

::: misses
- [P/R*Ron/2] One switch or the other carries the load current all the time.
- [any] $I_\text{rms}^2R_\text{on}$ with $I_\text{rms}^2 = P/R$.
:::
:::

::: part
answer: P/(P + P/R*Ron + Ps)*100
unit: %
tolerance: 0.5%

### What's its efficiency?

::: misses
- [any] $\frac{P}{P + P_\text{cond} + P_\text{sw}}$.
:::
:::
:::

::: check
kind: parts
given: R = 4 | 8 | 16; fc = 20 | 40

## A Butterworth LC filter feeds an {R} Ω speaker with a {fc} kHz corner.

::: part
answer: sqrt(2)*R/(2*pi*fc*1000)*1e6
unit: µH
tolerance: 0.5%

### What inductance?

::: misses
- [R/(2*pi*fc*1000)*1e6] A Butterworth section needs $\sqrt2R/\omega_c$.
- [any] $L = \frac{\sqrt2R}{2\pi f_c}$.
:::
:::

::: part
answer: 1/(sqrt(2)*R*2*pi*fc*1000)*1e6
unit: µF
tolerance: 0.5%

### What capacitance?

::: misses
- [any] $C = \frac{1}{\sqrt2R \cdot 2\pi f_c}$.
:::
:::
:::

::: check
given: V = 12 | 24 | 48; L = 10 | 47; f = 0.3 | 1; D = 0.25 | 0.5
answer: V*D*(1 - D)/(L*1e-6*f*1e6)
unit: A
tolerance: 0.5%

## A class D stage switches between 0 and {V} V at {f} MHz into a {L} µH inductor at duty {D}. What's the inductor's peak-to-peak ripple current?

::: right
Right. $\frac{V_SD(1 - D)}{Lf_s}$ = {answer}.
:::

::: misses
- [V/(L*1e-6*f*1e6)] The ripple scales with $D(1 - D)$.
- [any] $\Delta I = \frac{V_SD(1 - D)}{Lf_s}$.
:::
:::

::: check
given: V = 12 | 15 | 30; D = 0.2 | 0.6 | 0.9
answer: (2*D - 1)*V
unit: V
tolerance: 0.5%

## A class D stage switches between +{V} V and −{V} V at duty {D}. What's its average output?

::: right
Right. $(2D - 1)V$ = {answer}.
:::

::: misses
- [D*V] It switches between +V and −V, so 50% duty averages to zero.
- [any] $\bar v = (2D - 1)V$.
:::
:::

::: check
given: fc = 20 | 30 | 50; fs = 250 | 400 | 1000
answer: 40*log(fs/fc)
unit: dB
tolerance: 1%

## About how much does a second-order filter with a {fc} kHz corner attenuate a {fs} kHz switching frequency?

::: right
Right. 40 dB per decade: {answer}.
:::

::: misses
- [20*log(fs/fc)] A second-order filter falls at 40 dB per decade.
- [any] $40\log\frac{f_s}{f_c}$.
:::
:::

::: check
kind: choice

## Why does raising a class D amplifier's switching frequency eventually lower its efficiency?

- [ ] The LC filter loses more
- [x] Each transition dissipates energy, so switching loss grows in proportion to frequency
- [ ] The conduction loss rises
- [ ] The speaker draws more current

::: right
Right. Conduction loss doesn't depend on the frequency; switching loss does.
:::

::: misses
- [1] A higher frequency lets the filter be smaller, not lossier.
- [3] Conduction loss is $I^2R_\text{on}$, independent of frequency.
- [4] The load current follows the audio, not the switching.
:::
:::

::: check
kind: derivation
vars: V = 5..100, R = 2..32, f = 10000..100000, D = 0.05..0.95, L = 0.000001..0.001, s = 100000..5000000

## A class D stage on ±V drives load R through an LC Butterworth filter with corner f, at duty D and switching frequency s, with inductance L.

::: step
answer: (2*D - 1)*V

### What's the average output?
:::

::: step
answer: sqrt(2)*R/(2*pi*f)

### What inductance makes the filter Butterworth?
:::

::: step
answer: 2*V*D*(1 - D)/(L*s)

### What's the ripple current, the stage swinging 2V in all?
:::

::: right
Right. Doubling the switching frequency halves the ripple.
:::
:::

::: explain
## Why is a class D output stage so much more efficient than class B?

::: model
A transistor dissipates the product of the current through it and the voltage across it. In class B, the output transistors act as variable resistors: while they carry the load current they also hold a large voltage, the difference between the supply and the output, so they turn a large part of the supply's power into heat. In class D, the transistors are switches: each is either fully on, carrying current with only its small on-resistance drop, or fully off, with voltage but no current. The product is small in both states, and the only other losses are the brief transitions between them. The LC filter, which stores energy rather than dissipating it, turns the switched waveform back into audio.
:::
:::

::: practice

::: check
given: P = 2 | 30; R = 4 | 8; Ron = 0.03 | 0.15
answer: P/R*Ron
unit: W
tolerance: 0.5%

## {P} W into {R} Ω, $R_\text{on}$ = {Ron} Ω. Conduction loss?

::: misses
- [any] $\frac PR R_\text{on}$.
:::
:::

::: check
given: V = 20 | 40; D = 0.35 | 0.8
answer: (2*D - 1)*V
unit: V
tolerance: 0.5%

## ±{V} V, duty {D}. Average output?

::: misses
- [any] $(2D - 1)V$.
:::
:::
:::
