Noise Issue with Teensy 4.1, Audio Shield, and PAM8403 Amplifier

Hi everyone,

I’m working on a Teensy 4.1 audio project using the Teensy Audio Shield (SGTL5000) and a PAM8403 amplifier. The system plays audio from an SD card, but I’m consistently getting noisy output on the speaker connected via the PAM8403. Below are my details and tests:


Hardware Details:

  1. Microcontroller: Teensy 4.1
  2. Audio Shield: SGTL5000-based Teensy Audio Shield
  3. Amplifier: PAM8403, single-channel (right channel only connected).
  4. Speaker: (Add details: e.g., 4-ohm, 3W, etc.)

Connections:

  • Teensy 4.1 and Audio Shield: Standard I2S connections.
    • LRCLK: Pin 20
    • BCLK: Pin 21
    • DIN: Pin 7
    • MCLK: Pin 23
  • PAM8403 Amplifier:
    • Input Signal: Right channel from Teensy Audio Shield (R pin).
    • Input Ground: GND of Audio Shield.
    • Power: Separate 5V power supply (shared GND with Teensy and Audio Shield).
    • Speaker: Connected to PAM8403 output pins.
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioPlaySdWav playSdWav1;        // xy=69,177
AudioFilterStateVariable filter1; // xy=309,92
AudioFilterStateVariable filter2; // xy=312,257
AudioMixer4 mixer2;               // xy=584,261
AudioMixer4 mixer1;               // xy=602,114
AudioAnalyzePeak peak1;           // xy=810,386
AudioAnalyzePeak peak2;           // xy=836,450
AudioOutputI2S i2s1;              // xy=899,223
AudioConnection patchCord1(playSdWav1, 0, filter1, 0);
AudioConnection patchCord2(playSdWav1, 1, filter2, 0);
AudioConnection patchCord3(filter1, 0, mixer1, 0);
AudioConnection patchCord4(filter1, 1, mixer1, 1);
AudioConnection patchCord5(filter1, 2, mixer1, 2);
AudioConnection patchCord6(filter2, 0, mixer2, 0);
AudioConnection patchCord7(filter2, 1, mixer2, 1);
AudioConnection patchCord8(filter2, 2, mixer2, 2);
AudioConnection patchCord9(mixer2, 0, i2s1, 1);
AudioConnection patchCord10(mixer2, peak2);
AudioConnection patchCord11(mixer1, 0, i2s1, 0);
AudioConnection patchCord12(mixer1, peak1);
AudioControlSGTL5000 sgtl5000_1; // xy=539,383
// GUItool: end automatically generated code

#define SDCARD_CS_PIN BUILTIN_SDCARD
void setup() {
  Serial.begin(9600);
  delay(200);
  Wire.begin();
  delay(200);
  AudioMemory(8);
  delay(200);

  sgtl5000_1.enable();
  delay(200);
  sgtl5000_1.volume(1);
  sgtl5000_1.dacVolume(1);

  delay(1000);

  while (!Serial && millis() < 3000);
  delay(200);
  if (!(SD.begin(SDCARD_CS_PIN))) {
    while (1) {
      Serial.println("Unable to access the SD card");
      delay(500);
    }
  }
  mixer1.gain(0, 1);
  mixer2.gain(0, 1);
  pinMode(13, OUTPUT);
}

void loop() {
  playSdWav1.play("SDTEST1.WAV");
  while (playSdWav1.isPlaying()) {
    // Additional tasks can be performed here
  }
  delay(500);
  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(500);
}

  • Why does the PAM8403 produce noise while the other setups are clear?
  • Is there a way to improve the PAM8403’s performance with the Teensy Audio Shield?
  • Any recommendations for alternative amplifier setups or optimizations?

I don't know about the PAM8403 modules, but I bought something similar in mono, the PAM8302 and I tried several times to get clean sounding audio out of them but failed. It produced distorted/noisy audio regardless of supply voltage or load. I've relegated them to my pile of Aliexpress junk.

Instead, I use these:TPA3110. They sound good, have output filters, produce far more power and don't cost much. The only downside is that they need at least 8vdc; they don't work at 5 volts.

edit: Also, they lack an onboard volume control, which is inconvenient.

What other "setups"? If you've got something that works better, use it! :stuck_out_tongue:

Is there a volume control on the PAM input? If so that should tell you where the noise is coming from. i.e. If the noise stays the same when you turn down the volume the amplifier itself is the problem.

Otherwise, you can simply break the audio connection between the audio module and the amplifier to see if the noise goes-away.

Typically, these amplifiers have "too much gain" and the unnecessary gain boosts the noise. If you are powering the amp from 5V you can't boost the signal that much anyway. (I'm talking about voltage gain... You DO need current & power gain to drive a 4 or 8-Ohm speaker.)

Sometimes noise gets into an amplifier through the power supply. Try a separate power supply or a battery. (Of course you still need a common ground for the aueio signal.)

What's the nature of the noise? Hiss is usually from the amplifier itself. Hum or buzz is usually from the power supply. Whine is usually "digital noise" from the digital circuitry getting into the analog signal, or it can be from a switching power supply.

Thank you for your suggestion
@nixie

Could you suggest me with 5V supply amplifier which is suitable for this project