Introduction To Pspice: Creating A Circuit Description File
Introduction To Pspice: Creating A Circuit Description File
PSpice is a version of the standard circuit simulator Spice. The student edition of PSpice,
which is limited to small circuits, has been installed on the PCs in the circuits lab. You
may also download or order your own free copy of the student edition from Orcad by
going to http://www.cadencepcb.com/products/downloads/PSpicestudent/default.asp.
Creating a Circuit Description File
You can run PSpice by going to Programs ! !! ! PSpice Student ! !! ! PSpice AD Student
from the Start menu. Next, we have to create a text file that describes our circuit and the
simulation protocol. Create a new text file (File ! !! ! New ! !! ! Text File) and immediately
save it (File ! !! ! Save As) with the extension .cir (e.g., test.cir). Now you must open the
file (File ! !! ! Open, and change Types of Files to Circuit Files) before PSpice will
recognize it as a valid circuit description file.
Writing and Simulating a Circuit
Spice is a bit like a programming language, and you should review Appendices C and D
in Sedra and Smith for a description of this language. Another useful resource is
http://www.seas.upenn.edu:8080/~jan/spice/spice.overview.html;
especially the section on Most Common Mistakes. For now, lets type in the following
text:
* Test circuit. Remember, the first line is ALWAYS a comment.
* We can add additional comments by beginning a line with an asterisk.
* AC Voltage source, 1V magnitude, from node 1 to node 0 (ground):
Vin 1 0 AC 1
* 1 kOhm resistor from node 1 to node 2:
R1 1 2 1k
* 0.47 uF capacitor from node 2 to node 0 (ground):
C1 2 0 0.47u
* AC analysis, calculating 50 points per decade from 1 Hz to 1MHz:
.AC DEC 50 1 1MEG
* Enable plotting program:
.PROBE
.END
Now save the file, and run the simulation (Simulation ! !! ! Run). A new window should
appear with a blank plot. Note the tabs at the bottom left that you can click on to get
back to your circuit file. Go to Trace ! !! ! Add Trace and type VDB(2)-VDB(1). This
displays a magnitude Bode plot of the simple RC circuit you described from 10 Hz to 1
MHz. The output is node 2, and the input is node 1, so the transfer function is given by
the ratio of the two voltage magnitudes, but since were using a logarithmic measure
(dB), we subtract instead of dividing.
Now click on Plot ! !! ! Add Plot to Window A new box should appear above the old
plot. Now add a trace to this plot: VP(2)-VP(1). This is the phase Bode plot of our
circuit! So now we know how to do frequency-domain analysis. What about time-
domain analysis? Lets look at how this circuit responds to a square wave input. Go
back to the circuit file and replace the old description of Vin with this one:
Vin 1 0 pulse(-1 1 0 0 0 3m 6m)
This represents a voltage source connected to nodes 1 and 0 that generates pulses from 1
V to +1 V with a pulsewidth of 3 milliseconds and a repetition period of 6 milliseconds.
(Remember, 3m = 3M = 0.003; 3meg = 3MEG = 3,000,000.)
Now replace the .AC statement with the following statement:
.TRAN 12u 12m
This tells PSpice to do a transient (time-domain) analysis over 12 milliseconds, plotting
points every 12 microseconds. Run the simulation, and add the traces of V(1) and V(2)
to the same plot. You can print the circuit files or the plots (File ! !! ! Print).
Transistors
Transistors are a bit more complex than passive elements such as resistors and capacitors.
The format for entering a BJT in a circuit file is:
Qname collector base emitter model_name
For example:
Q1 4 7 6 Q2N3904
Where the model definition for this transistor must be included in the file:
.model Q2N3904 NPN(Is=6.734f Xti=3 Eg=1.11 VAf=74.03 Bf=416.4 Ne=1.259
+Ise=6.734f 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)
Notice that the + symbol is used to continue a statement on multiple lines. Dont be
intimidated by the model definition; it just contains a bunch of parameters used by PSpice
to simulate this particular transistor accurately. For example, VAf is the Early voltage
(V
A
= 74.03 V in this device), and Cjc is the parasitic capacitance between the base and
the collector (C