|On this page…|
A third kind of conditional subsystem combines two types of conditional execution. The behavior of this type of subsystem, called a triggered and enabled subsystem, is a combination of the enabled subsystem and the triggered subsystem, as shown by this flow diagram.
A triggered and enabled subsystem contains both an enable input port and a trigger input port. When the trigger event occurs, the enable input port is checked to evaluate the enable control signal. If its value is greater than zero, the subsystem is executed. If both inputs are vectors, the subsystem executes if at least one element of each vector is nonzero.
The subsystem executes once at the time step at which the trigger event occurs.
You create a triggered and enabled subsystem by dragging both the Enable and Trigger blocks from the Ports & Subsystems library into an existing subsystem. The Simulink® software adds enable and trigger symbols and enable and trigger control inputs to the Subsystem block.
You can set output values when a triggered and enabled subsystem is disabled as you would for an enabled subsystem. For more information, see Setting Output Values While the Subsystem Is Disabled. Also, you can specify what the values of the states are when the subsystem is reenabled. See Setting States When the Subsystem Becomes Enabled.
Set the parameters for the Enable and Trigger blocks separately. The procedures are the same as those described for the individual blocks.
A simple example of a triggered and enabled subsystem is illustrated in the following model.
You can use conditional subsystems in combination with Merge blocks to create sets of subsystems that execute alternately, depending on the current state of the model.
The following figure shows a model that uses two enabled blocks and a Merge block to model a full-wave rectifier – a device that converts AC current to pulsating DC current.
The block labeled pos is enabled when the AC waveform is positive; it passes the waveform unchanged to its output. The block labeled neg is enabled when the waveform is negative; it inverts the waveform. The Merge block passes the output of the currently enabled block to the Mux block, which passes the output, along with the original waveform, to the Scope block.
The Scope creates the following display.