WinSpiceTutorial PDF
WinSpiceTutorial PDF
WinSpice
A. Introduction
SPICE is short for Simulation Program with Integrated Circuit Emphasis. SPICE is a
general-purpose circuit simulation program for nonlinear dc, nonlinear transient, and linear ac analyses.
Circuits may contain resistors, capacitors, inductors, mutual inductors, independent voltage and current
sources, four types of dependent sources, lossless and lossy transmission lines (two separate
implementations), switches, uniform distributed RC lines, and the five most common semiconductor
devices: diodes, BJTs, JFETs, MESFETs, and MOSFETs. SPICE originates from the EECS
Department of the University of California at Berkeley. It could be said that it is the most well known
circuit simulator. In addition, there are at least 30 circuit simulators written, mostly to fulfill other
needs, that are derived from SPICE. One of these is WinSpice. WinSpice is a port of Spice3F4 to
Win32 systems. WinSpice is ported to run in a window as a native 32-bit application. Spice3F4 is one
of the most recent versions of “Berkeley Spice.” The most recent version is Spice3F5.
One advantage of using WinSpice over the numerous other spice programs available is that it
has no size limitations on the circuit you may simulate. It is a very powerful, but “bare-bones” circuit
simulator. Using WinSpice will force you to understand some simulator details, like netlists for
example, that you wouldn’t get by using a more sophisticated program that may use schematic capture.
Schematic capture allows you to draw the schematic and the then simulate this schematic. WinSpice
should be installed in most of the computers around the ECE department. You can also download it
and install it on your own computer.
In order to either get you familiar, or re-familiar, this short tutorial will cover some of the basics
with you. It is by no means complete. This document will also rely heavily on the WinSpice3 User's
Manual and A Tutorial for Spice3 / Nutmeg written by the author of WinSpice, Michael Smith.
B . Using WinSpice
There are many different ways to do a circuit simulation using WinSpice. This document will
discuss one of those.
An example of a WinSpice netlist and the schematic of the circuit it is simulating is:
Step 1
WinSpice Tutorial 2
Figure 1
Step 2
EXAMPLE.CIR
.END
WinSpice Tutorial 3
- Note that simple elements, like resistors and capacitors show the connection and value.
- More complex elements, like Q0 (and most semiconductor devices) require a “model”
statement. The model statement tells WinSpice what model to use and the values of the
parameters of that model.
More details will be discussed later.
Step 3
Figure 5WinSpice plot of the log of the magnitude of v(7) for the
frequency analysis.
Step 4
- Interpret the results. Are they correct?
Figure 7Plot of 20 times the log of v(7) vs. frequency after R12 has
been changed from 10kS to 1kS.
2. Any analysis and output control lines that may be specified in the netlist, may be typed and
thus performed directly into the WinSpice interactive interpreter. For example, typing the
following in the WinSpice window:
- destroy all
- ac dec 20 100k 100meg
- plot vdb(7)
The netlist contains a description of the circuit to be simulated. It shows what types of devices
exist, their values, model types and model parameters as well as a description of how those devices are
connected. The circuit nodes can be numbered or can be any text string, but one of the nodes must be
labeled 0, which is used as the ground node. It is somewhat traditional to number the nodes
sequentially, however you may want to label the nodes by meaningful names, such as in or out, for
example.
Each line of the circuit description netlist may contain one element. The rules governing the
format of these elements are in the manual and we will discuss a few of them. Examples of analog
elements which can be used are resistors, capacitors, inductors, independent voltage and current
sources, the four types of dependent sources, transmission lines, voltage and current controlled
switches, and five common semiconductor devices: diodes, BJT's, JFET's, MOSFET's and GaAsFET's.
Two very important statements that may included in the netlist are the .MODEL statement and the
.SUBCKT statement. A list of the elements that are allowed in WinSpice will follow this discussion.
The list is not complete. Also, the elements in the list are often simplified versions of the actual
element description. As you gain experience with PSpice, you may want to consult the PSpice manual
for more complicated definitions of the elements and some of the other types of elements available.
Element Statements
1. Resistor
Example:
R1 1 2 1k
The xxx represents and any other numbers or letters which you desire, and you must use at least
one. There is no limit the length of a component name, however common sense dictates you
use names with reasonable lengths which are somewhat meaningful.
2. Capacitor
C1 3 4 1e-6
3. Inductor
LR 5 4 1m
Vxxx <+ node> <- node> [ [DC] <value> ] [AC <magnitude> [phase]] [transient +
specification]
The items surrounded by < > are musts. The items surrounded by [ ] are options. The items
surrounded by < > but inside [ ] means that if the option is used, the item must be specified.
VBIAS 13 0 2.3mV
VAC 2 3 AC 0.001
VACPHS 2 3 AC 0.001 90
VPULSE 1 0 PULSE (-1mV 1mV 2ns 2ns 50ns 100ns)
V3 26 27 DC 0.002 AC 1 SIN(0.002 0.002 1.5MEG)
Note in the first example that a value was specified, however the type of voltage source was
not. In this case, PSpice defaults to a DC source. The transient specification must be one of:
Which means the voltage of the source at <tn> is <vn>. The points which specify the voltages
at given times are then "connected" with a straight line approximation.
Ixxx <+ node> <- node> [ [DC] <value> ] [AC <magnitude> [phase]] [transient +
specification]
IBIAS 13 0 2.3mV
IAC 2 3 AC 0.001
IACPHS 2 3 AC 0.001 90
IPULSE 1 0 PULSE (-1mV 1mV 2ns 2ns 50ns 100ns)
I3 26 27 DC 0.002 AC 1 SIN(0.002 0.002 1.5MEG)
6. Diode
Semiconductor devices require a .model statement. Consider the diode for example. Its
simplified form is:
There are 25 model parameters that describe the diode behavior and may be specified. You can
see from the model line above, the you may choose to specify no model parameters. If you
choose this option, PSpice uses default values for these parameters. We will worry about 3
parameters which we are familiar with. They are IS, N, and BV. These are the same
parameters which we have taught in EE 316. To make it clear how PSpice interprets these, a
table is presented.
D1 2 3 DMOD
.MODEL DMOD D (IS=1e-12 N=0.8 BV=80)
D1 2 3 DMOD
.MODEL DMOD D
As with the diode, a model statement is required and it has the form of
The user must specify whether the BJT is an npn or pnp. The BJT has 55 model parameters
that characterize its behavior. The parameters we will give attention to are:
Q1 1 2 3 PNPTYPE
.MODEL PNPTYPE PNP (IS=1e-15 NF=0.8 BF=80 VAF=125)
The user must specify whether or not the transistor is an n-channel JFET or a p-channel JFET.
The JFET has 21 model parameters that characterize its behavior. The parameters we will give
attention to are:
J1 1 2 3 NTYPE
.MODEL NTYPE NJF (VTO=-3 BETA=1E-5 LAMBDA=.1)
J13 2 13 18 JMOD
.MODEL JMOD PJF
Mxxxx <drain node> <gate node> <source node> <bulk/substrate node> <model name> +
[L = <value>] [W = <value>]
The user must specify whether or not the transistor is an n-channel MOSFET or a p-channel
MOSFET. The MOSFET has 52 model parameters that characterize its behavior. The
parameters we will give attention to are:
Additionally there are several levels of MOSFET modeling, which give 4 levels of complexity.
M1 1 2 3 3 NTYPE
.MODEL NTYPE NMOS (VTO=-3 KP=1E-5 LAMBDA=.1 W=10U L=50U)
This is equivalent to
Note the different ways that the length and width of the MOSFET can be specified.
Q13 2 13 18 18 PTYPE
.MODEL PTYPE PMOS
Exxxx <(+) node> <(-) node> <(+) controlling node> <(-) controlling node> <gain>
Example:
EOPAMP 1 3 5 6 100000
Which means the voltage controlled voltage source is connected between nodes 1 and 3, the
positive node at 1, with the controlling voltage being V(5,6) with a gain of 100000.
Gxxxx <(+) node> <(-) node> <(+) controlling node> <(-) controlling node> <gain>
Example:
G1 4 8 2 1 .1
Which means the current flows into node 4 and out of node 8 and with the controlling voltage
being V(2,1) with a gain of .1.
Example:
HLDR 2 10 VSENSE 10
Which means the current-controlled voltage source is connected between nodes 2 and 10, the
positive node at 2, with the controlling current the current through the voltage source named
VSENSE with a gain of 10.
Example:
F1 4 8 VSOURCE 25
Which means the current flows into node 4 and out of node 8 and with the controlling current
the current through the voltage source named VSOURCE with a gain of 25.
Lastly, we need to discuss a .subckt statement. A .subckt statement can used to define a device or
component which will be used repeatedly in the circuit under test or in future circuits.
Note that values can be specified in exponential notation as well as with power-of-ten suffix letters.
These are
f femto- 10-15
p pico- 10-12
n nano- 10-9
u micro- 10-6
m milli- 10-3
k kilo- 103
meg mega- 106
g giga- 109
t tera- 1012
mil (0.001") 25.4*10-6
WinSpice Tutorial 15
C1 3 4 1u
or
C1 3 4 1e-6
Once the nodes of the circuit have been labeled and the netlist is created, control statements
should be added to tell PSpice what to do. We will use control statements to tell PSpice what type of
analysis to do. The first control cards to use are the fundamental types of circuit analysis, an ac
analysis, dc analysis, or transient analysis.
Letter Description
R Resistor
C Capacitor
L Inductor
K Coupled inductor
S Voltage-controlled switch
W Current-controlled switch
I Independent current source
G Linear voltage-controlled current source
E Linear and non-linear voltage-controlled voltage source
F Linear and non-linear current-controlled current source
H Linear current-controlled voltage source
B Non-linear dependent voltage or current source
T Lossless transmission line
O Lossy transmission line
U Uniform distributed RC transmission lines
D Diode
Q Bipolar Junction Transistor (BJT)
J Junction Field-Effect Transistor (JFET)
M MOSFET
X Subcircuit call
Z MESFET
The first line is a “.control”. The last line is a “.endc”. The analysis and output control statement lines
are in between.
1. For an ac analysis:
AC <sweep type> <points value> <start frequency value> <end frequency value>
LIN Linear sweep. The frequency is swept linearly from the starting frequency to the
ending frequency. <points value> is the total number of points in the sweep.
OCT Sweep by octaves. The frequency is swept logarithmically by octaves. <points value>
is the number of points per octave.
DEC Sweep by decades. The frequency is swept logarithmically by decades. <points value>
is the number of points per decade.
AC LIN 101 100 200 The frequency is swept from 100Hz to 200Hz with 101 points,
resulting in the sweep being 100, 101, 102, etc.
AC DEC 20 1MEG 100MEG The frequency is swept from 1MEG to 100MEG with
20 points per decade. There is 2 decades between
1MEG and 100MEG resulting in a total of 40 points.
AC OCT 10 1k 16k The frequency is swept from 1k to 16k with 10 points per
octave. There are 4 octaves between 1k to 16k resulting in a
total of 40 points.
TRAN <print step value> <final time value> [no-print value [step ceiling value]]
(This is a simplified form)
<print step value> is the time interval used for printing or plotting the results of the transient analysis
to a specified output file.
<final time value> is the ending value of the time interval. Note that the transient analysis always starts
off at 0s and ends at the time specified by the final time value.
no-print value Although PSpice begins the transient analysis at 0s, a situation may occur where the
user is not interested in the results from 0s to a specified value. This specified value is the no-print
value and the results from this value are not plotted, printed, or given to probe. Note that PSpice still
does the analysis in this interval, but the results are not made available to the user. This may be
WinSpice Tutorial 17
step ceiling value When WinSpice calculates evaluates a time interval, the step size taken is
determined by WinSpice. This step size may increase or decrease depending on the rate of change of
the voltages and currents in the circuit. The default ceiling is <final time value>/50. If the time
interval between the points is to large the output may appear to be distorted. Specifying a step ceiling
value will reduce the maximum size of the time interval and usually will succeed in "smoothing" the
displayed waveform. Some examples are:
TRAN 1U 10U 5U 1U The transient analysis begins at 0s and ends at 10uS. Any plots
or tables printed in the output file will be in 1uS intervals, but
will not begin until 5uS. The maximum step actually used to
perform the transient analysis is 1uS.
TRAN 10U 100U The transient analysis begins at 0s and ends at 100uS. The
maximum time step is 100us/50 = 2us. Any plots or tables
printed in the output file will be in 10us intervals, and begin at
0s.
3. Finally, the control card used to perform a dc analysis has the form of:
The .DC statement causes a DC sweep analysis to be performed on the circuit. The DC sweep analysis
calculates the circuit's bias point over a range of values for <sweep variable name>.
<start value> may be greater or less <end value>. <increment value> must be greater than zero.
DC VIN -.25 .25 .05 The dc voltage source, VIN, will be swept from -.25V to .25V in
increments of 0.05V. The resulting sweep will be -0.25, -0.20, -0.15,
...
For the circuit we are simulating, we would like to look at a transient response. The period of the input
wave form is 1/60 = 16.67m, and we can then choose to view 3 periods. This gives a final time value
of 50m. We can choose the print step value to be 1u. We will choose the step ceiling value to be 1u.
This gives us the following control card:
TRAN 1U 50U 0 1U
4. Plot
Is simply:
Plot <node voltage>
A summary of commands available in WinSpice is provided here. Note that some of these are
more appropriate for entering in at the command line.
E. Device Modeling
.MODEL The .MODEL statement defines a set of device parameters for a specific device, which
can be referenced in the circuit.
.SUBCKT The .SUBCKT statement begins the definition of a subcircuit. Suppose, for example
you were simulating a circuit which contained 3 op-amps, each op-amp containing 15
components. Instead of listing the 15 components at each point it was necessary to
specify the op-amp, you can list the op-amp once, in a subcircuit, and call that
subcircuit up 3 times.
References