Arduino + Audio Amplifier Board Help

_Nate_

Jun 12, 2017
99
Joined
Jun 12, 2017
Messages
99
Hey, it's me again, struggling with electronics as usual. In my project, I am trying to get Arduino Text to Speech working, but I have run into a large issue. I am using this audio amplifier board wired as so:

The output right + and - are wired to my speaker
The 5v and Ground are wired to the input 5v and ground of the Arduino
The R input is wired to digital pin 3
The ground input is wired to the ground on the Arduino's digital pin side

Right now, when powered on, the speaker makes barely audible groans. Then, my speaker begins to heat up and I can smell ozone. I'm confused where my wiring went wrong.
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
What is the output from the Arduino? It cannot produce audio directly. If it is PWM, you need a resistor from the pin and capacitor to ground to make a low pass filter. It should have a cutoff of about 4000 Hz for voice.

Also use a coupling capacitor between the output of the RC filter and the input of the audio amp.

Bob
 

_Nate_

Jun 12, 2017
99
Joined
Jun 12, 2017
Messages
99
What is the output from the Arduino? It cannot produce audio directly. If it is PWM, you need a resistor from the pin and capacitor to ground to make a low pass filter. It should have a cutoff of about 4000 Hz for voice.

Also use a coupling capacitor between the output of the RC filter and the input of the audio amp.

Bob
Alright thanks! It is a PWM output. So should the wiring be
pin --> resistor --> audio signal input & resistor --> capacitor --> ground
or
pin --> resistor --> capacitor --> ground & capacitor --> audio signal input

Also, what resistance and capacitance should I use?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Like this:

upload_2018-5-20_11-12-3.png

And this will just get you some kind of sound, not good sound. It depends a lot on the PWM frequency. If it is 100 KHz it might work well, if 8 KHz it will be awful. You may need a much sharper filter (a couple of Sallen Key stages) after the RC filter if the PWM frequency is anywhere in the audio range.

Bob
 
Last edited:

Audioguru

Sep 24, 2016
3,656
Joined
Sep 24, 2016
Messages
3,656
The class-D oscillator in the PAM8403 is at 260kHz so it might beat with your PWM oscillator.
Maybe the ebay amplifier uses a Chinese version of the PAM8403 that has a defect in it. Maybe the amplifier has a solder short on it.
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Sending in raw PWM will certainly cause a problem with a class D amplifier. It absolutely needs to be smoothed with at least the simple filter I proposed, and probably much more to sound good.

Do you happen to know the PWM frequency?

Bob
 

_Nate_

Jun 12, 2017
99
Joined
Jun 12, 2017
Messages
99
Sending in raw PWM will certainly cause a problem with a class D amplifier. It absolutely needs to be smoothed with at least the simple filter I proposed, and probably much more to sound good.

Do you happen to know the PWM frequency?

Bob
I do not. I only know that I am using the "TTS-master"/jscrane TTS text to speech library that generates the sound. The code does not mention the frequency,
 

_Nate_

Jun 12, 2017
99
Joined
Jun 12, 2017
Messages
99
Sending in raw PWM will certainly cause a problem with a class D amplifier. It absolutely needs to be smoothed with at least the simple filter I proposed, and probably much more to sound good.

Do you happen to know the PWM frequency?

Bob
Can you also clarify the capacitance and resistance values in your diagram? Is this 390ohms, 1 micro farad, and 100 nano farads?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Yep, That would roll off starting at 4000 Hz.

Bob
 

_Nate_

Jun 12, 2017
99
Joined
Jun 12, 2017
Messages
99
Yep, That would roll off starting at 4000 Hz.

Bob
Unfortunately, I do not have any 390ohm resistors or 100 nf capacitors. If I were to use a 330R and another 1uf capacitor in the place of these two, what would happen?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
You would get a cutoff frequency of 482 Hz. Do you have any smaller capacitors?

Bob
 

_Nate_

Jun 12, 2017
99
Joined
Jun 12, 2017
Messages
99
You would get a cutoff frequency of 482 Hz. Do you have any smaller capacitors?

Bob
Smallest I currently have is 1uf, Will lowering the resistance lower the cutoff frequency?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Yes, but the output from the Arduino will not be able to drive it. I might go as low as 100Ω. That would raise it to 1200Hz. You can certainly try this, it will sound like you have no highs, but it should get you sound out. You can also put caps in series to lower the capacitance. Do you have any junked electronics sitting around? 100nF is a very common capacitor value. A ceramic disc would be marked 104.

Bob
 

_Nate_

Jun 12, 2017
99
Joined
Jun 12, 2017
Messages
99
Yes, but the output from the Arduino will not be able to drive it. I might go as low as 100Ω. That would raise it to 1200Hz. You can certainly try this, it will sound like you have no highs, but it should get you sound out. You can also put caps in series to lower the capacitance. Do you have any junked electronics sitting around? 100nF is a very common capacitor value. A ceramic disc would be marked 104.

Bob
Am I going for a high Hz cutoff or a mid-range cutoff?
 

Audioguru

Sep 24, 2016
3,656
Joined
Sep 24, 2016
Messages
3,656
Vowels in speech are grunts and groans and reach about 3kHz. Consonants in speech are important for understanding and reach about 14kHz. Tea or fee? Sim or him? The words Failing and Sailing sound the same without hearing the high frequency consonants.
 

_Nate_

Jun 12, 2017
99
Joined
Jun 12, 2017
Messages
99
Vowels in speech are grunts and groans and reach about 3kHz. Consonants in speech are important for understanding and reach about 14kHz. Tea or fee? Sim or him? The words Failing and Sailing sound the same without hearing the high frequency consonants.
So am I better off with a 482hz cutoff than a 1200hz cutoff?
 

Audioguru

Sep 24, 2016
3,656
Joined
Sep 24, 2016
Messages
3,656
With a cutoff at 482Hz I doubt you will understand anything in speech. With a 1200Hz cutoff it is only slightly better but is still extremely muffled.
Old fashioned telephones had a cutoff of about 2700Hz and the most common phrase was "What did you say?". AM radio has a cutoff of about 3500Hz but they use pre-emphasis (treble frequencies boost) to make it sound better.
FM radios and TVs have a cutoff of 15kHz and CD has 20kHz.
 

_Nate_

Jun 12, 2017
99
Joined
Jun 12, 2017
Messages
99
With a cutoff at 482Hz I doubt you will understand anything in speech. With a 1200Hz cutoff it is only slightly better but is still extremely muffled.
Old fashioned telephones had a cutoff of about 2700Hz and the most common phrase was "What did you say?". AM radio has a cutoff of about 3500Hz but they use pre-emphasis (treble frequencies boost) to make it sound better.
FM radios and TVs have a cutoff of 15kHz and CD has 20kHz.
So higher is indeed better? So what combination of resistors and capacitors can get me a high enough cutoff that speech will be understandable?
 
Top