Skip to main content
Tutorials

Class D Audio Amplifier HAT

Overviewโ€‹

In this tutorial, we will build a Class D Audio Amplifier HAT. This board takes stereo line-level audio input and amplifies it to drive two 3W speakers (Left and Right channels) with excellent efficiency and minimal heat output.

Unlike traditional analog amplifiers (such as Class A or AB) which dissipate excess power as heat, Class D amplifiers work by converting the analog input into a high-frequency PWM (Pulse Width Modulation) signal. The output MOSFETs switch fully ON or fully OFF rapidly, leading to efficiencies up to 90%, making them perfect for battery-powered or compact projects like Raspberry Pi audio HATs.

We will use the PAM8403 Class D amplifier chip, which is a filterless 3W stereo amplifier requiring minimal external components.


๐Ÿ“‹ Components Checklistโ€‹

Our amplifier HAT will consist of:

  1. PAM8403 Class D Amplifier (U1) โ€” 3W stereo audio amplifier in an SOP-16 package.
  2. Dual-Gang 10kฮฉ Potentiometer (RV1) โ€” Standard stereo volume control dial.
  3. 2x 2-pin Screw Terminals (J1, J2) โ€” Speaker output blocks for Left and Right speakers.
  4. 40-pin Raspberry Pi Header (J3) โ€” Pi HAT connector for power (5V) and audio line signals.
  5. Bulk Decoupling Capacitor (C1) โ€” 470ยตF electrolytic capacitor to buffer high-current speaker transients.
  6. Filtering Capacitors (C2, C3, C4, C5) โ€” Small ceramic capacitors (0.1ยตF to 1ยตF) to filter power supply noise and input signals.

๐Ÿ› ๏ธ Step-by-Step Implementationโ€‹

Create a new file in your project or editor and paste the following tscircuit design code.

Complete Circuit Codeโ€‹


๐Ÿ”Š Important Audio Circuit Design Notesโ€‹

  1. Input Coupling Capacitors (C4, C5):
    • These DC-blocking input capacitors are absolutely critical. They block any DC bias voltage from the host audio source while allowing the AC audio waveform to pass into the PAM8403 input pins.
  2. Bulk Capacitance (C1):
    • Class D amplifiers switch high currents to drive speakers. A large bulk decoupling capacitor (like the 470ยตF C1) must be placed as close to the power pins as possible to handle sudden current draws and prevent power sag.
  3. Filterless Design:
    • The PAM8403 uses a filterless modulation architecture. The inductance of the speaker coils acts as a low-pass filter to recover the audio signal from the PWM carrier, meaning you do not need bulky LC filters at the speaker outputs for short wire lengths.