Pages: [1]   Go Down
Author Topic: DAC & LM386  (Read 1232 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26523
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Gang,
I am making card to drive a single channel of audio into a little 8 ohm hobby speaker.
Using the adafruit wave shield DAC, but going into an 5V powered LM386 instead of some TL072's.
Got a lowpass filter to take out swithing noise, got that AC coupled into the LM386. And then AC coupled again out to the speaker.
Do I need to DC bias the signal into the LM386 so its output can sit at 2.5V & swing +/-2.5V from there?
If so, what are good resistor values? 5K? 20K? 100K?

If not, do I put R5 in series with C21 so I can let the DAC go 0/5V and reduce the level into the LM386 with its built in gain of 20?

12-bit DAC datasheet
http://ww1.microchip.com/downloads/en/DeviceDoc/22248a.pdf
LM386 datasheet
http://www.ti.com/lit/ds/symlink/lm386.pdf


* dac_amp.png (10.81 KB, 1008x509 - viewed 29 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26523
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

bump
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Anchorage, AK
Offline Offline
Edison Member
*
Karma: 42
Posts: 1176
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(Second attempt because I'm still green and misunderstood some things the first time. smiley-razz)

Why DC-block between the DAC and op-amp, then reconstruct the DC offset with a voltage divider?  Is it because the DAC will idle at 0v when you're not playing audio?  (EDIT:  Datasheet quote from next post says idle is centered, but that could be overridden depending on the idle data stream, if there is one.)

(EDIT:  Made some changes here.. I didn't calculate all the filters right.)

OK... the R8/C18 filter cutoff is 318Hz?  Is that right?  Seems awful low.  If you chose 100nF for C21 and 100k for R5/R6, you'll end up with a 15Hz cutoff on the highpass (DC block).  I wouldn't use this on an audio circuit for full-bandwidth -- not enough margin to avoid touching sub-bass frequencies -- but for a project board, that's probably cool.

(EDIT 2:  Missed some of the subtleties with the feedback loop.)

If I'm calculating this right, it looks like C15/R7 form a 318KHz lowpass.  You're not using feedback at all.  I'm still learning all the ins and outs of op-amps, but I think that turns the op-amp into a comparator.  My simulator shows mere microvolts on the output with the inverting input grounded and no feedback.

If you connect R7 to the inverting input instead, you get close to a voltage follower, which basically turns the 386 into a current amplifier capable of driving the signal level into 8 ohms.  I think you'll still have to tweak the filters though.

If this were me, I'd look into removing the DC-blocking on the input, fix the filters, buffer with an opamp to simplify any possible interactions, and just use a simple feedback loop with a resistor to set gain on the 386.
« Last Edit: May 25, 2012, 02:14:54 pm by SirNickity » Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 93
Posts: 3968
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've never seen bias resistors like that on an LM386. I'd leave the input AC-coupled, and eliminate R5 and R6. Datasheet says:

Quote
The inputs are ground referenced while the output automatically
biases to one-half the supply voltage.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26523
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks guys.

Nick, there is no feedback loop, I have it wired for a gain of 20 device like the datasheet shows with the values called out for stable operation.
I want to mimic the output here but into a speaker instead of  headphones.
http://www.ladyada.net/images/wavshield/v11/wave11schem.png

Jack, I was looking for the justification to not bias the input, guess I missed that part about the output  being autobiased.
I have room on the card for R5/R6. If I connect the top of R5 to C21 instead of +5, I can put a trim pot across there to play with volume control, find settings that work well and then put fixed values in. Or use an external pot.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Anchorage, AK
Offline Offline
Edison Member
*
Karma: 42
Posts: 1176
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, it has an internal feedback loop.  That makes a lot more sense now.  I was treating it like a normal op-amp, like many of the TI/National power op-amps are.  (I've used an LM3886 50W chip-amp.)

So, the filter on the output is an RF filter for stability -- hence the high cutoff frequency.  Makes sense.

The input filter still looks wrong to me, but I could be miscalculating it.  Did you mean to low-pass at 318Hz?  The waveshield link you posted is filtering at 10kHz.  Still low for my standards, but I don't think the DAC is quite up to CD-quality output anyway.

IME, speaker and headphone output isn't much different except that you expect the load impedance to be much lower for speakers.  Headphones are usually 64 ohms or higher.  (Some are 32, and they're considered difficult loads.)  In other words, since the 386 can handle a low-impedance load, you look OK to me.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 525
Posts: 26523
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Nick.
The Lowpass filter was just a couple components as placeholders, hadn't selected an actual cutoff frequncy yet.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: