PSpice Tutorial
LTSpice is another version of SPICE. The tutorial for LTSpice is
modified from this one, so if you found the layout of this one useful,
you will probably find the LTSpice tutorial easy to follow.
LTSpice is more freely available than PSpice, and it runs under WINE on
Linux as well.
- Getting the Parts
- Placing the Parts
- Connecting the Circuit
- Changing the Name of the Part
- Changing the Value of the Part
- Making Sure You Have a GND
- Voltage and Current Bubbles
- Saving
- Printing
- Before you do the Probe
- To Start the Probe
- Graphing
- Adding/Deleting Traces
- Doing Math
- Labelling
- Finding Points
- Saving
- Printing
- VDC
- VAC
- VSIN
- VPULSE
- PWL
- Find PSpice on the C-Drive. Open Schematics or you can go to PSpice A_D
and then click on the schematic icon .
- The first thing that you have to do is get some or all of the parts you
need.
- This can be done by
- Clicking on the 'get new parts' button ,
or
- Pressing "Control+G", or
- Going to "Draw" and selecting "Get New Part..."
- Once this box is open, select a part that you want in your circuit. This
can be done by typing in the name or scrolling down the list until you find
it.
- Some common parts are:
- r - resistor
- C - capacitor
- L - inductor
- d - diode
- GND_ANALOG or GND_EARTH -- this is very important, you MUST have a ground
in your circuit
- VAC and VDC
- Upon selecting your parts, click on the place button then click where you
want it placed (somewhere on the white page with the blue dots). Don't worry
about putting it in exactly the right place, it can always be moved later.
- Once you have all the parts you think you need, close that box. You can
always open it again later if you need more or different parts.
- You should have most of the parts that you need at this point.
- Now, all you do is put them in the places that make the most sense (usually
a rectangle works well for simple circuits). Just select the part and drag
it where you want it.
- To rotate parts so that they will fit in you circuit nicely, click on the
part and press "Ctrl+R" (or Edit "Rotate"). To flip them, press "Ctrl+F" (or
Edit "Flip").
- If you have any parts left over, just select them and press "Delete".
- Now that your parts are arranged well, you'll have to attach them with wires.
- Go up to the tool bar and
- select "Draw Wire"
or
- "Ctrl+W" or
- go to "Draw" and select "Wire".
- With the pencil looking pointer, click on one end of a part, when you move
your mouse around, you should see dotted lines appear. Attach the other end
of your wire to the next part in the circuit.
- Repeat this until your circuit is completely wired.
- If you want to make a node (to make a wire go more then one place), click
somewhere on the wire and then click to the part (or the other wire). Or you
can go from the part to the wire.
- To get rid of the pencil, right click.
- If you end up with extra dots near your parts, you probably have an extra
wire, select this short wire (it will turn red), then press "Delete".
- If the wire doesn't go the way you want (it doesn't look the way you want),
you can make extra bends in it by clicking in different places on the way
(each click will form a corner).
- You probably don't want to keep the names C1, C2 etc., especially if you
didn't put the parts in the most logical order. To change the name, double
click on the present name (C1, or R1 or whatever your part is), then a box
will pop up (Edit Reference Designator). In the top window, you can type in
the name you want the part to have.
- Please note that if you double click on the part or its value, a different
box will appear.
- If you only want to change the value of the part (if you don't want all
your resistors to be 1K ohms), you can double click on the present value and
a box called "Set Attribute Value" will appear. Type in the new value and
press OK. Use u for micro as in uF = microFarad.
- If you double click on the part itself, you can select VALUE and change
it in this box.
- This is very important. You cannot do any simulation on the circuit if
you don't have a ground. If you aren't sure where to put it, place it near
the negative side of your voltage source.
- These are important if you want to measure the voltage at a point or the
current going through that point.
- To add voltage or current bubbles, go to the right side of the top tool
bar and select "Voltage/Level Marker" (Ctrl+M)
or "Current Marker" .
To get either of these, go to "Markers" and either "Voltage/Level Marker"
or "Current Marker".
- To save the circuit, click on the save button
on the tool bar (or any other way you normally save files).
- To print, you must first use your mouse to make a rectangle around your
circuit, this is the area of the page that will be printed. Then select print
as usual. (You can select ).
- You have to have your circuit properly drawn and saved.
- There must not be any floating parts on your page (i.e. unattached devices).
- You should make sure that all parts have the values that you want.
- There are no extra wires.
- It is very important that you have a ground on your circuit.
- Make sure that you have done the Analysis
Setup and that only the things you want are enabled.
- Click on the Simulate button on the tool bar
(or Analysis, Simulate, or F11).
- It will check to make sure you don't have any errors. If you do have errors,
correct them.
- Then a new window will pop up. Here is where you can do your graphs.
- If you don't have any errors, you should get a window with a black background
to pop up (even with errors, it will be OrCAD PSpice A/D Demo).
- If you did have errors, in the bottom, left hand side, it will say what
your errors were (these may be difficult to understand, so go To "View - Output
File").
- PSpice will automatically put some traces in. You will probably want to
change them.
- Go to Trace - Add Trace or
on the toolbar. Then select all the traces you want.
- To delete traces, select them on the bottom of the graph and push Delete.
- In Add Traces, there are functions that can be performed, these will add/subtract
(or whatever you chose) the lines together.
- Select the first output then either on your keyboard or on the right side,
click the function that you wish to perform.
- There are many functions here that may or may not be useful. If you want
to know how to use them, you can use PSpice's Help Menu.
- It is interesting to note that you can plot the phase of a value by using
IP(xx), where xx is the name of the source you wish to see the phase for.
- Click on Text Label
on top tool bar.
- Type in what you want to write.
- Click OK
- You can move this around by single clicking and dragging.
- There are Cursor buttons that allow you to find the maximum or minimum or
just a point on the line. These are located on the toolbar (to the right).
- Select which curve you want to look at and then select "Toggle
Cursor" .
- Then you can find the max, min, the slope, or the relative max or
min ( is
find relative max).
- To save your probe you need to go into the tools menu and click display,
this will open up a menu which will allow you to name the probe file and choose
where to save it. You can also open previously saved plots from here as well.
- Select Print in Edit or on the toolbar .
- Print as usual.
To open the analysis menu click on the
button.
- The AC sweep allows you to plot magnitude versus frequency for different
inputs in your circuit.
In the AC sweep menu you have the choice of three types of analysis:
- Linear,
- Octave and
- Decade.
- These three choices describe the X-axis scaling which will be produced in
probe. For example, if you choose decade then a sample of your X-axis might
be 10Hz, 1kHz, 100kHz, 10MHz, etc.... Therefore if you want to see how your
circuit reacts over a very large range of frequencies choose the
decade option.
- You now have to specify at how many points you want PSpice to calculate
frequencies, and what the start and end frequency will be. That is, over what
range of frequencies do you want to simulate your circuit.
- In the AC sweep you also have the option of Noise enable in which
PSpice will simulate noise for you either on the output or the input of the
circuit. These noise calculations are performed at each frequency step and
can be plotted in probe.
- The two types of noise are:
- V(ONOISE) for noise on the outputs and
- V(INOISE) for noise on the input source.
- To use input noise you need to tell PSpice where you consider the 'input'
in your circuit to be, for example, if your voltage source is labelled 'V1'.
- Finally you need to specify in what interval you want the noise to be calculated
(note: the default interval for spice is zero, i.e.: no noise will be calculated).
- The DC sweep allows you to do various different sweeps of your circuit to
see how it responds to various conditions.
- For all the possible sweeps,
- voltage,
- current,
- temperature, and
- parameter and global
you need to specify a start value, an end value, and the number of points
you wish to calculate.
- For example you can sweep your circuit over a voltage range from 0 to 12
volts. The main two sweeps that will be most important to us at this stage
are the voltage sweep and the current sweep. For these two, you need to indicate
to PSpice what component you wish to sweep, for example V1 or V2.
- Another excellent feature of the DC sweep in PSpice, is the ability to do
a nested sweep.
- A nested sweep allows you to run two simultaneous sweeps to see how changes
in two different DC sources will affect your circuit.
- Once you've filled in the main sweep menu, click on the nested sweep button
and choose the second type of source to sweep and name it, also specifying
the start and end values. (Note: In some versions of PSpice you need to click
on enable nested sweep). Again you can choose Linear, Octave or Decade,
but also you can indicate your own list of values, example: 1V 10V 20V.
DO NOT separate the values with commas.
- This is a simple, but incredibly useful sweep. It will not launch Probe
and so give you nothing to plot. But by clicking on enable bias current
display or enable bias voltage display, this will indicate the
voltage and current at certain points within the circuit.
- Parametric analysis allows you to run another type of analysis (transient,
sweeps) while using a range of component values using the global parameter
setting. The best way to demonstrate this is with an example, we will use
a resistor, but any other standard part would work just as well (capacitor,
inductor).
- First, double-click the value label of the resistor that is to be varied.
This will open a "Set Attribute Value" dialog box. Enter the name {RVAL}
(including the curly braces) in place of the component value. This indicates
to PSpice that the value of the resistor is a global parameter called RVAL.
In order to define the RVAL parameter in is necessary to place a global parameter
list somewhere on the schematic page. To do this, choose "Get New Part"
from the menu and select the part named param.
- Place the box anywhere on the schematic page. Now double-click on the word
PARAMETERS in the box title to bring up the parameter dialog box. Set
the NAME1= value to RVAL (no curly braces) and the VALUE1= value to
the nominal resistance value. This nominal value is required, but it is only
used if the DC bias point detail is computed. Otherwise, the value is ignored
by PSpice.
- Finally, go to the "Analysis Setup" menu and enable "Parametric" analysis.
Open the Parametric setup dialog box and enter the sweep parameters: Name:
RVAL Swept variable type: Global Parameter. Make sure the other analysis
type(s) are selected in the analysis setup menu (transient, sweeps). PSpice
will now automatically perform the simulation over and over, using a new value
for RVAL during each run.
- Sensitivity causes a DC sensitivity analysis to be performed in which one
or more output variables may be specified.
- Device sensitivities are provided for the following device types only:
- resistors,
- independent voltage and current sources,
- voltage and current-controlled switches,
- diodes, and
- bipolar transistors.
- You would use the sensitivity setting for discovering the maximum range
of circuit performance and the causes of extreme operation. These techniques
are used to identify effective changes to improve the quality of circuit operation
(for example, which components need to have tight tolerance and which can
be lower quality and less expensive).
- This isn't as important for us in the lab, but some day when you are constructing
real circuits that need to function under various conditions this will be
useful.
- The temperature option allows you to specify a temperature, or a list of
temperatures (do not include commas between temperature values) for which
PSpice will simulate your circuit.
- For a list of temperatures that simulation is done for each specified temperature.
- This paragraph will only indicate the features of the digital setup on the
analysis menu, see below for a more complete description.
- In addition to letting you simulate analog circuits, PSpice provides a
number of digital parts that can be used in a homogeneous digital circuit,
or a heterogeneous analog/digital combination. The digital analysis option
allows you to specify the timing of your circuit, by running the gates at
their minimum, maximum and typical values. A superb feature allows you to
test the worst case timing of your circuit to see how it will operate under
these extreme conditions. You also have the option of setting the value of
any flip flops you have in your circuit to predefined states which is good
to simulate any startup conditions for finite state machines that you are
simulating.
- The transient analysis is probably the most important analysis you can run
in PSpice, and it computes various values of your circuit over time. Two very
important parameters in the transient analysis are:
- The ratio of final time: print step determines how many calculations
PSpice must make to plot a wave form. PSpice always defaults the start time
to zero seconds and going until it reaches the user defined final time. It
is incredibly important that you think about what print step you should use
before running the simulation, if you make the print step too small the probe
screen will be cluttered with unnecessary points making it hard to read, and
taking extreme amounts of time for PSpice to calculate. However, at the opposite
side of that coin is the problem that if you set the print step too high you
might miss important phenomenon that are occurring over very short periods
of time in the circuit. Therefore play with step time to see what works best
for your circuit.
- You can set a step ceiling which will limit the size of each interval,
thus increasing calculation speed. Another handy feature is the Fourier analysis,
which allows you to specify your fundamental frequency and the number of harmonics
you wish to see on the plot. PSpice defaults to the 9th harmonic unless you
specify otherwise, but this still will allow you to decompose a square wave
to see it's components with sufficient detail.
- This is your basic direct current voltage source
that simulates a simple battery and allows you to specify the voltage value.
- A few things to note about the alternating current
source, first PSpice takes it to be a sine source, so if you want to simulate
a cosine wave you need to add (or subtract) a 90° phase shift. There
are three values which PSpice will allow you to alter, these being:
- ACMAG which is the RMS value of the
voltage.
- DC which is the DC offset voltage
- ACPHASE which is the phase angle of the
voltage
- Note that the phase angle if left unspecified will be set by default to
0°
- The SIN type of source is actually a damped sine
with time delay, phase shift and a DC offset. If you want to run a transient
analysis you need to use the VSIN see how AC will effect your circuit over
time. Do not use this type of source for a phasor or frequency sweep analysis,
VAC would be appropriate for that.
- DC the DC component of the sine wave
- AC the AC value of the sine wave
- Voff is the DC offset value. It should
be set to zero if you need a pure sinusoid.
- Vamplitude is the undamped amplitude
of the sinusoid; i.e., the peak value measured from zero if there were
no DC offset value.
- FREQ is the frequency in Hz of the sinusoid.
- TD is the time delay in seconds. Set
this to zero for the normal sinusoid.
- DF is the damping factor. Also set this
to zero for the normal sinusoid.
- PHASE is the phase advance in degrees.
Set this to 90 if you need a cosine wave form.
- Note that the normal usage of this source type is
to set Voff, TD and DF to zero as this will give you
a 'nice' sine wave.
- The VPULSE is often used for a transient simulation
of a circuit where we want to make it act like a square wave source. It
should never be used in a frequency response study because PSpice assumes
it is in the time domain, and therefore your probe plot will give you inaccurate
results.
- DC the DC component of the wave.
- AC the AC component of the wave.
- V1 is the value when the pulse is not
"on." So for a square wave, the value when the wave is 'low'. This can
be zero or negative as required. For a pulsed current source, the units
would be "amps" instead of "volts."
- V2 is the value when the pulse is fully
turned 'on'. This can also be zero or negative. (Obviously, V1 and V2
should not be equal.) Again, the units would be "amps" if this were
a current pulse.
- TD is the time delay. The default units
are seconds. The time delay may be zero, but not negative.
- TR is the rise time of the pulse. PSpice
allows this value to be zero, but zero rise time may cause convergence
problems in some transient analysis simulations. The default units are
seconds.
- TF is the fall time in seconds of the
pulse.
- TW is the pulse width. This is the time
in seconds that the pulse is fully on.
- PER is the period and is the total time
in seconds of the pulse.
- This is a very important source for us because we
do a lot of work with the square wave on the wave generator to see how
various components and circuits respond to it.
- The PWL source is a Piece Wise Linear function that
you can use to create a wave form consisting of straight line segments drawn
by linear interpolation between points that you define. Since you can use
as many points as you want, you can create a very complex wave form This
source type can be a voltage source or a current source.
- The syntax for this source type is flexible and
has several optional parameters. The required parameters are two-dimensional
points consisting of a time value and a voltage (or current) value. There
can be many of these data pairs, but the time values must be in ascending
order, and the intervals between time values need not be regular.
- The two optional parameters are "DC" and "AC."
The use of an AC parameter with this source is not very well documented
and because this source is intended for use with a transient analysis any
AC value would be ignored.
- For any of the previous discussed voltage sources,
there exist the exact source except that they produce current. There is one
thing that should be mentioned; current sources in PSpice get a little confusing.
For those current sources whose circuit symbol has an arrow, you have to point
the arrow in the direction of conventionally flowing current. This applies
to all current sources, including AC and DC. Therefore placing the current
source in the circuit backwards with seemingly incorrect polarities will give
the correct results.
- An interesting little feature under the markers
menu is the ability to add markers to your circuit so you can see where the
current and voltage have imaginary values in the circuit, and the phase of
your source at any point in the circuit.
- PSpice can simulate digital circuits and Probe can
output a timing diagram showing the relationship between all the signals propagating
in the circuit. The following will be a brief introduction to digital analysis
using PSpice, you should consult the online PSpice manual if you are unsure
about any of the following properties.
- The evaluation version of PSpice provides many of
the common digital parts that we use in the lab exercises these include, but
are not limited to,
- counters,
- multiplexers,
- decoders,
- flip-flops,
- latches,
- all common gates,
- buffers,
- adders and a lot more.
- To begin, create a digital circuit the same way you
would create an analog one by getting and placing the parts (see above for
details on creating a circuit).
- Now instead of an analog voltage source you want to
place digital stimuli, these are located in the parts menu as HI and
LO.
- Draw wires connecting the parts like usual, but whenever
you have an output of a gate that would be an output to your circuit you need
to terminate it with a block.
- You can add these blocks to your circuit. On the tool
bar there is a button labelled Add Block; connect this block to any
output signal of your circuit.
- Then run a bias point analysis and click on the button
to see the enable voltage bias display, to see the logic level on each
of your lines.
- You can run a transient analysis at this point and
plot the signals, but they will just be straight lines, showing the logic
level of each signal. However a digital circuit that remains in a constant
state all the time is of little interesting. Eventually, you are going to
encounter a circuit that needs to be stimulated with a clock pulse.
- To add a time varying 'clock pulse' to your circuit,
enter the parts menu and get a part labelled STIM1 and place that as
the input to a device. Double click on the STIM1 to open up a dialogue
box that looks like this:
and fill it in with the Time Step that you want your 'clock' to have.
This Time Step value is the your 'clock' pulse. There are various ways
you can fill out the command prompts, one way is to do it as shown in the
picture, however here are some simple commands that will allow you to do a
range of simulations:
- REPEAT FOREVER, to simulate a real clock
- REPEAT <n> TIMES
- END REPEAT
- <<time>> INCR <<value>>
- <<time>> DECR <<value>>
- for <<value>> you can use, 0,1,R(rising), F(falling), X(unknown),
or Z(high impedance)
- There are other useful commands that are documented well in the online manual.
If you are interesting in seeing the voltage levels attached to these gates
to see if you need to buffer any signals or to see if you are exceeding the
fan out and/or fan in of any gate, you need to add dropping resistors to the
inputs of gates, and a load resistor the outputs of the gates and simulate
again. When you are running the transient analysis, don't forget to change
your print step and the final time so you will actually be
able to see the results.
- If your digital circuit contains a counter, or decoder or some other device
with many outputs that are all going to a single destination, instead of drawing
many individual signal lines from each source to the proper destination you
can use a bus. In the draw menu at the top of the screen is
an option for drawing a bus which is a thick wire able to carry many separate
signals to a single place. The order in which the signals go on the bus is
the order in which they come off at the destination.
- For the more obscure questions you might have go right to the source at
Orcad©
http://www.orcad.com
- In the PC221 text, at the end of each chapter, there is information on how
to use PSpice.
- Electronic Devices and Circuit Theory -- 7th edition
- Boylestad and Nashelsky
- Prentice Hall
- **All pictures and screen shots came from Orcad© PSpice evaluation
version 8 and 9.1
- Not related to PSpice specifically, but there is a tutorial on
using LaTeX to typeset technical documents
at
http://denethor.wlu.ca/latex/