| SimElectronics™ | ![]() |
| On this page… |
|---|
Importing SPICE Models Into a SimElectronics™ Library |
You can import circuit data from a SPICE netlist into a SimElectronics™ library. This lets you simulate SPICE circuits that describe the following types of devices within the Simulink® environment:
Resistors, capacitors, and inductors
Voltage and current sources
Diodes
Bipolar transistors
JFETs
This section contains the following topics:
You can only import SPICE netlist files that define one or more SPICE subcircuits or model cards. The subcircuits can contain other subcircuits and model cards.
SimElectronics software lets you import:
All subcircuit data in the netlist file. SimElectronics maps the SPICE netlist to a library that contains one or more blocks, with one block representing each subcircuit in the file.
When you import subcircuit data from a SPICE netlist, SimElectronics creates a black-box model of the circuit, that is, SimElectronics creates a block that represents the netlist, but you cannot look at the underlying circuit in the Simulink environment.
Only the model card data in the netlist file. SimElectronics maps the SPICE netlist to a library that contains one or more blocks, with one block representing each model card in the file.
When you import model card data from a SPICE netlist, SimElectronics uses the data to populate the parameter values of the corresponding SPICE-compatible SimElectronics block. You can verify the imported values by opening the block.
Note SimElectronics cannot model large circuits with dozens of analog components. If you try to simulate a model with more than a few tens of components, you may encounter numerical simulation problems. |
The following table lists the device models you can import into SimElectronics.
| Device Type | SPICE Device Model(s) |
|---|---|
| DC Source | DC |
| Exponential Source | EXP |
| Voltage- and Current-Controlled Sources with one controlling voltage or current | E, F, G, H |
| Sinusoidal Source | SIN |
| Piecewise Linear Source | PWL |
| Pulse Source | PULSE |
| Single-Frequency FM | SFFM |
| Resistor | R |
| Capacitor | C |
| Inductor | L |
| Diode | D |
| Bipolar Transistor | NPN, PNP |
| JFET | NJF, PJF |
When you import circuit data from a SPICE netlist, SimElectronics ignores parameters that pertain to AC analysis because the software only simulates the resulting blocks in the time domain.
SimElectronics does not support SPICE noise parameters.
Use the netlist2sl function to import information from a SPICE netlist into Simulink. This function maps the SPICE netlist to a SimElectronics library that contains one or more blocks.
The following command illustrates how to create a library called libraryname from the subcircuit in the netlist file filename. The library contains a block whose name matches the name of the subcircuit and has the same inputs and outputs.
netlist2sl(filename, libraryname)
The netlist2sl reference page describes the function arguments in detail and also explains how to use the function to import only the model card information from the netlist into a Simulink library.
Note If the library already exists in the specified directory, netlist2sl adds new blocks to this library. If a subcircuit name conflicts with an existing block name in the library, netlist2sl prompts you to either overwrite the existing block or rename the new block. |
For an example of importing a SPICE model into a custom library, see either Example — Modeling a Triangle Wave Generator or the SimElectronics demo, Creating Custom Library Blocks from Circuit Netlist.
You can include blocks from the SimElectronics library in a Simulink model. For more information on the library and the SimElectronics blocks, see SimElectronics™ Block Libraries.
This section contains the following topics:
Each topologically distinct physical network in a diagram requires exactly one Solver Configuration block, found in the Simscape™ Utilities library. The Solver Configuration block specifies global environment information for simulation and provides parameters for the solver that your model needs before you can begin simulation. For more information, see the Solver Configuration block reference page.
Each electrical network requires an Electrical Reference block. This block establishes the electrical ground for the circuit. Networks with electromechanical blocks also require a Mechanical Rotational Reference block. For more information about using reference blocks, see Grounding Rules in the Simscape documentation.
To add SimElectronics blocks to a Simulink model:
Type elec_lib at the MATLAB® prompt to open the SimElectronics library.
Navigate to the desired library or sublibrary.
Drag instances of SimElectronics blocks into the model window using the mouse.
Note You can also access SimElectronics blocks and other Simulink blocks from the Simulink Library Browser window. Type simulink at the MATLAB prompt to open this window. Add blocks to the model by dragging them from this window and dropping them into the model window. |
You follow the same procedure for connecting SimElectronics blocks as for connecting Simulink blocks: click a port and drag the mouse to draw a line to another port on a different block. For more information on connecting blocks, see Connecting Blocks in the Model Window in the Simulink documentation.
You can only connect blocks that use the same type of signal. SimElectronics blocks use the same physical signals that Simscape blocks use. These signals are different than Simulink signals, and are represented graphically by a different port style. Therefore, you can freely connect pairs of SimElectronics blocks and other Simscape blocks.
However, you cannot directly connect SimElectronics blocks to Simulink blocks. Instead, you must use the Simscape PS-Simulink Converter and Simulink-PS Converter blocks to bridge them.
The following topics in the Simscape documentation explain how physical ports work and how to bridge physical blocks and Simulink blocks.
![]() | Modeling an Electronic System | Specifying Parameters that Affect All SPICE-Compatible Blocks | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |