Amplifying Wave File Output

Hi Guys

Firstly, I'm new to Arduino and also electronics as a whole, recently taken up as a hobby to ease the boredom of retirement. Last month I got some brilliant help on the forum with my quest to develop a 'Mole Whacker' game for the grandkids at Christmas. The game works fine now and I decided to try and add some silly noises to add to the fun. I needed to learn how to get sound from an Arduino so I loaded up a Uno with the sound sketch sample in the 'Examples' connected up an SD card module and got a good result. I built a simple amplifier based on an L386 IC but linking the output of the Uno to the amplifier is proving a big problem. My scope showed that the Uno output is a square wave which gave huge distortion, so I added an RC network ( 3 x 1.5K resistors & 3 0.01uf caps ) and I now have what looks like sine wave audio output.

However, the amp doesn't like the signal at all, except when the 10k volume pot is roughly mid position there is some un-distorted playback but very quiet.

Can anybody see what I'm missing ??

Thanks

S

A square wave will sound louder than a sine wave because of the harmonics, and a square wave will sound a lot louder than undistorted voice or music with the same peak value because voice/music has a much lower average level.

The LM386 doesn't put-out lots of power... Test the amplifier & speaker by plugging-in something else (like the output from a CD or DVD player, etc.).

If the 386 isn't powerful enough, there are "bigger" amplifier chips (which generally require more voltage), or you can buy a little amplifier or an amplifier board/module, or you can use powered computer speakers.

and I now have what looks like sine wave audio output.

What's the voltage? What's the gain of your LM386? What's the output voltage from the 386 into the speaker?

so I added an RC network ( 3 x 1.5K resistors & 3 0.01uf caps )

Is there also a DC blocking capacitor?

except when the 10k volume pot is roughly mid position there is some un-distorted playback but very quiet.

And if you turn it up louder, it gets louder, but with distortion? And when it distorts, do you see clipping on your 'scope?

Hi Doug

Thanks for trying to help me … …

Yes, I did test the amp & spk with an old walkman player - all OK except for the music, but that’s another matter !! :slight_smile:

I know the 386 is not very powerful, but it’s good enough for this, it is only a kids game for 6 or 7 yr olds, and I’ve used one before and it was a lot stronger than this.
I’ve ordered a ready built little amplifier, just in case, but I don’t like being beaten !

You asked about voltages … …

all DC .

Arduino Output = 4.63v

RC out/VR1 in = 3.20v

Wiper / IC pin 3 = 0.10v

IC Pin 5 (output to spk) = 3.26v (Gain = 20 = 2v ?)

all AC.

Arduino Output = 1.00v

RC out/VR1 in = 0.29v

Wiper / IC pin 3 = 0.10v

IC Pin 5 (output to spk) = 1.00v ( Gain = 20 = 2v ?)

The Dc blocking Cap is next to spk output and is 250uf.

If the volume pot is moved away from the narrow band when sound can be heard, it doesn’t get louder or softer, it just goes off … … must be something to do with those voltages I think, they look bizarre to me. !!

I’ve attached a picture of my breadboard and also the datasheet for the LM386 - the amp is exactly as the first example shown with minimal components.

Thanks again

S

LM386N Datasheet.pdf (293 KB)

Sorry, pic was too big, I had to adjust

S

IMG_0304.JPG

My scope showed that the Uno output is a square wave

What libiary were you using. You can get audio output using the built in PWM signal, it is not a problem but some amplifiers do not like it. Rather than filtering it so much that the square waves turn into sin waves, pull back on the filtering and you will find the quality is better and louder. So reduce the vaue of the resistor by a factor of 10 and see how it goes.

This is an example of the sort of quality you can expect from the PWM output. https://youtu.be/WShVFcrFpwU

Doesn't take much filtering to sound pleasant. Here are 8 outputs mixed and run thru a cap into a self-powered/amplified computer speaker. https://www.youtube.com/watch?v=4c8idXN4Pg0 Schematic in this topic, Reply #4 http://forum.arduino.cc/index.php?topic=179761.0

The Dc blocking Cap is next to spk output and is 250uf.

The Arduino's output is 0 or 5V (before any filtering) so you should also have a capacitor between the Arduino and the amplifier's input to convert that to AC.

If the volume pot is moved away from the narrow band when sound can be heard, it doesn't get louder or softer, it just goes off .. .. must be something to do with those voltages I think, they look bizarre to me. !!

Yeah, that's strange. Maybe the pot is defective or wired wrong, or maybe it's DC into the amplifier's input messing it up.

Hi Guys

Firstly .. Doug ... you've cracked it first shot !! I added a cap between arduino signal and amp and all works now ! Amazing .. .. ..Thank you ..

Crossroads .. as a retired professional musician, I'm very impressed with the electronics, but not so much with your playing skills :D

Listen, thanks very much for everybody's efforts I do appreciate it .. .. ..

S

Well, I am more of a drummer and bass guitar player 8) MrsCrossroads is the piano player in the family.

Hi Guys

My euphoric reply yesterday evening was perhaps a little premature in hindsight. I have another problem now that I cannot understand, never mind solve .. .. .. ..

The addition of a DC blocking cap between the Arduino output and the amp input has solved the problem of very poor playback, clearly a solution to the problem I had. however, now when the volume pot is at a low setting there is a high pitched scream in the speaker, but if the pot is moved away from the low setting all sounds OK.... but .. .. a few seconds after playback has finished the high pitched scream returns, much louder and across the full volume range of the pot.

I've tried a range of blocking caps from 1uf to 1000uf makes no difference but doesn't occur if there is no blocking cap, but then I'm back to poor playback.

I'm convince it's not an amp problem but it's coming from the Arduino, but I don't understand how so I'm struggling to stop it .. .. . .

Any advice would be much appreciated .. .. .

Crossroads ... when you were reading my comments about your keyboard skills yesterday, did you feel a strange tugging of your left leg ? :)

S

Sounds like feedback caused by a floating amplifier input. Without the capacitor the amplifier input has a DC path to ground.

Try putting a 4K7 resistor from the amplifier input to ground, on the amplifier side of the coupling capacitor.

It would also help to add some good decoupling capacitors across the amplifier's power supply close to the amplifier.

Hi Mike …

Thanks for the help … …

I’ve put a 4k7 from the amp input to ground but has had little effect.

I do have decoupling caps on the supply to the amp … my amp schematic is attached … … .

I’ve ordered a couple of ready built amps today to see if they are better, but it’ll stick in my throat that I’ve been beaten by this seemingly simple task.

The Gain and Boost circuits on the schematic are currently disconnected, so the 386 gain is only 20.

Thanks again, if you think of anything more, please shout … …

S

Amp.pdf (109 KB)

Where did you get that schematic from. It looks most odd to me. C1 should be at least 1000uF.

ROFL .. .. .. .

All my own work Mike, all my own work !!

S

Can I recommend you look at the data sheet and try and draw the circuit like that. The way you have drawn it is most unconventional. You need a very large data decoupling cap, 100uF does not cut it. I used this amp a few years back and found that then.

Yes, for sure .. .. ..

The actual connections around the 386 are from the datasheet .. the rest of it I copied from here ..

http://i2.wp.com/www.circuitbasics.com/wp-content/uploads/2015/04/LM386-Audio-amplifier-with-Bass-Boost-NEW-2.png

I suppose this is another example of one of my pet hates .. .. you find a circuit published on the net that is recommended to do what you want, open the front door and tell funny jokes and then you build it and discover it doesn't actually do anything at all. I really find that most helpful and very discouraging .. .. .

I mean the amp board I've built isn't even big enough to use for a doorstop ! :)

Thanks Mike

The problem is that for some circuits the schematic is only half the story. Layout is vital in some circuits as well. This is one of those cases.

Morning .. ..

Exactly my point .. .. .. .. where on the datasheet or the Instructables Project does it ever tell you that ? .. it waits until you've spent money, time and effort before you find out there's another most important element that isn't actually mentioned anywhere, and consequently there is absolutely no chance of success !

The graphic layout on the breadboard is very pretty, but honest ?

And the net result to a novice like me is that unless you've got crystal balls any attempt is doomed to failure !

Ah well ,the grandkids can have the game and whistle whilst they play with it.

Thanks for your help Mike

S

where on the datasheet or the Instructables Project does it ever tell you that

Data sheets are not written for beginners they are written for professionals. We just tag along on their coat tails.

The graphic layout on the breadboard is very pretty,

Reminds me of a story my supervisor told me. He was one of the scientists developing radar during the war and he tells the story of the Germans capturing a VHF aircraft transmitter. They were so disgusted with the way it was wired up, not very neat. When they tried to copy it they could not get it to work because they tided it up and knew nothing about stray inductance and capacitance.

Hi Mike

I don't want to perpetuate a pointless discussion, but ..

"Data sheets are not written for beginners they are written for professionals. We just tag along on their coat tails."

I am a professional, but not a professional EE; It seems to me they are written for the clairvoyant !

I've been looking on the net this morning for a book or something meaningful about amplifier layout . .. .. almost everything I've found begins with the acronym .. IMHO .. .. .. in other words, this is what I think but don't blame me if it doesn't work !

The whole world seems to 'paddle' along on the notion of approximately right !

Anyway, I suggest we close the topic there .. .. .

Thanks again

S