Using Triggered Subsystems
A triggered subsystem is a conditionally executed atomic subsystem that runs each time the control signal (trigger signal):
Either rises from a negative value to a positive value or zero, or rises from a zero value to a positive value.
Either falls from a positive value to a negative value or zero, or falls from a zero value to a negative value.
Rises or falls through or to a zero value.
Unlike an Enabled Subsystem block, a Triggered Subsystem block always holds its outputs at the last value between triggers. Also, triggered subsystems cannot reset block states when executed; the states of any discrete block are held between triggers.
Create a Triggered Subsystem
To create a triggered subsystem:
Add a Triggered Subsystem block to your model.
Copy a block from the Simulink® Ports & Subsystems library to your model.
Click the model diagram, start typing
trigger
, and then select Triggered Subsystem.
Set initial and disabled values for the Outport blocks. See Conditional Subsystem Initial Output Values and Conditional Subsystem Output Values When Disabled.
Set how the control signal triggers execution.
Open the subsystem block, and then open the parameter dialog box for the Trigger port block. From the Trigger type drop-down list, select:
rising
— Trigger execution of the subsystem when the control signal rises from a negative or zero value to a positive value, or from a negative value to a zero value.falling
— Trigger execution of the subsystem when the control signal falls from a positive or zero value to a negative value, or from a positive value to a zero value.either
— Trigger execution of the subsystem with either a rising or falling control signal.
Different symbols appear on the Trigger and Subsystem blocks to indicate rising and falling triggers.
Output the enable control signal from the Trigger port block. Open the Trigger port block. Select the Show output port check box to pass the control signal into the triggered subsystem.
You can use this signal with an algorithm that depends on the value of the control signal.
From the Output data type drop-down list, select
auto
,int8
, ordouble
.The
auto
option causes the data type of the output signal to be the data type (eitherint8
ordouble
) of the block port connected to the signal.
Triggering with Discrete Time Systems
For a discrete time system, a trigger occurs when the control signal has more than one time step difference between two rises or two falls in the signal value.
Two rises in the signal value occurs when the control signal rises from negative to zero followed by a rise in the signal value from zero to positive.
Two falls in the signal value occurs when the control signal falls from positive to zero followed by a fall in the signal value from zero to negative.
Consider the following for rising signal values:
At t = 1 s, the signal value rises from -1 to 0 and at t = 2 s the signal value rises from 0 to 1. The subsystem triggers only at t = 1 s and does not trigger at t = 2 s because the two rising signal values are not separated by more than one time step.
At t = 4 s, the signal value rises from 0 to 1, and the subsystem is triggered because more than two time steps separate the rising signal value at t = 4 s and the previous rising signal value at t = 2 s.
Similarly, for falling signal values, in the following diagram:
At t = 1 s, the signal value falls from 1 to 0 and at t = 2 s, the signal value falls from 0 to -1. The subsystem triggers only at t = 1 s and does not trigger at t = 2 s because the two falling signal values are not separated by more than one time step.
At t = 4 s, the signal value falls from 0 to -1, and the subsystem is triggered because more than two time steps separate the falling signal value at t = 4 s and the previous falling signal value at t = 2 s.
Triggered Model Versus a Triggered Subsystem
You can place a Trigger port block in a Model block (referenced model) to simplify your model design instead of using one of these blocks:
A Triggered Subsystem block in a Model block.
A Model block in a Triggered Subsystem block.
For information about using Trigger port blocks in referenced models, see Conditionally Execute Referenced Models.
To convert a subsystem to use model referencing, see Convert Subsystems to Referenced Models.
Blocks in a Triggered Subsystem
All blocks in a triggered subsystem must have Sample time set to
inherited (-1
) or constant (inf
). This requirement
allows the blocks in a triggered subsystem to run only when the triggered subsystem itself
runs. This requirement also means that a triggered subsystem cannot contain continuous
blocks, such as an Integrator block.
Model Examples
For model examples, see:
See Also
Enabled Subsystem | Triggered Subsystem | Enabled and Triggered Subsystem | Function-Call Subsystem