LM386 Datasheet
It looks like this:
The device was first made in 1970's after the LM741 and LM324 by National Semiconductor. It has a wikipedia entry but there isn't much information on it. For those that are interested here is the link:
http://en.wikipedia.org/wiki/JRC386
It uses the standard OP-Amp pin out (inputs are on pins 2 and 3 and the output is on pin 5. Power is applied on pin 6 and ground is applied to pin 4. The gain of the amplifier is set by pins 1 and 8 and pin 7 is used for an optional bypass used to remove unwanted noise.
In order to use the device there are several reference circuits present in the datasheet and these will all work fine but because this integrated circuit has been around a long time there a also many other circuits around on the internet shared by enthusiasts everywhere. Rather than 'reinvent the wheel' I am going to talk about an improved amplifier circuit called the Ruby LM386 Amplifier which builds upon the reference design and provides gain and volume control and an FET input filter. I first learnt about the Ruby LM386 Amplifier from the most excellent website:
http://www.runoffgroove.com/ruby.html
It's a great site with loads of information about audio amplifier circuits and in particular the LM386. I chose the Ruby circuit because it has a low level of complexity, low component count and costs and sounded excellent!
Here is the circuit for the Ruby LM386 Amplifier:
I suppose I should really explain how this circuits works...The input jack shown on the left side of the diagram takes an audio signal from a suitable source such as an MP3 player or an Electric Guitar or Raspberry PI Audio output or whatever the user likes. This signal will be an alternating signal at around 100 mV. This input is sent directly to the gate of the 2N5457 JFET (Junction Field Effect Transistor). The drain of this transistor is connected to +12 Vdc and the source of the transistor is connected to 0 Vdc or ground via a 3k9 Ohm resistor as well as a 47nF capacitor. The transistor will always be on as this device is an N-Type Junction field effect transistor - When the input signal exceeds the VGS off Threshold of the FET the transistor will NOT allow current to flow from the drain out to the source and to the rest of the circuit. The VGS Off parameter for the 2N5457 is 6 Vdc according to the datasheet and therefore this transistor will always allow current to flow to the rest of the circuit as long as the signal voltage present at the gate is less than 6 Vdc. In the case of this circuit we are using this FET as a signal level limiter and filter. Signals which are too high and too fast stop the transistor switching on and are not amplified. Signals which are too fast and too high cause audible hiss and pops and scratches to be heard by the user.
2N5457 datasheet
The next component in the circuit is a 47 nF capacitor. This capacitor prevents any DC voltage being presented to the negative LM386 amplifier input and is known as a DC blocking capacitor. The 47 nF cap also affects the circuit's bass response and changing this value to a higher capacitance will change the circuit's frequency response. The 10k variable resistor next is the volume control. It is used to reduce the amount of signal presented to the LM386 amplifier negative input which directly affects the output - if there is less signal at the input there is less signal at the output. The gain of the LM386 amplifier (the amount the input signal can be increased) is set by the 1k variable resistor on pins 1 and 8. The gain is the amount the input signal can be increased - not quite the same as volume but audibly the result is similar. The gain sets the maximum loudness that can be achieved, the volume sets the amount of input signal present. If the designer wants a fixed amount of gain this variable resistor could be replaced with a fixed resistor or for maximum gain leave the pins effectively not connected and place a 10 uF capacitor across these pins.
The 100 nF capacitor on pin 7 of the LM386 is a bypass capacitor - it removes some of the unwanted high frequency signals that might be present during the amplification stage - its necessary for high gain operation (which this is). The output of the LM386 has a 10 Ohm resistor and a 47 nF capacitor connected to ground. These components improve the bass amplifier response meaning lower sounds are reproduced better. Next from the output of the LM386 amplifier is a 220 uF capacitor used to block any DC signal that might be introduced by the amplification and finally a speaker is present so that the user can hear the sound!
Here are the parts needed if one were going to make the circuit:
Qty | Value | Description | Parts |
1 | - | 3.5mm Audio Jack | U2 |
1 | - | 2.0mm DC Barrel Jack | CN1 |
1 | 100 nF | 25V Ceramic Capacitor | C4 |
1 | 100 uF | Capacitor Polarized | C1 |
1 | 10R | 1/4W Resistor | R3 |
1 | 10k | 10k Variable Resistor | U$2 |
1 | 1M5 | 1/4W Resistor | R1 |
1 | 1k | 1k Variable Resistor | U$3 |
1 | 220 uF | Electrolytic Capacitor | C2 |
1 | 2N5457 | 2N5457 N-channel JFET | U$1 |
1 | 3k9 | 1/4W Resistor | R2 |
2 | 47 nF * | 25V Ceramic Capacitor | C3, C5 |
1 | LM386 | Audio power amplifier | U1 |
1 | 8 Ohm Speaker | 8 Ohm Speaker | SP1 |
* If people want the improved bass response then the value for C3 should be 470 nF.
These parts are available from all good electronic component vendors - RS Components, Farnell, Rapid Electronics and one of my personal favourites in the UK - Bitsbox
They are a fantastic vendor and charge reasonable prices for low quantity orders and once an order is processed it is normally shipped and posted and arrives the very next day - awesome!
Once a circuit has been designed before constructing a finished version its always a good idea to prototype first. I always prefer it when I have prototyped first because it means I can change values and see the results and tailor things if required. Even better before prototyping if you have the software you can simulate. I use National Instruments Multisim to simulate my electronic circuits but there are many available - LT Spice is also very good. Here is a short video showing the circuit being simulated:
Just for fun I also used the circuit simulator to calculate the circuits frequency response. This information tells the designer how well the amplifier will reproduce sound from low level bass sounds, through the mid tones and to the treble tones. In practice this would be performed with a signal generator and a signal sweep from 20 Hz to say 20 MHz. As I still haven't finished my signal generator we will have to settle for simualtion ;). Here is the amplifier's frequency response - I performed an AC analysis on the output of the circuit:
LM386 Ruby Amplifier frequency response using a 47nF Capacitor at the input |
What this graph shows is that lower frequency signals (bass sounds) are not as well reproduced as higher frequency sounds because the red trace is lower on the left side than on the right side. The black vertical lines show the frequency range of human hearing. If we were to change the circuit configuration and component values slightly it might be possible to improve the amplifier's frequency response - to try to make sure all the tones of the music are present . The issue is that by changing the circuit response we will affect the mid tone and treble tone response which at the moment is very flat - all sound with middle and high frequency content will be very faithfully reproduced. Electronic circuit design is often a compromise and this is one of those cases. I have decided to keep the circuit as it is and leave nothing changed. If the user were to change C3 from 47 nF to 470 nF the Bass frequency response is much improved...
Now that the circuit design has been completed it's time to layout a printed circuit board (PCB). I used Eaglecad to design and place where the physical electronic components are sited on a piece of FR4 copper coated glass fibre sheet. I will chemically etch some of the copper away to create the circuit. Once I have drilled the holes for the component legs the soldering can begin:
Top Layer of PCB Layout |
Bottom Layer of PCB Layout |
Just for fun and to show how this PCB would look when professionally made I rendered the design using Eagle3D a user language program (ULP) addon for EagleCad. Here are the results:
Bottom layer |
Here is how the PCB Will look when it's populated with components:
Eagle3D render with PCB Populated |
I haven't actually made this PCB yet so I can't show pictures of the final product. I have prototyped the circuit on breadboard however and here is a photo and some video of the prototype working.
LM386 Ruby Amp on breadboard |
The prototype circuit in operation playing some Vivaldi
I have now etched a PCB and made a permanent version of the Ruby Guitar Amp - Here it is in all it's completed glory:
Here is a quick demonstration of the Guitar amplifier playing an MP3 - I don't have an electric guitar at the moment :(
Well...that is all for now people, thanks for reading and please post any comments you might have. I intend making some kits for this project available - watch this space...take care always - Langster
Bare PCBS for this project can be purchased here:
Lang Electronics Design Web Store
I have also shared the design files here, I hope this helps people make their own versions of this circuit:
Eagle Files for the LM386 Ruby Amplifier
UPDATE ---- Veroboad or Stripboard version for prototype construction
A youtube user watched the video of the circuit simulation asked if I could show how to construct this circuit using veroboard or stripboard.
Stripboard or veroboard is a product used by electronics engineers and hobbyists alike to construct electronic circuits. I'll be honest I don't like using it very much. I find it difficult to use and it takes me a very long time to place all of the components correctly and I always make mistakes and my circuits are always big and ugly! It is also very common to make a mistake when soldering up the circuit and invariably components have to be removed and resoldered. I prefer etching a PCB because then all of my parts fit the circuit board perfectly by design and no issues occur and I tend to make less mistakes!
There are some software packages designed to help with stripboard layout. I never found them to be particularly good. Here is a link to a website which discusses this further:
http://www.electroschematics.com/2270/veroboard-design-software/
I used a demo version of Lochmaster to layout a version of the LM386 Ruby amp. I was pleasantly surprised about how easy it was to use the software and I may well consider using it again in the future. I feel it is a little expensive for the full version (the demo version is software limited, no saving or post editing etc) but it was just what was needed to show how to perform a stripboard layout of the ruby amplifier. Here is a link to the website where it can be downloaded:
http://www.abacom-online.de/uk/html/lochmaster.html
Here are some screenshots of the layout for the Ruby Amplifier - I used a specific type of veroboard as requested:
Bare PCBS for this project can be purchased here:
Lang Electronics Design Web Store
I have also shared the design files here, I hope this helps people make their own versions of this circuit:
Eagle Files for the LM386 Ruby Amplifier
UPDATE ---- Veroboad or Stripboard version for prototype construction
A youtube user watched the video of the circuit simulation asked if I could show how to construct this circuit using veroboard or stripboard.
Stripboard or veroboard is a product used by electronics engineers and hobbyists alike to construct electronic circuits. I'll be honest I don't like using it very much. I find it difficult to use and it takes me a very long time to place all of the components correctly and I always make mistakes and my circuits are always big and ugly! It is also very common to make a mistake when soldering up the circuit and invariably components have to be removed and resoldered. I prefer etching a PCB because then all of my parts fit the circuit board perfectly by design and no issues occur and I tend to make less mistakes!
There are some software packages designed to help with stripboard layout. I never found them to be particularly good. Here is a link to a website which discusses this further:
http://www.electroschematics.com/2270/veroboard-design-software/
I used a demo version of Lochmaster to layout a version of the LM386 Ruby amp. I was pleasantly surprised about how easy it was to use the software and I may well consider using it again in the future. I feel it is a little expensive for the full version (the demo version is software limited, no saving or post editing etc) but it was just what was needed to show how to perform a stripboard layout of the ruby amplifier. Here is a link to the website where it can be downloaded:
http://www.abacom-online.de/uk/html/lochmaster.html
Here are some screenshots of the layout for the Ruby Amplifier - I used a specific type of veroboard as requested:
Top side of Veroboard LM386 Ruby Amplifier layout |
If I were making the circuit I would follow the steps below:
- Obtain all of the components required, including connecting wire of at least three different colours - I used Red (+VE), Black (0V) and Green (Signal)
- Obtain all of the tools needed - Soldering Iron, Solder, Wire cutters, wire strippers, pliers, desoldering tools etc.
- Get a printed copy of the schematic diagram to refer to. Also print out the above two diagrams also - they may come in handy
- Solder all of the 0V wire link connections - there should be eight connections from wire links to the 0V bus (track running along the bottom)
- Solder all of the +VE wire link connections - there are only three connections needed
- Now it is probably a good idea to solder in the IC holder and the 2N5457 transistor - make sure the IC holder is the correct way around with pin 1 on the bottom and the 'bite' on the left side. Make sure the transistor is in the correct orientation also...
- Solder in the resistors next - it doesn't matter which order or in which orientation. Resistors work in either direction - perfectionists like to make sure they all face the same way (it makes it easier to read the values).
- Solder the small capacitors next (47nF, 47nF and 100nF), as with the resistors orientation is not important.
- Next it's time to solder the screw terminals for the input or output. If needed the input screw terminals can be replaced with a 1/4" audio jack or similar connector. The output screw terminal can be replaced with wires directly soldered onto the speaker - it's up to you the maker!
- Next it is time to solder the electrolytic capacitors (100uF and 220uF). The polarity of these devices matters! Please pay attention - the stripe on the body of the capacitor denotes the -VE terminal. The 100uF capacitor is connected across if the incoming supply with the -VE terminal connected to 0V and the +VE terminal connected to +VE. The 220uF capacitor +VE terminal is connected to the wire link coming from pin 5 of the LM386 and the -VE terminal is connected to the output screw terminal or to a pad connected to the speaker.
- Now it is time to solder the potentiometers or variable resistors. Follow the diagram about and either directly solder the pots as shown or use wires and make the same connections - Its up to you as the maker to decide how the components are connected
- Finally check all of the connections and solder joints - check for short circuits and issues using a multimeter....fix any mistakes before carrying on - Good Luck!
- I like to count connections to the +VE and 0V referring to the schematic to make sure I haven't made any mistakes - there should be three +VE connections not including the power wires and there should be ten 0V connections if all of the components are connected. There are also 6 wire link connections present in order for this circuit to work...
The power from the battery or power supply is applied to the top two straight tracks labelled +VE and 0V. Check that power is present between 0V and pin 6 on the IC before removing power and inserting the LM386 (we don't want to blow up the amplifier). Next connect an audio source (MP3 player, signal generator or electric guitar) to the input screw terminals via wires or using a connector. Finally make sure there is a speaker connected to the output via screw terminals or directly and then apply at 5 to 18V at 500mA to hear sound!
I would then look at putting the circuit inside some kind of enclosure but thats for another post...
Enjoy!
No comments:
Post a Comment