-1
\$\begingroup\$

LM386 datasheet.

I'm working with an 8-bit, R2R-ladder DAC that is connected to the LM386 that is then connected to an 8ohm/3W speaker.

The output of the DAC is connected to pin 3 of the amplifier, which is configured accordingly to page 10 of the link (with the exception being pin 7 is left open and pin 6 is driven by 5v).

I've used this same configuration with a 6-bit DAC and have had success, but adding the extra 2-bits seems to be causing some problems.

The input for the DAC comes from a TM4C123: the digital wave is produced in software by creating an array of size 512 (needs to be double 2^8 to account for Nyquist effect) containing values between 0-256 arranged so that if they were plotted over time, we would get the shape of a sine wave.

A SysTick timer is used to determine the frequency. This is accomplished by incrementally outputting one value from the array with each interrupt.

If I take a voltmeter to the DAC's output, I get a DC reading of about 1~2V (If I connect the speaker directly, you can barely hear the sine wave produced).

If I connect the DAC to the amp, the voltage output from the amp is around 7~8V. If I connect the speaker, no sound is produced. Then, if I disconnect the speaker and do another voltage reading from the amp, it now reads about 0.11V.

The only way to get it back to that 7~8V reading is to reverse the direction of the 250uF capacitor from the schematic on page 10. But again, connecting the speaker produces no sound and rereading the volts from the amp gives around 0.11V.

I'm unsure what the issue could be since I've had success with no issues when using a 6-bit DAC.

The following schematic demonstrates the connections using a 6-bit DAC. The 8-bit utilizes two extra GPIO pins and additional resistors

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ Schematic, please \$\endgroup\$
    – fifi_22
    Dec 14, 2020 at 4:36
  • \$\begingroup\$ Looking at the schematic, it appears to create a short if you tie pin 2 to the same ground as 4. I have it grounded and had it grounded when i was working with the 6-bit DAC. But as I mentioned, it was working adequately with the 6-bit DAC and my voltage readings were adequate when using the 8-bit up until I connected the speaker. I'm going to assume the DAC is bipolar since I built it on my breadboard using 1 and 2K resistors, although I'm not to sure about DAC polarities. \$\endgroup\$
    – Fabian
    Dec 14, 2020 at 6:35

1 Answer 1

1
\$\begingroup\$

The R2R is driven by a 3.3V GPIO pins, so the output is between 0 and 3.3V and it has an output impedance of 1 kohm. It can't be bipolar. It needs to be AC coupled to the LM386 input to remove the 1.65V DC bias.

The absolute maximum input voltage to LM386 is -0.4V to +0.4V, or 0.8Vpp, so the 3.3Vpp output from DAC is too much. Fortunately the 1kohm impedance can limit the current so it may not be damaged, but it's possible.

Since the gain of LM386 is 20, and the supply voltage is 5V, it means that output to speaker is about 2.0 to 3.0 Vpp, the input must be maximum of 0.10 to 0.15 Vpp. So the DAC output must be divided down by about 30.

Even dividing by 30 would result in full volume, so in reality the voltage should be divided even more, perhaps with a volume pot.

Edit: It seems that the circuit has a gain of 200, not 20, so the DAC output needs to be divided by 300. This makes little sense, don't use gain of 200.

\$\endgroup\$
2
  • \$\begingroup\$ Hmm. Never mind. It's late for me. Sorry about the trouble. The current mirrors and diff-pairs are squished tight. Into mild saturation. But the amp does work okay. Better if the biasing resistors are allowed to float (better with capacitors.) But it's not as serious as I'd earlier imagined. I'll remove my other comments. My mistake. \$\endgroup\$
    – jonk
    Dec 14, 2020 at 10:23
  • \$\begingroup\$ @jonk you are quite right. The datasheet does mention that when using higher gains (as in the circuit), the input should not be directly grounded or problems will appear. It's just that higher gains should not be used in this circuit to begin with, so grounding it will not be a problem when gain is set to 20 like my answer expects. \$\endgroup\$
    – Justme
    Dec 14, 2020 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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