This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

subcircuit2ssc

Convert SPICE subcircuit to custom Simscape components

Syntax

subcircuit2ssc(filename,target)
subcircuit2ssc(__,subcircuit1,...,subcircuitN)
subcircuitArray = subcircuit2ssc(__)
[subcircuitArray,unsupportedCommands] = subcircuit2ssc(__)

Description

example

subcircuit2ssc(filename,target) reads the SPICE netlist specified by filename and converts every subcircuit into one or more Simscape™ files in the folder specified by target.

The function lists SPICE commands not supported by the conversion process in the comments of the corresponding Simscape files. After conversion, review the generated Simscape files and make manual edits for any unsupported items. You can also obtain a list of unsupported commands by using an optional output argument, described below.

For a detailed explanation of supported conversions, see Converting a SPICE Netlist to Simscape Blocks.

subcircuit2ssc(__,subcircuit1,...,subcircuitN) converts only the subcircuits with the specified names.

subcircuitArray = subcircuit2ssc(__) returns an array of objects containing the subcircuit information.

[subcircuitArray,unsupportedCommands] = subcircuit2ssc(__) returns an array of objects containing the subcircuit information and a struct array containing the subcircuit names and SPICE commands found in the converted subcircuits that are not supported by the conversion process.

Examples

collapse all

Create a SPICE netlist named rcsubcircuit.cir that contains a simple RC subcircuit.

RCSUBCIRCUIT.CIR - RC SUBCIRCUIT
*
.SUBCKT RC1      1
*
R1	1	2	1k
C1	2	0	0.32mF
*
.ENDS
*
.END

Convert all SPICE subcircuits in rcsubcircuit.cir to equivalent Simscape files and place them in a package directory called mylibrary.

subcircuit2ssc('rcsubcircuit.cir','+mylibrary');
Netlist converted. Review files and make manual edits for any
unsupported items before building the Simscape library located
at: +mylibrary.

Check the comments at the beginning of the generated component file rc1.ssc in the mylibrary package to verify that no manual conversion is required.

Generate the Simscape library using ssc_build.

ssc_build mylibrary;
Generating Simulink library 'mylibrary_lib' in the current directory

Open the generated library mylibrary_lib.slx to access the RC component as a Simscape block.

Create a SPICE netlist named mutualinductor.cir that contains a simple mutual inductor.

MUTUALINDUCTOR.CIR - MUTUAL INDUCTOR SUBCIRCUIT
*
.SUBCKT MutualInductor      p1 n1 p2 n2
*
L1 p1 n1 1u
L2 p2 n2 5u
K1 L1 L2 0.6
*
.ENDS
*
.END

Convert all SPICE subcircuits in mutualinductor.cir to equivalent Simscape files and place them in a package directory called mylibrary.

subcircuit2ssc('mutualinductor.cir','+mylibrary');
Netlist converted. Review files and make manual edits for any
unsupported items before building the Simscape library located
at: +mylibrary.

Check the comments at the beginning of the generated component file mutualinductor.ssc in the mylibrary package to identify required manual conversions.

The comments suggest that the mutual inductance K1 must be manually converted.

In the components section of the component file, replace the two inductors with a mutual inductor:

components(ExternalAccess=observe)
    M = foundation.electrical.elements.mutual_inductor(...
        L1={(1*1e-06),'H'},...
        L2={(5*1e-06),'H'},...
        k={0.6, '1'});
end

In the connections section of the component file, replace the connections to the two inductor nodes with connections to the mutual inductor nodes:

connections
    connect(M.p1,p1);
    connect(M.n1,n1);
    connect(M.p2,p2);
    connect(M.n2,n2);
end

Generate the Simscape library using ssc_build.

ssc_build mylibrary;
Generating Simulink library 'mylibrary_lib' in the current directory

Open the generated library mylibrary_lib.slx to access the mutual inductor component as a Simscape block.

Input Arguments

collapse all

Name of the SPICE network file to read. This file must be on the path.

Example: 'SpiceSubcircuits.cir'

Data Types: char | string

Name of the folder where the Simscape language files are generated. To allow the building of custom block libraries, specify a package directory with the '+' precursor. If the specified folder does not exist, the function creates it in the current folder.

Example: '+SimscapeSubcircuits'

Data Types: char | string

Names of the SPICE subcircuits to convert to Simscape language files.

Example: 'Subcircuit1','Subcircuit2'

Data Types: char | string

Output Arguments

collapse all

Array of objects containing the subcircuit information.

A struct array containing the subcircuit names and SPICE commands found in the converted subcircuits that are not supported by the conversion process.

Limitations

  • The netlist must be written in Cadence® PSpice format and be syntactically correct. The conversion assistant does not check for proper PSpice syntax.

  • Only a subset of the PSpice netlist language is supported. However, unsupported PSpice commands are identified at the top of the corresponding Simscape component file to facilitate manual conversion.

  • To build generated Simscape components into Simscape blocks, parameter values must conform to Simscape constraints. For example, capacitance of a fundamental capacitor and inductance of a fundamental inductor must be nonzero.

Introduced in R2018b