It takes a small signal, a tone from a board pin divided down or a microphone, and drives a 4 to 32 ohm speaker with up to a few hundred milliwatts. Its inputs are referenced to ground and its output centers itself on half the supply, so the simplest circuit needs no parts but a capacitor to the speaker. It is in the part panel under Timers and analog.
Aliases: LM386N, LM386N-1, LM386N-3, LM386N-4, LM386M-1, audio amplifier, speaker amplifier, audio power amplifier.
Pins
In package order from TI's data sheet (SNAS545D), pin 1 at the notch, counting down the left side and back up the right:
| Pin | Name | What it does |
|---|---|---|
| 1 | GAIN1 |
Gain setting. Open with pin 8 for a gain of 20. |
| 2 | IN- |
Inverting input, 50 k to GND inside. Wire it to ground when unused. |
| 3 | IN+ |
Non-inverting input, 50 k to GND inside. The signal goes here. |
| 4 | GND |
Ground. |
| 5 | VOUT |
The output, sitting at half the supply with no signal. |
| 6 | VS |
The supply, 4 V to 12 V (5 V to 18 V for the LM386N-4). |
| 7 | BYPASS |
The middle of the bias string. A capacitor to ground steadies it. |
| 8 | GAIN8 |
Gain setting. A 10 uF capacitor from pin 1 to here makes the gain 200. |
The data sheet names pins 1 and 8 both GAIN; here they are GAIN1 and GAIN8 so
a wire can say which.
How to wire it to a speaker
VSto the battery's plus,GNDandIN-to ground.- The signal into
IN+. Keep it under 0.4 V either way: a 5 V pin needs a divider, such as 10 k from the pin and 220 ohm to ground (0.108 V). VOUTthrough a 220 uF or 250 uF capacitor (plus side toward the chip) to the speaker, and the speaker's other tag to ground. The capacitor blocks the half supply the output sits at and passes the sound.- For more gain, 10 uF from
GAIN1toGAIN8(plus side on pin 1). A resistor in series with that capacitor sets any gain between 20 and 200.
The built-in LM386 speaker amp wires all of this to an Uno playing a tune with
tone(). No library is needed: the LM386 has no code, only wiring.
The model
The model is the schematic printed on page 1 of the data sheet, resistor for
resistor: 50 k from each input to ground, 15 k from VS to BYPASS and 15 k on to
the input pair, 150 ohm and 1.35 k between the pair's emitters with pin 8 between
them, and 15 k of feedback from VOUT to pin 1. A current mirror makes the pair's
two sides carry the same current, and the output drives VOUT until they do. What
the data sheet says then comes out of the circuit on its own:
- The output sits at half the supply, 4.5 V on 9 V, with no signal.
- The gain is 20 with pins 1 and 8 open. The network gives 1 + 2 x 15 k / 1.5 k = 21, 26.4 dB, which TI's table lists as 26 dB typical.
- The gain is 200 with 10 uF from pin 1 to pin 8. The capacitor shorts the 1.35 k for audio, and the network gives 1 + 2 x 15 k / 150 = 201, 46 dB.
- Parts you add on pins 1, 7 and 8 work the way the data sheet describes: a resistor and capacitor in series from pin 1 to 8 for a gain in between, an RC from pin 1 to pin 5 for bass boost, a capacitor on pin 7 for supply ripple.
The numbers
| Model | TI data sheet | |
|---|---|---|
| Gain, pins 1 and 8 open | 21 (26.4 dB) | 26 dB typical |
| Gain, 10 uF from pin 1 to 8 | 201 (46.1 dB) | 46 dB typical |
| Bandwidth at gain 20 | 300 kHz | 300 kHz |
| Input resistance | 50 k | 50 k |
| Output with no signal | half the supply | half the supply |
| Output swing | 0.75 V inside each rail | about the supply less 1.5 V peak to peak (Figure 6-3) |
| Output current | 0.45 A peak | about 0.4 A into 8 ohm (Figure 6-3) |
| Quiescent current | 4 mA at 6 V | 4 mA typical, 8 mA maximum, at 6 V |
The probe is VOUT in volts above GND.
What it does not model
- Distortion. The data sheet's 0.2% at 125 mW is a clean output here.
- Supply current against supply voltage. The 4 mA is drawn as a resistance, so it is right at 6 V and grows with the supply: 8 mA on 12 V, where a real one draws about 4.7 mA.
- Input bias current. A real one's open inputs float to about 12.5 mV; here they sit at 0 V.
- Heat and damage. Nothing burns out past the 15 V absolute maximum supply, the ±0.4 V input rating or the package's power limit. An input that is too big clips the output instead.
- Oscillation. A real LM386 is only stable at gains over 9 and can oscillate on a long-wired breadboard without the 10 ohm and 0.05 uF network from pin 5 to ground. The model is always stable.
- Loudness. The speaker part shows the note it hears, not how loud it is.
Common mistakes
- The signal is too big. A 5 V pin straight into
IN+asks for a 100 V swing; the output clips at the rails and sounds harsh. Divide it down first. - No capacitor to the speaker. The output sits at half the supply, so a speaker
wired straight from
VOUTto ground takes a steady current and heats up for nothing. IN-left floating at gain 200. The data sheet says to ground the unused input, or the gain drops and the chip can oscillate.