Вы находитесь на странице: 1из 57

Introduction to PSPICE

Ms. Alpana Barman

Assistant Professor, Dept. of EE


1
Haldia Institute of Technology
What is SPICE
• SPICE is a powerful general purpose
analog & digital circuit simulator
• used to verify circuit designs
• to predict about circuit behavior
• developed at the Electronics
Research Laboratory of the
University of California, (1975)

2
Full form of SPICE

• Simulation Program for Integrated


Circuits Emphasis

• PSpice is a PC version of SPICE

3
WHY SIMULATE?

 Test design ideas


 Save Time
 Predict Circuit Performance
 Make Difficult Measurements
 Hands-On Learning

4
To run Spice
• Start P-Spice
• Draw a schematic of the circuit (can
be skipped)
or
• Create an input file describing circuit
• Run the program
• Look at the output file and/or print
the results
5
To start with P-Spice A/D
• Create a new text file
• Write program in the text file
• Save the program
• Open the circuit file
• Run the program
• See required output file

6
Input File of P-Spice A/D
• A SPICE input file, called source file, consists of
five parts :

 Title statement: title of the circuit


 Data statements: description of the components and the
interconnections.
 Control statements: tells SPICE what type of analysis to
perform on the circuit.
 Output statements: specifies what outputs are to be
printed or plotted.
 Program terminating statement: tells SPICE to stop the
program

Page 38 Page 35 7
Format for a SPICE file
• titles statement

• circuit description

•power supplies/ signal sources


•element descriptions
•model statements

• analysis requests

• output requests
.end

8
Some Facts and Rules
about P-Spice A/D
• PSpice is not case sensitive
– Names such as Vbus, VBUS, vbus50
andHz ACvBuS
even Circuit
are equivalent
in the program. Vs 1 0 AC 120V 0
• All element names must be uniqueRg 1 2 0.5
– Therefore, you can't have two resistors that are named "R2“
and “r2“ Lg 2 3 3.183mH
• The first line in the data file is usedRm 3 as 4a title
16.0
Lm data.
– PSpice will ignore this line as circuit 4 0 31.83mH
Cx 3 0 132.8uF
– Do not place any actual circuit information in the first line.
• There must be a node designated.AC "0"LIN 1 50. 50
(Zero)
– This is the reference node against .PRINT ACvoltages
which all VM(3) VP(3)
are
calculated +IM(Rm) IP(Rm) IM(Cx)
• Each node must have at least two+IP(Cx) elements attached to it
.END

9
Some Facts and Rules about
PSpice (Contd….)
• All lines that are not blank (except for the title line) must
have a character in column 1, the leftmost position on the
line
 Use "*" (an asterisk) in column 1 in order to create a comment
line

 Use "+" (plus sign) in column 1 in order to continue the previous


line

 Use "." (dot) in column 1 followed by the rest of the "dot


command" to pass special instructions to the program

 Use the designated letter for a part (circuit element) in column 1


followed by the rest of the name for that part (no spaces in the
part name)

10
Some more Facts and
Rules about P-Spice A/D
• Use ";" (semicolon) to terminate data on a line if
you wish to add commentary information on that
same line

• Use "white space" (spaces or tabs) to separate


data fields on a line

• The last line in any data file must be ".END“

11
Large and Small Numbers in
PSpice
Number symbol Common Name

1012 "T" or "t" tera


109 "G" or "g" giga
106 "MEG" or "meg" mega
103 "K" or "k" kilo
10-3 "M" or "m" milli
10-6 "U" or "u" micro
10-9 "N" or "n" nano
10-12 "P" or "p" pico

12
An alternative approach
• “Textual scientific notation"
This notation is written by typing an "E" followed
by a signed or unsigned integer indicating the
power of ten
656,000 = 6.56E5

-0.0000135 = -1.35E-5

8,460,000 = 8.46E6

13
Types of circuit analyses
• Linear DC analysis
• Linear AC analysis
• Linear AC Analysis: calculates the output as a
function of frequency. A bode plot is generated.
• Linear Transient analysis (time domain)
• Non-linear transient analysis
• Noise analysis
• Sensitivity analysis
• Distortion analysis
• Fourier analysis: calculates and plots the
frequency spectrum.

14
Components
• Independent and dependent voltage and current
sources
• Resistors
• Capacitors
• Inductors
• Mutual inductors
• Transmission lines / paths
• Operational amplifiers
• Switches
• Diodes
• Bipolar transistors
• Digital gates

15
Data Statements to Specify the
Circuit Components and Topology
• name a component
• designate the nodes where it's connected,
• and give it a value.

For example,
RS 1 2 1000 ;

A resistance (name RS) of 1000 ohm is connected


between nodes 1 and 2

16
Data Statements to Specify the
Circuit Components and Topology….
• VOLTAGE SOURCE
SPICE has many voltage sources
available:
SINEWAVE, PULSE, AC, DC, etc.

17
Data Statements to Specify the
Circuit Components and Topology….
• Time domain example

VS 1 0 SIN(0V 0.2V 10kHz)

• It generates a sine wave source


(name VS) for the Transient (time)
Analysis. This sine wave has a DC
offset of 0 V, a peak amplitude of
0.2 V and a frequency of 10 kHz.

18
To Start With ………

Independent DC Sources
 Voltage source: Vname N1 N2 Type Value
 Current source: Iname N1 N2 Type Value

19
Independent voltage
sources
Examples:
*name +node -node type value comment

Va 4 2 DC 16.0V; "V" after "16.0" is optional

VWX 23 14 18k ; "dc" not really needed

vwx 14 23 DC -1.8E4 ;

20
Independent current
source
*name +node -node type value comment

Icap 11 0 DC 35m ; 35mA flows from node 11 to 0

ix 79 24 1.7 ; "DC" not needed

I12 43 29 DC 1.5E-4 ;

I12 29 43 dc -150uA ; same as above

21
Resistors

*name +node -node value comment

rshnt 12 15 99m ; 0.099 ohm resistor

Rbig 19 41 10MEG ; 10 meg-ohm resistor

Rabc 31 0 14k ; reported current from 31 to 0

Rabc 0 31 14k ; reported current changes sign

22
Linear Inductors in PSpice

*name +node -node L_val initial cond


Lag 1 2 50m IC=2.5

Lag 1 2 50mH IC=2.5A

23
Mutual Inductances in PSpice
*name node1 node2 inductance (comment line)
L1 1 2 40mH
L2 3 4 10mH

24
Linear Capacitors in Pspice

*name +node -node C_val initial cond

Cfb 4 5 50u IC=20

Cfb 4 5 50uF IC=20V

25
Example1
EXMPL01.CIR • Circuit Diagram
Vs 1 0 DC 20.0V
Ra 1 2 5.0k
Rb 2 0 4.0k
Rc 3 0 1.0k
Is 3 2 DC 2.0mA
.END

The output file


EXMPL01.OUT
is below 26
Continue...
Example_1 EXMPL01.CIR Title Line
Vs 1 0 20.0V
Ra 1 2 5.0k
Rb 2 0 4.0k
Rc 3 0 1.0k
Is 3 2 2.0mA
.END

Example_1 EXMPL01.CIR Title Line


NODE VOLTAGE NODE VOLTAGE NODE VOLTAGE NODE VOLTAGE
( 1) 20.0000 ( 2) 13.3330 ( 3) -2.0000 Results
VOLTAGE SOURCE CURRENTS
NAME CURRENT
Vs -1.333E-03 <== Current entering node 1 of Vs
TOTAL POWER DISSIPATION 2.67E-02 WATTS
JOB CONCLUDED
TOTAL JOB TIME .26

27
Still More Components ……
D device – Diode
M device – MOSFET
Q device - Bipolar Transistor
S device - Voltage-Controlled Switch
T device - Transmission Line
K device - Inductor Coupling
X device – Sub-circuit Call

28
Commands or Control Statements
to Specify the Type of Analysis
.DC Statement [DC Analysis]
This statement allows you to increment
(sweep) an independent source over a certain
range with a specified step

.DC name START STOP STEP


.DC V1 0 20 2
In the last statement above, the voltage V1
will be swept from 0 to 20V in steps of 2V

29
Commands or Control Statements
to Specify the Type of Analysis
.TRAN Statement [Transient Analysis]
This statement specifies the time interval
over which the transient analysis takes
place, and the time increments.
.TRAN TSTEP TSTOP <UIC>
.TRAN 5NS 100NS

requests a Transient (time) Analysis for a duration of 100


ns and prints out the results at 5 ns intervals.

30
Output Statements
The two types of outputs are the prints and plots.

A print is a table of data points &


a plot is a graphical representation

.PRINT TYPE OV1 OV2 OV3 ...


.PLOT TYPE OV1 OV2 OV3 ...

in which TYPE specifies the type of analysis to be printed


or plotted and can be:
 TRAN
 DC
 AC
The output variables are OV1, OV2 and can be voltage or currents.

31
Output Statements
Examples:

.PLOT DC V(1,2) V(3) I(Vmeas)

.PRINT TRAN V(3,1) I(Vmeas)

.PLOT AC VM(3,0) VDB(4,2) VM(2,1) VP(3,1) IR(V2)

32
Output Statements

.PROBE
This statement that causes PSpice to save the
data in a Common Simulation Data Format (CSDF)
which is a text format that allows us to look at
the raw data with a text editor
.PROBE V(5,23) I(Rx) I(L4)
The above statement tells PSpice to save only the voltage
drop between nodes 5 and 23, the current through resistor,
Rx, and the current through inductor, L4, all in binary
format. No other data will be saved.

33
Programming in PSPICE

Mr. Namrajit Dey

Assistant Professor, Dept. of EE


34
Haldia Institute of Technology
DC Analysis in PSpice
Probe the magnitude of current through Rb as Vs
is varied from 0 to 20 Volts.

DC Analysis
Vs 1 0 DC 20.0V
Ra 1 2 5.0k
Rb 2 0 4.0k
Rc 3 0 1.0k
Is 3 2 DC 2.0mA
.DC vs 0 20 2
.probe I(Rb) ; how I varies with Vs
.END

43 Page 7 35
DC Analysis in PSpice
Probe the magnitude of current through Rb as Vs
is varied from 0 to 20 Volts.

Plot represnts how I(Rb) changes with Vs

36
AC Analysis in PSpice
Print the magnitude and phase of voltage across
capacitor Cx and also magnitude and phase of
current flowing through Rm at 50 Hz.
50 Hz AC Circuit
Vs 1 0 AC 120V 0
Rg 1 2 0.5
Lg 2 3 3.183mH
Rm 3 4 16.0
Lm 4 0 31.83mH
Cx 3 0 132.8uF
.AC LIN 1 50 50
.PRINT AC VM(3) VP(3)
+IM(Rm) IP(Rm) IM(Cx)
+IP(Cx)
.END

43 Page 7 37
Steady-State AC Analysis in PSpice
50 Hz AC Circuit
**** SMALL SIGNAL BIAS SOLUTION TEMPERATURE
= 27.000 DEG C
*************************************************************
*****************
NODE VOLTAGE NODE VOLTAGE NODE VOLTAGE
NODE VOLTAGE
( 1) 0.0000 ( 2) 0.0000 ( 3) 0.0000 ( 4)
0.0000
VOLTAGE SOURCE CURRENTS
NAME CURRENT
Vs 0.000E+00
TOTAL POWER DISSIPATION 0.00E+00 WATTS
*************************************************************
*****************
FREQ VM(3) VP(3) IM(Rm) IP(Rm) IM(Cx)
5.000E+01 1.188E+02 -2.937E+00 6.296E+00 -3.494E+01
4.956E+00
FREQ IP(Cx)
5.000E+01 8.706E+01
JOB CONCLUDED
TOTAL JOB TIME 0.00

38
Using P-Spice to find Thevenin’s
Equivalent Circuit
5 Ohm 10 Ohm
1 2 3
A

10V 5 Ohm 5 Ohm

B
0
THEVENIN EQUIVALENT CIRCUIT
V1 1 0 DC 10
R1 1 2 5
R2 2 0 5
R3 2 3 10
R4 3 0 5
.TF V(3,0) V1
.END
39
Using P-Spice to find Thevenin’s
Equivalent Circuit
THEVENIN VOLTAGE
**** SMALL SIGNAL BIAS SOLUTION TEMPERATURE = 27.000 DEGC
***********************************************************************
*******
NODE VOLTAGE NODE VOLTAGE NODE VOLTAGE NODE
VOLTAGE
( 1) 10.0000 ( 2) 4.2857 ( 3) 1.4286
VOLTAGE SOURCE CURRENTS
NAME CURRENT
V1 -1.143E+00
TOTAL POWER DISSIPATION 1.14E+01 WATTS
**** SMALL-SIGNAL CHARACTERISTICS
V(3,0)/V1 = 1.429E-01 Transfer Function
INPUT RESISTANCE AT V1 = 8.750E+00
OUTPUT RESISTANCE AT V(3,0) = 3.571E+00 Thevenin’s Resistance
JOB CONCLUDED
TOTAL JOB TIME .02
40
Application of Thevenin’s Theorem

5 Ohm 10 Ohm
1 2 3
APPLICATION OF THEVENIN'S THEOREM

I(5 V1 1 0 DC 10
10V 5 Ohm
5 Ohm Ohm) R1 1 2 5
R2 2 0 5
R3 2 3 10
0 R4 3 0 1Meg
.TF V(3,0) V1
.END
41
Application of Thevenin’s Theorem
THEVENIN EQUIVALENT CIRCUIT
**** SMALL SIGNAL BIAS SOLUTION TEMPERATURE = 27.000
DEG C
*********************************************************************
*********
NODE VOLTAGE NODE VOLTAGE NODE VOLTAGE NODE
VOLTAGE
( 1) 10.0000 ( 2) 5.0000 ( 3) 4.9999
VOLTAGE SOURCE CURRENTS
NAME CURRENT
V1 -1.000E+00
TOTAL POWER DISSIPATION 1.00E+01 WATTS
**** SMALL-SIGNAL CHARACTERISTICS
V(3,0)/V1 = 5.000E-01 Transfer Function
INPUT RESISTANCE AT V1 = 1.000E+01
OUTPUT RESISTANCE AT V(3,0) = 1.250E+01 Thevenin’s Resistance
JOB CONCLUDED
TOTAL JOB TIME 0.00
42
Example of Transient
Circuit Analysis
Natural Response of a parallel RLC circuit
Rp 0 1 1.0
Lp 1 0 8mH IC=20A
Cp 1 0 10mF IC=0V
.TRAN 500us 100ms
.PROBE
.END

43
Example of Transient Circuit
Analysis
Voltage across node 1 & 0 (V1)

44
Example of Transient Circuit
Analysis
Current through inductor I(Lp)

45
R-C Series Circuit
Transient Analysis
RC transient analysis
Vpulse 1 0 pulse(0 5 0 0 0 50m 100m)
R 1 2 20
C 2 0 500u R

.tran 0.2us 200ms 20


.probe v(2,0) I(R)
.end V1 = 0v
V2 = 5v
Vpulse
C
TD = 0
TR = 0 500uF
TF = 0
PW = 50ms
PER = 100ms 46
R-C Series Circuit
Transient Analysis
Voltage across C V(2,0)

47
R-C Series Circuit
Transient Analysis
Charging Current through R I(R)

48
Assignment Sheet
1. Write down a SPICE program to calculate the current
through the 5 ohm resistance in the following circuit
given below.

49
Circuit Example
Example_1 EXMPL01.CIR
Va 1 0 DC 20.0V ; note the node placements
Vb 4 0 DC 10.0V
Vc 5 0 DC 50.0V
R1 1 2 15.0
R2 4 2 10.0
R3 3 2 20.0
R4 3 5 10.0
R5 3 0 5.0
.END
The output file EXMPL01.OUT is below. This has been edited to remove
extra lines.
Example_1 EXMPL01.CIR <== Title Line
Va 1 0 DC 20.0V ; note the node placements
Vb 4 0 DC 10.0V
Vc 5 0 DC 50.0V
R1 1 2 15.0
.DC Va 20 20 1 ; this enables the .print R2 4 2 10.0
commands R3 3 2 20.0
.PRINT DC V(1,2) I(R5) R4 3 5 10.0
R5 3 0 5.0
.DC Va 20 20 1 ; this enables the .print commands
.PRINT DC V(1,2) I(R5)
.END
Example_1 EXMPL01.CIR <== Title Line
**** DC TRANSFER CURVES TEMPERATURE = 27.000 DEG C
Va V(1,2) I(R5)
2.000E+01 5.455E+00 3.273E+00
JOB CONCLUDED
TOTAL JOB TIME .02 50
Assignment Sheet
2. Use PSpice to find voltage across 103.2ohm in the circuit
given below. Magnitude of voltage is varied between 5 to
105 v in steps of 10v.

51
Program:assign.2

50 Hz AC Circuit
Vs 2 0 AC 105V 0
R1 1 0 36.0
R2 1 0 12.0
R3 1 2 74.0
R4 2 3 16.4
R5 3 4 103.2
R6 0 4 28.7
.AC LIN 1 50 50
.step Vs 5 105 10
*.step variable startvalue stopvalue incrementstep
.PRINT AC V(3,4)
.END

52
Assignment Sheet
3. A circuit with two coupled inductors is shown in figure
below. If the input voltage is120V peak; calculate the
magnitude and phase of the output current for
frequencies varying 60 to 120Hz with a linear increment
using PSpice. The total number of points in the sweep is
2.The coefficient of coupling for the transformer is
0.999.

53
Program:assign.3
mutuAL inductance
Vin 1 0 ac 120
R1 1 2 0.5
R2 4 3 0.5
RL 4 0 150
L1 2 0 0.5M
L2 0 3 0.5M
K L1 L2 0.999 n+ node is taken as that
.ac lin 2 60 120 node where
*.AC [LIN] {points} {fstart} {fend}
Dot is marked
.PRINT AC IM(RL) IP(RL)
.END

54
Using P-Spice to find Thevenin’s
Equivalent Circuit
Thevenin Example- No. 2
Vs 2 5 DC 100V
Vc 2 3 DC 0V; controls Fx
Fx 6 7 Vc 4.0; gain = 4
* n+ n- NC+ NC gain
Ex 2 1 5 4 3.0; gain = 3
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; satisfies PSpice
* out_var input_source
.TF V(1,0) Vs
.END

32
29 55
Using P-Spice to find Thevenin’s
Equivalent Circuit
Thevenin Example No. 2
**** CIRCUIT DESCRIPTION
Vs 2 5 DC 100V
Vc 2 3 DC 0V; controls Fx
Fx 6 7 Vc 4.0; gain = 4.0
Ex 2 1 5 4 3.0; gain = 3.0
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
Rab 1 0 1MEG
.TF V(1,0) Vs
Thevenin Example No. 2
**** SMALL SIGNAL BIAS SOLUTION TEMPERATURE = 27.000 DEG C
NODE VOLTAGE NODE VOLTAGE NODE VOLTAGE NODE VOLTAGE
( 1) 180.0000 ( 2) -60.0010 ( 3) -60.0010 ( 4) -80.0010
( 5) -160.0000 ( 6) -176.0000 ( 7)-864.0E-06
VOLTAGE SOURCE CURRENTS
NAME CURRENT
Vs -4.000E+00
Vc 4.000E+00
TOTAL POWER DISSIPATION 4.00E+02 WATTS
**** SMALL-SIGNAL CHARACTERISTICS
V(1,0)/Vs = 1.800E+00 <== Transfer function
INPUT RESISTANCE AT Vs = 2.500E+01
OUTPUT RESISTANCE AT V(1,0) = 5.000E+00 <== Thévenin resistance
JOB CONCLUDED
TOTAL JOB TIME .01 56
THANK

YOU
57

Вам также может понравиться