Advertisement
Advanced Time: 4–5 weeks Electronics Engineering

Class-D Audio Amplifier Design

Design and build a 200W Class-D audio amplifier with digital input, gate drivers, LC output filter, and THD measurement.

AudioClass-DPWMAudio AmplifierTHDPCM5102A
DifficultyAdvanced
Duration4–5 weeks
Components10 items
Steps4 steps

Introduction

Design and build a 200W Class-D audio amplifier with digital input, gate drivers, LC output filter, and THD measurement. This comprehensive guide covers everything from design through implementation, testing, and deployment.

Theory & Background

Class A/AB amplifiers: output transistors conduct continuously — high linearity, low efficiency (25–60%). Class D: switching amplifier — MOSFETs fully ON or fully OFF. PWM signal: duty cycle proportional to audio amplitude. Output LC filter: averages the PWM to recover the audio signal. Efficiency: 85–95% (switching losses only, not conductive). Why it works: MOSFET fully ON → almost zero voltage across it (low Rds_on) → almost zero power dissipation. MOSFET fully OFF → zero current → zero power. Transition losses (finite switching time × voltage × current) are the primary loss mechanism.

Advertisement

Components & Requirements

10 components required for this project.

#ComponentPurposeQty
1IR2110 Gate Driver ICHalf-bridge high-side + low-side FET driverx2
2IRF540N N-channel MOSFETs × 4Half-bridge switching elements (2 per channel)x4
3STM32F4 (TIM1 complementary PWM)Digital audio PWM generationx1
4PCM5102A 32-bit I2S DACHigh-quality I2S to analog conversionx1
5Output LC filter (22µH inductor + 1µF film cap)PWM to analog conversion filterx2
6Bootstrap capacitors (100nF ceramic)High-side gate driver supplyx2
7Current sense resistors (0.01Ω, 2W)Over-current protection sensingx2
8Toroidal power transformer (50V, 5A)Bus voltage supplyx1
9Heat sink (0.5°C/W)MOSFET thermal managementx1
10Audio analyzer (software: REW)THD, frequency response measurementx1

Step-by-Step Implementation

Follow these 4 steps carefully.

1
Class D Amplifier Theory

Class A/AB amplifiers: output transistors conduct continuously — high linearity, low efficiency (25–60%). Class D: switching amplifier — MOSFETs fully ON or fully OFF. PWM signal: duty cycle proportional to audio amplitude. Output LC filter: averages the PWM to recover the audio signal. Efficiency: 85–95% (switching losses only, not conductive). Why it works: MOSFET fully ON → almost zero voltage across it (low Rds_on) → almost zero power dissipation. MOSFET fully OFF → zero current → zero power. Transition losses (finite switching time × voltage × current) are the primary loss mechanism.

2
Half-Bridge Gate Driver Design

IR2110 drives both high-side (connected to +50V) and low-side (connected to GND) MOSFETs of one half-bridge. High-side driver problem: gate must be driven above source voltage (which is at +50V during high-side conduction). Bootstrap circuit: 100nF capacitor charges to VCC during low-side ON time. When high-side must turn ON: bootstrap cap provides floating supply above high-side source. Dead-time: both MOSFETs cannot be ON simultaneously (shoot-through → short circuit → device destruction). STM32 TIM1 provides complementary PWM outputs with programmable dead time (100–500ns typically).

3
PWM Frequency and Audio Quality

PWM carrier frequency: must be >> audio bandwidth (20kHz). Typical: 300kHz–500kHz. Higher frequency: smaller LC filter, better SNR, more switching losses. Lower frequency: larger filter, worse audio-band noise. Modulation: natural sampling (audio sample compared with triangle wave → correct nonlinearity), uniform sampling (less correct but simpler digital implementation), sigma-delta modulation (noise shaped to high frequencies → very low THD). STM32 TIM1 at 168 MHz with 500 count period → 336 kHz PWM. Resolution: 500 steps → 9 bits. For 16-bit audio: use sigma-delta oversampling.

4
Output LC Filter Design

LC filter converts PWM to audio: inductor + capacitor form 2nd-order low-pass filter. Cutoff frequency: fc = 1/(2π√(LC)). Target fc at 30–40 kHz (between audio 20kHz and PWM carrier 300kHz). For 22µH and 1µF: fc = 1/(2π×√(22×10⁻⁶ × 1×10⁻⁶)) = 33.9 kHz. Inductor: toroidal core (Micrometals T50-26), hand-wound with 20 AWG magnet wire. Core must not saturate at peak audio current (calculate: Lpeak = inductance × current / N_turns → keep below core Bsat). Zobel network (8Ω + 100nF in series, across speaker): prevents resonance with speaker impedance at high frequency.

Code & Implementation

Core code for class_d_pwm.c:

class_d_pwm.c C
// STM32F4 Class-D Amplifier PWM Setup // Uses TIM1 complementary outputs with deadtime insertion  #include "stm32f4xx_hal.h"  void ClassD_PWM_Init(void) {     TIM_HandleTypeDef htim1 = {0};     TIM_OC_InitTypeDef sConfigOC = {0};     TIM_BreakDeadTimeConfigTypeDef sBreakDeadTime = {0};      htim1.Instance = TIM1;     htim1.Init.Prescaler = 0;            // No prescaler (168 MHz timer clock)     htim1.Init.CounterMode = TIM_COUNTERMODE_UP;     htim1.Init.Period = 500 - 1;         // 168 MHz / 500 = 336 kHz PWM     htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;     HAL_TIM_PWM_Init(&htim1);      sConfigOC.OCMode = TIM_OCMODE_PWM1;     sConfigOC.Pulse = 250;               // 50% duty = 0V (half rail)     sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;     sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;     HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1);      // Dead time: prevent shoot-through     sBreakDeadTime.DeadTime = 50;        // 50 × (1/168MHz) ≈ 298ns deadtime     sBreakDeadTime.BreakState = TIM_BREAK_DISABLE;     HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTime);      // Start complementary PWM on CH1 and CH1N     HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);     HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_1); }  // Update PWM duty cycle from audio sample (-32768 to +32767) void ClassD_SetAudioSample(int16_t sample) {     // Map: -32768 → 0 (0V), 0 → 250 (half-rail), 32767 → 499 (full rail)     uint16_t duty = (uint16_t)(((int32_t)sample + 32768) * 500 / 65535);     __HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1, duty); }

Testing & Troubleshooting

Test Class-D Audio Amplifier Design by verifying each subsystem individually before full integration.

!
Troubleshooting Tips

Verify power voltages, check ground connections, use serial monitor for debug.

Real-World Applications

*High-efficiency home audio system
*Subwoofer amplifier for home theater
*Outdoor PA system amplifier
*Electric guitar amplifier
*Automotive audio amplifier
*Hearing aid amplification stage
*Portable Bluetooth speaker driver
*Professional studio monitor amplifier

Extensions & Next Steps

  • Add digital input (Bluetooth, optical, coaxial SPDIF)
  • Implement dynamic range compression and limiter
  • Design a stereo Class-AB preamp for tone control
  • Add room correction DSP (FIR filters) in MCU
  • Build a measurement system to plot frequency response and THD vs level

Interactive Playground

Coming Soon

An interactive simulator will be available here — simulate circuits and run code in-browser without hardware.

Frequently Asked Questions

What is THD (Total Harmonic Distortion) and what is a good value for audio?
THD: when a 1 kHz sine wave is amplified, nonlinear distortion creates harmonics at 2kHz, 3kHz, 4kHz... THD = (sum of harmonic amplitudes) / fundamental amplitude, expressed as %. Human hearing sensitivity: harmonics below 0.1% are inaudible for most listeners. 0.01% THD: audiophile amplifier quality (high-end Class A or AB). 0.05–0.1%: good Class D amplifier. 0.5–1%: acceptable for powered speakers. >1%: audible distortion. Measure THD: connect to oscilloscope FFT mode or use REW (Room EQ Wizard) software with a soundcard. Class D amplifiers typically achieve 0.02–0.1% THD with good design.
Advertisement