introduction to winspice
TRANSCRIPT
-
8/19/2019 Introduction to WinSpice
1/47
Analog Electronics Laboratory 1
-
8/19/2019 Introduction to WinSpice
2/47
Introduction• SPICE: Simulation Program with Integrated
Circuit Em hasis
• SPICE is program that simulates electroniccircuits on your PC
• You can view any voltage or current waveform
in your circuit. SPICE calculates these voltages
or versus frequency (AC Analysis).
• SPICE was develo ed at Universit of California Berkeley.
• SPICE3 is the latest version that UCB offers.
Analog Electronics Laboratory 2
-
8/19/2019 Introduction to WinSpice
3/47
SPICE VersionsVarious SPICE based circuit simulators are available:
Commercial:
- HSpice- Spectre Widely used in Industry
-
- PSpice
Free:
- WinSpice
- LTSPICE
- ng p ce
Analog Electronics Laboratory 3
-
8/19/2019 Introduction to WinSpice
4/47
How SPICE Works?SPICE operates like this:
. .
extension) called a netlist OR draw the circuitusing graphical symbols on a schematic page.
2. Run a simulation. SPICE reads the netlist andthen performs the requested analysis: AC, DC,or TRANSIENT RESPONSE.
3. Plot or print the simulation results
In this lab we will be using the text file
o epa ocumen o escr e e c rcu
Analog Electronics Laboratory 4
-
8/19/2019 Introduction to WinSpice
5/47
SPICE file consists of three parts.
• Data Statements describe thecom onents and the interconnections.
• Analysis Statements tell SPICE what.
• Output Statements specify what outputs
.
Analog Electronics Laboratory 5
-
8/19/2019 Introduction to WinSpice
6/47
’Title statement
circuit descriptionPower Supplies / Signal Sources
Model Statements
Analysis Requests
Output Requests
Analog Electronics Laboratory 6
n ne
-
8/19/2019 Introduction to WinSpice
7/47
’
• e rst ne s a ways t e an can conta n any
information.
•
• Extra spaces are ignored.
• Comment statements must begin with an asterisk (*) andare ignored by SPICE except *DEFINE and *INCLUDE.
• The datum (ground) node must be named '0'.
• e or er o t e rema n ng nes s ar trary.• If you want to continue a statement to the next line, then
use a "+" si n at the be innin of the next line.
Analog Electronics Laboratory 7
-
8/19/2019 Introduction to WinSpice
8/47
SIMPLE TWO RESISTOR VOLTAGE DIVIDER
V1 1 0 10*Connect a DC power supply Vin between node
*
R1 2 1 10K
*Connect a 10K resistor between node 1 and 2
R2 2 0 10K
*Connect a 10K resistor between node 2 and 0
.TRAN 1NS 100NS 0NS
*Perform Transient Analysis from 0ns to 100ns
w t a step o ns.PLOT TRAN V(2)
*Plot the Voltage at node 2 of transient analysis
Analog Electronics Laboratory 8
.
*End of SPICE File
-
8/19/2019 Introduction to WinSpice
9/47
Output
Analog Electronics Laboratory 9
-
8/19/2019 Introduction to WinSpice
10/47
Representing basic circuitelements
• An element line specifies- The circuit nodes to
Letter DescriptionR Resistor
w c t e e ement s connecte .
-Values of the parameters
apac or
L Inductor
I Independent current source
characteristics.
• The first letter of the element
V Independent Voltage source
D Diode
name specifies the element type. Q Bipolar Junction Transistor(BJT)
M MOSFET
Analog Electronics Laboratory 10
-
8/19/2019 Introduction to WinSpice
11/47
Scale Factors
•A number field may be an
- . . , ,
a floating point field(3.14159), either an
n eger or oa ng po n
number followed by an
integer exponent (1e-14,2.65e3), or an integer or a
floating point number
scale factors.
Analog Electronics Laboratory 11
-
8/19/2019 Introduction to WinSpice
12/47
Representing basic circuit
elements
Resistors
• Rxxx is the name of the resistor in circuit.• an are t e two e ement no es.
• VALUE is the resistance (in ohms).
For example:
Analog Electronics Laboratory 12
-
8/19/2019 Introduction to WinSpice
13/47
Representing basic circuit
Capacitors
enera orm :
Cxxx N+ N- VALUE
Cxxx is the name of the resistor in circuit.
N+ and N- are the two element nodes.
VALUE is the capacitance in Farads.The o tional initial condition is the initial time-zero value o
capacitor voltage.
Example: C1 32 33 1U
Analog Electronics Laboratory 13
CSHUNT 50 51 10U IC=3 V
-
8/19/2019 Introduction to WinSpice
14/47
Representing basic circuit
Inductors
Lxxx N+ N- VALUE
xxx s e name o e res s or n c rcu .
N+ and N- are the two element nodes.VALUE s t e n uctance n Henr es.
The (optional) initial condition is the initial (time-zero) value of
n uctor current n mps t at ows rom +, t roug t e n uctor,to N-.
Exam le: L1 32 33 1U
Analog Electronics Laboratory 14
LSHUNT 50 51 10U IC=13.1MA
-
8/19/2019 Introduction to WinSpice
15/47
Voltage source: Vname N+ N- DCValueCurrent source: Iname N+ N- DCValue
N+ is the positive terminal & N– is the negative
terminal.DCValue gives the value of the source.
The name of a volta e and current source must
start with V and I, respectively.
Analog Electronics Laboratory 15
-
8/19/2019 Introduction to WinSpice
16/47
Independent Sources
VXXXXXXX N+ N-
-
8/19/2019 Introduction to WinSpice
17/47
Independent Sources (Cont’d)
+ - > < <
>>
IYYYYYYY N+ N-
• DC/TRAN is the DC and transient analysis value of the
source. If the source value is zero both for DC and transient
analysis, this value may be omitted. If the source value is
time-invariant (e.g., a power supply),then the value mayop ona y e prece e y e e ers .
• ACMAG is the AC magnitude and ACPHASE is the AC
phase. The source is set to this value in the AC analysis. If
s om e o ow ng e eywor , a va ue ounity is assumed. If ACPHASE is omitted, a value of zero is
assumed. If the source is not an AC small-signal input, the
Analog Electronics Laboratory 17
.
-
8/19/2019 Introduction to WinSpice
18/47
Examples
ISRC 23 21 AC 0.333 45.0
. .
Analog Electronics Laboratory 18
-
8/19/2019 Introduction to WinSpice
19/47
Pulse Source: PULSE()
General form:PULSE(V1 V2 TD TR TF PW PER)
ere
V1=initial value
V2= ulsed value
TD=delay time
TR=rise time
TF=fall time
PW=pulse width
=
Analog Electronics Laboratory 19
-
8/19/2019 Introduction to WinSpice
20/47
Exam leVIN 3 0 PULSE(-1 1 2NS 2NS 2NS 50NS 100NS)PULSE V1 V2 TD TR TF PW PER
Analog Electronics Laboratory 20
-
8/19/2019 Introduction to WinSpice
21/47
Sin Source: Sin()
General form:SIN(VO VA FREQ TD Theta)
=o set
VA=amplitude
=
Theta=Damping Factor
Example:VIN 3 0 SIN(0 1 100MEG )
Analog Electronics Laboratory 21
-
8/19/2019 Introduction to WinSpice
22/47
EXAMPLE
•V1 is the amplitude
• s e o se vo age•To is the time delay
•fo is the frequency
Analog Electronics Laboratory 22
•a is damping factor in perseconds
-
8/19/2019 Introduction to WinSpice
23/47
Device Models• For Semiconductor devices we use device models
• Each model specify different parameters of a device
This line appears any where in your netlist
D/Q/Mxxx N1 N2 N3.. MODName
Then any where you write
For diode.MODEL MODName D (IS= N= Rs= CJO= …..)
or
.MODEL MODName NPN/PNP (BETA= VA= CJBE=……)
For NMOS/PMOS MOSFET =. ……
N1, N2, N3 are the terminals of the device:
N1, N2 are Anode and Cathode nodes of Diode respectively
N1 N2 N3 are the Collector Base Emitter nodes of BJT res ectivel .
N4 is the (optional) Substrate node N1, N2, N3, N4 are the Drain, Gate, Source and Body nodes of MOSFETrespectively.
Analog Electronics Laboratory 23
-
8/19/2019 Introduction to WinSpice
24/47
Analysis Request lines. tatement
.DC SRCNAME START STOP STEP
.
STOP are the starting and ending value, respectively.STEP is the size of the increment.
Example: .DC V1 1 20 2.5
When the Start and Stop values are identical (and the Step isnon-zero), .DC command produces only one value
A DC anal sis is automaticall erformed rior to a transient
analysis with capacitors open circuit inductors short circuit and all time varying sources set to zero to determine the transient
Analog Electronics Laboratory 24
-
8/19/2019 Introduction to WinSpice
25/47
.Another form is
. <
START2 STOP2 INCR2>
.DC VDS 0 10 .5 VGS 0 5 1
to be swept from 0 Volts to 10.0 Volts inincrements of 0.5 Volts. For each increment in the
secon source, rst source s swept over ts range.
Analog Electronics Laboratory 25
-
8/19/2019 Introduction to WinSpice
26/47
Example
NMOS VDS-ID CURVES
VDUM 4 3 0VGS 2 0 1
= = .
.MODEL MN NMOS (LEVEL=1 TOX=2.6N VT0=0.3 GAMMA=0.2
+PHI=0.6 U0=250 LD=0.025U CJ=8E-4 CJSW=8E-12
+CGSO = 3.365E-10 CGDO=3.365E-10 LAMBDA=0.2)
.DC VDD 0 5 0.01 VGS 0 0.7 0.1
.PLOT DC I(VDUM)
.END
Analog Electronics Laboratory 26
-
8/19/2019 Introduction to WinSpice
27/47
Output
Analog Electronics Laboratory 27
-
8/19/2019 Introduction to WinSpice
28/47
Transient Analysis
.TRAN
.TRAN TSTEP TSTOP
.
time, and TSTART is the initial time. If TSTART isomitted, it is assumed to be zero. UIC (use initialconditions indicates that the user does not want SPICE tosolve for the quiescent operating point before beginningthe transient analysis. SPICE then uses the values specified
using IC=... on the various elements as the initial transientcon t on.
Example :
.TRAN 1NS 100NS
.TRAN 1NS 1000NS 500NS
Analog Electronics Laboratory 28
-
8/19/2019 Introduction to WinSpice
29/47
This statement is used to specify the frequency (AC) analysis. The format is asfollows:
.
.AC DEC ND FSTART FSTOP
.AC OCT NO FSTART FSTOP
LIN stands for a linear fre uenc variation.
DEC and OCT for a decade and octave variation respectively.
NP stands for the number of points and ND and
NO for the number of frequency points per decade and per octave respectively.FSTART and FSTOP are the start and stopping frequencies in Hertz.
Examples:
.
.AC DEC 10 1K 100MEG
.AC LIN 100 1 100HZ
Analog Electronics Laboratory 29
-
8/19/2019 Introduction to WinSpice
30/47
.OP: Operating Point Analysis
• General form:
.
determines the DC operating point of the
circuit with inductors shorted and
capacitors opened. The output of thisanalysis is automatically printed. i.e. no
explicit print command is required
Analog Electronics Laboratory 30
-
8/19/2019 Introduction to WinSpice
31/47
OUTPUT STATEMENTS.PRINT and .PLOT
.PRINT TYPE OV1 OV2 OV3 ...
.PLOT TYPE OV1 OV2 OV3 ...
.PLOT DC V(1,2) V(3)
.PLOT TRAN I(V1)
•In the original SPICE version (and the one that we will use
in the lab) we must place a DC dummy voltage source i.e.
, .
•We then use I(Vdum) to print or plot current through the
terminal is taken as positive.
•In one .PLOT statement OV1 OV2…can be current or
Analog Electronics Laboratory 31
voltage variables but not both.
-
8/19/2019 Introduction to WinSpice
32/47
Example
+15V
CCR133k
RC1. 2k
+
u
+
CB10uF Q1
NPN
+CE
100uF
+
-
VI NRL1kR2
18k RE1. 2k
Analog Electronics Laboratory 32
E l ( ’d)
-
8/19/2019 Introduction to WinSpice
33/47
Example (cont’d)
.MODEL QMOD NPN (Is=6.734f Xti=3 Eg=1.11 Vaf=74.03 Bf=100+Ne=1.259 Ise=0 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)
VDUM 12 10 0
RC 10 9 1.2k
RE 7 0 1.2K
R1 12 8 33K
R2 8 0 18K
CE 7 0 100UCB 6 8 10U
CC 9 11 10U
Analog Electronics Laboratory 33
RL 11 0 1K
E l ( ’d)
-
8/19/2019 Introduction to WinSpice
34/47
Example (cont’d)
* Note the AC keyword in the above line which specifies that the
* VSIN has magnitude 1 for the AC analysis. Omitting the AC
*
*hence will result in incorrect output for the AC analysis
.OP
.TRAN 100N 1M
.PLOT TRAN V(6) V(11)
.AC DEC 100 1 1000MEG
.PLOT AC V(11)
.
Analog Electronics Laboratory 34
-
8/19/2019 Introduction to WinSpice
35/47
Out ut: TRAN anal sis
Analog Electronics Laboratory 35
-
8/19/2019 Introduction to WinSpice
36/47
Out ut: AC anal sis
Analog Electronics Laboratory 36
-
8/19/2019 Introduction to WinSpice
37/47
Out ut: OP anal sis
Analog Electronics Laboratory 37
-
8/19/2019 Introduction to WinSpice
38/47
Circuit Restrictions
• Every node in the circuit
defined for SPICE musthave a DC path to 100mA
+
1uFgroun no e .
• A DC path to ground
can be through a0
res s or, n uc or orvoltage source but notthrough a capacitor or
12 +1uF
.
• In figures node 1 doesnot have a valid DC path -
10V 1uF 1uF
Analog Electronics Laboratory 38
0
-
8/19/2019 Introduction to WinSpice
39/47
Circuit Restrictions
• SPICE does not permit any loop to consist
sources.
1uH
+
-
SPICE does not permit series combination of
ca acitors and current sources.
Analog Electronics Laboratory 39
-
8/19/2019 Introduction to WinSpice
40/47
Subcircuits• A comp ex e ectron c c rcu t o ten conta n severa components, or
subsections of circuitry that are identical to each others
• Examples
-
- logic gates
• SPICE allows a user to create subcircuits that are created once andthen can be inserted into a larger system at as many places as desired.
• A subcircuit definition starts with .SUBCKT
. < , ….>
SUBNAM is the subcircuit name N1,N2,N3…are the node numbers in
cannot contain datum(0) node.Examples:
.SUBCKT OPAMP 1 2 3
Analog Electronics Laboratory 40
.SUBCKT INV IN OUT VCC
-
8/19/2019 Introduction to WinSpice
41/47
Subcircuits cont’d • A subcircuit can contain other subcircuits, device modelsand subcircuit calls.
• na ys s an output nes suc as . , . , . ,
cannot appear within a subcircuit definition• Any device models or subcircuit definitions included as
par o a su c rcu e n on are s r c y oca .e. sucmodels and definitions are not known outside thesubcircuit definition.
. ,with the exception of 0 (ground) which is always global.
• Local nodes can be made global by using the .GLOBAL.
Analog Electronics Laboratory 41
-
8/19/2019 Introduction to WinSpice
42/47
Calling Subcircuits• The last statement in a subcircuit must be
.ENDS
,
must be given in the .ENDS to specify which subcircuitdefinition has been ended.
,subcircuit call
X**** N1, SUBNAM
, … joined to subcircuit nodes specified in the .SUBCKT linein exactly the order. SUBNAM is the name of the
Examples:X1 6 7 8 OPAMP
Analog Electronics Laboratory 42
-
8/19/2019 Introduction to WinSpice
43/47
Example
+5V
RC3RC2RC1
RB3100 ohms
RB2100 ohms
1k1k1k
RB1100 ohms
+
-
PULSE0- 5V
3NPN
Q2NPN
NPN
Analog Electronics Laboratory 43
-
8/19/2019 Introduction to WinSpice
44/47
Example (cont’d)3 CASCADED INVERTERS
VSUPPLY VCC 0 5
VIN 1 0 PULSE (0 5 0 0 0 10N 20N)
X1 1 2 VCC INVERTER
X2 2 3 VCC INVERTER X3 3 4 VCC INVERTER
.SUBCKT INVERTER IN OUT VCC
Q1 OUT BASE 0 NPNMOD
RC VCC OUT 1K
.MODEL NPNMOD NPN(BF 100)
.
.TRAN 1N 100N
.PLOT TRAN V 1 V 4
Analog Electronics Laboratory 44
.END
-
8/19/2019 Introduction to WinSpice
45/47
OUTPUT
Analog Electronics Laboratory 45
D l d
-
8/19/2019 Introduction to WinSpice
46/47
Download
• Download and install WinSpice. Its Free
www.wins ice.com
• To check, double click on WinSpice icon, acommand window will o en then o to
File>Open>C:\Program Files\ Ouse
Tech\WinSpice\Examples and then double clickon any “.cir” file.
• WinSpice also has a very well written User
anua . o to start menu>Programs>WinSpice>User Manual
Analog Electronics Laboratory 46
-
8/19/2019 Introduction to WinSpice
47/47
. n p ce ser anua
2. “Spice and PSpice” an appendix chapter“ ”n ec ron c ev ces an rcu s y
Theodore F. Bogart.
• n ese s es we ave presen e on y asmall subset of all SPICE capabilities. For
WinSpice User Manual.
Analog Electronics Laboratory 47