Sunday, 29 December 2019

Audio from Arduino Due's analog outputs using LM386


Due's DACs provide 0-3.3v (actually less) and are rated at 3mA max. As far as I know, common speaker/headphone impedances range from 8Ω to a few hundreds, so driving these from the DACs will destroy it at best. I guess I could stick a series resistor, but it would need to have a huge resistance and would greatly reduce the output volume.


According to Arduino's SimpleAudioExample I can drive a speaker from Arduino's DAC using an LM386 amplifier. Is it because \$\rm{R_{in}}\$ (datasheet, page 2) is the LM386 input resistance, so \$I = \frac{V}{R_{\rm{in}}} = \frac{3.3\rm{v}}{50\rm{k\Omega}} = 66\rm{\mu A}\$, which is a lot less than the max 3mA the DACs can handle?


Arduino's SimpleAudioExample circuit looks like LM386's "Minimum Parts" example (datasheet, page 5) with a 10μF capacitor between \$V_{in}\$ and the pot:



Arduino's SimpleAudioExample circuit


Is this extra cap AC coupling the DAC with the LM386 input to remove the implied \$\frac{+3.3\rm{v}}{2}\$ DC bias at the input?


I hope I got all that right.


Even at a low 20x gain setting (pins 1-8 open) \$20*\frac{\pm3.3}{2}\ \rm{volts}\$ seems like a lot! Also, max input voltage is listed at \$\pm0.4\rm{v}\$ (datasheet, page 2). Is something (I guess the pot) reducing the input voltage and preventing huge Vout? Could it accidentally be set to deliver the whole 3.3v input and break the speakers?


What am I missing?



Answer



Well, it's shown as a gain of 200 amplifier, and the signal can be 1.18V RMS, so if it was amplified by 200 and fed into an 8\$\Omega\$ speaker, you'd have almost 7kW going into that speaker. That's not what's going to happen, fortunately.


The LM386 can't output more than Vs/2.8 RMS (+/- Vs/2 peak) volts so you don't need to worry too much. Once the output gets close to Vs or GND it stops.


It will start distorting horribly if you overdrive it (turn the volume up too high) and make it hit the limits. That's called "clipping". A ~100K resistor in series with the input would keep that from happening, and keep the input within the +/-400mV range.


You're correct about the purpose of the capacitor and about the input impedance.



No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...