Screeching sound when using UNO with Talkie library with PAM8403 amplifier

Hi,

I get a high screeching sound when using an UNO with the Talkie library with a PAM8403 amplifier and the following schematic and code from the Talkie examples. I have connected the UNO power to a power supply. I can hear the words at low volume without distortion, but at higher volume the screeching sound appears.
Can someone please help me get rid of the high screeching sound? I have tried to add resistor or capacitator between the PAM8403 and the UNO but to no avail. Do I need both resistors (which Ohm) AND a capacitator (which uF) and how to wire?

// Talkie library
// Copyright 2011 Peter Knight
// This code is released under GPLv2 license.

//
// Welcome to the Talkie library examples.
//
// Talkie is a speech synthesiser that works from a fixed vocabulary.
//
// There are hundreds of words in the 'Vocabulary' examples.
//

/*
 * Voice PWM output pins for different ATmegas:
 *  ATmega328 (Uno and Nano): non inverted at pin 3, inverted at pin 11.
 *  ATmega2560: non inverted at pin 6, inverted at pin 7.
 *  ATmega32U4 (Leonardo): non inverted at pin 10, inverted at pin 9.
 *  ATmega32U4 (CircuitPlaygound): only non inverted at pin 5.
 *
 *  As default both inverted and not inverted outputs are enabled to increase volume if speaker is attached between them.
 *  Use Talkie Voice(true, false); if you only need not inverted pin or if you want to use SPI on ATmega328 which needs pin 11.
 *
 *  The outputs can drive headphones directly, or add a simple audio amplifier to drive a loudspeaker.
 */
#include <Arduino.h>

#include "Talkie.h"
#include "Vocab_US_Large.h"

Talkie voice;

void setup() {
  voice.doNotUseInvertedOutput();
  voice.say(sp2_DANGER);
  voice.say(sp2_DANGER);
  voice.say(sp2_RED);
  voice.say(sp2_ALERT);
  voice.say(sp2_MOTOR);
  voice.say(sp2_IS);
  voice.say(sp2_ON);
  voice.say(sp2_FIRE);
}

void loop() {
}

You need a low pass RC filter between the Arduino output and the audio amplifier. A cutoff off 2 to 4 KHz would be good.

Also, you must make sure not to exceed the recommended voltage level on the amplifier input. The 5V Arduino PWM audio output surely exceeds that by a factor of 10 to 50.

To remove the 62.5 kHz PWM noise, try a second order filter like this one:

Expected frequency response:

Capture

Thanks for your answer. So

  1. I need the Low Pass RC filter consisting of 2 resistors and 2 capacitators to cut off the higher frequencies to remove the noice.
  2. I need to reduce the 5V Arduino PWM audio output to 5V/50 = 0.1V (=100mV). I have read that two resistors R1, R2 can accomplish this using the following formula
Vout = Vin * (R2 / (R1 + R2))

Given Vin = 5V and Vout = 100mV this gives

R1 = 49 * R2

I'll try to find resistors that match this equation as close as possible.
3. The low pass filter and the two resistors both need to be between the 5V Arduino PWM audio output and the audio amplifier input.

Am I correct in my conclusions? I am rather new to electronics.

Or just use a potentiometer.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.