Main Content

Simscape Automation Using Command Line Interface

You can programmatically convert a Simscape™ circuit diagram to a Mixed-Signal Blockset™ block or perform linear and switched circuit analyses of the circuit. The workflow involves three steps:

  • Read the Simscape model.

  • Configure the setup to build a Mixed-Signal Blockset block or perform analysis.

  • Build the block or run the analysis.

Note

This functionality requires a license for Simscape.

Read Simscape Model

Use the ssc2cw function to read the Simscape model and create the necessary variables and statements structure.

[variables,statements] = ssc2cw("SimscapeModel");

The function creates a statement for each Simscape block and the list of variables used in the model.

Configure Setup

You can configure the setup to build a block or analyze a circuit using a circuit configuration object.

An example syntax to build a block is shown:

cktObj = msblks.Circuit.CircuitConfiguration(variables,statements, ...
    "CircuitDesignName",'designName',"BlockName",'Loop Filter', ...
    "ConfigurationName",'configurationName',"AttachConfiguration",true);

This example creates a Loop Filter block with specified properties.

An example syntax to perform a linear circuit analysis is shown:

cktObj = msblks.Circuit.CircuitConfiguration(variables,statements, ...
    "PoleZeroReport",true',...
    "TransferFunctionPlot",true);

This code example plots the transfer function and generates the pole zero report after you run the analysis.

Circuit Configuration Object Properties

PropertyDescription
CircuitDesignName

The name of the block icon if you build a Simulink® block.

BlockName

The name of the block instance in the Simulink diagram if you build a Simulink block.

NetlistFileName

The name of the SPICE netlist used to construct the circuit model.

Note

Mixed-Signal Blockset does not generate or output SPICE netlists.

ConfigurationName

The name of a specific configuration of the circuit. Typically used to name a file containing the details of the configuration.

ConfigurationNotes

Notes attached with the configuration for future reference.

PortDefinitionTable

A table containing the port definitions, with a row for each port. The table contains the names and types (voltage or current) of each port and relevant node(s).

CircuitElementTable

A table for describing the details of each circuit element, with one row per circuit element. The table consists of the name of the circuit element, its default value and its role in the circuit analysis or simulation.

NumSwitchStates

The number of switched states in the circuit.

TransitionsTable

A table containing the switch state transition rules. There is a separate row for each switch state transition rule.

DeviceNoiseTable

A table containing the device noise sources. There is a separate row for each potential device noise source.

Temperature

The average temperature of the circuit, in °C. Used primarily to set the noise level in device noise generators.

PoleZeroReport

Determine whether to generate the pole-zero report. If PoleZeroReport is set to true, after you run the analysis, the resulting circuit object contains the pole-zero report.

TransferFunctionPlot

Determine whether to plot the transfer function. If TransferFunctionPlot is set to true, after you run the analysis, the resulting circuit object contains the x- y- axes values of transfer function.

LinearControlSystem

Determine whether the output of a set of symbolic control system matrices is required as input to the construction of a tunable Control System Toolbox™ object.

OutputPort

Name of the output port used for operating point analysis, specified as a string or a character array.

OutputValues

Desired operating point(s) for operating point analysis, specified as a real valued scalar or vector.

ControlVariable

The control variable for operating point analysis, specified as Duty cycle or Frequency.

DutyCycle

The value or the range of the duty cycle for an operating point analysis, specified as a real scalar or 2-element vector.

Frequency

The value or the range of the switching frequency for an operating point analysis, specified as a real scalar or 2-element vector.

PhaseOffsets

The expression for the phase offsets of one or more control signals relative to the beginning of the switching cycle, specified as a string or character array.

PulseDuration

The expression of the duration of one or more control signals in an operating point analysis, specified as a string or character array.

WaveSamples

The number of uniformly spaced samples to output for each waveform table generated by an operating point analysis. Each waveform table spans a single switching cycle at steady state for a specified average output value, and includes all of the voltages and currents in the circuit.

AttachConfiguration

Determine whether to attach the name of a configuration file used to construct the Linear Circuit or Switched Circuit block.

LinearAnalysisResults

Location to store the results of linear analysis.

SwitchedAnalysisResults

Location to store the results of switched circuit analysis.

mdlwks

The model workspace for the analysis, based on the structure of the model workspace for the Linear Circuit Wizard block.

Build Block

Once you have configured the setup as described in Configure Setup, use the circuitWizard to build the block and place it in a Simulink model.

cktObj = circuitWizard(cktObj,"build","SimulinkModelName")

You can then run the Simulink model for further investigation.

Analyze Circuit

Alternately, after configuring the analysis setup according to Configure Setup, you can run the analysis using the circuitWizard object.

cktObj = circuitWizard(cktObj,"analyze")

The object stores the analysis results inside the LinearAnalysisResults and LinearAnalysisResults variables inside the circuit object.

See Also

| |

Topics