You are on page 1of 41

Workshop on PSPICE

Phase 1: Electric circuit simulation using


classical code based PSPICE
Engr. Dr. Hadeed Ahmed Sher, PhD
Assistant Professor, EED
KFUEIT, Pakistan

Monday, December 26, 2016

Slide credits
This presentation is based on the examples given in the following
book
Nilsson,J.W . Introduction to SPICE: Third edition electric circuits.
Addison Wesley Publishing company, 1990.

Dr.Sher
2

Contents

Why we need simulation ?


What is PSPICE ?
How it works ?
Circuit description
Format of circuit files
Examples

Dr.Sher
3

Why we need simulation ?


Engineering designs require accurate methods for evaluating the
circuit performance.
Complex IC structures need in-depth performance evaluations
Computer aided analysis helps us in
Finding the impact of variations in circuit elements.
Assessing the circuit improvements and degradations
Evaluating the effects of noise and distortion without expensive
measuring instruments.
Dr.Sher
4

Why we need simulation ? (Cont..)


Sensitivity analysis to estimate the safe
tolerance limits for each element.
Frequency domain analysis without using
expensive spectrum analyzers.
Assessing the non linearity of a circuit.
Optimizing the circuit design

Dr.Sher
5

What is PSPICE ?
It is a mainframe version of SPICE by microsim.
What is SPICE ?
Simulation Program with Integrated Circuit Emphasis
Based on nodal analysis

Developed in 1975 by University of California.


Other mainframe versions include

HSPICE
RAD-SPICE
IG-SPICE
I-SPICE
PSPICE

Dr.Sher
6

What is PSPICE ? (Cont..)


Some PC based versions are
ALLSPICE
ISSPICE
ZSPICE
SPICE-PLUS
DSPICE
LTSPICE
PSPICE

Dr.Sher
7

What is PSPICE ? (Cont..)


Limitations
Student version for only 10 transistors.
Professional version for 200 BJT and 150 MOSFET.
Not an iterative method
Specified output cannot lead us to the circuit synthesis.

Input impedance can only be calculated after running the graphic post
processor.
Distortion analysis is not possible.

Dr.Sher
8

How it works ?
We create a source file for the circuit.
Describe the circuit
Type of analysis
Specify the output

Source file is entered in the PSPICE program.


Print and plot the results.

Dr.Sher
9

Circuit description
Define
Nodes
Elements with values
Element models
Sources
Type of analysis
Output command
Format of output files
Dr.Sher
10

Circuit description (Cont..)


Nodes
Identify the location of the node.
Each element must be connected between two nodes.
Ground is predefined as node 0 (zero).
Each nodes must have at least two elements
PSPICE allows any alphanumeric string up to 131 characters.
Only nonnegative integers
O,$D_HI,$D_LO,$D-X cant be used as a node name
Dr.Sher
11

Circuit description (Cont..)


Elements with values
Each element must have a name
Must start with a letter. Can have a number afterwards.
Maximum 8 characters long.
Passive element format is simple
<name><positive node><negative node><value>
Interchanging the nodes results in the change in current
direction.
Dr.Sher
12

Circuit description (Cont..)


<name><positive node><negative node><value>

<R><1><2><100>
R 1 2 100
Initial condition if
L 2 3 5m
any
L 2 3 5M IC=5
Remember MEGA in PSPICE is MEG.

Dr.Sher
13

Circuit description (Cont..)


DC source code
<name><positive node><negative node><type>(value)
Vdc 1 0 DC 100V

AC source code
<name><positive node><negative node><type>(value)
Vac 1 0 sin (0 312 50)
Starting value

Peak value for


220Vrms

Frequency

Dr.Sher
14

Circuit description (Cont..)


Dependent sources
<name><connecting nodes><controlling nodes><voltage gain>
VS2 4 3 1 2 3

Note that V is + at node 1; therefore order of controlling node is 1 2.


Dr.Sher
15

Circuit description (Cont..)


Element values
Particularly important in active circuits
Semiconductor models needs to be defined.
Tasked for phase 2 which is scheduled in January, 2017.

Dr.Sher
16

Circuit description (Cont..)

DC sweep (.DC)
Bias point (.OP)
DC sensitivity (.OP)
Transfer Function (.TF)
DC small signal sensitivities (.SENS)
Noise Analysis
Transient response
Fourier analysis
Monte carlo
Temperature
DC analysis is automatically performed just by describing the circuit (see
Example 1)

Dr.Sher
17

Format of circuit files

TITLE {First line must not be a circuit element}


Circuit description
Analysis command Order is not important
Output command
END {Last line must be .end statement}
A very long statement can be shifted to a new line by a + sign in the
first column of next line.
A semicolon ; is used to comment.
Not case sensitive
Save the file with a .cir extension.
Dr.Sher
18

Example 1
Example 1
F1 0 1 Valpha 0.1
Valpha 0 5 DC 0
R1 1 4 10
R2 4 0 22
V1 2 1 DC 20
R3 2 3 2
R4 3 4 3.6
R5 3 5 68
.end
Dr.Sher

To see the output file : Click on View > Output file


19

Example 1 (Cont)

Power generated only by the


independent sources

Dr.Sher
20

Example 2

Dr.Sher
21

Example 2 (Cont..)
Example 2
I1 0 1 DC 24
Vdelta 1 3 DC 0 Dummy voltage source added to measure the branch current
H1 2 0 Vdelta 20.3846
R1 1 0 5
R2 3 0 20
R3 1 2 1
OUTPUT
Node 1 : 104 V
.end
Node 2 : 106 V
Node 3 : 104 V
Dr.Sher
22

Example 3 . DC analysis
If more in-depth analysis is required four options are available.
.OP
.DC
.TF
.SENS

Control statements are


always initiated by a
period.

.DC statement is used to increment a variable.


<.DC><IndSource Name><First Value>< Last value><increment>

Dr.Sher
23

Example 3 . DC analysis (Cont..)


Find io and Vo when the source Vg varies from 0 to 100 in 10V
steps.

Dr.Sher
24

Example 3 . DC analysis (Cont..)


Circuit prepared for PSPICE analysis.

Dr.Sher
25

Example 3 . DC analysis (Cont..)


EX3 for .DC command
VSO 1 0 DC 0
ISO 0 3 DC 5
Vdelta 4 3 DC 0
Source
R1 1 2 5
Initial value
R2 2 0 40
Final value
R3 2 3 8
Increment
R4 1 4 32
.DC VSO 0 100 10
Notice the control
.print DC I(Vdelta) V(1,2)
commands
.probe
.end
Dr.Sher
26

Example 3 . DC analysis (Cont..)

.DC command can also be used to sweep two variables. (Remember IV curve of diode ?)
.DC<Source A><First Value>< Last value><Increment A> <Source B><First Value>< Last value><Increment B>

Dr.Sher
27

Example 4 .TF command


It performs three parameters
Find the transfer function
Find the resistance seen by the source
Find the output resistance

.TF <output variable><Input source>


This command finds the thevenin equivalent of a given circuit.
Transfer function = Output variable/Input source
Input resistance seen by the input source
Output resistance at the output variable

No .PRINT command is necessary


Dr.Sher
28

Example 4 .TF command (Cont..)


Find the Thevenin equivalent with respect to the terminals a,b .

Dr.Sher
29

Example 4 .TF command (Cont..)


Circuit modified for PSPICE analysis

Dr.Sher
30

Example 4 .TF command (Cont..)


Ex4 Thevenin equivalent
V1 1 0 DC 119.59E-3
R1 1 2 4E3
R2 2 0 21k
Vdelta 2 3 DC 0
R3 3 4 1.65k
R4 4 0 600
R5 4 5 20k
F1 5 4 Vdelta 39
R6 5 0 750
.TF V(5,0) V1
.end
Dr.Sher
31

Example 4 .TF command

This is also the Thevenin voltage

Thevenin voltage can be calculated as


V1 * Transfer function = 119.59mV*-0.8359)= -0.1
Transfer function
Dr.Sher

Thevenin resistance

32

Example 5 .TF command

Dr.Sher
33

Example 5 .TF command (Cont..)


Circuit prepared for Example 5

Dr.Sher
34

Example 5 .TF command (Cont..)


EX 5
V1 1 0 DC 10
Vdelta 1 2 DC 0
R1 2 3 5
R2 3 4 15
V2 4 0 20
.TF V(3,0) V1
.end
Dr.Sher
35

Example 5 .TF command (Cont..)

Vth

Dr.Sher

Rth
36

Example 6 .TRAN command


Performs the transient analysis
.TRAN tstep tstop <tstart <tmax>> UIC
tstep is the plotting increment
tstop is the final time
tstart is the starting time. If not given =0
tmax is the maximum step size
UIC is the initial condition
Dr.Sher
37

Example 6 .TRAN command (Cont..)

Dr.Sher

The analytical solution of this circuit


Yields the following results
Peak value of Vc = 7.7V at 362.29microseconds
This circuit has an underdamped response
38

Example 6 .TRAN command (Cont..)


Ex 6
C1 1 0 2u IC=-10
R1 1 2 20
L1 2 0 10m IC=-90m
.tran 20e-6 2000e-6 UIC
.plot tran V(1)
.probe
.end
Dr.Sher
39

Example 6 .TRAN command (Cont..)

Dr.Sher
40

You might also like