7th Tutorial on PSpice

Frequency Sweeps in PSpice

As promised in PSpice Tutorial No. 5, we now discuss frequency sweeps over a range of frequencies. The purpose of this type of analysis is to study the frequency response of different kinds of circuits. Since frequency sweeps produce a lot of data that needs to be graphed to be clearly understood, we will reintroduce Probe, the graphing program that is bundled with PSpice. We last used Probe in PSpice Tutorial No. 4, when we discussed transient analysis.

Specifying AC Sources

AC voltage and current sources are specified as they were described in PSpice Tutorial No. 5; i.e., we use the AC designation. To review AC source designations, click here.

To specify the frequency range we need the .AC command. When we discussed single-frequency phasor analysis in PSpice Tutorial No. 5, we alluded to the LIN, OCT and DEC types of frequency ranges. At that time we only wanted one frequency, so which range type we used didn't matter much. We will discuss the different range types here.

LIN Range Type

The LIN range type is linear. It divides up the range between the minimum and maximum user-specified frequencies into evenly spaced intervals. This is best used to view details over a narrow bandwidth. The first parameter after the keyword LIN is the number of points to calculate. This is followed by the lowest frequency value in Hz, then the highest frequency value in Hz. As with all the range types, the unit "Hz" is optional.

.AC LIN 101 2k 4k; 101 points from 2 kHz to 4 kHz
.AC LIN 11  800 1000; 11 pts from 800 Hz to 1 kHz

OCT Range Type

The OCT range is logarithmic to the base two. Thus each octave has the same number of points calculated. This is somewhat useful for designing electronic equipment for musical applications. However, the resulting graphs are very similar in appearance to sweeps made with the DEC range. The first parameter after the keyword OCT is the number of points per octave to calculate. This is followed by the lowest frequency value in Hz, then the highest frequency value in Hz.

.AC OCT 20 440Hz 1.76kHz; 20 points/octave over 2 octaves
.AC OCT 40 110Hz 880Hz; 40 points/octave over 3 octaves

DEC Range Type

The DEC range is logarithmic to the base ten. Thus each decade has the same number of points calculated. This is the most commonly used range for making Bode plots of a frequency response. The first parameter after the keyword DEC is the number of points per decade to calculate. This is followed by the lowest frequency value in Hz, then the highest frequency value in Hz.

.AC DEC 50 1kHz 100kHz; 50 points/decade over 2 decades
.AC DEC 25 100k 100MEG; 25 points/decade over 3 decades

Probe Needed

In PSpice Tutorial No. 4, we introduced PROBE since the transient analyses we were using then required storing lots of data and the ability to plot it. We have the same situation here. The major difference is that the independent variable used by PROBE in a .TRAN analysis is time; whereas the independent variable used in a frequency sweep is frequency. Also, when PROBE stores data in a transient (.TRAN) analysis, the dependent variables are instantaneous voltages and currents; whereas in a frequency sweep these dependent variables are real and imaginary components of phasor voltages and currents.

To review details of the .PROBE command, click here.

.PRINT AC?

Normally, we do not use the .PRINT AC command when we run a frequency sweep on a circuit because PROBE does a pretty good job of supplying graphical interpretations of the data. However, the .PRINT AC command can be used to store any voltage or current data in tabular form in the OUT file. This is readable and can be copied and pasted into other programs for whatever additional processing your imagination can contrive. This can be done simultaneously with the .PROBE command, whereas your alternative (if you must have a text-readable version of the data) is to make a separate run with the /CSDF parameter after the .PROBE command.

Examples of Frequency Sweeps

Passive Low-Pass Filter

The above circuit is a first-order low-pass filter. Since we want the gain of this filter, it is convenient to make the input voltage 1 volt so the output voltage is numerically equivalent to the gain. However, the post-processer within PROBE is fully capable of performing arithmetic such as dividing the input voltage into the output voltage. The source code for the CIR file follows.

First-order low-pass RC filter
Vin 1  0 AC 1.0V
Rf  1  2 1.59
Cf  2  0 100uF
.AC DEC 20 100Hz 100kHz
.PROBE
.END

After running this in PSpice, we start PROBE, choose "Add" from the "Trace" menu and plot the output voltage. PROBE provides the following graph.

Gain as a Ratio

Another option is to have PROBE plot the gain in decibels. To do this choose "Add" from the "Trace" menu in PROBE. Then select the "DB" function in the right-hand column and choose "V(2)" from the left-hand column.

Using the Add Traces Dialog Window

After selecting "OK," you should see the following trace.

Bode plot of 1st Order Low-pass filter

Notice that the gain is -3db at a frequency of 1 kHz (the half-power frequency) and declines at 20 dB/decade thereafter. The remaining demonstration for this example is to have PROBE plot the phase shift of the low-pass filter as a function of frequency. We simply specify "VP(2)" from the "Add Trace" dialog box. Notice that this is the same format used in the .PRINT AC command in PSPICE. PROBE automatically shows the angles in degrees.

Phase Shift Plot

We will now examine a second-order high-pass filter as our second example.

Passive 2nd-Order High-Pass Filter

Second-Order High-Pass Filter
Vin 1 0 AC 10V
Rf 1 2 4.0
CF 2 3 2.0uF
Lf 3 0 127uH
.AC DEC 20 100Hz 1MEG
.PROBE
.END

This time we did not use 1V for the input voltage. Therefore, we will need to have PROBE actually divide the input into the output to get the gain. We show this gain in decibels.

Bode Plot for 2nd Order High-pass Filter

Notice that the gain below the resonant frequency of 10 kHz slopes upward at 40 dB/decade. When we plot the phase shift of this filter, we only need to specify the phase angle of the output voltage since the input voltage was specified at 0 degrees.

Phase Shift of 2nd Order High-Pass Filter

Modifying PROBE Display

In PSpice Tutorial No. 4 we promised to show in a future tutorial how to make PROBE display a white background (as you have been seeing in the above examples) instead of a black one . We now fulfill this promise. However, we must make clear that we are modifying a file needed by PSpice and all of its associated programs for successful operation. Therefore, we strongly suggest that you make a back-up copy of this file before you modify it. If this file is lost or destroyed, you may have to reinstall PSpice on your computer. Also, making these modifications requires that you have WRITE as well as READ privileges in the WINDOWS folder of the computer you are using; i.e., don't try this on the school's lab workstations.

The file to be modified depends on which version of PSpice that you have. If you are running version 7 or 8 of the old MicroSim evaluation release, the file name will be "msim_evl.ini" whereas the new OrCAD release 9 evaluation version of PSpice uses the file name "pspiceev.ini" to specify the same start-up information. In either case the file will be found in the "WINDOWS" folder of your computer if you are running Windows 95 or Windows 98. It will be in the WINNT folder if you are running Windows NT or Windows 2000. If you are running Windows XP, you will have either a WINNT or a WINDOWS folder. Be sure to open this file with an ASCII-type text editor such as NOTEPAD or the DOS EDIT program. A word processor such as MS Word™ or WordPerfect™ may ruin the file unless you are very careful to save it as a DOS or TXT type file. The safest editor to use is the text editor that comes with PSpice. This is called TEXTEDIT in MicroSim releases 7 and 8. In the new OrCAD release the text editor is run from PSpiceAD itself. In either case, search for the following sequence of statements starting with "[PROBE DISPLAY COLORS]":

; (Original version)
.
.
[PROBE DISPLAY COLORS]
NUMTRACECOLORS=12
BACKGROUND=BLACK
FOREGROUND=WHITE
TRACE_1=BRIGHTGREEN
TRACE_2=BRIGHTRED
TRACE_3=BRIGHTBLUE
TRACE_4=BRIGHTYELLOW
TRACE_5=BRIGHTMAGENTA
TRACE_6=BRIGHTCYAN
TRACE_7=MUSTARD
TRACE_8=PINK
TRACE_9=LIGHTGREEN
TRACE_10=DARKPINK
TRACE_11=LIGHTBLUE
TRACE_12=PURPLE
.
.

There may be minor variations in some of these statements depending on your version; for instance, most MicroSim evaluation releases only define 6 trace colors. The most important two lines to change are the background and the foreground colors. You need to make the background color BRIGHTWHITE and the foreground color BLACK. If you specify just WHITE for the background color, it will actually be a light gray. This does not look very good when you paste a graph into a document for a report. The following listing is what I use in my own file:

; (Modified version)
.
.
[PROBE DISPLAY COLORS]
NUMTRACECOLORS=12
BACKGROUND=BRIGHTWHITE
FOREGROUND=BLACK
TRACE_1=BRIGHTRED
TRACE_2=BRIGHTBLUE
TRACE_3=BRIGHTGREEN
TRACE_4=BRIGHTMAGENTA
TRACE_5=BRIGHTCYAN
TRACE_6=PURPLE
TRACE_7=MUSTARD
TRACE_8=PINK
TRACE_9=LIGHTGREEN
TRACE_10=DARKPINK
TRACE_11=LIGHTBLUE
TRACE_12=BRIGHTYELLOW
.
.

You will find other editable features in this file such as schematic colors. Just be sure to back up the file before you make any changes.

Back to Main Page