Tutorial - How To Use The SPICE Module

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

How to Use the SPICE Module

Altair PSIM Tutorial

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us
Altair PSIM Tutorial / How to Use the SPICE Module

1. Overview
The SPICE Module is an add-on option in PSIM. The SPICE Module makes it convenient to run
LTspice simulation in the PSIM environment.
This tutorial is written for users who already have some experiences in both PSIM and SPICE
simulations. It provides a quick guide on how to use the SPICE Module in PSIM. For further details,
please refer to SPICE Module User Manual.
Before running LTspice simulation, user must install LTspice on the computer, and specify the
location of LTspice executable file by clicking PSIM menu Options >> Set Path. At the bottom of this
dialog, as shown in the picture below, use the Browse button to find and enter the path and filename
for the LTspice executable file. Then, click Save and then Close the dialog.

2. Getting Started with SPICE Simulation


To illustrate the basic process of running SPICE simulation from a PSIM schematic, we will use the
examples in the folder “examples\SPICE” in the PSIM directory.
To keep the original example unchanged, we will create a new folder “C:\PSIM_SPICE Tutorial”,
and use this folder as the working folder in this tutorial.
Click “File >> Open Examples…” then go to the subfolder “\examples\SPICE\SiC Devices\Rohm”.
Select the example file “Buck Converter with SCT2280KE (LT).psimsch” and use “File >> Save
As…” to save the file into the new folder.
The example circuit is as shown below. It is a basic buck converter circuit.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 2
Altair PSIM Tutorial / How to Use the SPICE Module

In this circuit,

• A SPICE Directive Block “XSPD1” contains a SPICE netlist.


• The diode D1 has a SPICE model name “DRFN20TF6S”. It is defined in a “.MODEL”
statement in XSPD1.
• The MOSFET Q1 has a SPICE subcircuit name “SCT2280KE”. It is a subcircuit block
defined in PSIM’s SPICE library.
How to insert a pre-existing SPICE models into a PSIM schematic will be explained in Section 3 –
Use SPICE Models in PSIM Schematics.

2.1 SPICE Simulation Control


Double click the clock shaped Simulation Control, then go to the SPICE tab, user may select the
analysis type, define the parameters, and choose options for SPICE simulation.
For SPICE analyse commands and options not available in this Simulation Control dialog, user can
write them in the SPICE Directive Block. For more information about the Simulation Control dialog
and the SPICE Directive Block, please refer to the SPICE Module User Manual.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 3
Altair PSIM Tutorial / How to Use the SPICE Module

For this example, the transient analysis will be performed with the settings as shown below.

2.2 Run SPICE Simulation


To run SPICE simulation, click on the Run LTspice Simulation button on tool bar or select
Simulate >> Run LTspice Simulation from the pull-down menu, as indicated below.

LTspice simulation is run in the LTspice engine. Only the content of the .log file generated from
LTspice will be displayed in PSIM’s message window. During the time while LTspice simulation is
running, there is no status or progress information passed from LTspice to PSIM for display. At the
end of LTspice simulation, PSIM’s message window will refresh the message from the .log file
generated by LTspice, and the content of .raw file can be displayed in SimView the same way as
PSIM simulation.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 4
Altair PSIM Tutorial / How to Use the SPICE Module

2.3 Export SPICE Netlists


User can capture a PSIM schematic and export it as a SPICE netlist by clicking Simulate >>
Generate SPICE Netlist (.cir). The netlist file thus generated can be loaded into LTspice for
simulation.
The netlist file with the same name as the PSIM schematic would be overridden each time “Generate
SPICE Netlist” is clicked or each time the LTspice simulation is run.

2.4 Import SPICE Netlists


Pre-existing netlists, either written by hand or generated from other schematic capture software, can
be loaded into PSIM and run LTspice simulation.
On PSIM menu, click “File >> Open SPICE Netlist File” to load the netlist file into PSIM, and then,
run LTspice simulation.

2.5 SPICE Netlist Format


PSIM provides convenience of running LTspice simulation with PSIM schematics. The SPICE netlist
syntax and functions must be supported by LTspice.
Some SPICE netlist files from other sources may contain syntaxes and/or functions which are not
supported by LTspice. In such a case, one needs to convert these statements manually.
PSIM provides a simple syntax check. The details are in section 3.1 SPICE Directive Block.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 5
Altair PSIM Tutorial / How to Use the SPICE Module

3. Use SPICE Models in PSIM Schematics


In PSIM schematics, user-defined or pre-existing SPICE models in either “.model” or “subckt” format
can be used. In our example, the diode is defined by “.MODEL DRFN20TF6S D…”, and the MOSFET
is defined by “.SUBCKT SCT2280KE …”.
PSIM provides several ways for user to define, save, and use SPICE models in PSIM schematics
with convenience and flexibility. This chapter is to explain those methods.

3.1 SPICE Directive Block


The easiest way to insert previously written SPICE models in a PSIM schematic is to write (or copy
and paste) the netlists into “SPICE Directive Block”, as shown in the example above. In PSIM, click
Elements >> SPICE >> SPICE Directive Block, and then enter the netlist content of the devices’
definitions.
Each PSIM schematic may contain only one SPICE Directive Block. All the SPICE commands,
model parameters, and subcircuit netlists must be written into this block.
In the example, the diode D1 is defined in a “.model” statement in the SPICE Directive Block.
In a PSIM schematic, to use a component with pre-written or third party netlist:

• Select Elements >> Power >> Switches >> Diode and place the diode in the circuit.
• In the diode parameter dialog, select the Model Level as “SPICE Model”.
• The button beside the SPICE Model Name would open the search dialog for SPICE model
files in PSIM’s SPICElib folder. User may search and find whether or not the model is
already in the libraries. If it is already included, user may select it from the list and there is
no need to write it in the directive block.
• If the model can not be found in the libraries, in the SPICE Model Name, enter the name
“DRFN20TF6S”.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 6
Altair PSIM Tutorial / How to Use the SPICE Module

• Write the “.model” directive and all the parameters in the SPICE Directive Block, as shown
below:

The content of the SPICE Directive Block can be saved into a file by clicking the “Save to file”
button.
The “Syntax Check” function check syntax of the PSpice netlist against LTspice format. If the
netlist is already in LTspice format, or any other SPICE format, the syntax will not be checked here,
but will be checked by LTspice when “Run LTspice Simulation” is performed.
In the SPICE Netlist Check dialog, there are following function buttons:

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 7
Altair PSIM Tutorial / How to Use the SPICE Module

Load Load the netlist content from a file.

Save Save the converted LTspice netlist content to a file.

Check Check the netlist syntax against LTspice syntax.


This function only compares the Pspice netlist against the LTspice format.
The original netlist is on the left and the converted netlist is on the right.
Statements that are different are marked in color based on the following:

• Lines highlighted in blue indicate that those statements are either


translated or with message provided for user to make the translation.
• Lines highlighted in yellow indicate that those statements have no
compatible conversion. User must edit those statements manually.

3.2 SPICE Subcircuit Netlist Block


In the example, the MOSFET is defined in a subcircuit with the “.subckt” statement. Since this
subcircuit’s node sequence is Drain, Gate, and Source, conventional for MOSFETs, it is easy to use
PSIM library element “MOSFET to define such a device in a circuit:

• From PSIM element list, select Elements >> Power >> Switches >> MOSFET and place
the block in the circuit.
• In this block’s parameter dialog, select the Model Level as “SPICE Subcircuit”,
• In the space for SPICE subcircuit name, enter “SCT2280KE”. The button beside the name
would open the search dialog for SPICE subcircuit files in PSIM’s SPICElib folder. User may
search and find if the subcircuit to be used is already included. If it is not included, user must
write the netlist in the directive block.

To accommodate different node numbers of subcircuit for MOSFET, PSIM provides the options for
3, 4, and 5 nodes devices. The node sequences are:

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 8
Altair PSIM Tutorial / How to Use the SPICE Module

• For 3 nodes: drain, gate, and source.


• For 4 nodes: drain, gate(+), gate(-), and source.
• For 5 nodes: drain, gate, source, Tj, and Tc.
For the devices with unconventional node definition and/or different node sequence in the subcircuit
definitions, PSIM provides a special element to insert such device into PSIM schematic: SPICE
Subcircuit Netlist Block.
In the example circuit, the MOSFET SCT2280KE can also be inserted into PSIM schematic in this
way, as shown in the graph below.

The steps are:

• Select Elements >> SPICE >> SPICE Subcircuit Netlist Block to place a block in the circuit.
• Double click the block to open the parameter dialog.
• In the “Model” box, enter the subcircuit name “SCT2280KE” to load it into the circuit.
• To modify the image of this subcircuit, select the image from the “Image” list or click “Edit
Image” to create a new image for this subcircuit. Please make sure the node sequence in the
image must be the same as in the subcircuit definition.
• Connect the wires.
• If the subcircuit parameters in the specific circuit is different from the default values, set the
desired number of parameters and the value of each parameter.
• Save the PSIM circuit under the name “Buck Converter with MOSFET
SCT2280KE_sub.psimsch”.
• Run simulation and verify the result of this implementation is the same as the previous one.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 9
Altair PSIM Tutorial / How to Use the SPICE Module

Please be aware that when using the SPICE Subcircuit Netlist Block, if the image of the subcircuit is
different from the default image, it will not be saved for future usage. To save this type of subcircuit
block together with the image, a PSIM element can be created. The detailed procedure of creating
a PSIM element is in the document “SPICE Module User Manual”.

3.3 Multi-Level Element


As mentioned in the Overview section, not all elements in the PSIM library are supported for
SPICE simulation. On the other hand, the elements defined with SPICE model or subcircuit netlists
cannot be used to run PSIM simulation. This seems inconvenient. However, PSIM provides multi-
level element settings for users who would like to run both PSIM and SPICE simulation using the
same PSIM schematic.
In our example circuit, the MOSFET and the diodes can be set to different model levels for different
simulation engines.
On the “Simulation Models” tab:

• The box is checked to “select different models for simulation”.


• The PSIM model is “Level 2” selected from the pull-down list.
• The SPICE model is “SPICE subcircuit” selected from the pull-down list.

On the “Parameters” tab, both models’ parameters must be entered. The PSIM file will save the
information for both models.

• Select “SPICE subcircuit” and enter the desired subcircuit name and parameters.
• Then, select “Level 2”, and enter all parameters from manufacture’s datasheet of the same
part name in the SPICE subcircuit definition.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 10
Altair PSIM Tutorial / How to Use the SPICE Module

PSIM will save both model information in the same file. User may run choose to run either simulation
without making any change in the circuit.

3.4 PSIM/SPICE Compatibility Check


Not all elements in PSIM library are supported for SPICE simulation. To see which elements are
supported, go to Options >> Settings >> Advanced and check the box “Show image next to
elements that can be used for SPICE”. When this box is checked, elements supported by SPICE will
be marked with the image (for SPICE simulation) next to the element in the Element menu and
in the Library Browser.
If the box “Show image next to elements that can be used for code generation” under Options >>
Settings >> Advanced is also checked, elements that are supported by both SPICE and by
SimCoder for code generation will be marked with the image for SimCoder and for SPICE.
In addition, some elements have multiple model levels. Some levels are supported for SPICE
simulation, but some levels are not.
To check model level settings, PSIM provides a function View >> Check Elements. The dialog
window of this function is shown below.

This table provides the following information to help users to select correct elements and model
levels for different simulation:

• Which simulation is supported for each element.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 11
Altair PSIM Tutorial / How to Use the SPICE Module

• Which elements are multi-level and which ones are not. And for multi-level elements, which
levels are for PSIM simulation and which levels are for SPICE simulation.
• The model levels of multi-level elements can be selected and changed in this table directly,
and it has the same effect as if they were changed through each element’s property dialog
window.
• Elements can be enabled/disabled by checking/unchecking the Enable checkbox.
• If the checkbox Highlight Elements is checked, all the elements listed in display will be
highlighted in the schematic.
The display can list elements in the circuit in the following ways:

• Show all: List all the elements in the schematic.


• Show only multi-level elements: List only the multi-level elements.
• Show only elements that are not supported by PSIM simulation: List only the elements that
are not supported by PSIM simulation.
• Show only elements that are not supported by DSIM simulation: List only the elements that
are not supported by DSIM simulation.
• Show only elements that are not supported by SPICE simulation: List only the elements that
are not supported by SPICE simulation.
With this function, one can quickly identify the elements that are not supported by the desired
simulation engine and correct the settings. And then, achieve the result of using the same PSIM
schematic to run both PSIM and SPICE simulation.

4. Managing SPICE Libraries


PSIM provides several ways for users to utilize pre-existing files containing SPICE models and
subcircuits. These approaches are explained below.

4.1 Search Path for SPICE Netlist Files


To use models (.model) and subcircuits (.subckt) in pre-existing SPICE netlist files, place those files
in the subfolder “SPICElib” in the PSIM directory. PSIM will load all models and subcircuits in this
subfolder automatically. Also, the file can have any extension and does not have to have the .lib
extension.
If you prefer to keep those files in a different location, you can add the folder location to the PSIM
search path. For example, a file named “My SPICE Models” contains SPICE models and is located
in the folder “C:\PSIM_SPICE Tutorial\SPICE Models”. To add it to the search path:

• In PSIM, select Options >> Set Path, and the search path dialog is shown as below.
• Click on “Add Folder” in the section “SPICE Model Path”, then browse for the file location
“C:\PSIM_SPICE Tutorial\SPICE Models” and add it.
• Click on “Reload Models” to refresh the search path.
• Click on “Save” and then “Close” to exit the dialog.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 12
Altair PSIM Tutorial / How to Use the SPICE Module

To check what models and subcircuits are available for SPICE simulation use, select View >> SPICE
Model List or View >> SPICE Subcircuit List. Once the models and subcircuits can be seen in
those lists, there is no need to write them in the SPICE Directive Block.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 13
Altair PSIM Tutorial / How to Use the SPICE Module

If a model file is placed in the “SPICElib” subfolder or in a folder that is in the PSIM search path, the
is no need to use the SPICE Directive Block for the model or subcircuit netlist. Also, the file’s
extension can be anything and does not have to be .lib or .txt.
If, by chance or intentionally, the name of the model or subcircuit in the SPICE Directive Block is the
same as one in the search path, the definition in the SPICE Directive Block in the PSIM schematic
will take the precedence and will be used.

4.2 Directives .LIB or .INCLUDE


Another way to use the files containing SPICE models and subcircuits is to write directives “.lib” or
“.include” in the SPICE Directive Block in a PSIM schematic.
.lib Path\Filename
or
.include Path\Filename
Note that the files’ absolute paths must be used.
In the above SPICE commands, the named file contains the definitions of models and subcircuits
for the SPICE models. With these directives, there is no need to copy the content of the files into
the same SPICE Directive Block.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 14
Altair PSIM Tutorial / How to Use the SPICE Module

4.3 Create PSIM Library Element from SPICE Netlist File


As mentioned in Section 3.2, the SPICE subcircuit loaded in the circuit “Buck Converter with
MOSFET SCT2280KE_sub.psimsch” has no image linked to it. Each time this subcircuit is called in
a new PSIM schematic, user must go through the all steps of adding a SPICE Subcircuit Netlist Block.
To save a SPICE subcircuit linked with an image so that it can be used in PSIM schematics the same
way as any other PSIM element, PSIM provides the “Image Library Editor”. User may either write a
new subcircuit netlist or use a pre-existing subcircuit netlist.
The detailed procedure of creating a PSIM element from a SPICE netlist file is in the document
SPICE Module User Guide.
The steps are:

• Open the example circuit “Buck Converter with MOSFET SCT2280KE_sub.psimsch” which
contains the SPICE Directive Block and the SPICE Subcircuit Netlist Block.
• Double click the SPICE Directive Block to open its parameter dialog. Click the “Save to file”
button to save the content into a file ““My SPICE Subckt,txt”, and save it in the folder
C:\PSIM_SPICE Tutorial\SPICE Subs.
• Select Edit >> Edit Library >> Edit Library >> Edit Library Files, and click the button New
Library (If you have created your own library before, and would save your new SPICE
elements in your own library, select your library, click the button Edit Selected Library, and
skip next three steps).
• Type the new library name to be displayed in PSIM’s Elements menu: “User SPICE
Elements”.
• Type the library file name: “My SPICE File”. Click OK to add this new file into the library list.
• Select this new library name “My SPICE File.lib”, then, click the button for “Edit Selected
Library”. The PSIM’s image library editor would open as shown below.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 15
Altair PSIM Tutorial / How to Use the SPICE Module

• Click the button New SPICE Element. All the models and subcircuits in the files which
already are put into the PSIM searching path would be displayed. If the user’s files are not
listed, please follow the procedure in Section “4.1 Setup Search Path” and then, come back
here.
• For our tutorial example, double click the file name “My SPICE Subckt.txt” and all the
subcircuits in this file would show.

• Double click on “Si4628DY”, and the editor for SPICE Library Element would open. In this
editor, the subcircuit’s definition, name, nodes, and parameters and their default values are
generated automatically.

• Write an optional brief description “SPICE Tutorial example MOSFET”.


• Select the MOSFET image from the image list. Please make sure the node sequence in the
image is the same as in the subcircuit definition.
• If a new image is desired, click "Edit Image" to edit this element’s image: to set the size, to
locate the nodes, to add texts, and to draw graphic designs for the image.
• It is optional to create a html formatted help file name "SPICE Tutorial MOSFET Help.html"
in the folder “Powersim\Help”, type the help file name in the space provided, and click the
button "Test Help Page" to verify the link.
• Click Save to save the element in the library, and click OK to close the SPICE element editor.
• In the Image Library editor, the new element “Si4628DY” is shown now.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 16
Altair PSIM Tutorial / How to Use the SPICE Module

• Click Save Image Library to update the library, then, click Update Menu button to update
the PSIM Elements menu for the display of this newly created element.
• Now this new PSIM element is ready to be used for in PSIM schematics for SPICE simulation.
To use this newly created PSIM element for SPICE simulation, in the example circuit “Buck -
MOSFET SI4628DY (SPSN).psimsch”

• Delete the SPICE Subcircuit Netlist Block “XSPS1” containing Si4628DY.


• Click menu “Elements >> User SPICE Elements >> Si4628DY”, place it in the proper location
in the schematic and connect the wires. If the subcircuit has parameters, remember to modify
the parameter values for the circuit if they are not the same as the default values.
• Save the file with a new name “Buck - MOSFET SI4628DY (SPICE Element).psimsch”.
• Run SPICE Simulation and the result should be the same as in section “2. Running SPICE
Simulation”.

© Altair Engineering, Inc. All Rights Reserved. / altair.com / Nasdaq: ALTR / Contact Us 17

You might also like