Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

ATTiny is generating PWM based tones with 32kHz sampling rate. Then I've created R-2R DAC and then trying to amplify it for speaker. However, LM386 is sinking signal from R-2R. If I don't connect LM386 then there is signal on DAC output. How to correct this circuit?

Also I'm planing to make low pass filter, to filter out PWM hiss during playback and some white noise during silence. But I will open separate question for that.

enter image description here

share|improve this question
    
There's a minor error in your DAC: R4 should be 20K (not 10K). But I have no idea about the answer to your main question. When the signal dies, do you still see toggling at the output pins of the MCU? –  Dave Tweed Dec 14 '12 at 20:16
    
There are some strange clicks on R-2R output, which corresponds to my control SPI signalling, which is not shown here. What I tried is to remove LM386 and connect high impedance external amplifier to R-2R out and the signal is fine then. –  Pablo Dec 14 '12 at 20:19
    
I take it you don't have a scope, then. OK, what happens if you connect both amplifiers simultaneously? What if you connect any other signal source to the input of the LM386? –  Dave Tweed Dec 14 '12 at 20:23
    
yep, ain't got scope... if I connect both amplifiers, I just hear series of clicks whenever tone supposed to be played back. If I remove ATTiny and connect external audio source to pin 3 of LM386 it amplifies the signal as expected. –  Pablo Dec 14 '12 at 20:30
1  
So, for some reason, the MCU is not generating the tone when the LM386 is connected. Do you have bypass capacitors on the power supply pins of all ICs? –  Dave Tweed Dec 14 '12 at 20:33

2 Answers 2

up vote 4 down vote accepted

LM386 has a ground-referenced input according to its datasheet so you need an AC coupling capacitor ( 1uF or so will do; even 0.1uf unless you need bass!) between the DAC output and pin 3.

As it is now, if you have a meter, you will probably find Vout (pin 5) is very close to Vcc (5V) instead of Vcc/2 (2.5V).

share|improve this answer
    
I've tried to connect 4.7uF between ground and pin 3, still no tone, just described clicks. Yes, on pin5 the voltage is about Vcc. –  Pablo Dec 14 '12 at 20:45
    
COUPLING not decoupling capacitor! From pin 3 to R1/R3, replacing the wire. –  Brian Drummond Dec 14 '12 at 20:56
    
If in doubt, look at Cc on page 6 of the datasheet. Don't bother with the resistors or C1 unless it's too loud or distorted - though it probably will be, since the gain is 20... –  Brian Drummond Dec 14 '12 at 21:03
    
The AC coupling capacitor solved the issue. thank you. I'm just not sure what type it has to be. The value is 1uF now. –  Pablo Dec 15 '12 at 0:11
    
Type is not critical. But if it's electrolytic or tantalum, + goes to the DAC. –  Brian Drummond Dec 15 '12 at 10:29

The LM386 has a fixed minimum gain of 20. As such, no matter what your DAC value is, you're going to get 5V as the output.

If you want to buffer the output of your R2R DAC, you'll need to use a proper op-amp. Something like a TL081 would work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.