1348713525_pspice for linear and switching electronic circuit
TRANSCRIPT
0
- 0 -
PSpice FOR LINEAR AND
SWITCHING ELECTRONIC CIRCUITS
2nd Edition: 1999
SMPC
- 1 -
Table of Contents
1. Introduction to PSpice .................................................................2 1.1 SPICE ......................................................................................2 1.2 PSpice ....................................................................................2 1.3 Types of Analysis .................................................................2 1.4 Text-Editing Mode or Schematics-Entering Mode ?.........2
2. PSpice Code ..................................................................................3 2.1 General Structure..................................................................3 2.2 Example ..................................................................................3
3. Circuit Description ........................................................................5 3.1 Circuit Elements ....................................................................5 3.2 Independent Sources ...........................................................7 3.3 Dependent Sources...............................................................9 3.4 Model Description ...............................................................20
Diode ........................................................................................21 BJT............................................................................................23 MOSFET ...................................................................................27 Voltage Controlled Switch.....................................................29
4. Subcircuits ....................................................................................31 4.1 General Structure................................................................31 4.2 Example ................................................................................31
5. Analysis Request.........................................................................33 6. Output Request............................................................................38 Appendix: PSpice Modeling and Analysis of Switching Electronics............................................................................................................39
Simple Switching Circuit #1.....................................................42 Simple Switching Circuit #2.....................................................45 Solenoid Drive Circuit...............................................................46 Bridge Rectifier ..........................................................................48 Controlled Full-Wave Rectifier.................................................49 Buck Converter ..........................................................................51 Boost Converter with Step Load Change ..............................52 Frequency-Domain Analysis of Buck Converter ..................53 Energy Transfer Circuit.............................................................61 Turn-Off Snubber Circuit ..........................................................63
- 2 -
1. Introduction to PSpice 1.1 SPICE (Simulation Program with Integrated Circuit Emphasis)
1) A general purpose circuit simulation program. 2) Originally developed as an instrumental tool for designing and
analyzing integrated circuits. 3) Initially developed in the early 1970s at the University of California,
Berkeley, and evolved into mainframe versions and PC-based versions. 4) Recognized as a standard circuit simulator from many universities and
industries.
1.2 PSpice
1) A PC-based version of SPICE developed for the use with IBM-PCs or compatibles
2) Introduced in 1984 by MicroSim and continuously upgraded thereafter.
1.3 Types of Analysis
1) Transient analysis computes the voltages and currents in the circuit as the time elapses, and yields the trajectory of the voltages and currents with respect the time.
2) AC analysis computes the frequency response of the circuit, and yields the Bode plot of the frequency response.
3) DC sweep consecutively computes the operating point of the circuit while incrementally changing the value of an independent voltage or current source.
4) Other types of analysis include transfer function, temperature analysis, sensitivity analysis, Monte Carlo analysis, noise analysis, Fourier analysis.
1.4 Text-Editing Mode or Schematics-Entering Mode ?
1) For educational purposes, the text-editing mode is far more beneficial than the schematics-entering mode.
2) For simulations requiring advanced commands and techniques, the text-editing mode is often convenient and advantageous.
- 3 -
2. PSpice Code 2.1 General Structure
Title statement
Circuit description Power supplies/signal sources Circuit element description Model description
Analysis request Output request
End statement
2.2 Example: Response of an RLC circuit to a voltage source
?? PSpice code
PSpice code for an RLC circuit; Title Statement * ********** * * RLCCKT * * ********** *** Circuit Description *** VS 1 0 SIN(0 2V 4KHZ); Sinusoidal source *VS 1 0 PULSE(-5V 5V 0 5NS 5NS 0.5MS 1MS); Pulse source *VS 1 0 PWL (0 0V 1US 5V 1S 5V); Step source R1 1 2 1 ; circuit element L1 2 3 50UH ; circuit element C1 3 0 50UF ; Circuit element **************************** .TRAN 5US 2MS ; Analysis request .PRINT TRAN V(1) V(3) ; Output request .Probe ; Output request .END ; End statement
VS
R1 L1
C1
990118kjw010
1 22 3
- 4 -
?? Simulation result
??PSpice Tips 1. The first line must be the title line, and it may contain any type of text. 2. The last line must be the .END command. 3. The order of the intervening lines does not affect the results of
simulations. 4. If a PSpice statement is more than one line, the statement can continue
to the next line. A continuation line is identified by a plus sign “+” in the first column of the next line.
5. A comment line may be included anywhere, preceded by an asterisk “*” at the beginning of the line, and by a semicolon “ ;” at the end of PSpice statement.
6. The number of blanks between items can be freely chosen. 7. The tabs and commas are equivalent to blanks. For example, “ “ and
“ , “ are equivalent. 8. PSpice statements or comments can be in either upper or lowercase
letters. 9. After execution, PSpice produces the output file that contains very
helpful information, including error messages and run-time statistics.
- 5 -
3. Circuit Description 3.1 Circuit Elements
Name + node - node Value or other descriptions ------------------------------------------------------------------------------------- R1 1 2 0.5 Ohm
??Name for circuit elements
First letter Representat
ion
Elements
Passive element C Capacitor L Inductor K Coupled inductor R Resistor
Active elements D Diode M MOSFET Q BJT J JFET
Sources V Independent voltage source I Independent current source E Depend voltage source G Depend current source
Switches S Voltage controlled switch W Current controlled switch
??Nodes
1) PSpice adopts the standard convention in defining the polarity of the device; the current enters “+ node” and exits “ – node”, developing a positive voltage drop from the + node to – node.
Exceptions to this rule are the voltage sources and current sources, as shown in the next section.
2) Node numbers can be integers from 0 to 999 or alphabets or combination of them.
3) The node number need not be sequential. 4) The integer “0” is reserved to mean “Ground”.
- 6 -
??Value for circuit elements
Representation
Meaning
Scale suffixes P 1E-12 N 1E-9 U 1E-6 M 1E-3 K 1E3
MEG 1E6 G 1E9
Units V Volts A Ampere
OHM Ohm ? ?? H Henry F Farad Hz Hertz
??PSpice Tips 1. It is often helpful to use an explanatory name for meaningful nodes, for
example, “GND,” “OUTPUT,” “INPUT” etc. 2. The units can be omitted since they are only for explanatory purposes
and ignored inside PSpice. 3. Be careful not to confuse “M” with “MEG” in using suffixes.
- 7 -
3.2 Independent Sources ??General form
Name +node -node Type Description ------------------------------------------------------------------------------- Vin 1 2 SIN (0 2V 4kHz)
Name Node assignmen
t
Type
Voltage
Source
Vname
Current
Source
Iname
DC: Constant SIN: Sinusoidal waveform Pulse: Periodic pulse signal PWL: Arbitrary waveform consisting of piecewise linear segments AC: Small-signal source needed for ac analysis
??Description Type Description Time-varying signal DC DC Value AC AC Magnitude
Phase
Sinusoid SIN (VO VM FREQ)
Pulse PULSE (VL VH TD TR TF TW TP)
Piecewise linear
PWL (T1 V1 T2 V2 - - - Tn Vn)
+node
99011901kjw01
-node
990119kjw03
VL
TD
TR
TW
VH
TFTP
V1
T1
T2
V2
Tn
Vn
990119kjw04
VOVM
1/FREQ
+node
99011901kjw01
-node
- 8 -
??Example
PSpice code Waveform
V1 1 0 SIN (0 1 1kHz) V2 2 0 PULSE (-5V 5V 0 5NS 5NS 0.5MS 1MS)
V3 3 0 PULSE (0 5V 0 5NS 5NS 0.1MS 1MS) V4 4 0 PULSE (-5V 5V 0 0.4MS 0.4MS 0.01MS 0.81MS) V5 5 0 PWL (0 0V 1US 1V 1S 1V) V6 6 0 PWL (0 0V 0.1MS 0V
0.1001MS 1V 0.15MS 1V 0.15001MS 0 1S 0V)
- 9 -
3.3 Dependent Sources ??General form
Time-domain form: Name + node - node VALUE={Arithmetic expression using the node voltage and branch current of the circuit} Frequency-domain form: Name + node - node LAPLACE { Input variable}={Transfer function between input variable and output of dependent source}
Name Node assignmen
t
PSpice code
Voltage Source
Ename
Current Source
Gname
Time-domain form: E1 3 0 VALUE={5*V(1,0)+1.5*V(2,0)} E2 3 0 VALUE={V(1,0)+1.3*I(VD)} G3 3 0 VALUE={SQRT(V(1,0))+1.3*V(2,0)} G4 3 0 VALUE={ABS(V(1,0))+COS(I(VD))}
Frequency-domain form:
E1 3 0 LAPLACE {V(1)}={5000/(S+500)} E2 3 0 LAPLACE {V(1)+V(2)} = {S*5000/(1+S/50+S*S/6000)} G3 3 0 LAPLACE {I(VD)}={5000/(1+S/50)} G4 3 0 LAPLACE {V(2)} = {((S+1)*(S+2))/(1+2*S+4*S*S)}
PSpice does not permit measuring the current through a passive component. A zero-valued voltage source,VD, can be used in measuring the current that will be used as a variable.
VD 3 0 DC 0
??Arithmetic operations
Symbol Operation Symbol Operation Symbol Operation
+ Addition ABS( X ) X PWR( X,Y ) YX _ Subtraction SQRT( X ) X
SIN( X ) )xsin(
* Multiplication EXP( X ) Xe COS( X ) )xcos(
/ Division LOG( X ) )X(ln TAN( X ) )xtan(
LOG10( X ) )Xlog( ARCTAN( X ) )x(tan 1?
+node
99011901kjw01
-node
+node
99011901kjw01
-node
- 10 -
??Example: Generation of waveforms
PSpice code WAVEFORM GENERATION CIRCUIT * *************** * *** WAVEGEN *** * *************** ********* WAVEFORM 1 ********** V1 1 0 SIN (0 1 2kHz) R1 1 0 1 V2 2 0 SIN(0 1 50kHz) R2 2 0 1 E 3 0 VALUE={5*V(1,0)+1.5*V(2,0)} R3 3 0 1 .TRAN 1US 2MS .PROBE .END WAVEFORM GENERATION CIRCUIT ********* WAVEFORM 2 ********** V1 1 0 PULSE(0 1 0 1NS 1NS 0.5MS 1MS) R1 1 0 1 V2 2 0 SIN(0 1 50kHz) R2 2 0 1 E 3 0 VALUE={V(1,0)*1.3*V(2,0)} R3 3 0 1 .TRAN 1US 2MS .PROBE .END WAVEFORM GENERATION CIRCUIT ********* WAVEFORM 3 ********** V1 1 0 SIN(0 1 1kHZ) R1 1 0 1 V2 2 0 SIN(0 1 20kHz) R2 2 0 1 E 3 0 VALUE={V(1,0)*1.3*V(2,0)} R3 3 0 1 .TRAN 1US 2MS .PROBE .END
1 2 3
0 0 0
V1 R1 V2 R2 E R3
Signal sources
11
- 11 -
Simulation result
??PSpice Tips 1. Multiple simulations can be performed by stacking several independent
PSpice programs in series.
- 12 -
??Example: Response of a voltage amplifier to a sinusoidal source
PSpice code VOLTAGE AMPLIFIER * **************** * *** VOLAMP01 *** * **************** .PARAM PRI = 0.1K *.STEP PARAM PRI LIST 0.1K 1K 10K VS 1 0 SIN (0 4.5V 4kHZ) RS 1 2 1K RI 2 0 {PRI} E0 0 3 VALUE={10*V(2,0)} RO 3 4 1K RL 4 0 1K .TRAN 1US 1M .PROBE .END
990204ggh01
RI EO
RO
RL
RS
1 2 3 4
- 13 -
Simulation result
??PSpice Tips 1. .PARAM PRI = 1.1K; This statement assigns a numerical value or
arithmetic expression to a specific parameter. Once a parameter is defined, it can be used as a variable anywhere in PSpice code.
2. RI 2 0 {PRI}; E0 0 3 VALUE={10*V(2,0)}; An expression using the parameters and other variables should appear within braces “{ }.”
3. .STEP PARAM PRI LIST 0.1K 1K 10K; This statement performs a series of simulations, each with a different value for “PRI” as listed in the statement.
- 14 -
??Example: Frequency response of second-order filters
PSpice code FREQUENCY RESPONSE OF A SECOND-ORDER FILTER * ***************** * *** SFILTER01 *** * ***************** ***** LOW-PASS FILTER ***** .PARAM PR=1 .STEP PARAM PR 0.5 2.5 0.5 VS 1 0 AC 1 L 1 2 120UH C 2 0 211UF R 2 0 {PR} .AC DEC 20 10HZ 100kHZ .PROBE .END *FREQUENCY RESPONSE OF A SECOND-ORDER FILTER ***** HIGH-PASS FILTER ***** *.PARAM PR=1 *.STEP PARAM PR 0.5 2.5 0.5 *VS 1 0 AC 1 *C 1 2 211UF *L 2 0 120UH *R 2 0 {PR} *.AC DEC 20 10HZ 100kHZ *.PROBE *.END
0 0
1 2 1 2
VS
L
C R VS
C
L R
990208GGH01
Low pass filter High pass filter
- 15 -
Simulation result
??PSpice Tips
1. .STEP PARAM PR 0.5 2.5 0.5 ; This statement sweeps the parameter
“PR” from 0.5 to 2.5 by a step of 0.5, and simulates the circuit for each value of “PR.”
2. VS 1 0 AC 1; A transfer function can be conveniently evaluated by 1) exciting the input with an ac source of unit amplitude and zero phase ,and 2) directly measuring the output.
- 16 -
??Example: Time response of second-order filters
PSpice code
TIME RESPONSE OF A SECOND-ORDER FILTER * ***************** * *** SFILTER02 *** * ***************** ***** LOW-PASS FILTER ***** V1 1P 0 SIN(0 1 100HZ) R1 1P 0 1 V2 2P 0 SIN(0 1 10kHZ) R2 2P 0 1 E1 1 0 VALUE={5*V(1P,0)+5*V(2P,0)} L 1 2 120UH C 2 0 211UF R 2 0 1 .TRAN 2U 20MS .PROBE .END TIME RESPONSE OF A SECOND-ORDER FILTER ***** HIGH-PASS FILTER ***** V1 1P 0 SIN(0 1 100HZ) R1 1P 0 1 V2 2P 0 SIN(0 1 10kHZ) R2 2P 0 1 E1 1 0 VALUE={5*V(1P,0)+5*V(2P,0)} C 1 2 211UF L 2 0 120UH R 2 0 1 .TRAN 2U 20MS .PROBE .END
0 0 0 0
1P 2P 1 2 1 2
V1 R1 V2 R2 E1 E1
L
C R L
C
R
990208GGH01
Signal sources Low pass filter High pass filter
- 17 -
Simulation result
??PSpice Tips
- 18 -
0
1
VS
R1
2 3
RI1
990209GGH01
RI2
4 5
EO1 EO2
C2
R2C1
??Example: Application circuit of op amps
PSpice code
APPLICATION CIRCUIT USING OP AMPS * ***************** * **** OPAMP01 **** * ***************** VS 1 0 PULSE (-5V 5V 0 0.4MS 0.4MS 0.01MS 0.81MS) R1 1 2 10K C1 2 3 0.1U IC=0 RI1 2 0 1E6 EO1 0 3 VALUE={1E6*V(2,0)} C2 3 4 0.1U IC=0 R2 4 5 20K RI2 4 0 1E6 EO2 0 5 VALUE={1E6*V(4,0)} .TRAN 10U 100MS 95MS UIC .PROBE .END
- 19 -
Simulation result
??PSpice Tips
3.4. Model Description
- 20 -
??General form Component Name Terminals - - - - - - Model name .MODEL Model name Device type (Device parameters) ---------------------------------------------------------------------------------------------
Q1 Collector Base Emitter NBJT .MODEL NBJT NPN ( Is=1.8e-15 BF=100 VA= 50)
Name Device type
Typical PSpice code
Diode
Dname
D
D1 Anode Cathode DMOD .MODEL DMOD D ( Is N BV )
Is: Saturation current N: Emission coefficient (1- 2) BV: Breakdown voltage
BJT
Qname
NPN PNP
Q1 Collector Base Emitter NBJT .MODEL NBJT NPN ( Is BF VA ) Is: Saturation current
BF: Forward beta VA: Early voltage
JFET
Jnam
e
NJF PJF
J1 Drain Gate Source NJFET .MODEL NJFET NJF ( VTO BETA LAMBDA ) VTO: Zero-bias threshold voltage
BETA: Transconductance coefficient LAMBDA: Channel-length modulation
MOSFET
Mnam
e
NMOS PMOS
M1 Drain Gate Source Body MOSFET .MODEL MOSFET NMOS ( VTO KP LAMBDA ) VTO: Zero-bias threshold voltage
BF: Transconductance coefficient LAMBDA: Channel-length modulation
Voltage-controlle
d switch
Sname
VSWITCH
S1 + node – node + Vc – Vc SMOD Vc + Vc - Vc Pulse (VL VH TD TR TF TW TP) .MODEL SMOD VSWITCH ( Ron Roff )
Ron: Turn-on resistance Roff: Turn-off resistance
Undefined parameters assume the default values.
- 21 -
Junction Diode ??General form
D1 Anode Cathode DMOD .MODEL DMOD D ( Is=1.8e-15 N=1 BV=4 )
??BJT parameters
Symbol Parameter Unit Default value
Typical value
Is Saturation current A 1E-14 1E-14 N Emission coefficient 1 1 – 2 BV Reverse breakdown
voltage V ∞ 50
??Example: Curve tracer to measure I-V characteristics of a diode
PSpice code I-V CURVE OF A DIODE * ************* * * DI-VCURVE * * ************* VD 1 0 DC 700mV R 1 2 0.0001 D1 2 0 DMOD .MODEL DMOD D(IS=1e-15 N=1 BV=4) .DC VD -5V 5V 10mV .PLOT DC I(D1) .PROBE .END
R
2
VD D1
1
0 990208GGH01
- 22 -
Simulation result
??PSpice Tips 1. .DC VD -5V 5V 10mV; This statement sweeps “VD” from –5V to 5V
by a step of 10mV, and calculates the operating point of the circuit for each value of “VD.”
- 23 -
Bipolar Junction Transistor (BJT) ??General form
Q1 Collector Base Emitter NBJT .MODEL NBJT NPN ( Is=1.8e-15 BF=100 VA= 50)
??BJT parameters
Symbol Parameter Unit Default value
Typical value
Is Saturation current A 1E-16 1E-16 BF Forward beta 100 100 VA Early voltage V ∞ 100
??Example: Curve tracer to measure I-V characteristics of BJT
PSpice code I-V CURVES OF A BJT * ************* * * BJTCURVES * * ************* IB 0 1 DC 0A Q1 2 1 0 NBJT .MODEL NBJT NPN (Is=1.8e-15 Bf=100 VA=50) RC 3 2 0.001 VCE 3 0 DC 0V .DC VCE 0 10V 20mV IB 1u 10u 2u .PLOT DC I(RC) .PROBE .End
VCEQ1
RC
IB
0
1
2 3
- 24 -
Simulation result
??PSpice Tips 1. .DC VCE 0 10V 10mV IB 1u 10u 2u ; This statement sweeps “IB” from 1u
to 10u by step of 2uA, and for each value of “IB” sweeps “VCE” from 0 to 10V by step of 10mV.
- 25 -
??Example: Common emitter amplifier
PSpice code
COMMON EMITTER AMPLIFIER WITH EMITTER RESISTANCE * ************* * * CEAMP01 * * ************* VI 1 0 SIN(0 0.001 1000) RS 1 2 330 C1 2 3 100U RB 3 0 100K Q1 5 3 4 NBJT;COLLECTOR, BASE, EMITTER VCC 6 0 DC 5 RC 6 5 10K RE1 4 8 120 C2 8 0 100U RE 8 9 16K VEE 9 0 DC -5 C3 5 7 100U RL 7 0 220K .OP .MODEL NBJT NPN (IS=9.3E-15 BF=100 VA=100 ) .TRAN 0.1US 3MS .PROBE .END
990209GGH02
VS
1 RS 2 C1 3
RBRE1
REC2
VEE
RC
C3
RL
VCC
4
8
9
5 7
6
- 26 -
Simulation result
??PSpice Tips
- 27 -
Metal Oxide Silicon Field-Effect Transistor (MOSFET) ??General form
M1 Drain Gate Source Body MMOD .MODEL MMOD NMOS ( Is=1.8e-15 BF=100 VA= 50)
??MOSFET parameters Symbol Parameter Unit Default
value Typical value
VTO Zero-bias threshould voltaget
V 0 0.1
KP Transconductance coefficient
2E-5 2.5E-5
LAMBDA Channel length modulation
0 0.02
??Example: Common source amplifier
PSpice code COMMON SOURCE AMPLIFIER * ************* * * CSAMP01 * * ************* VS 1 0 SIN(0 0.05 1000) C1 1 2 15U R1 4 2 330K R2 2 0 220K RD 4 3 50K VDD 4 0 DC 18 M1 3 2 5 5 MMOD .MODEL MMOD NMOS (VTO=0.1 KP=2.5E-5 LAMBDA=0.02) RS 5 0 50K CS 5 0 15U C2 3 6 15U RL 6 0 50K .OP .TRAN 0.1US 3MS
990209GGH03
VS
1 2C13
R2
RD
C2
RL
VDD
5
4
6
R1
RS CS
- 28 -
.PROBE
.END Simulation result
??PSpice Tips
- 29 -
Voltage Controlled Switch ??General form
S1 +node -node +Vc -Vc SMOD Vcon +Vc -Vc Pulse (VL VH TD TR TF TW TP) .MODEL SMOD VSWITCH (Ron=0.01 Roff=1E6)
??Switch parameters
Symbol Parameter Unit Default value
Typical value
Ron On resistance ? 1.0 0.01 Roff Off resistance ? 1E6 1E6 Von Control voltage for on
state V 1.0 5
Voff Control voltage for off state
V 0.0 -5
??Example: Simple switching circuit
PSpice code EXAMPLE OF SIMPLE SWITCHING CIRCUIT * ******************** * *** SWITCH01.CIR *** * ******************** VS 1 0 DC 24 S1 1 2 11 0 SMOD D 0 2 DMOD IO 2 0 DC 2 VCON 11 0 PULSE ( -5 5 0 1NS 1NS 10MS 25MS ) .MODEL SMOD VSWITCH (RON=0.01 ROFF=1E6) .MODEL DMOD D(N=1) .TRAN 1US 70MS .PROBE .END
? ?11
0
Vcon
D
Io
Vs
SW
- 30 -
Simulation result
??PSpice Tips
- 31 -
4. Subcircuit 4.1 General Structure ??Defining subcircuit
.SUBCKT Name_of_subcircuit List_of_nodes Circuit description
Power supplies/signal sources Circuit element description Model description
.End ?? Invoking subcircuit
Xname List_ of_ nodes Name_of_subcircuit
4.2. Example: Application circuit of op amps ?? PSpice code
APPLICATION CIRCUIT USING OP AMPS * ***************** * **** OPAMP02 ** * ***************** ****** OP AMP SUBCIRCUIT ****** .SUBCKT OPAMP 2P 0P 3P RI 2P 0P 1E6 EO 0P 3P VALUE={1E6*V(2P,0P)} .ENDS OPAMP ******************************** VS 1 0 PULSE (-5V 5V 0 0.4MS 0.4MS 0.01MS 0.81MS) R1 1 2 10K C1 2 3 0.1U IC=0 X1 2 0 3 OPAMP; Statement invoking the subcircuit C2 3 4 0.1U IC=0 R2 4 5 20K X2 4 0 5 OPAMP; Statement invoking the subcircit .TRAN 10U 100MS 95MS UIC .PROBE .END
0
1
VS
R1
2 3
RI
990823GGH01
RI2
4 5
EO EO2
C2
R2C1
2P
0P
3P
- 32 -
?? Simulation result
??PSpice Tips 1. The subcircuit can be placed anywhere in the main circuit.
5 Analysis Request
- 33 -
??General form .TRAN 1US 1MS .AC DEC 20 10HZ 100KHZ .DC VD -0.6 0.6 0.01 .OP
Analysis Typical PSpice code Transient analysis
.TRAN PSTEP TFINAL [TDELAY] * [ UIC] * PSTEP: Plot interval TFINAL: Final time of simulation TDELAY: Period for which no output is plotted UIC : Use initial condition * :optional
AC analysis
.AC DEC POINT FSTART FFINAL POINT: Number of data point per decade FSTART: Initial frequency of simulation FFINAL: Final frequency of simulation
DC sweep
.DC PARAM IVALUE FVALUE STEP PARAM: Parameter to be swept FSTART: Initial value of parameter FFINAL: Final value of parameter STEP: Size of step increase
Operating point
.OP Evaluates operating points of nonlinear devices and list them in the output file.
- 34 -
??Example: First-order low pass filter
PSPICE Code
FIRST-ORDER LOW-PASS FILTER * ***************** * *** FFILTER01 *** * ***************** *VS 1 0 SIN (0 1 1KHZ); TRANSIENT RESPONSE VS 1 0 AC 1 ; AC RESPONSE R 1 2 1K C 2 0 0.16UF *.TRAN 1US 4MS ; TRANSIENT RESPONSE .AC DEC 20 10HZ 100kHZ ; AC RESPONSE .PROBE .END
0
1 2
VS C
R
990208GGH01
- 35 -
Simulation result
??PSpice Tips
- 36 -
??Example: BJT differential amplifier
PSpice code BJT DIFFERENTAIL AMPLIFIER * ************* * * DIFFAMP01 * * ************* *VD 1 0 DC 0;DC SWEEP VD 1 0 SIN(0 0.02 1kHZ);TRANSIENT ANALYSIS RD 1 0 1 VCC 7 0 DC 15 VEE 9 0 DC -15 E+ 2 0 VALUE={0.5*V(1,0)} Q1 3 2 4 NBJT R1 7 3 20k E- 5 0 VALUE={-0.5*V(1,0)} Q2 6 5 4 NBJT R2 7 6 20k Q3 4 8 9 NBJT Q4 8 8 9 NBJT R4 0 8 28.6K .MODEL NBJT NPN (Is=1.8E-15 Bf=100 VA=100) *.DC VD -0.6 0.6 0.01:DC SWEEP .TRAN 2U 3MS;TRANSIENT ANALYSIS .PROBE .End
0
VD RD E+
Q1 Q2
R1 R2 VCC
E-
R4
Q4 Q3
VEE
1 2 3 6
5
0
4
7
8
9
990208GGH02
- 37 -
Simulation result
??PSpice Tips
- 38 -
6. Output Request ??General form
.PRINT AC VDB(5) VP(5)
.PROBE
Output Features Print
Dumps the selected variables to the output file
Plot Plots the selected variables in the output file
Probe
Invokes the graphical waveform analyzer equipped with a post-processor that provides arithmetic manipulation of the output variables
- 39 -
??Example: Squire wave and its spectrum
PSpice code
SQUARE WAVE AND ITS SPECTRUM * **************** * *** SPECTRUM *** * **************** .PARAM PMAG = 5 .PARAM PPER = 1MS .PARAM PI = 3.141592 VS 1S 0 PULSE ({-PMAG} {PMAG} 0 5NS 5NS {0.5*PPER} {PPER}) RS 1S 0 1 V1 1 0 SIN (0 {4*PMAG/(1*PI)} {1/PPER} R1 1 0 1 V3 3 0 SIN (0 {4*PMAG/(3*PI)} {3/PPER} R3 3 0 1 V5 5 0 SIN (0 {4*PMAG/(5*PI)} {5/PPER} R5 5 0 1 V7 7 0 SIN (0 {4*PMAG/(7*PI)} {7/PPER} R7 7 0 1 V9 9 0 SIN (0 {4*PMAG/(9*PI)} {9/PPER} R9 9 0 1 .TRAN 2US 3MS .PROBE .END
0
1S
VS RS
0
1
V1 R1
0
3
V3 R3
0
5
V5 R5
0
7
V7 R7
0
9
V9 R9
990208GGH02
- 40 -
Simulation result
??PSpice Tips 1. Arithmetic manipulations available for post-processing are shown in the
“Probe Screen.”
- 41 -
PSpice Modeling and Analysis of Switching Electronics
- 42 -
Simple Switching Circuit # 1
??Circuit representation of PSpice code
24V 2A
ON
OFF
10ms25ms
? ?
11
0
Vcon
D
Io
Vs
SW
? ?
0
D
Io
Vs11 12
RD
VD
- 43 -
??PSpice code
EXAMPLE OF SIMPLE SWITCHING CIRCUIT * ******************** * *** SWITCH01.CIR *** * ******************** VS 1 0 DC 24 SW 1 2 11 0 SMOD D 0 2 DMOD IO 2 0 DC 2 VCON 11 0 PULSE ( -5 5 0 1NS 1NS 10MS 25MS ) .MODEL SMOD VSWITCH (RON=0.01 ROFF=1E6) .MODEL DMOD D(N=1) .TRAN 1US 70MS .PROBE .END EXAMPLE OF SIMPLE SWITCHING CIRCUIT * ************** * *** CASE 2 *** * ************** VS 1 0 DC 24 M 1 11 2 2 IRF150 RD 12 11 5 D 0 2 DMOD IO 2 0 DC 2 VDRIVE 12 2 PULSE ( -8 8 0 1US 1US 10MS 25MS ) .MODEL DMOD D(N=1) .MODEL IRF150 NMOS (VTO=2.8 KP=30) .TRAN 1US 70MS .PROBE .END
- 44 -
Simple Switching Circuit #2
??Circuit representation of PSpice code
??PSpice code
EXAMPLE OF SIMPLE SWITCHING CIRCUIT * ******************** * *** SWITCH02.CIR *** * ******************** VS 1 0 DC 50 SW 1 2 11 0 SMOD D 0 2 DMOD L 2 3 1MH VO 3 0 DC 20 VCON 11 0 PULSE ( -5 5 0 1NS 1NS 0.08MS 0.2MS ) .MODEL SMOD VSWITCH (RON=0.01 ROFF=1E6) .MODEL DMOD D(N=1) .TRAN 5US 0.6MS 0MS 10US .PROBE .END
50V 20V
1mH
ON
OFF
0.08ms0.2ms
0
11
? ? ?
Vs
Vcon
D1 Vo
L
- 45 -
Solenoid Drive Circuit
??Circuit representation of PSpice code
90V 200mH
10ms100ms
? ?
?
?
?
0
Vcon
Vcc
S1
S2
L
D2
D1
VDU
- 46 -
??PSpice code
SOLENOID DRIVE CIRCUIT * ********************* * ***** SDRIVE01 ****** * ********************* VCC 1 0 DC 90 VDU 1 2 AC 0 S1 2 3 5 0 SMOD D1 0 3 DMOD L 3 4 200MH S2 4 0 5 0 SMOD D2 4 2 DMOD VCON 5 0 PULSE (-10 10 0 1U 1U 10MS 100MS) .MODEL SMOD VSWITCH (RON=0.001) .MODEL DMOD D .TRAN 0.1M 200MS .PROBE .END
- 47 -
Bridge Rectifier
??Circuit representation of PSpice code
??PSpice code
BRIDGE RECTIFIER * ********************* * ***** BRECTI01 ****** * ********************* VS 1 0 SIN(0 110 60HZ) RS 1 2 10 D1 2 4 D1N4148 D2 3 0 DIN4148 D3 0 4 DIN4148 D4 3 2 DIN4148 CF 4 3 50UF RL 4 3 1K .MODEL DIN4148 D(IS=0.1PA RS=0 CJO=2P TT=12N BV=200 IBV=0.1P) .TRAN 0.1U 0.04 .PROBE .END
t602sin110 ??
?5.0
50uF?K1
Vs
Rs
D4
D2
D1
D3CF
RL
? ?
? ?
0 ?
- 48 -
Controlled Full-Wave Rectifier
??Circuit representation of PSpice code
??PSpice code
CONTROLLED RECTIFIER .PARAM R=10 .PARAM VRMS=120 .PARAM ALPHA=60 .PARAM F=60 VS 1 0 SIN ( 0 {VRMS*SQRT(2)} 60 0 0 {ALPHA} ) D1 1 10 DMOD S1 10 2 D12 0 SMOD D3 0 11 DMOD
?10Vs
Q1 Q3
Q4 Q2
Q1,Q2
Q3,Q4
?60
?60
?
?
0
?
11
1312
10
D12
D34
Vcon34 Vcon12
S1
D1
D3
S3
S4
D4
S2
D2
RVs
- 49 -
S3 11 2 D34 0 SMOD D4 4 12 DMOD S4 12 1 D34 0 SMOD D2 4 13 DMOD S2 13 0 D12 0 SMOD R 2 4 {R} VCON12 D12 0 PULSE (-10 10 0 1US 1US {.51/F} {1/F} ) VCON34 D34 0 PULSE (-10 10 {0.5/F} 1US 1US {0.51/F} {1/F} ) .MODEL DMOD D .MODEL SMOD VSWITCH (RON=0.001) .TRAN .1MS 200MS 166.7MS 0.1MS .PROBE .END
- 50 -
Buck Converter
??Circuit representation of PSpice code
PSpice code
BUCK CONVERTER * ********************** * *** TIBUCK01.CIR *** * ********************** VS 1 0 DC 50 SW 1 2 11 0 SMOD D 0 2 DMOD L 2 3 1MH C 3 0 100UF R 3 0 4 VCON 11 0 PULSE ( -5 5 0 1NS 1NS 40US 100US ) .MODEL SMOD VSWITCH (RON=0.01 ROFF=1E6) .MODEL DMOD D(N=1) .TRAN 5US 5MS .PROBE .END
1mH
100uF ?450V
50us100us
VsVcon
L
C R
? ? ?
0
- 51 -
Boost Converter with Step Load Change
??Circuit representation of PSpice code
??PSpice code
BOOST CONVERTER WITH STEP LOAD CHANGE * ***************** * *** TIBOOST1 **** * ***************** VS 1 0 DC 12 L 1 2 60UH SW1 2 0 22 0 SMOD D 2 3 DMOD C 3 0 120UF RL1 3 0 8 RL2 3 3P 4 SW2 3P 0 33P 0 SMOD VCON1 22 0 PULSE(-1 1 0 1NS 1NS 80E-6 200E-6) VCON2 33P 0 PWL ( 0 0 1N 5 6E-3 5 6.1E-3 -5 20E-3 -5) .MODEL SMOD VSWITCH (RON=0.01 VON=0.1 VOFF=-0.1) .MODEL DMOD D (N=0.1) .TRAN 100US 10MS .PROBE .END
12V
60uH
120uF?8
?4
80us
200us
Vs
L
C
D
SW1RL1
RL2
? ? ?
22
Vcon1
Vcon20
3P
33P
- 52 -
Frequency-Domain Analysis of Buck Converter
??Small-signal model of buck power stage
0.05 37.5uH
0.02
400uF
5V
20uS
PWM
E/A
3.6
?116V
Qsw
Vramp
Vc
Z2
Vo=5V
Z1
980903ycy05
1:D
gv
dIL ˆ?
dVG ˆ? L Rl Li
oi
ov
Rc
C
R
980903ycy05
- 53 -
??Circuit representation of PSpice code
??PSpice code
OPEN-LOOP BUCK POWER STAGE ********************** ** OBUCK01.CIR ** ********************** ************** INPUT PARAMETERS **************** ************** MEASUREMENT OPTIONS ************* .PARAM PAU=0 ;INPUT-TO-OUTPUT [VDB(5)] .PARAM PZO=0 ;OUTPUT IMPEDANCE [VDB(5)] .PARAM PDH=1 ;CONTROL-TO-OUTPUT [VDB(5)] ************************************************ *** OPERATING CONDITIONS .PARAM PVG=16 ;INPUT VOLTAGE .PARAM PVC=5 ;OUTPUT VOLTAGE .PARAM PIO=5 ;LOAD CURRENT *** POWER STAGE PARAMETERS .PARAM PL1=37.5U ;INDUCTOR .PARAM PRL1=0.05 ;ESR OF THE INDUCTOR .PARAM PC1=400U ;CAPACITOR .PARAM PRC1=0.02 ;ESR OF CAPACITOR .PARAM PRL=1 ;LOAD RESISTOR ********************************* ***** CALCULATED PARAMETERS ***** ********************************* .PARAM PD={PVC/PVG} *********************************************** ***********************************************
VG
G1
G1D
EVD
EVG VDL1RL1
RC1
C1
RL
IO
IDH VDH
? ? ? ? ?4P
0
51
C1
980903ycy06
- 54 -
VG 1 0 AC {PAU} ***** PWM SWITCH ***** G1 1 0 VALUE={PIO*V(C1,0)} G1D 1 0 VALUE={PD*I(VD)} EVD 2 0 VALUE={PD*V(1,0)} EVG 3 2 VALUE={PVG*V(C1,0)} VD 3 4 AC 0 ;DUMMY SOURCE TO MEASURE IL RL1 4 4P {PRL1} L1 4P 5 {PL1} ***** OUTPUT CAP ***** RC1 5 51 {PRC1} C1 51 0 {PC1} IO 0 5 AC {PZO} ***** LOAD ***** RL 5 0 {PRL} ***** DUTY CYCLE PERTURBATION ***** IDH C1 0 AC 0 VDH C1 0 AC {PDH} .OPTIONS PIVTOL=10E-20 .AC DEC 100 10HZ 0.1MEGHZ .PROBE .PRINT AC VDB(5) VP(5,0) .END
- 55 -
??Small-signal model of buck converter with an integrator
??Circuit representation of PSpice code
??PSpice code
VOLTAGE-MODE CONTROLLED BUCK CONVERTER ******************* ** VBUCK01.CIR ** ******************* ************************************************ *** POWER STAGE: BUCK WITH SINGLE-STAGE OUTPUT *** FILTER
1:D
gV
dIL ˆ?
dVG ˆ?
L Rl Li
oi
oV
Rc
C
R
d Fm
CV3
980903ycy06
10K
VG
G1
G1D
EVD
EVG VDL1RL1
RC1
C1
RL
IO
? ? ? ? ?4 P
0
5 1
IDH
EDD
C1
CV3 RV1
EOV
RVO
IFV
RVI
VTM
EVO
V5
V3
V6
V1
V11
980903ycy06
- 56 -
*** CONTROL: VOLTAGE MODE CONTROL *** COMPENDATION:SIMPLE INTEGRATOR *** DATE OF UPDATED: 12/29/96 ************************************************ ************** INPUT PARAMETERS **************** ************** MEASUREMENT OPTIONS ************* .PARAM PAU=0 ;AUDIOSUSCEPTIBILITY [VDB(5)] .PARAM PZO=0 ;OUTPUT IMPEDANCE [VDB(5)] .PARAM PTM=1 ;OVERALL LOOP GAIN [VDB(5)] ************************************************ *** OPERATING CONDITIONS .PARAM PVG=16 ;INPUT VOLTAGE .PARAM PVC=5 ;OUTPUT VOLTAGE .PARAM PIO=5 ;LOAD CURRENT *** POWER STAGE PARAMETERS .PARAM PL1=37.5U ;INDUCTOR .PARAM PRL1=0.05 ;ESR OF INDUCTOR .PARAM PC1=400U ;CAPACITOR .PARAM PRC1=0.02 ;ESR OF CAPACITOR .PARAM PRL=1 ;LOAD RESISTOR *** PWM GAIN *** .PARAM PFM=0.2778 ************** CALCULATED PARAMETERS ********** *** DUTY CYCLE *** .PARAM PD={PVC/PVG} ;D *********************************************** VG 1 0 AC {PAU} ***** PWM SWITCH ***** G1 1 0 VALUE={PIO*V(C1,0)} G1D 1 0 VALUE={PD*I(VD)} EVD 2 0 VALUE={PD*V(1,0)} EVG 3 2 VALUE={PVG*V(C1,0)} VD 3 4 AC 0 ;DUMMY SOURCE TO MEASURE IL RL1 4 4P {PRL1} L1 4P 5 {PL1} ***** OUTPUT CAP ***** RC1 5 51 {PRC1} C1 51 0 {PC1} IO 0 5 AC {PZO} ***** LOAD ***** RL 5 0 {PRL} ***** OUTPUT VOLTAGE FEEDBACK ***** EVO V11 0 VALUE={(PAU+PZO)*V(5,0)} VTM V11 V1 AC {PTM} RV1 V1 V3 10E3 RVI V3 0 1E6 EOV 0 V6 VALUE={1E6*V(V3,0)} CV3 V3 V5 0.2U RVO V5 V6 10 IFV V5 0 AC 0 *** PWM *** EDD C1 0 VALUE={PFM*V(V5,0)} IDH C1 0 AC 0
- 57 -
.OPTIONS PIVTOL=10E-20 .AC DEC 50 10HZ 0.1MEGHZ .PROBE .PRINT AC VDB(5) VP(5,0) .END
??Buck converter with three-pole two-zero compensation
??Circuit representation of PSpice code
1:D
gV
dIL ˆ?
dVG ˆ?
L R l Li
oi
oV
Rc
C
R
dFm
C3
*3RR2 C1 C2
R1
980903ycy07
VG
G1
G1D
EVD
EVG VDL1RL1
RC1
C1
RL
IO
? ? ? ? ?4P
0
51
IDH
EDD
C1
CV3 RV1
EOV
RVO
IFV
RVI
VTM
EVO
V5
V3
V6
V1
V11
RV2 CV1 RV3 CV2
V4 V2
980903ycy07
- 58 -
??PSpice code
VOLTAGE-MODE CONTROLLED BUCK CONVERTER ******************* ** VBUCK02.CIR ** ******************* ************************************************ *** POWER STAGE: BUCK WITH 1-STAGE OUTPUT FILTER *** CONTROL : VOLTAGE MODE CONTROL *** COMPENSATION: THREE-POLE TWO-ZERO *** DATE OF LAST UPDATE: 12/29/96 ************************************************ ************** INPUT PARAMETERS **************** ************** MEASUREMENT OPTIONS ************* .PARAM PAU=0 ;AUDIOSUSCEPTIBILITY [VDB(5)] * .PARAM PZO=0 ;OUTPUT IMPEDANCE [VDB(5)] * .PARAM PTM=1 ;OVERALL LOOP GAIN [VDB(C3)] * ************************************************ *** OPERATING CONDITIONS .PARAM PVG=16 ;INPUT VOLTAGE .PARAM PVC=5 ;OUTPUT VOLTAGE .PARAM PIO=5 ;LOAD CURRENT *** POWER STAGE PARAMETERS .PARAM PL1=37.5U ;INDUCTOR .PARAM PRL1=0.05 ;ESR OF INDUCTOR .PARAM PC1=400U ;CAPACITOR .PARAM PRC1=0.02 ;ESR OF CAPACITOR .PARAM PRL=1 ;LOAD RESISTOR *** PWM GAIN *** .PARAM PFM=0.48 *** VOLTAGE COMPENSATION PARAMETERS .PARAM PKM=2500 ;INTEGRATOR GAIN .PARAM PWZ1={6.28*800} ;FIRST COMPENSATION ZERO .PARAM PWZ2={6.28*1000} ;SECOND COMPENSATION ZERO .PARAM PWP1={6.28*18000} ;FIRST COMPENSATION POLE .PARAM PWP2={6.28*25000} ;SECOND COMPENSATION POLE ********************************* ***** CALCULATED PARAMETERS ***** ********************************* .PARAM PD={PVC/PVG} ;D .PARAM PRV3=2200 .PARAM PCV2={1/(PRV3*PWP1)} .PARAM PRV1={1/(PCV2*PWZ2)-PRV3} .PARAM PC1PC3={1/(PKM*PRV1)} .PARAM PCV3={PWZ1*PC1PC3/PWP2} .PARAM PCV1={PC1PC3-PCV3} .PARAM PRV2={1/(PWZ1*PCV1)} ************************************************ VG 1 0 AC {PAU} ***** PWM SWITCH ***** G1 1 0 VALUE={PIO*V(C1,0)} G1D 1 0 VALUE={PD*I(VD)}
- 59 -
EVD 2 0 VALUE={PD*V(1,0)} EVG 3 2 VALUE={PVG*V(C1,0)} VD 3 4 AC 0 ;DUMMY SOURCE TO MEASURE IL RL1 4 4P {PRL1} L1 4P 5 {PL1} ***** OUTPUT CAP ***** RC1 5 51 {PRC1} C1 51 0 {PC1} IO 0 5 AC {PZO} ***** LOAD ***** RL 5 0 {PRL} ***** OUTPUT VOLTAGE FEEDBACK ***** EVO V11 0 VALUE={(PAU+PZO)*V(5,0)} VTM V11 V1 AC {PTM} CV2 V1 V2 {PCV2} RV3 V2 V3 {PRV3} RV1 V1 V3 {PRV1} RVI V3 0 1E6 EOV 0 V6 VALUE={1E6*V(V3,0)} CV1 V3 V4 {PCV1} RV2 V4 V5 {PRV2} CV3 V3 V5 {PCV3} RVO V5 V6 10 IFV V5 0 AC 0 *** PWM *** EDD C1 0 VALUE={PFM*V(V5,0)} IDH C1 0 AC 0 ***** COMPESATION PARAMETERS ***** VCV1 RC1 0 DC {-PCV1} RRC1 RC1 0 1 VCV2 RC2 0 DC {-PCV2} RRC2 RC2 0 1 VCV3 RC3 0 DC {-PCV3} RRC3 RC3 0 1 VRV1 RR1 0 DC {-PRV1} RRR1 RR1 0 1 VRV2 RR2 0 DC {-PRV2} RRR2 RR2 0 1 VRV3 RR3 0 DC {-PRV3} RRR3 RR3 0 1 .OPTIONS PIVTOL=10E-20 .AC DEC 50 10HZ 0.1MEGHZ .PROBE .PRINT AC VDB(5) VP(5,0) .END
- 60 -
Energy Transfer Circuit
??Circuit representation of PSpice code
??PSpice code
ENERGY TRANSFER CIRCUIT * ************************* * **** ENERGY01.CIR **** * ************************* .PARAM PVCC=24 .PARAM PD=0.45 .PARAM PC=5uF
24V100uH
1:1
5uF
45us
100us 980903ycy08
0
25
431
10
Vcc
VconSW Rcon
D
CLp Ls
980903ycy08
- 61 -
.PARAM PFREQ=10KHz
.PARAM PLm=100uH
.PARAM PLs=100uH VCC 1 0 DC {PVCC} LP 1 2 {PLm} IC=0 LS 5 3 {PLs} IC=0 K LP LS {1-1P} SW 2 0 10 0 SMOD D 3 4 DMOD C 4 5 {PC} IC=0 RCON 0 5 10MEG VCON 10 0 PULSE( 0 5 0 {0.001/PFREQ} {0.001/PFREQ} {PD/PFREQ} {1/PFREQ}) .MODEL SMOD VSWITCH (RON=0.001 ROFF=10E6 VON=5 VOFF=0) .MODEL DMOD D(N=1) .TRAN 100US 500US 0 100US UIC .PROBE .END
- 62 -
Turn-Off Snubber Circuit
??Circuit representation of PSpice code
??PSpice code
TURN-OFF SNUBBER CIRCUIT * ********************* * **** OFFSNUB1 **** * ********************* .PARAM PVS=80 .PARAM PIL=5 .PARAM PRS=256 .PARAM PCS=3.90625nF
80V
5A
?256
3.90625nF
5us
10us980903ycy09
1
23
0
Vs
DL IL
Ds
RsIBJT
980903ycy09
- 63 -
VS 1 0 DC {PVS} DL 2 1 DMOD IL 1 2 {PIL} DS 2 3 DMOD RS 2 3 {PRS} CS 3 0 {PCS} IBJT 2 0 PWL (0 5 0.5E-6 5 1E-6 0 5E-6 0) .MODEL DMOD D(CJO=0.001fF,RS=0.01,IS=1E-6) .TRAN 0.01US 1.5US UIC .PROBE .END