Essential conditions that define an edge-triggered Stateflow® block are:
The following model shows an edge-triggered Stateflow block named Callee:
The Input from Simulink event has an Either edge-trigger type. If you define more than one Input from Simulink event, the Simulink® model determines the sample times to be consistent with various rates of all the incoming signals. The outputs of a triggered Stateflow block are held after the execution of the block.
There are two ways you can define a sampled Stateflow block.
Set the chart Update method (in the Chart properties dialog box) to Discrete and enter a Sample Time value. (See Specify Chart Properties.)
Alternatively, add and define input data either in the Stateflow Editor by selecting Chart > Add Inputs & Outputs > Data Input from Simulink or in the Model Explorer. (See Share Output Data with Simulink.)
Simulink determines the chart sample time to be consistent with the rate of the incoming data signal.
The Sample Time you set in the Chart properties dialog box takes precedence over the sample time of any input data.
You specify a discrete sample rate to have Simulink trigger a Stateflow block that does use an explicit trigger port. You can specify a sample time for the chart in the Chart properties dialog box. Simulink then calls the Stateflow block at a defined, regular sample time.
The outputs of a sampled Stateflow block are held after the execution of the block.
Essential conditions that define an inherited trigger Stateflow block are:
The chart Update method (set in the Chart properties dialog box) is Discrete or Inherited. (See Specify Chart Properties)
The chart has an Input from Simulink data object defined using the Stateflow Editor Add menu or the Model Explorer. (See Share Output Data with Simulink.) Simulink determines the chart sample time to be consistent with the rate of the incoming data signal.
Simulink can trigger a Stateflow block that does not use an explicit trigger port or a specified discrete sample time. In this case, the Simulink calls the Stateflow block at a sample time determined by the model.
In this example, the chart contains two Input from Simulink data objects. Simulink determines the sample times to be consistent with the rates of both incoming signals.
The outputs of an inherited trigger Stateflow block are held after the execution of the block.
To define a continuous Stateflow block, set the chart Update method in the Chart properties dialog box to Continuous.
This topic shows you how to trigger a function-call subsystem in a Simulink model with a function-call output event in a Stateflow chart. The procedure assumes that you have a programmed function-call subsystem and a Stateflow block in the model. Use the following steps to connect the Stateflow block to the function-call subsystem and trigger it during simulation.
In your chart, select Chart > Add Inputs & Outputs > Event Output To Simulink.
The Event properties dialog box appears with a default name
event and a Scope of
Set Trigger to
Name the event appropriately and click OK to close the dialog box.
An output port with the name of the event you add appears on the right side of the Stateflow block.
Connect the output port on the Stateflow block for the function-call output event to the input trigger port of the subsystem.
Avoid placing any other blocks in the connection lines between the Stateflow block and the function-call subsystem.
You cannot connect a function-call output event from a chart to a Demux block to trigger multiple subsystems.
To execute the function-call subsystem, include an event broadcast of the function-call output event in the actions of the chart.
For examples of using function-call output events, see Activate a Simulink Block Using Function Calls.
Simulink controls the execution of edge-triggered subsystems with output events. Essential conditions that define this use of triggered output events are:
The chart has an Output to Simulink event with the trigger type set to Either. See Activate a Simulink Block Using Output Events.
The Simulink block connected to the edge-triggered Output to Simulink event has its own trigger type set to the equivalent edge trigger.
For examples of using edge-triggered output events, see Activate a Simulink Block Using Edge Triggers.