Download 232PspiceLecture

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Spark-gap transmitter wikipedia , lookup

Mercury-arc valve wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Bode plot wikipedia , lookup

Electromagnetic compatibility wikipedia , lookup

Signal-flow graph wikipedia , lookup

Electrical substation wikipedia , lookup

Variable-frequency drive wikipedia , lookup

Stepper motor wikipedia , lookup

Electrical ballast wikipedia , lookup

Power inverter wikipedia , lookup

Pulse-width modulation wikipedia , lookup

History of electric power transmission wikipedia , lookup

Transistor wikipedia , lookup

Islanding wikipedia , lookup

TRIAC wikipedia , lookup

P–n diode wikipedia , lookup

Distribution management system wikipedia , lookup

Ohm's law wikipedia , lookup

Rectifier wikipedia , lookup

Three-phase electric power wikipedia , lookup

Triode wikipedia , lookup

Schmitt trigger wikipedia , lookup

Metadyne wikipedia , lookup

Surge protector wikipedia , lookup

Voltage regulator wikipedia , lookup

Power electronics wikipedia , lookup

Switched-mode power supply wikipedia , lookup

Stray voltage wikipedia , lookup

Current source wikipedia , lookup

Resistive opto-isolator wikipedia , lookup

Alternating current wikipedia , lookup

Buck converter wikipedia , lookup

Voltage optimisation wikipedia , lookup

Network analysis (electrical circuits) wikipedia , lookup

Opto-isolator wikipedia , lookup

Mains electricity wikipedia , lookup

Current mirror wikipedia , lookup

Transcript
Lecture on PSpice
Introduction to SPICE
 SPICE was originally developed at the University of
California, Berkeley (1975).
 Simulation Program for Integrated Circuits Emphasis
 HSPICE = High-performance SPICE
 PSpice = PC version of SPICE
SPICE Functions
 DC analysis:
DC transfer curve
 Transient analysis:
voltage and current as a function of time
 AC Analysis:
output as a function of frequency
 Noise analysis
 and more ….
 SPICE has analog and digital libraries for standard
components
(Transistor, NAND, NOR, …)
 Different temperatures

Default temperature is 300K
Components








Independent voltage and current sources
Dependent voltage and current sources
Resistor
Capacitor
Inductor
Operational amplifier
Transistor
Digital gates …
SPICE Source File
 Title statement: first line
 Data statements: specify the Circuit, components,
interconnections
 Control statements: specify what types of analysis
to perform on the circuit.
 Output statements: specify outputs
 Comment statements: begin with an asterisk (*)
 End statement: .END <carriage return>
 "+" sign (continuation sign)
Suffixes









T
G
MEG
K
M
U
N
P
F
Tera (10+12)
Giga (10+9)
Mega (10+6)
Kilo (10+3)
Mili (10-3)
Micro (10-6)
Nano (10-9)
Pico (10-12)
Femto (10-15)
Independent DC Sources
 Voltage source: Vname N+ N- Type Value
 Current source: Iname N+ N- Type Value





Type: DC, AC or TRAN (transient) (like PULSE, …)
Vin 2 0 DC 10
Vin 2 0 AC 10
Is 3 4 DC 1.5
Voltage and Current Conventions
N1(+)
N1(+)
N2(-)
N2(-)
Dependent DC Sources
 Voltage controlled voltage source:
 Ename N+ N- NC+ NC- Value
 Voltage controlled current source:
 Gname N+ N- NC+ NC- Value
 Current controlled voltage source:
 Hname N+ N- Vmeas Value
 Current controlled current source:
 Fname N+ N- Vmeas Value
 N+ and N- are terminals of the dependent source
 NC+ and NC- are terminals of the controlling
voltage source
Ename
N+ N- NC+ NC- α
Gname
N+
N- NC+ NC- γ
NVmeas
Vmeas
N+
Hname N+ N- Vmeas ρ
Fname
N+ N- Vmeas β
Example
F1 0 3 Vmeas 0.5
Vmeas 4 0 DC 0
Resistors, Capacitors, Inductors




Rname
N+ N- Value
Cname
N+ N- Value <IC>
Lname
N+ N- Value <IC>
IC = initial condition (DC voltage or current)
Example:
C1
34
C2
12
L1
34
L2
73
3
1pF
2pF
1mH
2mH
5V
1pF
+
5V
_
4
1mA
Damped Sinusoidal Sources
 Vname N+ N- SIN(VO VA FREQ TD THETA
PHASE)
Vname  VO  VAe THETA(t TD ) sin 2f (t  TD )  PHASE / 360







VO - offset voltage in volt.
VA - amplitude in volt.
f = FREQ in Hz
TD - delay in seconds
THETA - damping factor per second
Phase - phase in degrees
If TD, THETA and PHASE are not specified, it is
assumed to be zero.
Example:
V1 1 2 SIN(5 10 50 0.2 0.1)
V2 3 4 SIN(0 10 50)
F=1, THETA=.4, VO=5, VA=3, TD=0, Phase=600
10
9
8
7
6
5
4
3
2
1
0
0
0.5
1
1.5
2
2.5
3
3.5
Piecewise linear source (PWL)
 Vname N+ N- PWL(T1 V1 T2 V2 T3 V3 ...)
 Vi is the value source at time Ti
 Example: Vg 1 2 PWL(0 0 10U 5 100U 5
110U 0)
Pulse
 Vname N+ N- PULSE(V1 V2 TD Tr Tf PW
Period)
 V1 - initial voltage
 V2 - peak voltage
 TD - initial delay time
 Tr - rise time
 Tf - fall time
 pw- pulse-width
 Period - period
Subcircuits
 A subcircuit allows you to define a collection of
elements as a subcircuit (e.g. an operational
amplifier)
.SUBCKT SUBNAME N1 N2 N3 ...
Element statements
.
.ENDS SUBNAME
 N1, N2, N3 are the external nodes of the
subcircuit. The external nodes cannot be 0.
 The node numbers used inside a subcircuit are
strictly local, except for node 0 which is always
global.
Example: µ741 (Op Amp)
* Subcircuit for 741 op amp
* +in (=1) -in (=2) out (=3)
.subckt opamp741 1 2 3
rin
1 2 2meg
rout
6 3 75
e1
4 0 1 2 100k
r1
4 5 0.5meg
c1
5 0 31.85nf
eout
60501
.ends opamp741
Using Subcircuit
vs
r1
rf
x1
1 0 dc 5
1 2 200
2 3 1k
0 2 3 opamp741
.dc vs 0 10 1
.option post
.end
.OP Statement
 Instructs SPICE to compute DC operating points
 voltage at each node
 current in each voltage source
 operating point for each element
.DC Statement
 Increment (sweep) an independent source over a
certain range with a specified step
.DC SRCname START STOP STEP




SRCname = name of the source
START and STOP = starting and ending values
STEP = size of increments
Example: .DC V1 0 20 2
.TRAN Statement
 Specifies time interval for transient analysis
.TRAN TSTEP TSTOP <TSTART>
 TSTEP = increment
 TSTOP = final time
 TSTART = starting time
.AC Statement
 Specify frequency (AC) analysis
.AC LIN
NP
FSTART
FSTOP
 LIN = linear frequency variation
 NP = number of points.
 FSTART and FSTOP = start and stopping
frequencies (Hz)
 Example: .AC LIN 10 1000 2000
Output Statements
 .PLOT plots selected output variables, to
design.lis using ASCII characters. .PLOT is
useful for looking at plotted results without
access to AvanWaves.
 .PRINT DC V(2) prints node voltage value
for node 2 in the design.lis file.
.PRINT & .PLOT
 .PRINT TYPE OV1 OV2 OV3 ...
 .PLOT TYPE OV1 OV2 OV3 ...
 TYPE = type of analysis printed or plotted



DC
TRAN
AC
 OV1, OV2 = output variables
Examples:
.PLOT DC
V(1,2) V(3) I(Vmeas)
.PRINT TRAN V(3,1) I(Vmeas)
Example 1
* We are interested in finding the following characteristics:
* 1. Node voltages v12, v2 and current i4 when vin=10V
* 2. Thevenin equivalent voltage and resistance, seen
* at the output terminals v(3,0)
VIN 1 0 DC 10
VMEAS 4 0 DC 0
*VMEAS is a 0V source to measure i4
F1 0 3 VMEAS 0.5
R1 1 2 1K
R2 2 3 10K
R3 1 3 15K
R4 2 4 40K
R5 3 0 50K
.tran .01n 50n
.TF V(3,0) VIN
.DC VIN 0 20 2
.PLOT DC V(1,2)
.END
Example 2
10M
1uF
Pulse
10M
100n
5V
50n
0.1n
0.1n
* pulse generator
* +node -node
V1 V2 TD TR TF PW PER
VIN 1
0 PULSE ( 0 5 0 0.1N 0.1N 50N 100N)
R1 1 2 10M
R2 2 0 10M
C1 2 0 1uF
* transient simulation for 50ns with 0.01ns step size
.tran .1n 500n
* dc simulation with stimulus voltage (source VIN) from 0 to 5V in 0.1V
steps
.DC VIN 0 5 0.01
.end
Example 3
* Thevenin
Vs
1
0
10V
E1
3
2
5
R1
1
2
R2
1
4
R3
0
4
R4
3
4
R5
2
5
R6
2
6
R7
5
4
R8
4
6
.TF V(5,6)
DC
4
1
6
5
2
-
5
5
5
10
10
10
10
10
Vs
.plot DC V(5,6)
.plot DC I(Vs)
.DC Vs 0 100 10
.END
5V46
+
10
10
+
3
5
10V
5
6
_
10
0
5
4
10
10
Example 4
OLD_HW1_Solution
* Thevenin
Vs
2 5 DC
Vmeas 2 3 DC
Fx
6 7 Vmeas
Ex
2 1 5 4
R1
3 4 5.0
R2
4 7 5.0
R3
5 4 4.0
R4
7 0 4.8
R5
5 6 1.0
R10
1 0 1MEG
.TF
V(4,0) Vs
.plot
DC V(5,4)
.plot
DC V(1,0)
.plot
DC I(Vmeas)
.DC
Vs 0 100 10
.tran
1n 50n 0
.END
100V
0V
4.0
3.0
Example 5
1mH
1
Vs =
1V AC
2
1nF
0
10M
OLD_HW2_Solution
Vs 1 0 AC 1
L1 1 2 1m
C1 1 2 1n
R1 2 0 10M
.AC LIN 10 1000 2000
plot AC V(1,2) I(Vs)
.END