Modeling Electronic Components

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:

This section contains the following topics:

Supported SPICE Netlists

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:

The following table lists the device models you can import into SimElectronics.

Device TypeSPICE Device Model(s)
DC SourceDC
Exponential SourceEXP
Voltage- and Current-Controlled Sources with one controlling voltage or currentE, F, G, H
Sinusoidal SourceSIN
Piecewise Linear SourcePWL
Pulse SourcePULSE
Single-Frequency FMSFFM
ResistorR
CapacitorC
InductorL
DiodeD
Bipolar TransistorNPN, PNP
JFETNJF, 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.

How to Import SPICE Models

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.

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.

Adding SimElectronics™ Blocks to a Model

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:

Required Blocks

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.

How to Add SimElectronics™ Blocks to a Model

To add SimElectronics blocks to a Simulink model:

  1. Type elec_lib at the MATLAB® prompt to open the SimElectronics library.

  2. Navigate to the desired library or sublibrary.

  3. Drag instances of SimElectronics blocks into the model window using the mouse.

Connecting Model Blocks

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.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS