orcad tutorial
TRANSCRIPT
-
42
TABLE OF CONTENTS (OrCAD TUTORIAL)
1. Introduction 43
1.1 What is SPICE and what is PSPICE? 43
1.2 What does SPICE stand for? 43
1.3 How does PSPICE help in circuit design? 43
2. Basics 44
2.1 Installation 44
2.2 Starting the software 45
2.2.1 Running CAPTURE 45
CAPTURE environment 45
2.2.2 Running PSPICE Model Editor 47
3. Passive and active elements in CAPTURE 48
3.1 Resistors, capacitors and inductors 48
Initial conditions (IC) for inductors & capacitors 49
3.2 Transistors 50
3.2.1 BJT models 50
3.2.2 FET models 50
MOSFET models 50
JFET models 51
3.3 Diodes 51
3.4 Operational amplifiers 51
4. Sources 53
4.1 DC source: Battery & grounding 53
4.2 AC sources 53
4.2.1 AC source for frequency domain simulation 53
4.2.2 Sinusoidal source 53
4.2.3 Square, triangular and other pulses 53
4.2.4 Piecewise Linear Voltage Source 53
5. Macro-modelling 56
6. Simulation examples 58
6.1 AC sweep (Bode plot) 58
6.2 Parametric sweep 61
6.3 Temperature sweep 62
6.4 Noise analysis 62
6.5 Time domain simulations 62
6.6 DC sweep 65
7. Hierarchical blocks in SPICE 65
8. References 75
Additional Simulation Software Information 75
-
43
1. INTRODUCTION
1.1 WHAT IS SPICE AND WHAT IS PSPICE?
SPICE is an analogue (originally) circuit simulator that was developed at the University of
California at Berkeley. PSpice is one of the many commercial SPICE derivatives, and has
been developed by MicroSim Corporation (now taken over by Cadence ORCAD).
1.2 WHAT DOES SPICE STAND FOR?
SPICE stands for Simulation Program with Integrated Circuit Emphasis.
1.3 HOW DOES PSPICE HELP IN CIRCUIT DESIGN?
PSpice's strong point is that it helps the user simulate the circuit design graphically on the
computer before building a physical circuit. Hence, the designer can make any necessary
changes on the prototype without modifying any hardware. As soon as the test design is
completed, PSpice can help one run a check on it before deciding to commit yourself to
building a hardware model. Hence, PSpice allows one to check the operability of the
circuit model in real life simulations to validate its viability (Nilsson & Riedel, [1]). Since
all the tests, designs and modifications are made over a terminal; the designer can save a
lot of money that would have otherwise been spent on the building of models and
modifying them.
SPICE is used to fine tune the design process, not to replace it. Although approximate
first-cut circuit designs can often be made by hand, an exact analysis of circuit behaviour is sometimes required. A complicated IC design, for example, must be perfected before it is
actually fabricated, since fabrication to accommodate even minor design changes is costly.
In such situations, SPICE can provide valuable assistance in testing a tentative design
before it is actually fabricated.
-
44
2. BASICS
2.1 INSTALLATION
A copy of ORCAD may be downloaded from the ENE310 website. The direct link to the
site is < ftp://ftp.ee.up.ac.za/pub/windows/eda/OrCAD_16_5_Full_Demo.zip (872
MB/Version 16.5) >. This is just a demo (student) version but should suffice for your
practical work: Download, decompress (use WinZip) and install (by running the setup.exe)
the software. WinZip is available for download on the download site of the course
. The
University laboratories (CAEC, NWII as well as the Electronic Engineering Labs B/C)
have this copy of ORCAD installed. It, hence, wont be required to do the installation.
2.2 STARTING THE SOFTWARE
Figure 1 shows the Orcad Family Release 9.2 Lite Edition folder (go into the programs menu and then look for Orcad Family Release 9.2 Lite Edition). The main components that
will be utilized this semester are:
CAPTURE CIS Lite Edition (referred to as just CAPTURE in this tutorial), and
PSPICE Model Editor. The CAPUTRE CIS Lite Edition is used to set up the schematics as well as simulations (it
has SPICE built-in). The step-by-step procedure for this will be detailed in the rest of this
tutorial. The PSPICE Model Editor can be used to create new models. However, for this
course it will be typically used for looking at pre-existing transistor parameters (i.e. those
components that are supplied with the PSPICE Student version).
Figure 1.
The figure shows the CAPTURE CIS Lite Edition folder (after installation).
-
45
2.2.1 RUNNING CAPTURE
Start CAPTURE (Go into Start, the Orcad Family Release 9.2 Lite Edition folder/menu
(see figure 1), then click once or twice depending on the configuration of the computer).
The basic screen (as seen on the front cover of this tutorial) will be instantly seen as the
program starts.
Step C-0: Click on file. Click on New project. The dialog box will appear as shown in figure 2.
Figure 2.
The figure shows the New Project dialog box.
The following selections must be done:
ensure that the Analog or Mixed A/D is selected,
the location path (if the directory already exists, CAPTURE will append it, or else it will create a new one) must be specified (please ensure this is on a read/write
hard-disk or it can be alternatively on your own disk the latter would be slower), and
specify a filename (this can be any name a useful name may help you to recall it easier later).
Example: Location: H:\ENE310
Name: ENE_PRAC0
Press OK. You will be prompted to either "Create based upon an existing project" or to
"Create a blank project." Select the latter (as at this stage, the earlier option may have no
fields defined). Press OK.
-
46
CAPTURE environment
Figure 3. The figure shows the basic features of the CAPUTRE schematic window.
Click on project manager in figure 3. To expand the directory structures, simply click the + next to the given directory. Names may be modified, for example to change PAGE1, simply right click on the name, click rename and rename it (for example to block0). To go back to the schematic page (figure 3), click edit page or just double click on
PAGE1.
Figure 4.
The figure shows the project manager of CAPTURE.
Voltage, current and differential
voltage markers
Show bias values for voltage &
current on circuit
Zoom window Snap-to-Grid Show the project manager window
Add a dc power supply
Add a ground
Status bar
Add a port
Scroll bar
Add graphics/text
to schematic Title block
-
47
2.2.2 RUNNING PSPICE MODEL EDITOR
Start PSPICE Model Editor (Go into Start, the OrcadLite folder/menu (see figure 1), then
click once or twice depending on the configuration of the computer).
Step P-0: Click on file. Click on Open The dialog box will appear as shown in figure 5.
Type in the path to the directory containing the PSPICE libraries:
C:\Program Files\OrcadLite\Capture\Library\PSpice
Note: Simulation may only be done with components that have implementation definitions.
CAPTURE is often used merely for schematics; hence additional libraries may be also
given in the C:\Program Files\OrcadLite\Capture\library\ directory. However, these may not be used for simulation (they are merely symbols/pictures). Generally, the libraries in the PSPICE directory (C:\Program Files\ OrcadLite\Capture\library\PSpice) have complete
implementations given.
Step P-1: In the demo version, the EVAL and Breakout libraries may be opened for
viewing or editing. It is sometimes useful to use these as a template to create your own parts or libraries (as discussed in 3.5). Once this is opened, it will appear as in the
background (list of components) of figure 5. A click on any component will show its
parameters (PSPICE parameters) that will be used for simulation. For example click on
Q2N2222. The f used by PSPICE for this transistor will be 255.9.
Figure 5.
The figure shows the Open dialog box of the PSPICE model editor. The background (the list of components) is an example of a library (EVAL.LIB) once it is opened.
-
48
3. PASSIVE AND ACTIVE ELEMENTS IN CAPTURE
This section focuses on the inserting various commonly used types of elements into
CAPTURE. To open the parts menu, press or (or Click on Place then
Part). By default, all the libraries are not added, so you may have to do this yourself. This
can be done by going to Add Library , select all , then say Open . This is illustrated in figure 6. Do a general browse through the parts to see what are the typical analogue/digital components available for simulation.
Figure 6.
The figure shows how to add more libraries to the Place Part menu.
Press P to insert a part. Press R to rotate a part. Press V to vertically flip a part (vertical mirroring). Press H to horizontally flip a part (horizontal mirroring). Press I to zoom in and O to zoom out.
Note: In some versions, you may have to press with the hotkey e.g.
to open the parts.
3.1 RESISTORS, CAPACITORS AND INDUCTORS
To insert a resistor, look for the element R (double click). The resistor will be floating on
your screen, single click to place it at a suitable position on the CAPTURE screen.
to
select all
-
49
Additional settings may be done by double clicking on the parameters of the resistor. A
default resistor is shown in figure 7. To change the value of the resistor, simply double
click the 1k and change the value in the dialog box that will appear. To change the resistor label, the same can be done. Try the hotkeys on the previous page to see how to
rotate and mirror the resistor.
R1
1k Figure 7.
The figure shows a resistor schematic.
In the same way an inductor and a capacitor may be placed. Figure 8 shows typical
inductors and capacitors. L1
10uH
1 2C1
1n Figure 8.
The figure shows typical inductors and capacitors with default values used in SPICE.
Initial conditions (IC) for inductors & capacitors
Initial conditions (IC) such as initial inductor current and initial capacitor voltage may be
specified by clicking on the component and editing its properties . A
spreadsheet window opens. This is shown in figure 9.
Figure 9.
The figure shows the component property editor for an inductor. Note that Orcad-
PSpice needs to be selected prior to the settings (if this is not the case by default). The
enclosure shows the initial condition specification for the inductor.
Note:
When changing the values, you may use engineering notation symbols such as: n 10-9 G 109 u 10-6 meg 106 m 10-3 k 103
You may prefer to use scientific notation e.g. 10e-6 to represent 10.
Units such as H need not be placed.
-
50
Other tricks in CAPTURE:
Two capacitors in series as shown in figure 10 (a) does not simulate. This is due to a mathematical bad definition (floating node error). The correction is shown in figure 10 (b).
C1
1n
C2
1n
C1
1n
R2
1e18
C2
1n
0 (a) (b)
Figure 10.
The figure illustrates (a) one of the SPICE faults when simulating two capacitors.
(b) This can be easily corrected by adding an open circuit in between e.g. a large-valued resistor to ground.
Other shortcut keys:
1. To remove an element from a network: select the element, press while dragging
it out (if is not pressed then other elements may also move).
2. To duplicate an element, select the element; press while dragging it out. A
duplicate of the element will be dragged out. Make sure to change the element label as this
will cause a problem during simulation. These problems are common and can be seen in
the session log (in the Window menu).
3. Copy elements: Click the element and press . To paste it press
and click to place the element on a suitable position on the screen. Make sure to change the
element label. Duplicate labels (such as two R1s on your schematic) will give a simulation
error.
4. Select all elements:
5. Select more than one items on the screen: Hold down the button while doing
the selections. For example, if you require seeing the property editor dialog box of more
than one element. An alternative to this may be to select an element, press to
view its properties then go to Edit and Select all .
6. Undo previous action: . Redo previous action: (Edit, Redo
previous action). The latter may only be activated if the earlier undo is executed.
3.2 TRANSISTORS
3.2.1 BJT MODELS
A BJT (for example, the Q2N2222, Q2N6905 or Q2N3904) may be inserted in the same
manner as a resistor. The default model parameters can be seen and modified as in 2.2.2.
In certain ORCAD versions, this may be done more simply by simply right clicking the
part and selecting Edit SPICE model. Q1
Q2N2222 Figure 11.
The figure shows a BJT (Q2N2222).
-
51
3.2.2 FET MODELS
MOSFET Models
Use MbreakN (NMOS) and PbreakN (PMOS). The W and L values may be specified using
the property editor as discussed for the resistor. Typical configurations are shown in
figure 12.
M1
MbreakN
V2
5VdcM2
MbreakP0 0
(a) (b)
Figure 12.
The figure shows typical MOSFET models.
JFET Models
Typical JFETs available are the J2N4393 and J2N3819. Like for MOSFETs, JbreakN and
JbreakP may also be used. This is shown in figure 13.
J1
JbreakN
J4
J2N4393
J2
JbreakP
J3
J2N3819 (a) (b) (c) (d)
Figure 13.
The figure shows typical JFET models.
3.3 DIODES
Typical diodes available are the d1N4148/1N914 (small signal diode) and d1N4002 (power
diode). Zener diode models such as d1N750 and dbreakZ are also available. A typical
varactor diode that can be used is the DbreakW.
3.4 OPERATIONAL AMPLIFIER/COMPARATORS MODELS
Most common SPICE (demo version) models:
Amplifiers: uA741& LM324
Comparators: LM111 & LF411
(Pins that are not used can be possibly left unconnected (depending on the SPICE model
for the part) see figure 14.)
-
52
V
0
U1
uA741
3
2
74
6
1
5+
-
V+
V-
OUT
OS1
OS2
VEE15VdcRS
1k
0
Vi
FREQ = 100e3VAMPL = 26mVVOFF = 0
RF
1k
VCC
15Vdc
0
Figure 14.
The figure shows a typical operational amplifier circuit. As can be seen pins 1 and 5
are not being used. Right clicking into Edit part can be used to modify the Op-amp symbol (just like in CAD). The sub-circuit used to design the op-amp can be seen by
right clicking and selecting Edit PSpice model. Basic pin layouts are also given here.
Common problem: The op-amp often needs to be flipped or mirrored. This can be done by using the hotkey V as discussed earlier.
-
53
4. SOURCES 4.1 DC SOURCES: BATTERY & GROUNDING
Figure 15 shows the typical DC supplies and grounds.
V1
12V+
-
HI
LO VCC_BAR
0 (a) (b) (c) (d)
Figure 15.
The figure shows (a) a battery of cells (analogue), (b) digital HI and LO, (c) VCC_BAR power supply, and (d) ground (0) .
Note: VCC_BAR does not work. Reason: The VCC_BAR does not have a PSpice
implementation. This is discussed in 2.2.2. Remove the CAPSYM (symbolic) library as
these parts cannot be used for PSpice simulations (unless you define the parts by yourself).
Figure 15(a) is found in the Parts menu. The rest of the components are part of the Sources library and can be inserted by clicking Place a ground symbol (see figure 3). Circuits must have a ground for simulation.
4.2 ac SOURCES
4.2.1 AC SOURCE FOR FREQUENCY DOMAIN SIMULATIONS
The part (VAC) to be inserted is found in the Parts menu. This is shown in Figure 16. V2
1Vac
0Vdc
Figure 16.
The figure shows a typical ac source that can be used for frequency sweep simulations.
4.2.2 SINUSOIDAL SOURCE
The part (VSIN) to be inserted is found in the Parts menu. This is shown in Figure 17. Double clicking can be used to specify the VOFF (offset voltage), VAMPL (voltage
amplitude) and the frequency.
V3
FREQ = VAMPL = VOFF =
Figure 17.
The figure shows a typical ac source that can be used for frequency sweep simulations.
4.2.3 SQUARE, TRIANGULAR AND OTHER PULSES
Figure 18 shows a basic square wave and its typical parameters. Rise (TR) and fall times
(TF) should be specified realistically. Typical values are also shown in figure 18. The part
name is VPULSE.
-
54
Time
0s 0.1ms 0.2ms 0.3ms 0.4ms 0.5ms 0.6ms 0.7ms 0.8ms 0.9ms 1.0ms
V(V4:+)
0V
2.0V
4.0V
6.0V
PW
T
tdV1
V2
Figure 18.
The figure shows a typical square wave. The figure also shows typical pulse settings
for a square wave.
The parameters of the VPULSE source can be modified to obtain a triangular wave.
Typical settings are shown in figure 19.
Figure 19.
The figure shows a typical triangular wave. The figure also shows typical pulse
settings for a triangular wave (PW values, as shown, should be realistic).
Likewise, several other waveforms may be defined.
This tool is used mainly for periodic waveforms.
4.2.4 PIECEWISE LINEAR VOLTAGE SOURCE
Piecewise linear voltage sources are often used for transient analysis.
This tool is used for mainly aperiodic (nonperiodic) waveforms.
Time
0s 1ns 2ns 3ns 4ns 5ns 6ns 7ns 8ns 9ns 10ns V(R8:1)
0V
2.0V
4.0V
6.0V
PER = T
V2
V1 TR TF
PW
V9
TD = 0
TF = 1nPW = 0.001nPER = 2n
V1 = 0
TR = 1n
V2 = 5
V4
TD = 50u
TF = 1pPW = 100uPER = 200u
V1 = 0
TR = 1p
V2 = 5
-
55
Figure 20.
Typical settings and simulation settings (the property editor for the part is displayed
in the background) for a piecewise linear voltage source.
Time
0s 10ns 20ns 30ns 40ns 50ns 60ns 70ns 80ns 90ns 100ns
V(V8:+)
0V
2.0V
4.0V
6.0V
V8
V1 = 1V2 = 2V3 = 3V4 = 4V5 = 5V6 = 6T1 = 1nT2 = 3nT3 = 5nT4 = 9nT5 = 13nT6 = 54n
-
56
5. MACRO-MODELLING
Figure 21 illustrates a typical design procedure for an integrated circuit (IC). Macro-
modelling or mathematical modelling of systems helps in the decision process as well as
often forms part of the implementation phase. Macro-modelling is done in ORCAD by
using the analogue behaviour modelling (ABM) library. Macro-modelling serves to
simplify complicated circuits or parts that do not have a SPICE library.
Figure 21.
The figure shows a typical design procedure. The figure is taken from Sinha, [2].
Typical components that are available in the ABM library are:
- basic arithmetic devices (such as sum, diff and mult),
- trigonometric functions (such as sin, cos and tan),
- inverse trigonometric functions (such as atan/arctan),
- constants (such as and const), - other mathematical functions (such as abs, log, log10, pwr, pwrs, sqrt and exp),
- ideal filters (such as bandpass, hipass, lopass and bandrej),
- electronic blocks (such as gain, hilo, softlim and limit),
- function tables (ftable and table),
- calculus function (such as integ and differ), and
- two-port models (such as elaplace, egain, efreq, emult, esum, etable, evalue, elaplace,
gfreq, gmult, gsum, glimit, gtable and gvalue).
Furthermore, common parameters are often represented as variables. These can be
represented using parameters. This is part of the special library. To create a new
parameter such as Beta, , the following may be done: - start parts and choose parameter from the special library. The parameter element will now be floating on the screen, like earlier electronic components in 3, place this on a
suitable position in the CAPTURE window (This will typically appear as figure 22 (a)),
and
- to add the parameter such as Beta, look at the property of Parameters (select and
). In the property editor window, click new column, then enter Beta for name and a value such as 3 (this can be adjusted as will be shown in 6.2.)
PARAMETERS:
PARAMETERS:Ao = 3000Beta = 3
(a) (b)
Figure 22.
The figure shows (a) the parameter component, and (b) a typical parameter added.
-
57
A typical block diagram may be constructed. One such example is shown in figure 23. This
type of modelling is often common when testing for feedback loop stability (whether the
circuit will operate as an amplifier or an oscillator). A quick way to examine the stability is
by using bode plots (ESL220/ELI220) or a frequency sweep (this is covered in 6.1). A
voltage marker may be added (PSpice Markers Voltage level or by using the toolbar as illustrated in figure 3).
1
1 + sv _in1Vac
0Vdc
Ao
PARAMETERS:Ao = 3000Beta = 3
Beta
V
0
Figure 23.
The figure shows a typical block diagram using the ABM library. The figure uses two
parameters viz. Ao and Beta for simulation. The placement of the beta gain stage is in
the feedback path. The loop deploys negative feedback.
Similarly, various other circuits can be modelled using the ABM library.
Trick:
0 then the feedback path is basically an open circuit. For simulation, let = 1/1000.
Voltage marker
-
58
6. SIMULATION EXAMPLES
To illustrate simulation procedures the circuit of figure 23 (from 5) and figure 31 (later in
6.5) will be used. The simulation profile needs to be given a name and setup. This can be
done by selecting the PSpice menu and selecting New Simulation profile. This is illustrated
in figure 24.
Figure 24.
The figure shows how to create a new simulation profile.
Further simulation setup depends on what kind of simulation is required. The following
simulations will be covered in the next few sections:
- ac sweep ( 6.1), parametric sweep ( 6.2) and temperature sweep ( 6.3), - noise analysis ( 6.4), - time domain simulation ( 6.5), and - dc sweep ( 6.6).
6.1 ac sweep (Bode plot)
Consider the circuit of figure 23. An ac sweep (bode plot) is required. This can be
generated by setting the simulation profile as illustrated in figure 25. The following needs
to be done:
- analysis type: ac sweep/noise, - specify whether the frequency increment should be linear or logarithmic
(decade or octave),
- specify the start frequency and stop frequency, and
-
59
- specify the number of points/Decade to be used in simulation (more points corresponds to longer simulation time (and additional RAM)).
This completes the settings to generate the bode plots.
Figure 25.
Setting up an ac sweep to generate the bode plots of a given circuit or macro-model.
Start the simulation (go into the PSpice menu, and click on run).
Press to start the simulation.
The PSpice A/D Lite program will start. This will display the required simulation as shown
in figure 26. Information (for example temperature, time & date) about the trace can be
obtained by right clicking and selecting information on the trace. Further settings, such as
colour and line type can be changed by selecting the properties (instead of information like
earlier). This is illustrated in figure 26.
Grid colour: Click on the trace background (the area where the grid is shown), selecting
properties and appropriate settings may be done as earlier.
Grid type (major/minor) & axes settings (such as axes scaling & labelling) can be done by
clicking in the area of either the horizontal axis or the vertical axis. Minor grids are often
removed for clarity in presentations and documentation.
To add an additional plot (for example to also display the phase plot), add a plot (this
option is part of the plot menu). The function can be selected [for example P() or dB()], the
-
60
waveform may then be inserted [for the previous example: as P(V(GAIN2:IN)) and
dB(V(GAIN2:IN))]. To copy the waveforms to clipboard (so that it can be used for
documentation), click on the Window menu and Copy to Clipboard. User-dependent
settings may be done.
Figure 26.
The PSpice A/D Lite window for the circuit of figure 23.
Further, the logarithmic scale can also be selected for the vertical axis (for the amplitude
plot). Such an exported figure (to a documentation software) is shown in figure 27.
Frequency
10Hz 100Hz 1.0KHz 10KHz 100KHz 1.0MHz
P(V(GAIN2:IN))
-100d
-50d
0dP
h
a
s
e
db(V(GAIN2:IN))
-1.0
-100A
m
p
l
i
t
u
d
e
SEL>>
Figure 27.
The figure shows a paste result of the simulation from PSpice A/D Lite.
Frame FFT opt.
-
61
6.2 Parametric sweep
It is often required to investigate the effect of changing a parameter. For example, in
figure 23, how will the bode plots change if Ao is varied? This can be investigated by using
the parameter element as discussed in 5. The profile simulation needs to be modified
(select the PSpice menu, select the edit simulation profile option) as shown in figure 28.
Simulation result may be obtained as discussed in 6.1. The final simulation traces are
shown in figure 29.
Figure 28.
The figure shows the typical settings for a parametric sweep.
Frequency
10Hz 100Hz 1.0KHz 10KHz 100KHz 1.0MHz
P(V(GAIN2:IN))
-100d
-50d
0d
SEL>>
DB(V(GAIN2:IN))
-1.0
-100
Figure 29.
The figure shows the simulation results for changes in Ao over the interval specified
in figure 28.
-
62
6.3 Temperature sweep
The appropriate option should be selected in the simulation profile. The temperature
selection will show the settings in figure 30. A list of temperatures can be inserted as
shown in figure 30.
Figure 30.
The figure shows the typical temperature sweep (for a list of temperatures) settings.
6.4 Noise simulation
This section will be updated later (EMK732, & EME732) you will not be required to do noise simulations as part of the ENE310 laboratory work.
6.5 Time domain simulation
This is the default setting after a new simulation profile is created. The run to time (TSTOP) value needs to be defined. This typically depends on the period of the waveform.
To illustrate this, construct the circuit of figure 31. The circuit basically consists of a
triangular wave input being fed into an op-amp inverter (with gain 5). Prior to feeding it
into the amplifier, some mathematics (it is half wave rectified [if vIN < 0.7, then vIN 0] and the dc level is shifted) is performed on the initial input waveform.
For this simulation, specify the TSTOP value to be 10 seconds. Simulate the circuit. Time
domain simulation results are shown in figure 32.
-
63
0
v IN
TD = 0
TF = 1PW = 0.001PER = 2
V1 = 4.7
TR = 1
V2 = -3 Rp 833
Rs
1k
VShif t
1+
-
00
V
0
V
0
U1uA741
3
2
74
6
+
-
V+
V-
OUT
V
VEE15V+
-
0
D1
D1N4148vO
R1 10k
vBvA
Rf
5k
VCC15V
+
-
V
ESL/ELI220 ELK220 ESL/ELI220 EBN121(0)/210
Figure 31.
The figure shows another example. The example consists of an input waveform (a
modified triangular wave) being fed into an op-amp inverter. The circuit also illustrates the articulation of ORCAD (ENE310) in previously (or simultaneously)
taken courses (such as ESL/ELI220, and EBN121(0)/210).
Time
0s 1s 2s 3s 4s 5s 6s 7s 8s 9s 10s
V(vIN:+) V(D1:2) V(DIFF1:OUT) V(Rf:2) V(Rp:2)
-20V
-10V
0V
10VV
o
l
t
a
g
e
w
a
v
e
f
o
r
m
s
V
(a)
Frequency
0Hz 0.5Hz 1.0Hz 1.5Hz 2.0Hz 2.5Hz 3.0Hz
V(vIN:+) V(D1:2) V(DIFF1:OUT) V(Rf:2)
0V
5V
10VA
m
p
l
i
t
u
d
e
s
p
e
c
t
r
u
m
(b)
Figure 32.
The figure shows (a) time domain analysis, and (b) Fourier transform (FFT) of the
waveforms obtained from the simulation of figure 31. Figure 26 frames the FFT opt.
-
64
6.6 dc sweep
The curve of vO vs. vIN is often required. The dc sweep can be set up as shown in figure 33.
To illustrate this, the example of figure 31 is reconsidered. It is required to plot vC (output
voltage) as a function of Vshift. The dc sweep switch in the options should be selected, and
the appropriate (horizontal axis) voltage source (e.g. Vshift) specified. The range is defined
by selecting the start to stop range and the number of points (incremental value) to be used.
Figure 33.
The figure shows the dc sweep setup.
V_VShift
-10V -8V -6V -4V -2V 0V 2V 4V 6V 8V 10V
V(U1:OUT)
-20V
-10V
0V
10V
20VO
U
T
P
U
T
(7.4382,14.613)
(-10.000,-14.615)
Figure 34.
The figure shows the transfer characteristic of figure 31 (effect of change in vIN on vC).
-
65
7. HIERARCHIAL BLOCKS IN SPICE
Hierarchical blocks are a simple way of modelling large (often complicated) circuits. For
example consider the circuit of figure 31. This is a simple circuit; however, most circuits in
practice are seldom as simple. To simulate large circuits, it may be good practice to
represent sub-circuits as hierarchical blocks (this is not the same as creating a new part, but
a faster way-out.) One such example could be (in the case of figure 31), an ELK220 block, two ESL/ELI220 blocks and an EBN121(0)/210 block. The use of blocks further
helps if the sub-circuits repeat in a given circuit. For documentation, the use of hierarchical
block simplifies large schematics and is an effective way to represent/explain circuits.
It must be noted that during simulation, ORCAD descends to the lowest hierarchy
(transistor/resistor/diode/source level) and uses this to generate the required waveforms or
do the required computations.
The rest of this section will briefly guide you towards creating a custom library with a
previously created schematic as a component in the new library. The aim is to create a file
with a .olb extension which contains the schematic as a placeable part in the OrCAD
schematic environment, with PSPICE functionality included to describe the circuit. This
clearly illustrates the idea behind hierarchical block creation.
7.1 Creating a new project
A new project needs to be created to create a infrastructure for the desired schematic to be
created. Therefore, as an example, create a new project (File>>New Project ) called CreatePart.
Figure 35.
New Project window
and select the option to base the design on a blank hierarchy.
-
66
7.2 Creating the schematic RC network For the purpose of the tutorial, an RC-network will be used to illustrate the necessary
methods. In the schematic editor which is now open (if the prior steps were followed),
create an RC-network with R = 1 k and C = 1 nF. Use the analog.olb library to obtain the necessary components.
Figure 36.
RC-circuit schematic
To add connectivity to the circuit when using it as a single black box component, you need to define ports. To do this, select the Place port tool from the drawing toolbar and add
hierarchical ports to the desired points on the schematic.
Figure 37.
Ports added to the circuit
-
67
You need now to rename the ports to some specific name which will be later used to hook up the schematic to a symbol when creating a part from the schematic. Therefore, rename the port names as in the diagram below.
Figure 38.
Naming the ports
Now save the schematic and close the schematic window. Next, make sure you are looking
at the project manager window.
7.3 Creating and naming a library
Go to File>>New>>Library and select the option. The following change will occur in
your project manager window:
Figure 39.
Project Manager window with library highlighted.
Rename the library as ENETut.olb by right-clicking on it and selecting the save as option. Rename the schematic as well:
-
68
Figure 40.
Project Manager window with schematic folder highlighted.
7.4 Including the schematic into the library and creating a part
The next step is to add the created schematic to the library so that the information is
available in the library itself. To do this, select the RCNet schematic folder and drag it
across to the library enetut.olb. A notice will appear which states that a copy will be made
of the schematic folder in both the library and the project root folder. After completing the
operation, the project manager should look like this:
Figure 41.
Schematic folder added to library.
Now save the library (right click option). Notice the path where the .olb file is stored. Close
the project completely and select Open>>Library and select your enetut.olb
-
69
7.5 Creating a part
If all went well, your new project manager for the library file should look like this:
Figure 42.
Project Manager window of library.
Notice that all the design information (eg. ports, the capacitor and resistor etc.) are
referenced in the library cache. Also notice the presence of your schematic folder RCNet.
Now right-click on the c:\orcad\ene310\enetut.olb entity and select New Part.
In the Name space, fill in the name for the new part, eg. RC. The next step is to assign an
implementation for the part, which is basically the method to describe the electrical
behaviour of the part. Click on Attach Implementation, select Schematic View in
Implementation Type, since we are interested in hooking up a schematic to a part. In the
Implementation box, type in the name of the schematic folder which is to be used, namely
RCNet in this case. In the Implementation Path, one need to define only the library name
itself, since the schematic is included in the library (remember the dragging).
The settings are shown in the snapshot.
-
70
Figure 43.
Part Properties window.
7.6 Editing the part symbol
Now, in creating the part, we need to define a symbol which will be used in subsequent
schematic compilations. The following screen is automatically presented upon completion
of the previous steps.
Figure 44.
Symbol editing of part
-
71
The created schematic only has two ports, named A and B. Therefore, draw a symbol to be
used and define the ports by placing pins from the toolbar and naming them TO
CORRESPOND TO THE SCHEMATIC PORTS.
Figure 45.
Symbol editing of part
Notice that the text has been deleted, since we are not using it. Next, select from
the menus, Options>>Part Properties Add a new property called Primitive and set the value as NO. This tells the simulator to look underneath the component, where it will find the schematic implementation which describes its PSPICE behaviour.
After this operation, select File>>Save to save the complete library. A new part has now
appeared in the project manager window:
Figure 46.
New part created
-
72
This indicates the presence of a useable component. The next step would be to test the
inclusion of the library in a totally independent project.
7.7 Verifying the library functionality
Close everything and start a new project as shown in a previous section.
Figure 47.
New project to test library.
When placing parts, include libraries analog.olb, source.olb and enetut.olb, the created
library. The Place part window should look something like this:
Figure 48.
Placing the part.
-
73
Construct a test circuit for the component. A good choice would be to construct an AC-
analysis. The time constant of the circuit (using R = 1 k and C = 1 nF) dictates a -3 dB frequency of about 159 kHz. Therefore, make sure an AC analysis is set up to have this
point clearly visible.
Figure 49.
Test circuit for testing the hierarchical block.
Figure 50.
Simulation settings for the test circuit.
-
74
7.8 Results
Figure 51.
Results from simulation of hierarchical block.
-
75
8. REFERENCES
[1] Rieddel S.A. & James W.N. (1996), Using Computer Tools for Electric Circuits, Addison-Wesley Publishing Company, Massachusetts, pp.33-35.
[2] Sinha S. (2001), Design of an integrated CMOS PLL frequency synthesizer, Final
report for Project EPR400, Department of Electrical, Electronic & Computer Engineering,
University of Pretoria, South Africa, p.17.
ADDITIONAL SIMULATION SOFTWARE INFORMATION
A full version of OrCAD ver. 10 is available, please refer to the instructions: http://www.ee.up.ac.za/~subjects/files/EPR400_uE/Installing%20OrCAD%20on%20the%20UP%20network.pdf
Other simulators that are recommended (free): http://cgi.www.catena.uk.com (Catena) http://www.linear.com/company/software.jsp (LTSpice/SwitcherCAD III)