PDA

View Full Version : How to Calculate LM386 gain?


disney_snoopy
03-05-2009, 02:30 PM
Hi all,

Can any1 teach me how to calculate the gain=20?
izit the Vin is from the pin3 of the IC's or measure the Vin right after my microphone?

And the Vout is measure from the pin5 or measure at the speaker???

Plz comment on this...

thank you.

thatoneguy
03-05-2009, 05:23 PM
Gain is controlled between pins 1 and 8, if both are left disconnected, the default gain is 20 (Output voltage is 20x input voltage, or 26dB)

The datasheet has the info on changing the gain, as well as an internal schematic that shows how a capacitor between pins 1 and 8 change the gain, as well as several example circuits.

http://www.datasheetcatalog.com/datasheets_pdf/L/M/3/8/LM386.shtml

The 20x voltage gain is between the Input (pins 2 and 3), and VOUT (pin 5).

disney_snoopy
03-06-2009, 02:48 AM
huh...
i think this website should band this batateam...
As he is sending a porn photo/movie to us... maybe it is a virus in the website...

disney_snoopy
03-06-2009, 02:52 AM
file:///C:/DOCUME%7E1/HPUSER%7E1/LOCALS%7E1/Temp/moz-screenshot-1.jpgthatoneguy (http://forum.allaboutcircuits.com/member.php?u=41928),

but i have a problem in getting this gain.
i measure the pin3=0.6V and pin5=3V(maximum volt i can get)
so my gain=5 instead of 20...

So what should i do le?

disney_snoopy
03-06-2009, 02:55 AM
thatoneguy,

i measure pin3=0.6V and pin5=3V(max voltage that i can get)
from here my gain=5 instead of 20
what should i do to solve the problem so that i can get gain=20?

thatoneguy
03-06-2009, 08:45 PM
Are you measuring a waveform with an oscilloscope, or are you getting the voltage from a multimeter measurement of DC levels?

Audioguru
03-06-2009, 11:28 PM
Pin 3 is at 0VDC so he must be using a multimeter set to read AC volts.
A multimeter reads the 50Hz or 60Hz mains frequency sine-wave. It is not accurate at higher frequencies with any other waveform.

disney_snoopy
03-10-2009, 01:30 AM
I use multimeter to measure the volt but i set it to DCvolts.
However, i change the setting of multimeter to ACvolts; it gives me 0.045 for Vin while my Vout is 0.9V.
Hence, my gain was accurate to 20.
Is that correct that change the multimeter to ACvolts?
Plz comment...

Audioguru
03-10-2009, 05:04 AM
The input and output volts of an audio amplifier are AC, not DC.

thatoneguy
03-10-2009, 07:36 AM
Have you tried connecting a speaker to the circuit?

That's a good test to see if more gain is needed for the input source level.

Multimeter AC Range isn't useful, as you are getting either "mean" or RMS voltage, depending on meter, and usually only at low frequencies, under 200Hz. DC Range won't give you any useful information, since audio is AC, you are only seeing the bias output from a single ended supply.

If you need DC gain, Operational Amplifiers such as the TL082 are designed for high voltage gain, but low current ability, which, among other factors, makes them not very good as an audio power amplifier.

disney_snoopy
03-10-2009, 01:52 PM
ya i do connect speaker after a capacitor of the LM386 output pin5.
but since the case that u said using multimeter ACvolts only measure frequency below 200Hz, then what tools should i use to measure the frequency above 200Hz?

if using oscilloscope, then how to measure???
Can explain more details?

Thank You.

thatoneguy
03-10-2009, 07:22 PM
Oscilloscope probe from ground to speaker terminal, while driving speaker.

If your power supply is only 6 Volts, attach a 0.25V peak-peak sinewave signal generator to the input. Look at the oscilloscope, you should see a tall sinewave with peak-peak voltage of around 5. If you increase the output of the signal generator above 0.3V, you will notice the sinewave "Flattens out" at the top and bottom, looking more like a square wave in extreme cases.

This is the amplifier clipping, as the gain is increasing the signal extends past what the power rails will allow (0V and 6V).

If you do not have a signal generator, whistle into a microphone from a distance, change distance to change level. This produces a surprisingly useful sine-ish waveform.

Audioguru
03-10-2009, 08:02 PM
The datasheet for the LM386 shows its output is a max of 4V p-p when its supply is only 6V and the speaker is 8 ohms. then its output power is only 0.25W at a horrible-sounding 10% distortion or a whopping 0.2W at clipping. Flea-power.

thatoneguy
03-10-2009, 09:07 PM
Granted, the LM386 definitely isn't a "Power Amplifier" as one would normally define it. At the same time, there isn't a simpler to use, stable (term used loosely) IC amplifier to compare with it.

For use as a signal tracer/low power, they are useful. If you require flat response from 10Hz to 30kHz with low THD+N, this isn't the IC you are looking for.

Look at this nice waveform when the output is loaded. Input is in blue.
BTW: That waveform sounds very icky :eek:.

http://forum.allaboutcircuits.com/attachment.php?attachmentid=7834&stc=1&d=1236719034

Audioguru
03-11-2009, 12:38 AM
...the LM386...
If you require flat response from 10Hz to 30kHz with low THD+N, this isn't the IC you are looking for.
Oh yeah?
Its frequency response is from almost DC to 300kHz.
Its distortion at clipping is only 0.2%.
Its noise is not bad.

BTW: That waveform sounds very icky :eek:.
Your simulation software sees no supply bypass capacitor. Then of course the waveform is messed up.

thatoneguy
03-11-2009, 01:44 AM
Oh yeah?
Its frequency response is from almost DC to 300kHz.
Its distortion at clipping is only 0.2%.
Its noise is not bad.


Your simulation software sees no supply bypass capacitor. Then of course the waveform is messed up.

I believe I screwed up the LM386 Model... It didn't exist, and I left some stuff tacked on.

Do you have a correct model for an LM386?



################## Model Data Report ##################

**************** Operational Amplifier **********************
* *
* O* LM386 subcircuit model follows:
************************************original* IC pins: 2 3 7 1 8 5 6 4
* IC pins: 1 2 3 4 5 6 7 8
* | | | | | | | |
.subckt LM386 g1 inn inp gnd out vs byp g8
************************************original*.subc kt LM386 inn inp byp g1 g8 out vs gnd

* input emitter-follower buffers:

q1 gnd inn 10011 ddpnp
r1 inn gnd 50k
q2 gnd inp 10012 ddpnp
r2 inp gnd 50k

* differential input stage, gain-setting
* resistors, and internal feedback resistor:

q3 10013 10011 10008 ddpnp
q4 10014 10012 g1 ddpnp
r3 vs byp 15k
r4 byp 10008 15k
r5 10008 g8 150
r6 g8 g1 1.35k
r7 g1 out 15k

* input stage current mirror:

q5 10013 10013 gnd ddnpn
q6 10014 10013 gnd ddnpn

* voltage gain stage & rolloff cap:

q7 10017 10014 gnd ddnpn
c1 10014 10017 15pf

* current mirror source for gain stage:

i1 10002 vs dc 5m
q8 10004 10002 vs ddpnp
q9 10002 10002 vs ddpnp

* Sziklai-connected push-pull output stage:

q10 10018 10017 out ddpnp
q11 10004 10004 10009 ddnpn 100
q12 10009 10009 10017 ddnpn 100
q13 vs 10004 out ddnpn 100
q14 out 10018 gnd ddnpn 100

* generic transistor models generated
* with MicroSim's PARTs utility, using
* default parameters except Bf:

.model ddnpn NPN(Is=10f Xti=3 Eg=1.11 Vaf=100
+ Bf=400 Ise=0 Ne=1.5 Ikf=0 Nk=.5 Xtb=1.5 Var=100
+ Br=1 Isc=0 Nc=2 Ikr=0 Rc=0 Cjc=2p Mjc=.3333
+ Vjc=.75 Fc=.5 Cje=5p Mje=.3333 Vje=.75 Tr=10n
+ Tf=1n Itf=1 Xtf=0 Vtf=10)

.model ddpnp PNP(Is=10f Xti=3 Eg=1.11 Vaf=100
+ Bf=200 Ise=0 Ne=1.5 Ikf=0 Nk=.5 Xtb=1.5 Var=100
+ Br=1 Isc=0 Nc=2 Ikr=0 Rc=0 Cjc=2p Mjc=.3333
+ Vjc=.75 Fc=.5 Cje=5p Mje=.3333 Vje=.75 Tr=10n
+ Tf=1n Itf=1 Xtf=0 Vtf=10)

.ends
*----------end of subcircuit model-----------perational Amplifier Model *
* Interactive Image Technologies *
* SPICE MODEL MAKER TOOL Version 1.1 *
* All Rights Reserved *
* *
************************************************** ***********

* Date: Tuesday, March 10, 2009
* Model Name generic_uA741

* INPUT VALUES:

* Page 1

* General
* Model Name generic_uA741
* Identifier 0

* Input
* Input Capacitance = 1.400e+000 pF
* Input Offset Current = 2.000e+001 nA
* Input Bias Current = 8.000e+001 nA
* Input Offset Voltage = 1.000e+000 mV
* Common-mode Input Resistance = 2.000e+000 GOhm
* Differential-mode Input Resistance = 2.000e+000 MOhm
* Common-mode Rejection Ratio = 9.000e+001 dB
* Voltage Gain = 1.060e+002 dB

* Page 2
* Gain-frequency curve poles and Zero
* Pole 1 = 5.000e+000 Hz
* Pole 2 = 2.000e+000 MHz
* Pole 3 = 2.000e+001 MHz
* Pole 4 = 1.000e+002 MHz
* Zero 3 = 5.000e+000 MHz

* Page 3

* Output
* Slew Rate (non-inverting mode) = 5.000e-001 V/us
* Slew Rate (inverting mode) = 5.000e-001 V/us
* Output Resistance = 7.500e+001 Ohm
* Maximum Source Output Current = 2.500e+001 mA
* Maximum Sink Output Current = 2.500e+001 mA

* OP-AMP Model
.SUBCKT generic_uA741 1 5 9 11 14
* terminal 1: invert input
* terminal 5: non-invert input
* terminal 9: positive power source
* terminal 11: negative power source
* terminal 14: output
.MODEL DMOD D (N=0.001)
r1 3 0 2.000e+009
r3 3 0 2.000e+009
c3 3 5 1.400e-012
r2 3 5 2.000e+006
vc 3 1 1.000e-003
i1 3 0 9.000e-008
i2 4 0 7.000e-008
r6 13 0 1.000e+003
c2 13 0 7.958e-011
g4 13 0 3 4 1.000e-003
r7 17 18 1.000e+004
c4 17 18 3.183e-012
r8 18 0 3.333e+003
e1 17 0 13 0 4.000e+000
r9 19 0 1.000e+003
c5 19 0 1.592e-012
g5 19 0 3 4 1.000e-003
r4 0 6 1.000e+003
c1 0 7 3.183e-005
vb 6 7 dc=0
g1 0 6 19 0 1.995e+002
g2 0 6 poly(2) 3 0 4 0 0 3.155e-003 3.155e-003
d7 7 9 DMOD
d3 7 8 DMOD
d4 8 9 DMOD
d8 11 7 DMOD
d5 10 7 DMOD
d6 11 10 DMOD
f1 8 9 poly(1) vb -1.592e+001 1
f2 11 10 poly(1) vb -1.592e+001 -1
va 12 14 dc 0
d9 14 15 DMOD
d10 15 9 DMOD
d12 11 16 DMOD
d11 16 14 DMOD
f3 15 9 poly(1) va -2.500e-002 1
f4 11 16 poly(1) va -2.500e-002 -1
g3 0 12 7 0 1.333e-002
r5 0 12 7.500e+001
rshunt1 9 0 1e6
rshunt2 11 0 1e6
.ENDS

============= Model template =================
x%p %tGAININ %tINPUT- %tINPUT+ %tGND %tOUT %tVS+ %tBYPASS %tGAINOUT %m

disney_snoopy
03-11-2009, 06:16 AM
sigh... i read it late... i was in college but i forgotten to bring my circuit to college... will test it tomolo.

by the way, maybe i know what software simulation that have the LM386 and is download free?

thatoneguy
03-11-2009, 07:27 AM
You can get LTSpice or a variety of other SPICE like programs for free on the net.

I believe the one from orcad.com is used by a few people here.

As far as the LM386 Model, I found a couple variants on the net, but they aren't working so good, as you can see above...

I'm sure somebody here has a proper model for one. ;)

Ron H
03-11-2009, 06:06 PM
You can get LTSpice or a variety of other SPICE like programs for free on the net.

I believe the one from orcad.com is used by a few people here.

As far as the LM386 Model, I found a couple variants on the net, but they aren't working so good, as you can see above...

I'm sure somebody here has a proper model for one. ;)Here's the model I have. I think it works.:rolleyes:
q1 gnd inn 10011 ddpnp
r1 inn gnd 50k
q2 gnd inp 10012 ddpnp
r2 inp gnd 50k


* differential input stage, gain-setting
* resistors, and internal feedback resistor:


q3 10013 10011 10008 ddpnp
q4 10014 10012 g1 ddpnp
r3 vs byp 15k
r4 byp 10008 15k
r5 10008 g8 150
r6 g8 g1 1.35k
r7 g1 out 15k


* input stage current mirror:


q5 10013 10013 gnd ddnpn
q6 10014 10013 gnd ddnpn


* voltage gain stage & rolloff cap:


q7 10017 10014 gnd ddnpn
c1 10014 10017 15pf


* current mirror source for gain stage:


i1 10002 vs dc 5m
q8 10004 10002 vs ddpnp
q9 10002 10002 vs ddpnp


* Sziklai-connected push-pull output stage:


q10 10018 10017 out ddpnp
q11 10004 10004 10009 ddnpn 100
q12 10009 10009 10017 ddnpn 100
q13 vs 10004 out ddnpn 100
q14 out 10018 gnd ddnpn 100


* generic transistor models generated
* with MicroSim's PARTs utility, using
* default parameters except Bf:


.model ddnpn NPN(Is=10f Xti=3 Eg=1.11 Vaf=100
+ Bf=400 Ise=0 Ne=1.5 Ikf=0 Nk=.5 Xtb=1.5 Var=100
+ Br=1 Isc=0 Nc=2 Ikr=0 Rc=0 Cjc=2p Mjc=.3333
+ Vjc=.75 Fc=.5 Cje=5p Mje=.3333 Vje=.75 Tr=10n
+ Tf=1n Itf=1 Xtf=0 Vtf=10)


.model ddpnp PNP(Is=10f Xti=3 Eg=1.11 Vaf=100
+ Bf=200 Ise=0 Ne=1.5 Ikf=0 Nk=.5 Xtb=1.5 Var=100
+ Br=1 Isc=0 Nc=2 Ikr=0 Rc=0 Cjc=2p Mjc=.3333
+ Vjc=.75 Fc=.5 Cje=5p Mje=.3333 Vje=.75 Tr=10n
+ Tf=1n Itf=1 Xtf=0 Vtf=10)


.ends
*----------end of subcircuit model-----------

disney_snoopy
03-14-2009, 07:08 AM
Hi Thatoneguy,

I have replace the sine wave generator from the microphone and my probe was connect to the speaker. And i plug in the 0.25V from sine wave generator. However, my output was 3.02V from the oscilloscope instead of 5V that u said. Another point is my supply voltage is 6V from 4 AA battery.

Can u tell me why my gain is only 15 compare than what u said gain=20(5V at output).

disney_snoopy
03-14-2009, 07:13 AM
Ron H,
The software u used is Microsim??? Is there any free trial package for student and is there any LM386 on it?

Well as u know im a student and im sure i cant afford to buy an original full version. If there is any freeware of LM386 can let me know??? I need it for my final year project simulation.

Thank You.

thatoneguy
03-14-2009, 01:07 PM
See Audioguru's post Here (http://forum.allaboutcircuits.com/showpost.php?p=125374&postcount=13) Regarding max output.

For multisim, a student version is available http://www.ni.com/multisim/]HERE. I didn't check he matrix to see which features it has, but I've heard it is as good as most other SPICE programs around the same price (free).

The Power Pro Edition is nifty for rapid design verification, and has a huge library. I wasn't fully paying attention when I horked the LM386. Abuse of software, 10 yard penalty. Employers are how that is usually obtained.

Ron H
03-14-2009, 04:04 PM
Ron H,
The software u used is Microsim??? Is there any free trial package for student and is there any LM386 on it?

Well as u know im a student and im sure i cant afford to buy an original full version. If there is any freeware of LM386 can let me know??? I need it for my final year project simulation.

Thank You.I use LTspice (http://www.linear.com/designtools/software/). Free and uncastrated. They do not have an LM386 model in their library, but you can easily add models from other manufacturers. If you decide to try LTspice, you can come here for help.

Audioguru
03-14-2009, 04:42 PM
Hi Thatoneguy,

I have replace the sine wave generator from the microphone and my probe was connect to the speaker. And i plug in the 0.25V from sine wave generator. However, my output was 3.02V from the oscilloscope instead of 5V that u said. Another point is my supply voltage is 6V from 4 AA battery.

Can u tell me why my gain is only 15 compare than what u said gain=20(5V at output).
Look at the curves of Peak To Peak Output Voltage Swing on the datasheet of the LM386.
If your supply is 6V (a battery voltage drops as the battery is used) then the output is typically 5V p-p without a load and is 4V p-p with an 8 ohm load.

Your 3.02V measurement might be average or RMS instead of peak-to-peak.

You cannot measure gain when the output of the amplifier is clipping. Turn down the input level.

disney_snoopy
03-16-2009, 07:49 AM
Look at the curves of Peak To Peak Output Voltage Swing on the datasheet of the LM386.
If your supply is 6V (a battery voltage drops as the battery is used) then the output is typically 5V p-p without a load and is 4V p-p with an 8 ohm load.

Your 3.02V measurement might be average or RMS instead of peak-to-peak.

You cannot measure gain when the output of the amplifier is clipping. Turn down the input level.

Turn down the input level??? how to turn down? can explain further?

However, my speaker were 8ohm load. Plz refer my screenshot and comment...

disney_snoopy
03-16-2009, 07:53 AM
I use LTspice (http://www.linear.com/designtools/software/). Free and uncastrated. They do not have an LM386 model in their library, but you can easily add models from other manufacturers. If you decide to try LTspice, you can come here for help.


Hi Ron H,

If i would like to try and use the LTSpice, can u teach me how to install it and teach me how to add LM386 device in the software???

As i was no other wayz to do in order to settle my fyp...

Thank you.

disney_snoopy
03-16-2009, 07:55 AM
See Audioguru's post Here (http://forum.allaboutcircuits.com/showpost.php?p=125374&postcount=13) Regarding max output.

For multisim, a student version is available http://www.ni.com/multisim/]HERE (http://www.ni.com/multisim/%5DHERE). I didn't check he matrix to see which features it has, but I've heard it is as good as most other SPICE programs around the same price (free).

The Power Pro Edition is nifty for rapid design verification, and has a huge library. I wasn't fully paying attention when I horked the LM386. Abuse of software, 10 yard penalty. Employers are how that is usually obtained.

Thatoneguy,

why i click on the link but there are error and not found on the webpage?

thatoneguy
03-16-2009, 05:51 PM
I had a typo in the link: http://www.ni.com/multisim/

Ron H
03-16-2009, 07:39 PM
Hi Ron H,

If i would like to try and use the LTSpice, can u teach me how to install it and teach me how to add LM386 device in the software???

As i was no other wayz to do in order to settle my fyp...

Thank you.Sure.
LTspice installs itself, and puts an icon on your desktop. I already told you where to find it. See the attached file for details on how to place an LM386 on a schematic.

thatoneguy
03-16-2009, 10:03 PM
If you do not intend to be purchasing Multisim, I'd suggest getting LTSpice.

Audioguru
03-16-2009, 10:50 PM
The output of the LM386 is clipping badly as shown on your 'scope. Turn down the input level so that the output is a smooth sine-wave without the top nor bottom showing clipping.

Ron H
03-16-2009, 11:33 PM
I also have a symbol for LM386, which is makes the sim slightly simpler and cleaner. Copy and paste the following code into Notepad and save the file as C:\LTC\SwCADIII\lib\sym\misc\LM386.asy.

Version 4
SymbolType CELL
LINE Normal -64 -63 64 0
LINE Normal -64 65 64 0
LINE Normal -64 -63 -64 65
LINE Normal -60 -48 -52 -48
LINE Normal -60 48 -52 48
LINE Normal -56 52 -56 44
LINE Normal -48 -80 -48 -55
LINE Normal -48 80 -48 57
LINE Normal -44 -68 -36 -68
LINE Normal -40 -72 -40 -64
LINE Normal -44 68 -36 68
LINE Normal -16 -39 -16 -64
LINE Normal 0 32 0 48
LINE Normal 48 -8 48 -32
SYMATTR Value LM386
SYMATTR Prefix X
SYMATTR ModelFile LM386.sub
SYMATTR Value2 LM386
SYMATTR Description Low power audio amplifier
PIN -16 -64 LEFT 8
PINATTR PinName g1
PINATTR SpiceOrder 1
PIN -64 -48 NONE 0
PINATTR PinName In-
PINATTR SpiceOrder 2
PIN -64 48 NONE 0
PINATTR PinName In+
PINATTR SpiceOrder 3
PIN -48 80 NONE 0
PINATTR PinName V-
PINATTR SpiceOrder 4
PIN 64 0 NONE 0
PINATTR PinName OUT
PINATTR SpiceOrder 5
PIN -48 -80 NONE 0
PINATTR PinName V+
PINATTR SpiceOrder 6
PIN 0 48 LEFT 8
PINATTR PinName bp
PINATTR SpiceOrder 7
PIN 48 -32 LEFT 8
PINATTR PinName g8
PINATTR SpiceOrder 8The next time you open LTspice, LM386 will show up as a symbol in the [Misc] library of the Select Component Symbol window. You can select it and put it on the schematic. LM386.asy calls the LM386.sub file, so you don't have to invoke it with a separate .lib option.

disney_snoopy
03-17-2009, 03:01 AM
The output of the LM386 is clipping badly as shown on your 'scope. Turn down the input level so that the output is a smooth sine-wave without the top nor bottom showing clipping.

Turn down the input level?
Izit u mean the 0.25V Vamp that from the function generator?

If not then can u explain what does input level mean.

Thank You.

Audioguru
03-17-2009, 04:32 AM
Turn down the input level?
Izit u mean the 0.25V Vamp that from the function generator?
If the function generator is the input signal and it has a peak of 0.25V (but is it 0.25V p-p or is it 0.25V RMS?) then the max output is 0.25V x 20= 5V.
Your 'scope shows a max output of about 3.5V p-p so maybe the input is too high at 0.25V peak.
If the input level is reduced to 175mV peak then maybe the amplifier will not clip.

disney_snoopy
03-17-2009, 12:10 PM
If the function generator is the input signal and it has a peak of 0.25V (but is it 0.25V p-p or is it 0.25V RMS?) then the max output is 0.25V x 20= 5V.
Your 'scope shows a max output of about 3.5V p-p so maybe the input is too high at 0.25V peak.
If the input level is reduced to 175mV peak then maybe the amplifier will not clip.

but unfortunately,

my college function generator min Vamp is 0.24V. I hace try to adjust to smaller Vamp but i cant...
is it my circuit problem?

Do u need me to draw attach my circuit design?

Ron H
03-17-2009, 03:23 PM
but unfortunately,

my college function generator min Vamp is 0.24V. I hace try to adjust to smaller Vamp but i cant...
is it my circuit problem?

Do u need me to draw attach my circuit design?Put a voltage divider (attenuator) between the generator and the amplifier input.
Hint: You will need two resistors.

Audioguru
03-17-2009, 06:12 PM
An audio amplifier circuit usually has a volume control to adjust the input level.

disney_snoopy
03-21-2009, 03:39 AM
oh... my circuit has 2 variable resistor for my volume control and another 1 is to adjuxt the sensitivity...