Spice Stuff Spice Stuff: diode and transistor models; netlist examples for feedback amplifier, reverse recovery time of diode, and opamp amplifier

Click for a tutorial example and gschem with opamp. Also google spice and go to links like this.

Diode 1N4007

*vvvvvvvv  Included SPICE model from 1N4007.mod vvvvvvvv
.MODEL  1N4007  D(IS=3.872n RS=1.66E-02 N=1.776 XTI=3.0 EG=1.110 
+               CJO=1.519E-11 M=0.3554 VJ=0.5928 FC=0.5 ISR=1.356E-09
+               NR=2.152 BV=1000.0 IBV=1.0E-03 Tt=4u)
*^^^^^^^^  End of included SPICE model from 1N4007.mod ^^^^^^^^

Diode 1N4148

.model 1N4148   D(Is=5.84n N=1.94 Rs=.7017 Ikf=44.17m Xti=3 Eg=1.11 Cjo=.95p
+               M=.55 Vj=.75 Fc=.5 Isr=11.07n Nr=2.088 Bv=100 Ibv=100u Tt=11.07n)

NPN 2N3904

.model 2N3904   NPN(Is=6.734f Xti=3 Eg=1.11 Vaf=74.03 Bf=416.4 Ne=1.259
+               Ise=6.734f Ikf=66.78m Xtb=1.5 Br=.7371 Nc=2 Isc=0 Ikr=0 Rc=1
+               Cjc=3.638p Mjc=.3085 Vjc=.75 Fc=.5 Cje=4.493p Mje=.2593 Vje=.75
+               Tr=239.5n Tf=301.2p Itf=.4 Vtf=4 Xtf=2 Rb=10)

NPN 2N2222

.model 2N2222 NPN(IS=14.34F XTI=3 EG=1.11 VAF= 74.03 BF=255.9 
+             NE=1.307 ISE=14.34F IKF=.2847 XTB=1.5 BR=6.092 NC=2 
+             ISC=0 IKR=0 RC=1 CJC=7.306P MJC=.3416 VJC=.75 FC=.5 
+             CJE=22.01P MJE=.377 VJE=.75 TR=46.91N TF=411.1P ITF=.6 
+             VTF=1.7 XTF=3 RB=10)

PNP 2N3906 I don't believe this since I measured Is=6.5E-15.

.model 2n3906   PNP(Is=455.9E-18 Xti=3 Eg=1.11 Vaf=33.6 Bf=204.7 Ise=7.558f
+               Ne=1.536 Ikf=.3287 Nk=.9957 Xtb=1.5 Var=100 Br=3.72
+               Isc=529.3E-18 Nc=15.51 Ikr=11.1 Rc=.8508 Cjc=10.13p Mjc=.6993
+               Vjc=1.006 Fc=.5 Cje=10.39p Mje=.6931 Vje=.9937 Tr=10n Tf=181.2p
+               Itf=4.881m Xtf=.7939 Vtf=10 Rb=10)

Enhancement NMOS

.model enmos    NMOS(VTO=2.474 RS=1.68 RD=0.0 IS=1E-15 KP=0.296
+               CGSO=23.5P CGDO=4.5P CBD=53.5P PB=1 LAMBDA=267E-6)

Here is a spice netlist for a 2-transistor negative feedback amplifier.

* gnetlist -g spice-sdb -o fdbk.net fdbk.sch
*********************************************************
* Spice file generated by gnetlist                      *
* spice-sdb version 4.28.2007 by SDB --                 *
* provides advanced spice netlisting capability.        *
* Documentation at http://www.brorson.com/gEDA/SPICE/   *
*********************************************************
*vvvvvvvv  Included SPICE model from 2N3904.mod vvvvvvvv
.model 2N3904   NPN(Is=6.734f Xti=3 Eg=1.11 Vaf=74.03 Bf=416.4 Ne=1.259
+               Ise=6.734f Ikf=66.78m Xtb=1.5 Br=.7371 Nc=2 Isc=0 Ikr=0 Rc=1
+               Cjc=3.638p Mjc=.3085 Vjc=.75 Fc=.5 Cje=4.493p Mje=.2593 Vje=.75
+               Tr=239.5n Tf=301.2p Itf=.4 Vtf=4 Xtf=2 Rb=10)
*               Fairchild        pid=23          case=TO92
*==============  Begin SPICE netlist of main design ============
Q1 Vc1 Vb1 3 0 2N3904 
RLoad 0 Vout 50k  
C4 1 Vc2 10uf  
V2 Vcc 0 DC 12V
R4 Vb2 Vc2 500k  
V1 Vin 0 dc 0 ac 10mV sin(0 10mv 10kHz)
RC Vc1 Vcc 2k  
R3 Vc2 Vcc 5k  
R1 0 Vb1 3k  
R2 Vb1 Vcc 20k  
RE 0 2 200  
RE2 2 3 1  
Rf 2 1 20k  
C3 Vc2 Vout 10uf  
C2 Vc1 Vb2 10uf  
C1 Vin Vb1 10uf  
Q2 Vc2 Vb2 0 0 2N3904 
.end

Here is the circuit

Here is a diode circuit for investigating the reverse recovery time. Use this netlist as source, then "run", then "plot vout vin". Should get graph showing large negative current spikes indicating backwards current flow in diode as shown below in graph of simulation. Actual data also shown.

Diode circuit for reverse recovery time
.MODEL  1N4007  D(IS=3.872n RS=1.66E-02 N=1.776  
+               XTI=3.0 EG=1.110 CJO=1.519E-11 M=0.3554 
+               VJ=0.5928 FC=0.5 ISR=1.356E-09
+               NR=2.152 BV=1000.0 IBV=1.0E-03 Tt=5u)
* Use realistic square wave with rise time/ fall time 50n
v1 vin 0 pulse(2.5 -2.5 0 50n 50n 5u 10u)
d1 vin vout 1n4007
r1 vout 0 2.2k
.tran 5n 20u
.end
 

Here is inverting opamp amplifier and frequency response. Uses 1k for input resistor, and 10k for feedback, so gain of -10. Do "run" and then "plot -vout vin".

*test op amp circuit
* inverting amplifier G = -R2/R1
* gets freq response
*
V1 vin 0 ac 1 sin(0 10m 500kHz)
R1 vin vg 1k
R2 vg vout 10k
xop 0 vg vout opamp1
*.tran 10n 5u
.ac oct 5 1k 5meg
*
* OPAMP MACRO MODEL, SINGLE-POLE 
* connections:      non-inverting input
*                   |   inverting input
*                   |   |   output
*                   |   |   |
.SUBCKT OPAMP1	    1   2   6
* INPUT IMPEDANCE
RIN	1	2	10MEG
* DC GAIN=100K AND POLE1=100HZ
* UNITY GAIN = DCGAIN X POLE1 = 10MHZ
EGAIN	3 0	1 2	100K
RP1	3	4	1K
CP1	4	0	1.5915UF
* OUTPUT BUFFER AND RESISTANCE
EBUFFER	5 0	4 0	1
ROUT	5	6	10
.ENDS
.END