Orcad Tutorial
Orcad Tutorial
1. Introduction 1.1 What is SPICE and what is PSPICE? 1.2 What does SPICE stand for? 1.3 How does PSPICE help in circuit design? 2. Basics 2.1 Installation 2.2 Starting the software 2.2.1 Running CAPTURE CAPTURE environment 2.2.2 Running PSPICE Model Editor 3. Passive and active elements in CAPTURE 3.1 Resistors, capacitors and inductors Initial conditions (IC) for inductors & capacitors 3.2 Transistors 3.2.1 BJT models 3.2.2 FET models MOSFET models JFET models 3.3 Diodes 3.4 Operational amplifiers 4. Sources 4.1 DC source: Battery & grounding 4.2 AC sources 4.2.1 AC source for frequency domain simulation 4.2.2 Sinusoidal source 4.2.3 Square, triangular and other pulses 4.2.4 Piecewise Linear Voltage Source 5. Macro-modelling 6. Simulation examples 6.1 AC sweep (Bode plot) 6.2 Parametric sweep 6.3 Temperature sweep 6.4 Noise analysis 6.5 Time domain simulations 6.6 DC sweep 7. Hierarchical blocks in SPICE 8. References Additional Simulation Software Information 43 43 43 43 44 44 45 45 45 47 48 48 49 50 50 50 50 51 51 51 53 53 53 53 53 53 53 56 58 58 61 62 62 62 65 65 75 75
42
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).
43
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 <http://www.ee.up.ac.za/~subjects/files/ENE310/winzip100.exe (~5.6 Mb)>. 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.
Figure 1. The figure shows the CAPTURE CIS Lite Edition folder (after installation). 44
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. 45
CAPTURE environment
Zoom window
Snap-to-Grid
Show the project manager window Add a dc power supply Add a ground Add a port Scroll bar Add graphics/text to schematic
Title block
Status bar
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.
46
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.
47
Figure 6. The figure shows how to add more libraries to the Place Part menu. <HOTKEY-1> Press P to insert a part. <HOTKEY-2> Press R to rotate a part. <HOTKEY-3> Press V to vertically flip a part (vertical mirroring). <HOTKEY-4> Press H to horizontally flip a part (horizontal mirroring). <HOTKEY-5> Press I to zoom in and O to zoom out. Note: In some versions, you may have to press <SHIFT> with the hotkey e.g. <SHIFT+P> to open the parts.
48
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.
C1 1 1n 10uH L1 2
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 <CTRL+E>. A spreadsheet window opens. This is shown in figure 9.
Figure 9. The figure shows the component property editor for an inductor. Note that OrcadPSpice 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 -6 u 10 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.
49
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 R2
C1 1n C2 1n
1e18
(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 largevalued resistor to ground. Other shortcut keys: 1. To remove an element from a network: select the element, press <ALT> while dragging it out (if <ALT> is not pressed then other elements may also move). 2. To duplicate an element, select the element; press <CTRL> 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 <CTRL+C>. To paste it press <CTRL+V> 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: <CTRL+A> 5. Select more than one items on the screen: Hold down the <CTRL> 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 <CTRL+E> to view its properties then go to Edit and Select all <Alt, E, L>. 6. Undo previous action: <CTRL+Z>. Redo previous action: <Alt, E, R> (Edit, Redo previous action). The latter may only be activated if the earlier undo is executed.
Q2N2222
50
M1 MbreakN
M2 5Vdc MbreakP
V2
(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 J2 JbreakP J3 J2N3819 J4 J2N4393
(a) (b) (c) Figure 13. The figure shows typical JFET models.
(d)
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.
51
V-
OS1
uA741 1 6 5
V+
OS2
15Vdc
0
7
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.
52
4. SOURCES
4.1 DC SOURCES: BATTERY & GROUNDING
Figure 15 shows the typical DC supplies and grounds.
12V + V1
HI
VCC_BAR
LO
(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.
Figure 16. The figure shows a typical ac source that can be used for frequency sweep simulations.
Figure 17. The figure shows a typical ac source that can be used for frequency sweep simulations.
53
6.0V T V2
4.0V
PW 2.0V
0V 0s
V1
V4
0.1ms V(V4:+)
1.0ms
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.
6.0V
V2
PW
4.0V
2.0V
PER = T
0V 0s V(R8:1) 1ns 2ns
TR
3ns
TF
4ns
V1
5ns Time 6ns 7ns 8ns
V1 = 0 V2 = 5 TD = 0 TR = 1n TF = 1n PW = 0.001n PER = 2n
9ns
V9
10ns
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.
54
6.0V
V8 V1 = 1 V2 = 2 V3 = 3 V4 = 4 V5 = 5 V6 = 6 T1 = 1n T2 = 3n T3 = 5n T4 = 9n T5 = 13n T6 = 54n
4.0V
2.0V
0V 0s V(V8:+) Time 10ns 20ns 30ns 40ns 50ns 60ns 70ns 80ns 90ns 100ns
Figure 20. Typical settings and simulation settings (the property editor for the part is displayed in the background) for a piecewise linear voltage source.
55
5. MACRO-MODELLING
Figure 21 illustrates a typical design procedure for an integrated circuit (IC). Macromodelling 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 <Ctrl+E>). 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 = 3000 Beta = 3
(a) (b) Figure 22. The figure shows (a) the parameter component, and (b) a typical parameter added. 56
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).
Ao v _in 1Vac 0Vdc 1 1+s
Voltage marker
V
PARAMETERS:
Beta Ao = 3000 Beta = 3
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.
57
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).
58
specify the number of points/Decade to be used in simulation (more points corresponds to longer simulation time (and additional RAM)).
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). <HOTKEY-6> Press <F11> 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 59
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.
A m p l i t u d e -100
-50d
100Hz
1.0KHz Frequency
10KHz
100KHz
1.0MHz
Figure 27. The figure shows a paste result of the simulation from PSpice A/D Lite.
60
Figure 28. The figure shows the typical settings for a parametric sweep.
-100
-1.0 DB(V(GAIN2:IN)) 0d
-50d
100Hz P(V(GAIN2:IN))
1.0KHz Frequency
10KHz
100KHz
1.0MHz
Figure 29. The figure shows the simulation results for changes in Ao over the interval specified in figure 28.
61
Figure 30. The figure shows the typical temperature sweep (for a list of temperatures) settings.
62
Rf 5k
D1N4148
V V
1k
V-
D1
vA
vB
Rs
V+
R1 10k
+ - 1 VShif t
3 Rp 833
vO
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).
V o l t a g e w a v e f o r m s V 10V
15V+ VEE
0V
-10V
(a)
A m p l i t u d e s p e c t r u m 10V
5V
0V 0Hz V(vIN:+)
0.5Hz V(D1:2)
V(DIFF1:OUT)
1.0Hz V(Rf:2)
1.5Hz Frequency
2.0Hz
2.5Hz
3.0Hz
(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.
63
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.
10V
0V
-10V
(-10.000,-14.615)
-6V
-4V
-2V
0V V_VShift
2V
4V
6V
8V
10V
Figure 34. The figure shows the transfer characteristic of figure 31 (effect of change in vIN on vC).
64
Figure 35. New Project window and select the option to base the design on a blank hierarchy.
65
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.
66
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.
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: 67
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
68
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.
69
70
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 <Value> 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:
71
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.
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:
72
Construct a test circuit for the component. A good choice would be to construct an ACanalysis. 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.
73
7.8 Results
74
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.
75