Subsystem

Purpose

Create functional entity in hierarchical simulation model

Library

System

Description

../../_images/subsystem.svg

A subsystem block represents a system within another system. In order to create a subsystem, copy the subsystem block from the library into your schematic. You can then open the subsystem block and copy components into the subsystem’s window.

The input, output, and physical terminals on the block icon correspond to the input, output, and physical port blocks in the subsystem’s schematic. If the block names are not hidden, they appear as terminal labels on the subsystem block.

A terminal can be moved around the edges of the subsystem by dragging it with the middle mouse button. Alternatively, use the left mouse button while holding the Shift key.

Note

A subsystem can be converted to a configurable subsystem (see the Configurable Subsystem block) by selecting Convert to configurable subsystem from the Edit > Subsystem menu or the block’s context menu.

Example Model

  • The example model “Enabled Subsystem” features enabled subsystems.

  • Find it in PLECS under Help > PLECS Documentation > List of Example Models.

Example Model

  • The example model “Triggered Subsystem” features triggered subsystems.

  • Find it in PLECS under Help > PLECS Documentation > List of Example Models.

Virtual and Atomic Subsystems

By default, PLECS treats subsystems as virtual, which means that they only represent a graphical grouping of the components that they comprise. At simulation start, virtual subsystems are flattened and the components they comprise are ordered individually when PLECS determines their proper execution order (see Block Sorting).

In an atomic subsystem, on the other hand, the components are not only grouped graphically but they are also executed as a group. This is necessary if the execution depends on a condition such as a common sample time or an enable and/or a trigger signal (see the Enable block and the Trigger block).

Whether a subsystem is virtual or atomic is controlled by the subsystem execution settings.

Note

A subsystem that has physical terminals cannot be made atomic.

Execution Settings

To open the dialog for editing the subsystem settings, select the block, then choose Execution settings… from the Edit > Subsystem menu or the block’s context menu.

Treat as atomic unit

If this parameter is checked, PLECS treats the subsystem as atomic, otherwise as virtual (see Virtual and Atomic Subsystems).

Minimize occurrence of algebraic loops

This parameter only applies to atomic subsystems. If it is unchecked, PLECS assumes that all inputs of the subsystem have direct feedthrough, i.e. the output functions of the blocks feeding these inputs must be executed before the output function of the subsystem itself can be executed (see Block Sorting). If the atomic subsystem is part of a feedback loop, this can result in algebraic loop errors where a virtual subsystem could be used without problems.

If the parameter is checked, PLECS determines the actual feedthrough behavior of the individual inputs from the internal connectivity. A subsystem input that is internally only connected to non-direct feedthrough inputs of other blocks (e.g. the inputs of Integrator, Memory or Delay blocks) does not have direct feedthrough. This can help reduce the occurrence of algebraic loops.

Sample time

A scalar specifying the sampling period or a two-element vector specifying the sampling period and offset, in seconds \((\mathrm{s})\). This parameter is enabled only if the subsystem is atomic and specifies the sample time with which the subsystem and the components that it comprises are executed. A setting of auto (which is the default) causes the subsystem to choose its sample time based on the components that it comprises. See also section Sample Times.

Enable code generation

Checking this option causes the subsystem to be added to the list of systems in the Coder Options dialog (see Generating Code). Note that it is not possible to enable code generation for a subsystem that is contained by or that itself contains other subsystems that enable code generation. Checking this option also implicitly makes the subsystem atomic and disables the minimization of algebraic loops.

Discretization step size

This parameter is enabled only if code generation is enabled. It specifies the base sample time for the generated code, in seconds \((\mathrm{s})\), and is used to discretize the physical model equations (see Physical Model Discretization) and continuous state variables of control blocks.

Simulation mode

This parameter is enabled only if code generation is enabled. When this parameter is set to Normal, which is the default, the subsystem is simulated like a normal atomic subsystem. When the parameter is set to CodeGen, the generated code is compiled and linked to PLECS to be executed instead of the subsystem during a simulation.

In connection with the “Traces” feature of the scopes (see Adding Traces), this allows you to easily verify the fidelity of the generated code against a normal simulation.

Parameters

You can create a dialog box for your Subsystem by masking the block (see Mask Dialog for more details).