Adventures with the LM386 – Part I

Before I get started, let me issue a warning: I’m assuming my reader has at least a passing familiarity with the LM386 and its applications. This isn’t really intended to be an ‘LM386 101’ course, and there are far, far better resources available if that is what you seek. This post is more of a look under the hood, and some of what I’m going to cover could potentially destroy your LM386 and any associated circuitry. Now given that we’re at worse talking about a handful of inexpensive parts, that’s probably not a big concern, but just be aware of the possibility. I subjected one chip to nearly every harebrained idea discussed here, and it went on to lead a normal life, so it can be done. Have fun!

Lest I be accused of being hopelessly stuck in the vacuum tube era, I decided to tackle something of more recent vintage – the LM386 audio amplifier chip. This chip has been around for nearly four decades now, making it almost ancient by integrated circuit standards. Yet despite its age, it remains quite popular. And it seems to be everywhere. I once heard the 2N2222 described as the ‘cockroach’ of transistors, and I suppose the same could be said of the ‘386 (perhaps vying for top honors with the 741 op amp and the 555 timer). There are a lot of good reasons for its long standing popularity, and like anything that’s been around for that long, it often seems to provoke strong feelings amongst certain groups of experimenters. Some people love it and some people just plain despise it.

One group that’s really taken to it – perhaps surprisingly – is the electric guitar community. The Internet is positively awash with small practice amplifiers and a variety of distortion pedals based upon this versatile chip. Some players have even claimed that the ‘386 sounds sort of tube-ish, whatever they mean by that nebulous description. Robotic experimenters often press the ‘386 into duty as a DC motor driver for small robots. And we Amateurs and radio experimenters generally seem to love them as well, as there’s really no easier way to attach a speaker to our creations. Better ways perhaps, but not easier.

Two groups that seem to hate it are the hi-fidelity crowd (with some justification) and people who fail to bypass the incoming power. So there’s my first admonition: bypass the incoming power. Let me repeat that – bypass the incoming power. I’ve seen some minimalist designs that fail to hang a nice electrolytic capacitor from V+ to GND, and that’s just asking for trouble with this chip. In fact, I think it safe to say that that’s most common problem I see when someone says that can’t get this little amp to work.

Okay, that admonition aside, let’s talk about the two biggest inherent problems with the LM386. For one thing, it’s fairly noisy. Oftentimes this noise issue seems to be alleviated somewhat with the aforementioned bypassing, but not always. Some people have reported that different chips exhibit far more noise than others, so if you run into a particularly nasty one, you could always try plugging in a different chip. In any event, there are more or less ‘standard’ ways of dealing with this hash, which we’ll get to in a bit. The other problem is the ‘high’ level of THD (Total Harmonic Distortion), although we need to quantify that statement a bit.

The LM386 datasheet  http://www.ti.com/lit/ds/symlink/lm386.pdf  lists a ‘low’ distortion level of 0.2%, which is pretty bad by modern day audiophile standards. Realistically however, I doubt that most people could even hear that level of distortion. There is a catch however. If you peruse the datasheet a little further, you’ll soon come across a graph that tells – as Paul Harvey might have said, “the rest of the story”. The graph is entitled “Distortion vs Output Power”, and what it basically shows is essentially ‘flat’ distortion, right up to a power output of around 125mW or so. Once you start going much above that power level however, the percentage of distortion takes off like a scalded rocket, quickly reaching an unacceptably high 10%. 10% is bad. Really bad. And while 125mW is more than adequate for headphone use, it’s not going to cut it for driving a speaker in any but the quietest of locations. There had to be a way to address this problem.

And so began my adventure.

The Quest

It seemed to me that the easiest way to keep the distortion level down would be to keep the output power as low as possible. This meant using external power transistors to actually drive the speaker, with the LM386 acting as a driver for these transistors. This would allow the ‘386 to stay well within that 125mW or less ‘butter zone.’ That concept seemed so obvious to me that I was a bit surprised to find that virtually no one else was doing it. The one exception (I’m sure there are others; I simply couldn’t find them) was a nifty little circuit designed by Lewis Loflin, “Adding a Push-Pull Output Stage to a LM386 Audio Amplifier“.

http://www.bristolwatch.com/radio/lm386_power_amp.htm

Lewis made no claims with regards to reducing distortion, but instead touted it as way to increase output power. I’m sure it did both.

Lewis coupled the output of the LM386 directly to the base of one of his output transistors. This approach greatly appeals to me, as I have something of a history of doing similar things with other integrated circuits, often in ‘violation’ of commonly accepted practice. This is definitely true of the LM386, as there seems to be an unwritten rule in place: Thou shalt not disturb the DC bias on thy sacred pins. As a result, virtually every ‘386 circuit you see has a number of coupling capacitors in place in order to provide DC isolation. Meh.

Not content to leave well enough alone, I wanted my output transistors included in LM386’s feedback loop as well. Clear down to DC. Yeah.

Let’s be clear on something here. The LM386 is NOT – contrary to popular belief – a ‘power’ op amp. Nor any other kind of op amp. That’s unfortunate in a way, because if it had been a power op amp, my quest would have been made a whole lot easier. But the ‘386 designers obviously wanted to keep the external parts count to a minimum. Consequently, they buried the feedback loop deep inside the chip. Let’s look at a partial schematic….

 

Figure 1

Figure 1

My partial schematic (fig. 1) is a whole lot more ‘partial’ than the partial schematic shown on the datasheet, but it includes everything of interest here, as well as my own nomenclature for some of the internal bits. I’ll be referring to this diagram quite a lot.

What’s interesting about the circuit is that while it basically follows the usual topography for a modern power amplifier, i.e. a differential input stage, a voltage amplifier stage, and a class B output stage, the feedback (listed as R5 in my diagram) is quite atypical for such a setup. Given its topography, you’d expect to see voltage feedback going to the negative input of the differential pair. Instead, what you have in fact is current feedback going to the positive ‘half’ of the differential pair. Weird but functional. I can only assume the designers did this in order to give the end user full access to either differential input. Or both. By contrast, operational amplifiers have no such internal feedback loop, as you’re fully expected to provide it externally.

Disaster

Blissfully oblivious to the perils of ignoring the internal feedback path, I decided to try a little op amp-esque style external feedback (fig. 2). The plan was relatively simple; run the output of the external push-pull amplifier (at 1/2 Vcc) through a 2:1 voltage divider, knocking it down to 1/4 Vcc. Run this to the inverting input on pin 2. Compare this to a reference voltage on the non-inverting input on pin 3. I figured if I tied pin 3 to Vcc through a 150k resistor, I’d get exactly 1/4 Vcc dropped across the internal 50k resistor. Since the differential amplifier would attempt to keep these two inputs the same, the quiescent output of the push-pull stage would always be forced to 1/2 Vcc. (Again, this is only a partial schematic.)

 

 Figure 2

 Figure 2

Clever, no? No. I’m reminded of a line from the movie, The Matrix Reloaded, as the Architect explains the creation of the very first Matrix to Neo: “…it was a work of art, flawless, sublime. A triumph equaled only by its monumental failure.”

The only part of my cunning plan that actually worked was that the non-inverting input did indeed park itself nicely at around one quarter Vcc. But as the two independent feedback loops struggled for control, the output basically slammed into the positive rail, rendering any further tests pointless. It was quite a useful failure really, as it forced me to work with the internal feedback loop, rather than simply ignore it.

Setting my sights a bit lower, I decided to see if I could at least coax the output of the LM386 to 1/2 Vcc. This may seem confusing to some, as it’s generally believed that it already does that. Even the datasheet suggests as much, claiming that, “…the output automatically biases to one-half the supply voltage.” In actuality however, the output biases to 1/2 Vcc + Vbe – theoretically at least. Now in most situations that’s a distinction without a difference, but in my quest to understand this little beasty, it was significant. So assuming a Vbe (voltage base to emitter) of 0.6 volts, let’s take another look (fig. 3)…

 

Figure 3

 Figure 3

The differential input stage is comprised of transistors Q2 and Q5, with Q1 serving as an emitter follower to drive Q2 and Q6 likewise serving as an emitter follower to drive Q5 (again, that is strictly my nomenclature). The only significance of this arrangement for us DC-wise is that it means each leg of the input stage is sitting at approximately 2 * Vbe above ground, as we’re going through two base- emitter junctions on either side of the differential stage. Since we’re assuming Vbe is 0.6 volts, that means the voltage on the emitters of both Q2 and Q5 should equal approximately 1.2 volts. Assuming that our supply voltage Vcc is equal to 10 volts, let’s calculate the current through Q2: (Vcc – VeQ2)/(R1 + R2) = (10-1.2)/(15k +15k) = 293.3uA.

Transistors Q3 and Q4 form a current mirror. This circuit ensures that the current in the Q5 leg equals (mirrors) the current in the Q2 leg, thus making the current through Q5 equal to 293.3uA as well (this isn’t strictly true, as the Q2 leg is also supplying the base current for both Q3 and Q4, but the imbalance is small enough to be safely ignored for our purposes.). Working our way back up, we come across resistors R3 and R4. What is their contribution to all this? Since the voltage differential across these two resistors is essentially 0 volts (VQ2e – VQ5e = 1.2V – 1.2V = 0V), there can be no current flowing through them under static DC conditions. We may ignore them for now.

We’re almost there.

Since we decided that the current through Q5 is equal to 293.3uA, and that there’s no current flow through R3 and R4, that leaves us only one path: through resistor R5 to the output on pin 5. The voltage drop across R5 will be equal to 293.3uA * 15k = 4.4 volts. But one leg of R5 was already 1.2 volts above ground, so our output voltage will be 4.4V + 1.2V = 5.6 volts. In other words, (1/2 Vcc) + Vbe.

So how do we set the output to exactly 1/2 Vcc? Working backwards, IF the output were at 1/2 Vcc, then the current flow through R5 would be equal to (5V – 1.2V)/15k, or 253.3uA. Somehow, we need a way to soak up that 40uA of ‘excess’ current (293.3uA – 253.3uA = 40uA). Get ready…

 

Figure 4

Figure 4

What we’ve done (fig. 4) is add a 220k offset resistor (labeled Ro) from Vcc to pin 1. This provides a secondary current path for Q5, essentially diverting some of the ‘excess’ current away from resistor R5. How much? Well IRo = (Vcc-VQ5e)/Ro = (10V-1.2V)/220k = 40uA. This leaves 253.3uA to flow through R5, thereby setting the output voltage to exactly Vcc/2.

Now in reality, there’s very little point in doing this, at least for most audio applications. For one thing, that extra 0.6 volts isn’t going to make any appreciable difference to the operation of 99.9% of the LM386 circuits out there. The only exception might be if one were trying to operate the chip at as low a Vcc value as possible (typically four to five volts, depending upon the model of chip), and one wanted as much available voltage swing on the output as one could get. But even with that, those current mirror imbalances we dismissed a little while ago are often sufficient to drive the output to half Vcc anyway, so there’d be nothing to gain. It might even force the output in the opposite direction (closer to 1/2 Vcc – Vbe). The other problem with this approach is that it’s voltage dependent; in other words, the value of Ro will have to be changed for different values of Vcc. For example, if we were supplying 12 volts to the chip (as opposed to 10 volts), then Ro would need to be increased to 270k. I’ll leave it to you, gentle reader, to work out the math.

As an exercise in understanding the chip however, this experiment proved invaluable. Setting aside the theoretical for a moment, I lashed together a more or less ‘standard’ LM386 amplifier circuit, minus all the capacitors needed to pass a signal through the thing, as I was really only interested in the DC component on the output. Curiously, while the applied voltage was ten volts, the output on pin 5 was only 4.89 Vdc. Pressing on, I installed the 220k resistor. The output voltage then dropped to 4.15 Vdc, for a difference of 0.74 Vdc. This was fairly close to the predicted drop, although I wondered what the actual value of Vbe was (remember, I had assumed 0.6 volts). Since the voltage on pin 1 should be approximately twice Vbe (because we’re measuring Q5Vbe and Q6Vbe in series), this seemed as good a way as any to find out. Pin 1 had exactly 1.4 Vdc on it, indicating a ‘global’ Vbe (I say ‘global’ because all the transistors on the chip have essentially identical characteristics, and hence identical Vbe values) of 0.7 volts. So my output was off from what might be expected by a mere 40mV. This was within the range I might have expected just based upon the tolerance rating of the resistor.

Could we go the other direction? Let’s assume the output voltage was low – as was the case with my test subject. [I’m not sure why this was the case. Maybe I just poked and prodded on that unfortunate IC one too many times, or maybe Radio Shack just didn’t give me the pick of the litter that day. Who knows?] Sure can. Let’s say we wish to increase the output voltage by Vbe. Given the previous analysis, it stands to reason that we’d need to supply an additional 40uA of current through R5, rather than divert it elsewhere as we did before. That’s easy….

 

Figure 5

Figure 5

Here we’ve made two simple changes (fig. 5). Ro has been reduced from 220k to 30k [Twice the value of R5. Interesting coincidence, eh? Or not!] and the ‘other’ end of Ro now goes to ground instead of Vcc. It’s in effect become a 40uA current source (VQ5e/Ro = 1.2V/30k = 40uA). Best of all, it’ll work the same way regardless of Vcc, because VQ5e is more or less fixed at 1.2V.

So then, we’ve ‘discovered’ that we can shift the DC output level of an LM386 either up or down (within reason) by simply applying an external resistor to pin 1. And while this analysis has focused on adding or subtracting a value equal to Vbe, there’s nothing stopping the experimenter from tweaking the resistor values a bit in order to obtain other levels of offset. You could even try something crazy like this…

 

Figure 6

Figure 6

A simple modification like this (fig. 6) should give the intrepid experimenter the ability to adjust the DC output level plus or minus maybe a volt or so, assuming a 10 volt supply. I haven’t tried it myself though, so I make no guarantees here. I’m simply throwing it out there as an idea. If someone is so inclined to try it, make sure to include the 10k and 100k range limiting resistors, or else chip smokage is all but assured! I’d love to hear from anyone who attempts it.

But why do it at all? For audio applications, I honestly can’t think of a compelling reason. But it might make an interesting modification for the small robot crowd. They often use the ‘386 in a kind of bridge configuration with a pair of small drive motors on the output. They could use something like this to either dial out an unwanted offset, or else purposely dial one in. I suppose the distortion pedal crowd might use something like this to play around with some asymmetrical clipping, but this is likely a stretch.

Sharp eyed LM386 gurus have probably already noticed that these modifications will increase the signal gain of the chip slightly, as any resistance we hang off of pin 1 is effectively in parallel (to AC) with R3 and R4. But while this is certainly true, the resistors discussed are so large relative to R3 and R4, that any increases in gain would be measured in fractions of a dB, and would be completely inconsequential.

Course, I still really haven’t touched upon my original goal of coupling this chip to a pair of output transistors and including them within the DC feedback loop. I’ll get to that on the next installment. Here’s a little something to ponder in the meantime though. We’ve discussed modifying the DC output of the LM386 on the basis of changing the current flow within the Q5 half of the circuit, via pin 1. But don’t forget about that Q3/Q4 current mirror. We can (and will) just as easily affect the current flow through Q5 by modifying the current flow through Q2. The current mirror will ensure that Q5 sees these changes too. Then there is the added advantage that such changes will be ‘hidden’ from the signal path, quite unlike the resistors we’ve been hanging off of pin 1. So get ready to meet pin 7, the infamous ‘Bypass’ pin. And judging by the information – or lack thereof – about pin 7 that I’ve found – or not – on the Internet, it seems to be widely misunderstood, and often thought to do nothing at all. But I beg to differ. More importantly, as I’ve largely pooh-pahed the notion of changing the output voltage for the sake of changing the output voltage (except for you robot experimenters), we’ll look at just why we’d want to mess with the Q5 current, and it has little to do with changing the quiescent voltage on pin 8. Hopefully this introduction has given you some insight into the methodology behind this madness.

2 thoughts on “Adventures with the LM386 – Part I

  1. The LM386 actually can work in the feedback configuration shown in Figure 2. Basically what has to happen is that there needs to be a bypass capacitor across pins 1 and 8 to boost the gain to 200, and then the output for the feedback voltage divider needs to be taken after the output coupling capacitor at the load to eliminate the DC offset. The feedback resistors need to be kept small in comparison to 50k, as the lower one is essentially in parallel with the internal resistor to ground.

    At that point it will sort of just act like a lousy power op amp, as only a gain of 200 is available for feedback correction. And it will oscillate like crazy if you try to use it in any more complicated “standard” op amp circuits, or look at it funny. I’m pretty sure that even in this configuration it would be unstable if you tried to hang external transistors on it and include them in the loop.

    • You’re right of course, although my initial goal was to force the output transistors to ‘park’ themselves at exactly 1/2 Vcc, which is what led to the failed DC feedback configuration in figure two. Connecting the network after the coupling capacitor would have prevented the ignoble power rail slam, but then I would have simply been left with a rather pointless and unstable AC feedback circuit, with all the associated problems you mentioned.

      At first glance, it might seem that the additional negative feedback would actually help things somewhat, but I suspect the AC instability is caused by the exact same factors that led to the DC instability; two feedback networks fighting for control. So the high gain you suggest is necessary just to allow one of the networks to ‘win’. Barely.

      As I alluded to in the post, it was a useful and educational failure – albeit a rather annoying one, as I was so sure it was going to work. Such is life. Anyway, I appreciate your taking the time to read and comment on this post. Your observations were spot on!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s