Go Down

Topic: Amplifying Wave File Output (Read 1 time) previous topic - next topic

Musicmanager

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

DVDdoug

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.

Quote
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?

Quote
so I added an RC network ( 3 x 1.5K resistors & 3 0.01uf caps )
Is there also a DC blocking capacitor?

Quote
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?



Musicmanager

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 !! :)

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

Musicmanager

Sorry, pic was too big, I had to adjust


S

Grumpy_Mike

Quote
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

CrossRoads

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
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

DVDdoug

Quote
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.


Quote
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.

Musicmanager

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


CrossRoads

Well, I am more of a drummer and bass guitar player 8)
MrsCrossroads is the piano player in the family.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Musicmanager

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

Grumpy_Mike

#10
Nov 02, 2016, 09:36 pm Last Edit: Nov 02, 2016, 09:37 pm by Grumpy_Mike
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.

Musicmanager

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

Grumpy_Mike

#12
Nov 02, 2016, 10:35 pm Last Edit: Nov 02, 2016, 10:38 pm by Grumpy_Mike
Where did you get that schematic from. It looks most odd to me.
C1 should be at least 1000uF.

Musicmanager

ROFL .. .. .. .

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

S

Grumpy_Mike

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.

Go Up