Creating New Spice Models
Working with SPICE Models in Circuit Maker
SPICE is an industry standard program for simulating circuits. In order to make devices work with Circuit Maker in analog simulation, there must be SPICE data available for each device. Using the Symbol Editor, you can include SPICE model and subcircuit information with a new or existing device. You can also edit SPICE information using an ASCII Text Editor.

Note: If you intend to create non-functional device symbols or simply draw schematics, you do not need to include SPICE information. However, even if you are going to simulate your circuit, adding SPICE models from other sources is easy and beneficial.

There are 3 basic types of components in SPICE:

1) Elementary components such as resistors, capacitors, power sources, etc.
2) Models defining discrete devices such as BJTs, J-FETs, MOSFETs, etc.
3) Subcircuits which combine multiple items (such as elementary components, models, and other subcircuits) to create a more complex device.

SPICE models and subcircuits are available from many sources, including component manufacturers, see these links.

Adding Spice Data to a New Symbol
You can easily edit a wide range of device information related to schematic, simulation, pcb netlists and other purposes.
To edit a device, right click and select expand macro. Answer yes to clear screen, then either double-click on a device to display and select netlist or right click to display the Edit Device Data dialog box. (Screenshot below.)

All of the dialog boxes will now be explained.

Device
This non-editable field shows the device name as it appears in the library menus. The device name is defined when the symbol was created under the new macro menu. Use the Visible check box to show or hide the name in the schematic. If visible, the device name retains the same orientation as the device when you rotate it. The label-value, designation and description, however, will remain right-side up no matter how the device is rotated. Note that some device names, such as "Resistor", cannot be made visible.

Label-Value
Use this field to enter information about the device such as its label (1N914, 2N3904, etc.) or its value (47K, 100U, etc.), or to replace the existing Device name (that is, make the Device not visible and the Label visible). The Label-Value can be dragged around the device on the schematic with the mouse and will remain attached to the device when the device is moved.

Designation
Use this field to identify the device in the circuit such as U3, CR7, RLOAD, etc. You can also make this field visible with the Visible check box. This field must contain the device designation in order for simulation and pcb netlists to work properly. The Designation label may also be dragged around on the schematic with the mouse. It will remain right-side up no matter how the device is rotated. This field is filled in automatically when you place the device. See Auto Designation Prefix later in this section for more information.
Important: Individual parts of multipart packages must be grouped properly. CircuitMaker takes care of this automatically if you use devices as they are from the library. However, if you have altered multipart packages, they must be grouped using the Edit > Group Items command. Just changing the Designation field is not sufficient. Each individual part must be identified as PART A, PART B, etc., from the Edit Device Pin Data dialog box. See Pins section.

Description
Use this field for schematic reference only. You can use it to display additional information such as custom part numbers, tolerances, etc. This field does not affect simulation. Use the Visible check box to make the field visible or not.

Package
Use this field to identify the type of physical package (footprint) the device is in (DIP14, TO-92B, etc.). When you are creating pcb netlists for TraxMaker or other pcb layout programs, make sure the Package name you enter exactly matches the name of the corresponding component footprint in your pcb layout programs library.

Auto Designation Prefix
This is the prefix used when CircuitMaker automatically assigns a devices designation (whenever you place a device or select Edit > Set Designations). The prefix may be up to 4 characters in length.

Spice Prefix Character(s)
This is the SPICE prefix used in conjunction with the %D and %M flags described later under Spice Data. You would normally use this field when linking the macro symbols you define to the proper model selections when creating new devices. The spice prefix is a single or double alphabet charcater as shown in the table below:

Spice Prefix Table
A XSpice Model
BV Nonlinear Dependent Voltage Sources
BI Nonlinear Dependent Current Sources
C Capacitors
D Junction Diodes
DZ Zener Diodes
E Linear Voltage-Controlled Voltage Sources
F Linear Current-Controlled Current Sources
G Linear Voltage-Controlled Current Sources
H Linear Current-Controlled Voltage Sources
I Independent Current Sources
JN JFETs (N-channel)
JP JFETs (P-channel)
K Coupled (Mutual) Inductors
L Inductors
MN MOSFETs (N-channel)
MP MOSFETs (P-channel)
O Lossy Transmission Lines
QN Bipolar Junction Transistors (NPN)
QP Bipolar Junction Transistors (PNP)
R Resistors
S Voltage Controlled Switches
T Lossless Transmission Lines
U Uniform Distributed RC Lines (Lossy)
V Independent Voltage Sources
W Current Controlled Switches
X Subcircuits
ZN MESFETs (N-channel) (GaAs FETs)
ZP MESFETs (P-channel) (GaAs FETs)

Analog
This check box identifies this as a device that can be used in Circuit Makers Analog simulation mode. The analog simulator can only simulate a device if there is SPICE simulation data for that device. If you attempt to run an Analog simulation using a device that does not have the Analog check box checked, CircuitMaker displays a warning message and that device will be ignored in the simulation. When creating your own models, this box should be checked only if you have supplied SPICE data for the device or if the device is a macro circuit containing other analog devices.

Digital
This check box identifies this as a device that can be used in Circuit Makers Digital simulation mode. The digital simulator can only simulate a device if there is digital SimCode for that device. If you attempt to run a digital simulation using a device that does not have the Digital check box checked, CircuitMaker displays a warning message and that device will be ignored in the simulation. When creating your own device, select this box only if the device is a macro circuit containing other digital devices or was created using digital SimCode (see Chapter 17: Digital SimCode for more on digital device creation).

Parameters
This field stores information that affects the simulation of certain devices. For digital SimCode devices, this field would contain type:digital. It could then be followed by a list of parameters which are generally set in the Digital Model Parameters dialog box. Some generic device models can be redefined by passing parameters as an alias to describe a specific device. For example, the parameter field of a crystal would contain alias:XCRYSTAL and could be followed by a list of databook parameters that define that specific crystal. Generally, you enter these parameters in the Subcircuit Parameters dialog box.

Bus Data
Use this field to specify which pins on the device are connected to the power or ground buses, since these pins are not shown on the predefined device packages. This field holds up to 2048 characters, which is helpful when creating devices with many power and ground pins. The general format for this data is:
busnam[=pinnum[,pinnum,...]];[busnam=pinnum[,pinnum,...];...]
For example, on a 74LS83 the Bus Data is:
DVCC=5;DGND=12;
This means that the Vcc bus is connected to pin 5 and the Ground bus is connected to pin 12. The bus data for a 74AC11190 would look like:
DVCC=15,16; DGND=4,5,6,7;
The order in which the buses are listed is not important.
To connect these bus pins for Analog simulation or for creating a PCB netlist to export into TraxMaker or other PCB layout program, each bus must be defined. There are three devices that can be used for this purpose: +V, Ground and Terminal. The Bus Data format for these devices is simply:
busnam;
where busnam identifies the specific bus. For example, each Ground device, by default, contains the Bus Data GND; which causes all of the Ground symbols to be tied together in a single node or net.
Note: For simulation purposes, the Ground device always equates to Spice node 0, even if the Bus Data changes.
A +V device does not contain any default Bus Data. This is because each +V device may represent a different supply voltage. However, the Bus Data field can also be used on these devices to identify it as the voltage source for the digital devices. For this example, set the Bus Data to DVCC; or DVDD;.
In some cases it may be necessary to connect a different voltage source (such as the output of a voltage regulator) to the digital devices. In such cases, connect a Terminal device to the power source and enter DVCC in its Terminal Name field. CircuitMaker will make a connection between the Terminal device and any bus that has the same name. CircuitMaker will also make a connection between the Terminal and any Input or Output connector that has the same name. Do not use a semicolon in the Terminal Name field. For example, DVCC is correct, but DVCC; is incorrect for the Terminal Name field. Note: CircuitMaker automatically copies what you enter in Terminal Name field to the Terminal's Bus Data field and appends a semicolon.
You can short multiple +V and Terminal devices together by Bus Data for the +V device and Terminal Name for the Terminal device. If you short two +V devices together, you will receive an XSpice error when you run the simulation. To avoid this problem, remove the Spice Data and Spice Prefix Character from all but one of the shorted +V devices.

Spice Data
This field is used to specify the SPICE simulation data for the device. The analog devices provided with CircuitMaker already have default SPICE data included. If you create your own devices to use with the analog simulation, you will need to fill in this field yourself. You can enter SPICE data into this field directly, or you can reference it to the other fields in the dialog box. The percent sign (%) is used as a flag to tell CircuitMaker to reference the already defined fields. Their meanings are:

Name (%N)
Inserts the Device Name into the SPICE data string. This is the name found in the library menus.

Label (%L)
Inserts the Label-Value into the SPICE data string. This requires the first character in the Label-Value string to be an alpha character. The label may not exceed 8 characters.

Value (%V)
Inserts the Label-Value into the SPICE data string. This requires the first character in the Label-Value string to be numeric. The value may be an integer (12, -44), a floating point number (3.14159), either an integer or floating point number followed by an integer exponent (1e-14, 2.65e3), or an integer or floating point number followed by one of the following multipliers:
T= 1012 G= 109 Meg= 106
K= 103 m= 10-3 u= 10-6
n10-9 p10-12 f10-15
If multipliers are used, they must immediately follow the number with no spaces. Letters that are not multipliers immediately following a number are ignored, and letters immediately following a multiplier are ignored. For example, 10, 10V, 10Volts, and 10Hz all represent the same number and M, MA, Msec, and MMhos all represent the same multiplier. Note that 1000, 1000.0, 1000Hz, 1e3, 1.0e3, 1KHz, and 1K all represent the same number.

Model (%M)
Inserts the Label-Value into the SPICE data string. If the first character of the Spice Prefix Character(s) does not match the first character in the label, then it inserts the first character of the prefix at the beginning of the string. The %M is also required in order to guarantee that the .MODEL data for this device will be included in the SPICE netlist file for simulation. The Label (including prefix) may not exceed 8 characters.

Subcircuit (%S)
Inserts the Label-Value into the SPICE data string. If the first character in the label is not an X, then it inserts an X at the beginning of the string. The %S is also required to ensure that the .SUBCKT data for this device will be included in the SPICE netlist file for simulation. The Label (including the X) may not exceed 8 characters.

Designation (%D)
Inserts the Designation label into the SPICE data string. If the first character of the Spice Prefix Character(s) does not match the first character in the designation, then it inserts the first character of the prefix at the beginning of the string.

Description (%I)
Inserts the Description field into the SPICE data string.

Package (%P)
Inserts the Package label into the SPICE data string.

Bus Data (%B)
Inserts the entire Bus Data field into the SPICE data string.

Named Subcircuit (%X)
Inserts the specified subcircuit into the SPICE data string. If the subcircuit resides in a .SUB file other than the one associated with the symbol name of the current device, the .SUB file name where the subcircuit is located must also be specified. For example: %XUA741 or %XUA741:OPAMP5.

Include File (%="path\filename.ext")
Inserts the ASCII text file filename into the SPICE data string by using SPICE's .INCLUDE command. Path is the same as the current circuit unless enclosed in quote marks (" ").

Node (%number)
Inserts the node number for the specified pin into the SPICE data string. Number refers to the position of the pin in the Edit Device Pin Data dialog box. For example, the pin at the top of the list is represented by %1, the next pin down is %2, etc. See Pins later in this section.

Analysis Probe Name (%[ )
Inserts the output node number associated with an Analysis Probe. For example, %[TP1] or %[+TP1] inserts the node number associated with the + pin of the Analysis Probe that has the name TP1. %[-TP1] inserts the node number associated with the - pin.

Pins
Click the Pins button on the Edit Device Data dialog box to display the dialog box shown below.

This dialog box lets you edit the pin designations of the package for the selected device and determine whether the pin designations will be shown on the schematic.

You can specify pin numbers using up to five alphanumeric characters. Not only can you use standard pin numbers such as 1, 2, 3, but you can also use pin numbers such as A1, B1, C1, A2, B2, C2.

Some device packages actually contain more than one of the same device. For example, a 7400 Quad 2-Input NAND gate actually has 4 gates in the same package. The pin numbers are different for each gate. CircuitMaker groups together the individual gates to indicate which gates go in which package. As you place each gate in the circuit, the next available gate is used from the previous package. If no gates are available in the previous package, a new package is used. You can regroup the gates as needed using the Edit > Group Items option. Each gate in the package is assigned a letter (A, B, C, etc.) and the pin numbers for that gate correspond to that assignment. You can manually reassign the pins used for a particular gate by selecting the appropriate letter (PART A, PART B, etc.) for that gate with the Up and Down Arrows in the dialog box.

Default pin data has already been entered for the predefined devices. Clicking the Default Designations button restores the pin numbers to their original default values. You can add default pin numbers to a macro device by editing the pin numbers while the macro is expanded and while saving the macro.

To edit macro pin names and designations, double-click them in the Symbol Editor. The order in which the pins appear in the list is determined by the order in which you placed pins on the device.

To edit pin designations for a specific part, double-click them in this dialog box. This does not change the pin designations in the library.



SPICE Data Usage Examples
The following examples show how you can use the SPICE Data field when creating custom devices.
Example 1
If a resistor, R2 has a value of 22kohms and is connected between node 5 and ground, the SPICE data for R2 could be written as:
R2 5 0 22k
However, by using a generalized form of the SPICE data, it can be updated automatically if items such as designations or node numbers change. Each item in the above spice data can be substituted with variables as shown in the following table:
ValueDescriptionSubstitution
R2Designation%D
5First pin node number%1
0Second pin node number%2
22kLabel-Value%V
Using the above substitutions the SPICE data can be wrote in the following generalized form:
%D %1 %2 %V

Example 2
If transistor Q2 is a 2N3904 with its collector connected to node 7, its base to node 4 and its emitter to node 12, the SPICE data may be written as:
Q2 7 4 12 Q2N3904
However, you may need to enter SPICE model data into the netlist manually. A more universal method would be to enter the following string:
%D %1 %2 %3 %M

Example 3
If op amp U4 is an LM741 where the +input is connected to node 3, the -input is connected to node 1, the +V pin to node 5, the -V pin to node 12 and the output to node 9, the SPICE data may be written as:
XU4 3 1 5 12 9 XLM741
But again, a more universal method would be to enter the following string: %D %1 %2 %3 %4 %5 %S


Example, Adding Spice Data to a New Symbol
Below left is a new symbol for an electrolytic capacitor that I have created. See Creating new symbols for to learn how to draw components.

After the macro has been expanded and edit default data selected, the additional data fields can be filled in. Label value has been set to 100u, (although any value could have been chosen). Designation is set to C1, Auto designation and Spice Prefix data also set to C. As the part is to be used in analog simulations the analog box is checked. Finally the component has two pins, N1 and N2, N1 being the "+" terminal.

Return to Circuit Maker