Amplify audio signal

Hello,

If this has already been posted I do apologize. I found this schematic for an audio amplifier and decided to try it out. I’m using an LM386 audio amplifier and an 8ohm speaker. The audio quality is fine at lower volumes but when setting the volume to higher than 5 using music.setVolume(); it gets really distorted. Can I amplify the volume any other way? Perhaps by using a speaker with a higher impedance?

This is my code:

#include “SD.h” //Lib to read SD card
#include “TMRpcm.h” //Lib to play auido
#include “SPI.h” //SPI lib for SD card
#define SD_ChipSelectPin 4 //Chip select is pin number 4
TMRpcm music; //Lib object is named “music”

void setup(){
music.speakerPin = 9; //Auido out on pin 9
Serial.begin(9600); //Serial Com for debugging
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println(“SD fail”);
return;
}

pinMode(2, INPUT_PULLUP)
music.setVolume(5); // 0 to 7. Set volume level
music.quality(1); // Set 1 for 2x oversampling Set 0 for normal
}
void loop()
{
if (digitalRead(2) == LOW ) {
music.play(“1.wav”
}
}

I’m only using one button, a limit switch, which starts the music when open. The idea is to put it all in a box and have the lid of the box close and open the switch when opening and closing the lid. I guess the resonance in the box will add some extra volume but it would be nice to be able to ampliy it even further. I’m thinking that maybe a speaker with higher impedance would result in a better impedance matching?

I'm using an Arduino Uno with an SD-card module. I have converted the songs to .wav with 16k Hz sampling rate and 8-bit resolution.

Well the LM386 components are nearly all wrong, that will have something to do with it.

The output capacitor to the speaker should be more like 220uF to 1000uF, not 1uF. So you're getting almost nothing in the lower frequencies.

The snubber network is supposed to be 47nF and 10 ohms, not 10uF and 10k ohms. Get this wrong and it might oscillate.

The input should be low-pass filtered and AC coupled, add an RC filter and a cap in series with pin 2 of the
LM386, so that it only sees audio frequencies and can float to its proper bias voltage.

Thank you! I'll try that also :slight_smile:

If you remember where you found that circuit, go back and complain!

BTW note that the LM386 is a discontinued product, it may hard to find in the future.

With a 5V power supply the theoretical maximum power is 0.4W into 8-Ohms or 0.8W into 4-Ohms. In the real world there will be some voltage-loss through the amplifier so you’ll get less. (5V peak-to-peak is 1.75VRMS.)

Perhaps by using a speaker with a higher impedance?

With higher impedance, you’ll get less current ([u]Ohm’s Law[/u]) and therefore less power. Resistance (and impedance) is the “resistance to current flow”.

If you double the voltage, you also double the current so doubling the voltage gives you 4 times the power*, whereas halving the impedance just doubles the current giving you twice the power.*

I believe the minimum voltage gain of the LM386 is 20, and since you can get 5V peak-to-peak out of the Arduino you don’t need much (if any) voltage** gain and you can easily drive it into distortion. (And, you might get better quality if you add an analog volume pot so you can run the digital volume “hotter” and reduce the analog volume.)

  • Within the limits of the chip.
    ** You do need power gain… More current than the Arduino can directly supply.

For a small battery powered project, you really should use a class-D amplifier chip. They are vastly more efficient.

Here's one that might work.

http://www.ti.com/product/tpa2005d1
https://www.digikey.com/product-detail/en/texas-instruments/TPA2005D1DGNR/296-26876-1-ND

Sparkfun makes a very convenient breakout board with the class D TP2005D1 amplifier.

There is a possibility with such a class D amp that its oscillator will mix with the PWM frequency of a
low-pass filtered PWM output and cause spurious notes and whistles. Some class D chips allow
the oscillator frequency to be changed (usually to reduce AM radio interference in fact), which may
be handy to know.

I'm just going to continue the discussion since I literally was just about to ask the same question. I'm going to follow the recommendation from MarkT. I know you were recommending to use an external power source, is 9V the recommended input and how does it get wired in?