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.
Design and build a 200W Class-D audio amplifier with digital input, gate drivers, LC output filter, and THD measurement.
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.
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.
10 components required for this project.
| # | Component | Purpose | Qty |
|---|---|---|---|
| 1 | IR2110 Gate Driver IC | Half-bridge high-side + low-side FET driver | x2 |
| 2 | IRF540N N-channel MOSFETs × 4 | Half-bridge switching elements (2 per channel) | x4 |
| 3 | STM32F4 (TIM1 complementary PWM) | Digital audio PWM generation | x1 |
| 4 | PCM5102A 32-bit I2S DAC | High-quality I2S to analog conversion | x1 |
| 5 | Output LC filter (22µH inductor + 1µF film cap) | PWM to analog conversion filter | x2 |
| 6 | Bootstrap capacitors (100nF ceramic) | High-side gate driver supply | x2 |
| 7 | Current sense resistors (0.01Ω, 2W) | Over-current protection sensing | x2 |
| 8 | Toroidal power transformer (50V, 5A) | Bus voltage supply | x1 |
| 9 | Heat sink (0.5°C/W) | MOSFET thermal management | x1 |
| 10 | Audio analyzer (software: REW) | THD, frequency response measurement | x1 |
Follow these 4 steps carefully.
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.
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).
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.
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.
Core code for class_d_pwm.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); }
Test Class-D Audio Amplifier Design by verifying each subsystem individually before full integration.
Verify power voltages, check ground connections, use serial monitor for debug.
An interactive simulator will be available here — simulate circuits and run code in-browser without hardware.