Using PSpice for Circuit Simulation

Revised

Fall 2006

PSpice allows one to simulate electrical circuits using models of electrical components. One can use a graphically based approach, using the schematic editor, or use a text based approach depending on the version of SPICE. Let us first look at the text based approach.

SCALE FACTORS

Scale factors for values are as follows [1]

F or f10^-15

P or p10^-12

N or n10^-9

U or u10^-6

M or m10^-3

K or k10^3

MEG or meg10^6

G or g10^9

T or t10^12

INDEPENDENT VOLTAGE/CURRENT SOURCES [1]

For DC voltage Vxxx/current Ixxx sources, the syntax is

Vxxx node+ node- DC DC Mag (volts)

Ixxx node+ node- DC DC Mag (amperes).

For AC voltage Vxxx/current Ixxx sources, the syntax is

Vxxx node+ node- AC AC Mag (volts) AC phase (degrees)

Ixxx node+ node- AC AC Mag (amperes) AC phase (degrees).

For transient voltage Vxxx/current Ixxx sources, the syntax is

Vxxx node+ node- transient_type

Ixxx node+ node- transient_type

The transient types for voltage/current can be EXP (exponential), PULSE (pulse), PWL (piece wise linear), and SIN (damped sinusoid). The list below describes the voltage sources. The current sources are described similarly except that voltage is replaced by current.

1)EXP (start voltage peak voltage delay for first change in voltage rise time constant from start

to peak delay for exponential decay from peak fall time constant from peak to start)

2)PULSE (minimum voltage maximum voltage delay to pulse rise time from minimum to peak fall time from maximum to minimum pulse width at maximum value pulse period)

3)PWL (ti value at ti tj value at tj ……. ) paired values for source, at ti, the source has value of value(ti)

4)SIN (value at time 0 peak voltage frequency in Hz delay before oscillation starts dampen is the damping coefficient phase shift)

BASIC COMPONENT MODELS [1]

Resistors

For basic resistors the syntax is

Rxxx node+ node- resistor value in ohms

Inductors

For basic inductors the syntax is

Lxxx node+ node- inductor value in henries

Capacitors

For basic capacitors the syntax is

Cxxx node+ node- resistor value in farads

COMMON ANALYSIS [1]

DC

For DC analysis the syntax is as follows:

.DC DC sweep type voltage name start value for voltage name end value for

voltage name step size or number of points used

AC

For AC analysis the syntax is as follows:

.AC AC sweep type number of points used or the number of points used starting frequency for analysis ending frequency for analysis

sweep types

1)LIN denotes a linear sweep, uses the step size to increment the voltage of voltage name

2)OCT is a logarithmic sweep done in octaves, uses number of points per octave

3)DEC is a logarithmic sweep done in decades, uses number of points per decade

Transient

For basic transient analysis the syntax is as follows:

.tran time step used in the simulation ending time of simulation

EXAMPLES

Let us look at the following example circuit. First we will set up the text based file describing the circuit. After that we will look at a GUI version of SPICE where the circuit is input using a schematic editor.

Figure 1. – Simple Resistive Circuit

We can find the current and voltages in the circuit. Let us find the current through R1, R2, and R3 as well as the voltage drops across each resistor.

First R2 and R3 are in parallel. We know thatRparallelis found by the following for two resistors R2 and R3.

Therefore Rparallelis 1kΩ.

Figure 2. – Simple Resistive Circuit Equivalent

Next we can find the current through R1 using Ohm’s Law.

Thus the voltage drop across R1 is

This is also the drop across Rparallel since it is also 1k. Therefore there is a 5V drop across R2 and R3 since these two are in parallel. The current through each then can be determined using Ohm’s Law.


I2 and I3 are both 2.5 mA since both branches have the same resistance.

Now let us use PSPICE to solve for these same values. First we need to input the circuit. We can draw the circuit and number all nodes. Use node 0 for the reference node or ground node.

Figure 3. - Simple Resistive Circuit with All Nodes Numbered

One should generate a .cir file which incorporates text describing the interconnections of the circuit and the analysis to be performed. Then if using the ORCAD Pspice Student Version 9.1, 9.2, start PSpice AD. Click File, then click on open. Browse for your *.cir file. Open it. If one has made no mistakes, then one can click on Simulation. Then click run. After it finishes, choose the analysis from the list of possibilities that were stated in the file. The .probe statement will then open the PROBE environment. Since the file below did not specify which variables to look at using probe there will not be any displayed. However, one can add traces using the menus at top ADD TRACE.

The text file for the above figure will follow on the next page.

**

**

**Text PSPICE example

**Filename - SimpleResistive.cir

**

R1 1 2 1k

R2 2 0 2k

R3 2 0 2k

V1 1 0 DC 10V

** operating point for circuit, the bias points for the circuit

.OP

** DC analysis, linear sweep, V1 varied linearly from 0-10 in 0.5 volt ** steps

.DC LIN V1 0 10 0.5

** plotting tool started, we will have to add traces in the probe

** window since we did not specify which outputs to look at

.probe

** end of file

.end

Figure 4. – Node Voltages

Figure 5. – Currents in Each Branch

All text files should include a commented title line first, or in this case multiple comments were included

** text  comment is designated

Thus the simulation has generated data as V1 varied from 0 to 10V. Specifically we found the values at V1=10V which check with the values we have obtained from the plots above.

We can also look at the .out (output) file that was generated for the .cir (circuit) file. The file SimpleResistive.out is included on the next page. The file includes the operating point given V1 of 10V. The node voltages in this case match exactly with what we calculated.

**** 10/04/05 18:19:50 *********** Evaluation PSpice (Nov 1999) ****************

**** CIRCUIT DESCRIPTION

******************************************************************************

**

** Text PSPICE example

** Filename - SimpleResistive.cir

**

R1 1 2 1k

R2 2 0 2k

R3 2 0 2k

V1 1 0 DC 10V

** operating point for circuit, the bias points for the circuit

.OP

** DC analysis, linear sweep, V1 varied linearly from 0-10 in 0.5 volt ** steps

.DC LIN V1 0 10 0.5

** plotting tool started, we will have to add traces in the probe

** window since we did not specify which outputs to look at

.probe

** end of file

.end

**** 10/04/05 18:19:50 *********** Evaluation PSpice (Nov 1999) **************

**

**** SMALL SIGNAL BIAS SOLUTION TEMPERATURE = 27.000 DEG C

******************************************************************************

NODE VOLTAGE NODE VOLTAGE NODE VOLTAGE NODE VOLTAGE

( 1) 10.0000 ( 2) 5.0000

VOLTAGE SOURCE CURRENTS

NAME CURRENT

V1 -5.000E-03

TOTAL POWER DISSIPATION 5.00E-02 WATTS

**** 10/04/05 18:19:50 *********** Evaluation PSpice (Nov 1999) ****************

**** OPERATING POINT INFORMATION TEMPERATURE = 27.000 DEG C

******************************************************************************

JOB CONCLUDED

TOTAL JOB TIME .01

If using the GUI Pspice (for example student PSpice 9.1, or 9.2), then start the Pspice schematics. Under File, click on New. This will bring up a new schematic sheet. To place parts, click on Draw from the toolbar, then click get new part (CTRL+G). A menu should drop down detailing some of the libraries available with the version of spice you are using. Find the part you are looking for and click on either Place or Place and Close.

If you have placed the part previously, place part (Ctrl+P) from that menu would bring up a drop down menu with previously placed parts which you could click on. To draw wires or a bus, you can repeat the above process but this time click on wire or bus instead of get new part, or use (CTRL+W) for wires or (CTRL+B) for a bus.

To edit the part values double click on the component or double click on the value. To place voltage or current probes, from the toolbar click on markers. The menu has choices for voltage, differential voltage, current, etc. Thus the circuit below can be put in part by part.

If one looks at the above circuit, one sees that the circuit implements a non-inverting amplifier with gain [1 + R2/R1]. The operational amplifier used is an LM324 which can be found on one of the data sheets that you looked at on homework one. The compensating resistor Rp has been implemented as R4 in parallel with R5.

Note the above amplifier is powered using a single power supply, (one power supply is GND). The circuit has each node labeled with a unique number. The duplicate numbers around the operational amplifier as can be seen below, denote the pin numbers as can be found on the data sheets. Thus pins are as follows:

Pin Number Signal

3non-inverting input

2inverting input

11negative power supply

4positive power supply

1 output

For the simulation output, the circuit will automatically generate the voltages at nodes 2, 11, and 1 since voltage probes (markers) were placed there in the circuit.

The following text file describes the connections in the original figure.

R denotes resistor, C capacitor, Vxxx voltage source, Ixxx current source, Lxxx inductor, Xxxx subcircuit.

R6 4 0 1k

R2 2 4 10k

R4 11 1 10k

R1 0 2 10k

R5 11 1 10k

V1 8 0 15V

V4 7 0 0V

V3 11 10 DC 0 AC 1 SIN 0 1 1K 0 0 0

V6 10 0 DC 0V AC 1V 0

X_U2A 1 2 8 7 4 LM324

V1 and V4 denote DC voltage sources. The syntax is

Vxxx node+ node- DC DC Mag.

V3 is a sinusoidal voltage source which is used in the transient analysis. The syntax is

Vxxx node+ node- DC DC Mag. AC AC Mag. SIN Offset Mag. Freq. Delay Damping Factor Phase

If one needs current sources instead, then can model with same syntax except denoted Ixxx for the name of the current source. Again the scale factors for values are as

follows [1]:

F or f10^-15

P or p10^-12

N or n10^-9

U or u10^-6

M or m10^-3

K or k10^3

MEG or meg10^6

G or g10^9

T or t10^12

Hence the resistors in the circuit have values of 10K.

Now that the circuit has been placed in the schematic editor. From the toolbar, click on analysis and click electrical rule check. After one has corrected any problems which were found in the electrical rule check, one can setup the analysis.

From the toolbar, click on analysis, then click setup. This menu allows one to setup DC sweep, transient, AC, monte carlo, etc analysis. If one clicks on the transient analysis, one can set the print step, the step ceiling, and final time which details the step size and maximum step size used in the transient analysis. If one has an AC source in the circuit, one can perform and AC analysis which will do a frequency sweep across the frequencies one sets in the AC setup for the AC source. This will generate a Bode type plot of the response. Other choices in the setup are available.

Thus for the circuit, one could set up an AC, transient, temperature, transfer function, and operating point analysis. The GUI for PSpice would then generate the text commands in the text file describing the circuit after you setup the analysis and click simulate.

Thus for AC analysis the syntax is as follows:

.ac type number points start freq (Hz) end freq (Hz)

so the text file that follows performs a linear sweep (in freq) from 10 to 10000KHz and takes 101 data points. Other types of sweep would be OCT and DEC which perform logarithmic sweeps either by octaves or decades; for these two, then the number of points would be per octave or decade.

Transient analysis would be as follows:

.tran time step end time time to initial plotted point internal step size of time

so the above performs a transient analysis from 0 to 5ms, and uses a time step size of 100ns.

.TEMP sets the simulation temperature at 25 degrees C.

.TF finds the transfer function. Thus the above finds V(4)/V3.

.OP find the operating bias point for the circuit.

If one wants to view high quality output plots, one can use the statement

.probe V(3) I(R1)

which will bring up a graphical interface for the simulation outputs, node voltage at node 3 and current through resistor R1. Or, one can use the print statement

.print AC V(3)

would print the AC voltage at node 3 in a table format.

THE FILE MUST end with a .end statement.

Thus if one wants to use PSpice without the graphical interface, one should generate a .cir file which incorporates text describing the interconnections of the circuit and the analysis to be performed. Then if using the ORCAD Pspice Student Version 9.1, 9.2, start PSpice AD. Click File, then click on open. Browse for your *.cir file. Open it. If one has made no mistakes, then one can click on Simulation. Then click run. After it finishes, choose the analysis from the list of possibilities that were stated in the file. The .probe statement will then open the PROBE environment. Since the file below did not specify which variables to look at using probe there will not be any displayed. However, one can add traces using the menus at top ADD TRACE.

**

**

**Text PSPICE example

**Filename - Textexample.cir

**

R6 4 0 1k

R2 2 4 10k

R4 11 1 10k

R1 0 2 10k

R5 11 1 10k

V1 8 0 15V

V4 7 0 0V

V3 11 10 DC 0 AC 1 SIN 0 1 1K 0 0 0

V6 10 0 DC 0V AC 1V 0

X_U2A 1 2 8 7 4 LM324

**** includes the library nom.lib to get the model for the opamp which **** came with the student version of PSpice

.lib "nom.lib"

.ac LIN 101 10 10000K

.tran 0ns .005s 0 .0000001

.TEMP 25

.TF V([4]) V3

.OP

.probe

.end

All text files should include a commented title line first, or in this case multiple comments were included

** text  comment is designated

This figure has replaced the operational amplifier with a model. This figure assumed a Rin of 1000K, Ro=0, and A = 100000K

The syntax for the voltage controlled dependent source is

Exxx non-invert. node invert. node controlling non-invert. controlling invert. Gain

Thus the text file *.cir would look as seen on the next page. Note the simulation for this model would not have a cutoff due to a pole in the model since there are no capacitors in the model. Therefore this model relates an ideal operational amplifier with infinite BW.
*

*

*Text PSPICE example

*

*

R6 4 0 1k

R2 2 4 10k

R4 11 1 10k

R1 0 2 10k

R5 11 1 10k

R7 1 2 1000k

V3 11 10 DC 0 AC 1 SIN 0 1 1K 0 0 0

V6 10 0 DC 0V AC 1V 0

E1 4 0 2 1 100000

**** includes the library nom.lib to get the model for the opamp which came with

**** the student version of PSpice

.lib "nom.lib"

.ac LIN 101 10 10000K

.tran 0ns .005s 0 .0000001

.TEMP 25

.TF V([4]) V3

.OP

.probe

.end

References:

1.James W. Nilsson and Susan A. Riedel, Introduction to PSPICE Manual for Electric Circuits, 6th Ed., Prentice Hall, 2002.