General form: c[name] [node1] [node2] [value] ic=[initial voltage] Example 1: c1 12 33 10u Example 2: c1 12 33 10u ic=3.5Comments: The “initial condition” (ic=) variable is the capacitor’s voltage in units of volts at the start of DC analysis. It is an optional value, with the starting voltage assumed to be zero if unspecified. Starting current values for capacitors are interpreted by SPICE only if the .tran analysis option is invoked (with the “uic” option).
General form: l[name] [node1] [node2] [value] ic=[initial current] Example 1: l1 12 33 133m Example 2: l1 12 33 133m ic=12.7mComments: The “initial condition” (ic=) variable is the inductor’s current in units of amps at the start of DC analysis. It is an optional value, with the starting current assumed to be zero if unspecified. Starting current values for inductors are interpreted by SPICE only if the .tran analysis option is invoked.
General form: k[name] l[name] l[name] [coupling factor] Example 1: k1 l1 l2 0.999Comments: SPICE will only allow coupling factor values between 0 and 1 (non-inclusive), with 0 representing no coupling and 1 representing perfect coupling. The order of specifying coupled inductors (l1, l2 or l2, l1) is irrelevant.
General form: r[name] [node1] [node2] [value] Example: rload 23 15 3.3kComments: In case you were wondering, there is no declaration of resistor power dissipation rating in SPICE. All components are assumed to be indestructible. If only real life were this forgiving!
General form: d[name] [anode] [cathode] [model] Example: d1 1 2 mod1DIODE MODELS:
General form: .model [modelname] d [parmtr1=x] [parmtr2=x] . . . Example: .model mod1 d Example: .model mod2 d vj=0.65 rs=1.3
General form: q[name] [collector] [base] [emitter] [model] Example: q1 2 3 0 mod1BJT TRANSISTOR MODELS:
General form: .model [modelname] [npn or pnp] [parmtr1=x] . . . Example: .model mod1 pnp Example: .model mod2 npn bf=75 is=1e-14The model examples shown above are very nonspecific. To accurately model real-life transistors, more parameters are necessary. Take these two examples, for the popular 2N2222 and 2N2907 transistors (the “+”) characters represent line-continuation marks in SPICE, when you wish to break a single line (card) into two or more separate lines on your text editor:
Example: .model m2n2222 npn is=19f bf=150 vaf=100 ikf=.18 + ise=50p ne=2.5 br=7.5 var=6.4 ikr=12m + isc=8.7p nc=1.2 rb=50 re=0.4 rc=0.4 cje=26p + tf=0.5n cjc=11p tr=7n xtb=1.5 kf=0.032f af=1
Example: .model m2n2907 pnp is=1.1p bf=200 nf=1.2 vaf=50 + ikf=0.1 ise=13p ne=1.9 br=6 rc=0.6 cje=23p + vje=0.85 mje=1.25 tf=0.5n cjc=19p vjc=0.5 + mjc=0.2 tr=34n xtb=1.5Parameter definitions: is = transport saturation current in amps bf = ideal maximum forward Beta (unitless) nf = forward current emission coefficient (unitless) vaf = forward Early voltage in volts ikf = corner for forward Beta high-current rolloff in amps ise = B-E leakage saturation current in amps ne = B-E leakage emission coefficient (unitless) br = ideal maximum reverse Beta (unitless) nr = reverse current emission coefficient (unitless) bar = reverse Early voltage in volts ikrikr = corner for reverse Beta high-current rolloff in amps iscisc = B-C leakage saturation current in amps nc = B-C leakage emission coefficient (unitless) rb = zero bias base resistance in ohms irb = current for base resistance halfway value in amps rbm = minimum base resistance at high currents in ohms re = emitter resistance in ohms rc = collector resistance in ohms cje = B-E zero-bias depletion capacitance in farads vje = B-E built-in potential in volts mje = B-E junction exponential factor (unitless) tf = ideal forward transit time (seconds) xtf = coefficient for bias dependence of transit time (unitless) vtf = B-C voltage dependence on transit time, in volts itf = high-current parameter effect on transit time, in amps ptf = excess phase at f=1/(transit time)(2)(pi) Hz, in degrees cjc = B-C zero-bias depletion capacitance in farads vjc = B-C built-in potential in volts mjc = B-C junction exponential factor (unitless) xjcj = B-C depletion capacitance fraction connected in base node (unitless) tr = ideal reverse transit time in seconds cjs = zero-bias collector-substrate capacitance in farads vjs = substrate junction built-in potential in volts mjs = substrate junction exponential factor (unitless) xtb = forward/reverse Beta temperature exponent eg = energy gap for temperature effect on transport saturation current in electron-volts xti = temperature exponent for effect on transport saturation current (unitless) kf = flicker noise coefficient (unitless) af = flicker noise exponent (unitless) fc = forward-bias depletion capacitance formula coefficient (unitless) Comments: Just as with diodes, the model name given for a particular transistor type must begin with a letter, not a number. That’s why the examples given above for the 2N2222 and 2N2907 types of BJTs are named “m2n2222” and “q2n2907” respectively. As you can see, SPICE allows for very detailed specification of transistor properties. Many of the properties listed above are well beyond the scope and interest of the beginning electronics student, and aren’t even useful apart from knowing the equations SPICE uses to model BJT transistors. For those interested in learning more about transistor modeling in SPICE, consult other books, such as Andrei Vladimirescu’s The Spice Book (ISBN 0-471-60926-9).
General form: j[name] [drain] [gate] [source] [model] Example: j1 2 3 0 mod1JFET TRANSISTOR MODELS:
General form: .model [modelname] [njf or pjf] [parmtr1=x] . . . Example: .model mod1 pjf Example: .model mod2 njf lambda=1e-5 pb=0.75Parameter definitions: vto = threshold voltage in volts beta = transconductance parameter in amps/volts2 lambda = channel length modulation parameter in units of 1/volts rd = drain resistance in ohms rs = source resistance in ohms cgs = zero-bias G-S junction capacitance in farads cgd = zero-bias G-D junction capacitance in farads pb = gate junction potential in volts is = gate junction saturation current in amps kf = flicker noise coefficient (unitless) af = flicker noise exponent (unitless) fc = forward-bias depletion capacitance coefficient (unitless)
General form: m[name] [drain] [gate] [source] [substrate] [model] Example: m1 2 3 0 0 mod1MOSFET TRANSISTOR MODELS:
General form: .model [modelname] [nmos or pmos] [parmtr1=x] . . . Example: .model mod1 pmos Example: .model mod2 nmos level=2 phi=0.65 rd=1.5 Example: .model mod3 nmos vto=-1 (depletion) Example: .model mod4 nmos vto=1 (enhancement) Example: .model mod5 pmos vto=1 (depletion) Example: .model mod6 pmos vto=-1 (enhancement)Comments: In order to distinguish between enhancement mode and depletion-mode (also known as depletion-enhancement mode) transistors, the model parameter “vto” (zero-bias threshold voltage) must be specified. Its default value is zero, but a positive value (+1 volts, for example) on a P-channel transistor or a negative value (-1 volts) on an N-channel transistor will specify that transistor to be a depletion (otherwise known as depletion-enhancement) mode device. Conversely, a negative value on a P-channel transistor or a positive value on an N-channel transistor will specify that transistor to be an enhancement mode device. Remember that enhancement mode transistors are normally-off devices, and must be turned on by the application of gate voltage. Depletion-mode transistors are normally “on,” but can be “pinched off” as well as enhanced to greater levels of drain current by applied gate voltage, hence the alternate designation of “depletion-enhancement” MOSFETs. The “vto” parameter specifies the threshold gate voltage for MOSFET conduction.
General form: v[name] [+node] [-node] ac [voltage] [phase] sin Example 1: v1 1 0 ac 12 sin Example 2: v1 1 0 ac 12 240 sin (12 V ∠ 240o)Comments: This method of specifying AC voltage sources works well if you’re using multiple sources at different phase angles from each other, but all at the same frequency. If you need to specify sources at different frequencies in the same circuit, you must use the next method! AC SINEWAVE VOLTAGE SOURCES (when NOT using .ac card to specify frequency):
General form: v[name] [+node] [-node] sin([offset] [voltage] + [freq] [delay] [damping factor]) Example 1: v1 1 0 sin(0 12 60 0 0)Parameter definitions: offset = DC bias voltage, offsetting the AC waveform by a specified voltage. voltage = peak, or crest, AC voltage value for the waveform. freq = frequency in Hertz. delay = time delay, or phase offset for the waveform, in seconds. damping factor = a figure used to create waveforms of decaying amplitude. Comments: This method of specifying AC voltage sources works well if you’re using multiple sources at different frequencies from each other. Representing phase shift is tricky, though, necessitating the use of the delay factor. DC VOLTAGE SOURCES (when using .dc card to specify voltage):
General form: v[name] [+node] [-node] dc Example 1: v1 1 0 dcComments: If you wish to have SPICE output voltages not in reference to node 0, you must use the .dc analysis option, and to use this option you must specify at least one of your DC sources in this manner. DC VOLTAGE SOURCES (when NOT using .dc card to specify voltage):
General form: v[name] [+node] [-node] dc [voltage] Example 1: v1 1 0 dc 12Comments: Nothing noteworthy here! PULSE VOLTAGE SOURCES
General form: v[name] [+node] [-node] pulse ([ i ] [p] [td] [tr] + [tf] [pw] [pd])Parameter definitions: i = initial value p = pulse value td = delay time (all time parameters in units of seconds) tr = rise time tf = fall time pw = pulse width pd = period
Example 1: v1 1 0 pulse (-3 3 0 0 0 10m 20m)Comments: Example 1 is a perfect square wave oscillating between -3 and +3 volts, with zero rise and fall times, a 20 millisecond period, and a 50 percent duty cycle (+3 volts for 10 ms, then -3 volts for 10 ms). AC SINEWAVE CURRENT SOURCES (when using .ac card to specify frequency):
General form: i[name] [+node] [-node] ac [current] [phase] sin Example 1: i1 1 0 ac 3 sin (3 amps) Example 2: i1 1 0 ac 1m 240 sin (1 mA ∠ 240o)Comments: The same comments apply here (and in the next example) as for AC voltage sources. AC SINEWAVE CURRENT SOURCES (when NOT using .ac card to specify frequency):
General form: i[name] [+node] [-node] sin([offset] + [current] [freq] 0 0) Example 1: i1 1 0 sin(0 1.5 60 0 0)DC CURRENT SOURCES (when using .dc card to specify current):
General form: i[name] [+node] [-node] dc Example 1: i1 1 0 dcDC CURRENT SOURCES (when NOT using .dc card to specify current):
General form: i[name] [+node] [-node] dc [current] Example 1: i1 1 0 dc 12Comments: Even though the books all say that the first node given for the DC current source is the positive node, that’s not what I’ve found to be in practice. In actuality, a DC current source in SPICE pushes current in the same direction as a voltage source (battery) would with its negative node specified first. PULSE CURRENT SOURCES
General form: i[name] [+node] [-node] pulse ([i] [p] [td] [tr] + [tf] [pw] [pd])Parameter definitions: i = initial value p = pulse value td = delay time tr = rise time tf = fall time pw = pulse width pd = period
Example 1: i1 1 0 pulse (-3m 3m 0 0 0 17m 34m)Comments: Example 1 is a perfect square wave oscillating between -3 mA and +3 mA, with zero rise and fall times, a 34 millisecond period, and a 50 percent duty cycle (+3 mA for 17 ms, then -3 mA for 17 ms). VOLTAGE SOURCES (dependent):
General form: e[name] [out+node] [out-node] [in+node] [in-node] + [gain] Example 1: e1 2 0 1 2 999kComments: Dependent voltage sources are great to use for simulating operational amplifiers. Example 1 shows how such a source would be configured for use as a voltage follower, inverting input connected to output (node 2) for negative feedback, and the noninverting input coming in on node 1. The gain has been set to an arbitrarily high value of 999,000. One word of caution, though: SPICE does not recognize the input of a dependent source as being a load, so a voltage source tied only to the input of an independent voltage source will be interpreted as “open.” See op-amp circuit examples for more details on this. CURRENT SOURCES (dependent):
by Cabe Atwell
by Gary Elinoff
by Nick Davis