Method 4. Generating Parts with the PSpice Model Editor
You can construct new models by using existing model listings as examples and/or the model descriptions found in the PSpice reference guide (
pspcref.pdf) located in the
OrCAD/doc folder. The following sections describe how to download primitive models (models beginning with .model) from the Internet and how to create your own subcircuit models (models beginning with .subcircuit). The models can then be added to a PSpice library from which you can generate Capture part libraries as described. Creating custom primitive models is not described here.
MAKING A PSPICE MODEL FROM A CAPTURE PROJECT
In the event that a PSpice model (or even a generic spice model) cannot be located, you can make your own *.mod file. There are two ways to do this, depending on the type of model you are trying to make. If you need to make a primitive model for a device (e.g., a diode or P-channel MOSFET transistor), you need to compose a .mod file using a text editor then import the model into a library as just described. To make an accurate model, you need to be familiar with model parameters for the part and the “code” that PSpice understands. This is not described here, but you can read about the details in the PSpice Reference document (
pspcref.pdf) located in the
OrCAD/doc folder. As a starting point you can also look at examples from the PSpice Breakout library (
breakout.lib).
If you need to make a model for a nonprimitive part (an IC or a transformer, for example), you can compose a subcircuit model without having extensive knowledge of model parameters or PSpice code. You simply “draw” the circuit using Capture, have Capture write the subcircuit model for you, then save it as a PSpice library. Once you have the .LIB file, you can use
Method 3 or to make a Capture part with the model attached to it and attach a PCB Editor footprint if so desired.
An example of how to make a PSpice model and subsequent Capture part is given here for a transformer with a single primary winding and a center-tap secondary, similar to the one in
Figure 7-3 (except that the transformer in this example has a PSpice model—a PSpice template—associated with it). Using this procedure you can specify the inductance and DC resistance of the windings and the coupling between the windings for a specific part as described in a data sheet.
The basic process is as follows:
1. Use Capture to draw a circuit that you can simulate. The circuit will consist of inductors, resistors, and coupling coefficients.
2. After the transformer “circuit” is simulated to verify it behaves correctly, simulation sources are deleted and hierarchical ports are added to the schematic, which will become the leads (pins) of the transformer.
3. Use Capture to create a PSpice library netlist file (.lib) for the circuit.
Method 3 or
Method 4 is used to generate a Capture part from the .lib file. In this example we use
Method 4 so that we can look at and modify the model prior to making a Capture part for it.
To make a .subcircuit model, open Capture and choose
New → Project… from the session frame’s
File menu. From the
New Project dialog box, choose
Analog or Mixed A/D as shown in
Figure 7-40.
Select the location of the new project using the
Browse… button at the bottom of the dialog box. If you plan on making more models in the future, it is a good idea to create a new folder just for model development. Once you have your models fully developed and tested, you can copy the finished libraries into the normal Capture and PSpice library folders.
After you click
OK, the
Create PSpice Project dialog box (
Figure 7-41) will be displayed. Check the
Create based upon an existing project radio button and select either the
empty.opj or the
simple.opj project template. Different templates may be displayed depending on which version you have. For what we are going to do in this example, it really does not matter which template you start with. Click
OK.
In the Project Manager window, expand the
Design (.dsn) icon if it is not already expanded, and double click the
SCHEMATIC1 folder (see
Figure 7-42). The name of the design (
DesignName.dsn) will become the default name of the PSpice library (
DesignName.lib), and the name of the root folder (
FolderName) will become the
name of the PSpice part model (
.subcircuitFolderName…), so you want to change the name of the folder from
SCHEMATIC1 to the name you wish for your part.
To rename the schematic folder, select the folder by left clicking once, then right click, and select
Rename from the pop-up menu. Change the name of the schematic folder to the name that you want the part to have (e.g.,
S_Pri_CT_Sec for single-winding primary, center-tap secondary).
Double click on the
PAGE1 icon to display the schematic page (see
Figure 7-42). Delete any parts or text provided by the template by dragging a box around (or across) the parts to highlight them, then hit the
Delete key on your keyboard.
Place four resistors from the
Analog library (which have PSpice models associated with them) on the schematic page (see
Figure 7-45 later). The resistors are used to simulate the DC resistance of the windings and a dummy load resistor. You can get the resistors from the
Place Part dropdown list located on the toolbar at the top of the window frame or by selecting the
Place Part button,
, on the toolbar at the right of the schematic page. If you use the
Place Part button, you will be presented with the
Place Part dialog box shown in
Figure 7-43. Select
ANALOG from the
Libraries: list then scroll down the
Part List: and select part
R. Notice that the parts in the
Analog library have PSpice models and footprints associated with them, as indicated by the PSpice and Layout (not PCB Editor) icons located under the part preview box in the lower right corner of the dialog box. Click
OK. Click on the schematic page in four places to place four resistors (see
Figure 7-45 later for reference).
Repeat this procedure to place three inductors (part
L) on the schematic page. One inductor serves as the primary winding, and the other two serve as the secondary windings. The inductors will be used to define the inductance (the turns ratios) of the primary and secondary windings.
Next, place one
K_Linear part from the
Analog library on the schematic page.
K_Linear defines the coupling coefficient of the windings.
Place a
VSIN part on the schematic page so that we can test the operation of the transformer. VSIN is located in the
SOURCE library.
Finally, place three zero (0) ground references on the schematic page. Click the
Place Ground tool,
, then select
0/SOURCE from the
Place Ground dialog box, as shown in
Figure 7-44. For schematic entry and PCB Editor, you can use any ground symbol, but for PSpice simulations you have to have at least one 0 reference ground.
Position and rename the components, wire the circuit, and change the values of the components as shown in
Figure 7-45. To change the reference designators (e.g., R1 or Rp) or the component values (e.g., 10
Ω), double click the property you want to change. In the
Display Properties dialog box, enter the appropriate value and click
OK.
You can also modify a part’s properties by double clicking the part (or click once to select it then right click and select
Edit Properties… from the pop-up menu). A
Property Editor spreadsheet will pop up, as shown in
Figure 7-46. If the properties are listed across in rows instead of vertically in columns, you can change the view by selecting the upper left-hand (corner) cell to highlight the entire spreadsheet, then right click and select
Pivot from the pop-up menu. You can also specify how many items are listed by using the
Filter by: dropdown list just above the spreadsheet cells. To display all pertinent properties, select the
<Current properties> option located at the top of the list.
To modify and display the
K_Linear coupling properties, double click the coupling part to bring up the spreadsheet. Make sure that either the
Current properties or the
OrCAD-PSpice filter option is selected. In the L1 cell, type
Lp1 (or whatever you named your primary coil) then click the
Display button, which is located just above the spreadsheet cells. Enter
Ls1 in the L2 cell and
Ls2 in the L3 cell and click the
Display button for both of these parameters too. The L1, L2, and so on cells establish which coils are coupled as part of the transformer. You can have additional or separate coupling coefficients for different sets of coils, but for this example we have all three equally coupled together using the single linear coupler. Once you finish, close the spreadsheet by clicking the
X button in the upper right-hand corner of the spreadsheet.
Now we need to simulate the part with PSpice. You can perform several types of simulations with PSpice. In this example we perform a time domain analysis so that we can see the AC waveforms at the input of the transformer and at the load resistor.
To test the circuit we need to set up a simulation profile.
To set up a simulation profile, choose
Edit (or
New)
Simulation Profile from the
PSpice menu. In the
Simulation Settings dialog box (see
Figure 7-47), select the
Analysis tab. In the
Analysis type: dropdown list, select
Time Domain (Transient). Set the rest of the parameters as shown in
Figure 7-47, then click
OK.
Place voltage markers on the circuit to specify which voltages to display in the PSpice probe window. Click the Voltage Probe button,
, on the toolbar and place a probe on the wire coming from VSIN (green marker) and one (red marker) on the wire going from the secondary winding to the load resistor (RL).
Start the simulation by clicking the
Run PSpice button,
. PSpice runs the simulation and displays the results in a probe window, as shown in
Figure 7-48.
The voltage curves show that the transformer functions as a 1:2 step-up transformer, since the output (red marker curve) is twice as high as the input (green marker curve). Additional tests (e.g., frequency response) could be performed to validate the circuit model further, but these are not discussed here.
Since the circuit model has been validated, we now prepare to make a PSpice model of the circuit. Begin by deleting the VSIN source, the load resistor RL, and all the ground references.
Add ports to the schematic, which will serve as the leads of the transformer. Click the Place Port tool,
. Select the
PORTBOTH-L port from the
Place Hierarchical Port dialog box, as shown in
Figure 7-49. All the port symbols behave identically in Capture, PSpice, and PCB Editor. The only difference is the appearance
on the schematic. Since the transformer is a passive device, we use the symbol that indicates that an applied signal can go in either direction. Click
OK and place five of the ports on the schematic page (two for the primary and three for the secondary).
Reposition, connect, and label the ports as shown in
Figure 7-50.
Display the
Project Manager window by minimizing the schematic page or
ProjectName.opj from the
Window menu. Select the
Design icon then select
Create Netlist from the
Tools menu.
In the
Create Netlist dialog box (
Figure 7-51), select the
PSpice tab. Check the
Create SubCircuit Format Netlist box and the
Descend radio button. A default name will be given to the netlist. Modify the path and name as desired. Make sure the name ends with the .LIB file extension. Click
OK.
You now have a PSpice library file with one model (the transformer) in it. You can use
Method 3 or to generate a Capture part library from this model or add it to an existing part
library. To complete the example we use
Method 4 so that we can take a look at the PSpice model generated by Capture.
Start the PSpice Model Editor again. From the
File menu, select
Open and navigate to the transformer library that you made previously. Click on the
S_Pri_CT_Sec model to display the model in the editing window, as shown in
Figure 7-52. Notice that the model type is .SUBCKT (a subcircuit). The name of the library is whatever you specified as the netlist file in the
Create Netlist dialog box, and the name of the part is the schematic folder name in the Capture design (see
Figure 7-42). At this point you could modify the part to add specific requirements that will carry forward into the Capture part. Once the model editing (if any) is completed, generate the Capture part as described previously, using
Method 3 or
Method 4.
Note that, as shown in
Figure 7-52, the pin names and order in the Capture part (as indicated in the
Pin Properties spreadsheet) and the PSpice Template (as indicated in the
Part Properties spreadsheet) must match the pin names and order in the PSpice model exactly or simulations will fail. The
Implementation name in the part properties spreadsheet must also match the model name in the PSpice model file. And finally, the part’s pin numbers must match the pin (padstack) numbers in PCB Editor, which is governed by the part’s data sheet. If the part’s pin number is a letter instead of a number (e.g., A, for the anode of
a diode), then the pad in PCB Editor must be named accordingly or the ECO (engineering change order) will fail.
ADDING PSPICE TEMPLATES (MODELS) TO PREEXISTING CAPTURE PARTS
Rather than using
Method 3 or to make a new part from the transformer PSpice library, you might wonder why we did not just add the PSpice model to the transformer already created in the first example (for which
Method 1 was used). In older versions of OrCAD, this was somewhat of a challenging task (e.g., you have to know what “X^@REFDES %A %B %Y %VCC %GND @MODEL PARAMS:
1 IO_LEVEL5@IO_LEVEL MNTYMXDLY5@MNTYMXDLY” means). Fortunately, it is a simpler matter with the newer versions.
In this example we see how to add an existing PSpice model to an existing Capture part. We add a basic capacitor model to one of Capture’s capacitor parts that has no model associated with it.
A basic capacitor (part C or CAP) from Capture’s
discrete.olb library has no PCB Editor footprint or PSpice model associated with it. We add a PSpice model to the part now. The location of the basic PSpice capacitor model that we use is in the PSpice
Breakout library (
breakout.lib).
To add a PSpice model to an existing Capture part, start Capture and select
Open→Library and select the library with the part to which you want to add a PSpice model (use
discrete.olb for this example). Find the capacitor (C or CAP, for example) in the Capture Library Part Manager and click the part’s icon to select it. Right click and select
Associate PSpice Model… from the pop-up menu.
At the
Import Model Wizard dialog box (
Figure 7-53), use the
Browse… button in the upper right-hand corner to find the PSpice model you want to associate
with the Capture part. The wizard automatically searches through the PSpice library and lists all models in the
Matching Models window that have the same number of pins as the Capture part you selected in the Part Library Manager. Select the
CBREAK model and click
Next.
The wizard then displays the Pin Matching tool shown in
Figure 7-54. This is where you connect the PSpice model pin to the Capture part pin. Click
Finish when the pins are matched. The information box shown in
Figure 7-55 should be displayed, indicating that the capacitor now has a PSpice model attached to it.