LM 386 Model Created for pSPice Sim but get a "pin Gain not found in template" error

Thread Starter

jcrock

Joined Jul 30, 2019
8
Hello All, this problem is driving me nuts and I've been working a few weeks on it to try and learn how to go about getting it right. I built a small AM radio kit - check, I wrote a 20 page report - check, now I need to run a PSpice simulation to get some input output Gain figures about two IC's in the circuit and plots for AC DC input output. I have built the circuit in pSpice and jumped through the hoops to associate a Model with the NJM386 part schematic. When mapping the pins the part diagram had two pins named Gain so I renamed them, It wouldn't accept it otherwise, to match the model I had gotten on the web. Now it doesn't give an error of not having an associated Model for Pspice simulation and everything is mapped properly. I pull the part into the circuit but now it gives me an error for each of the two pins that I renamed for correct mapping purposes and I still can't run the sim. This is beyond the fact its hitting me with about 8 floating node errors. Anyway, I really hope someone can help me out as it was my last effort to finally ask for help from some expert users.

Here's the Circuit Schematic:

RadioLab_Schematic.png


And the errors:

RadioLab_Schematic_Errors.png
 

eetech00

Joined Jun 8, 2013
3,934
Hello All, this problem is driving me nuts and I've been working a few weeks on it to try and learn how to go about getting it right. I built a small AM radio kit - check, I wrote a 20 page report - check, now I need to run a PSpice simulation to get some input output Gain figures about two IC's in the circuit and plots for AC DC input output. I have built the circuit in pSpice and jumped through the hoops to associate a Model with the NJM386 part schematic. When mapping the pins the part diagram had two pins named Gain so I renamed them, It wouldn't accept it otherwise, to match the model I had gotten on the web. Now it doesn't give an error of not having an associated Model for Pspice simulation and everything is mapped properly. I pull the part into the circuit but now it gives me an error for each of the two pins that I renamed for correct mapping purposes and I still can't run the sim. This is beyond the fact its hitting me with about 8 floating node errors. Anyway, I really hope someone can help me out as it was my last effort to finally ask for help from some expert users.

Here's the Circuit Schematic:

View attachment 182808


And the errors:

View attachment 182810
Hi

Just a guess...but It looks like there is a gain parameter missing in the 386 model. Check the voltage/current sources in the model file.

eT
 

Thread Starter

jcrock

Joined Jul 30, 2019
8
Thanks for the reply eT

This is the model file I'm working with: ie I'm not experienced enough to spot any possible issues

*lm386 subcircuit model follows:
* IC pins: 2 3 7 1 8 5 6 4
* | | | | | | | |
.subckt 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-----------
 

Alec_t

Joined Sep 17, 2013
14,312
When mapping the pins the part diagram had two pins named Gain so I renamed them, It wouldn't accept it otherwise, to match the model I had gotten on the web.
I don't see any obvious error in the model. Perhaps the sim is still calling an oudated model file?
Try deleting the 386 from the schematic, saving the schematic file minus the 386, closing the app and restarting it, then re-adding the 386.

Edit: Have the pin attributes of the symbol file been amended for consistency with the model file?
 
Last edited:

crutschow

Joined Mar 14, 2008
34,408
What are the pin numbers of the gain pins?
If you got rid of the "gain" name why is it appearing in the error message?
I don't understand why you renamed them and to what did you rename them?
 

eetech00

Joined Jun 8, 2013
3,934
Thanks for the reply eT

This is the model file I'm working with: ie I'm not experienced enough to spot any possible issues

*lm386 subcircuit model follows:
* IC pins: 2 3 7 1 8 5 6 4
* | | | | | | | |
.subckt 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-----------
Are you using an evaluation copy of PSpice?

eT
 

Audioguru

Joined Dec 20, 2007
11,248
The New Japan NJM386 is a copy of a real LM386. The datasheet shows a voltage gain of 200 times when there is a 10uF capacitor between pin 1 and pin 8. Simulate the Mickey Mouse radio circuit (it is a horrible AM radio) with a 50k resistor replacing the input resistance of the NJM386 then simply multiply its output voltage times 200 times.
 

Thread Starter

jcrock

Joined Jul 30, 2019
8
I don't see any obvious error in the model. Perhaps the sim is still calling an oudated model file?
Try deleting the 386 from the schematic, saving the schematic file minus the 386, closing the app and restarting it, then re-adding the 386.

Edit: Have the pin attributes of the symbol file been amended for consistency with the model file?
I had hoped this would work but I tried many times deleting, rebuilding, relinking the model to no avail. It seems like something is hanging over from before I edit the pins of the symbol but I can't figure out where. The pin attributes of the symbol the only thing I am updating from the existing LM386/NJM386 symbol to match the model file. I change "Gain" to "Gain 1" and the other "Gain" to "Gain 8" to match the model file pin names G1 and G8.
 

Thread Starter

jcrock

Joined Jul 30, 2019
8
Are you using an evaluation copy of PSpice?

eT
I am using a full copy by virtual machine through the University Portal. It has all the bells and whistles so I had hoped this would be my best chance at success. I had been digging at it with a trial, and Lite but ran into the exact same issue so I'm thinking that's not my limitation.
 

Thread Starter

jcrock

Joined Jul 30, 2019
8
I assume the gain pins are nodes g1 and g8 in his model.
Exactly, I only update the pin names of the symbol from "Gain" to "Gain 1" and the other "Gain" to "Gain 8" to match the model file pin names G1 and G8. The preloaded symbol has two "Gain" pins and doesn't like the duplicates and only allows me to link one which means I come up short to have everything linked correctly. That is the only reason why I changed the names in the first place.
 

Thread Starter

jcrock

Joined Jul 30, 2019
8
What are the pin numbers of the gain pins?
If you got rid of the "gain" name why is it appearing in the error message?
I don't understand why you renamed them and to what did you rename them?
Exactly, this is what is driving me nuts. I'm not sure what "template" is still looking for the "Gain" names. I only updated the ppins of the symbol to match the model file because the preloaded LM386 symbol has two pins named the same, "Gain". When I go to map the pins of the model file G1 and G8 to the Gain pin it only links once and then I come up short. In other words although "Gain" appears twice in the symbol attributes I only am allowed to use it once and the other goes away, very screwy. I'll attached a picture to try and show what/where I updated the pin names.
 

Thread Starter

jcrock

Joined Jul 30, 2019
8
Here's a few pics to explain what I am actually doing and why which may answer a few question more clearly and ping a response as to what I might be doing wrong here. Selection of none is not allowed as it means I am short in mapping the pins and receive and error. Once I change the names both "Gains" are able to be mapped to the model.

Screenshot (2).png
Screenshot (3).png
Screenshot (8).png Screenshot (10).png
Screenshot (11).png
 

Alec_t

Joined Sep 17, 2013
14,312
I only update the pin names of the symbol from "Gain" to "Gain 1" and the other "Gain" to "Gain 8"
Methinks your simulator doesn't like pin names with spaces and interprets both "GAIN 1" and "GAIN 8" as "GAIN"; hence the duplication causes problems. Try removing those spaces.
 
Top