Stateflow | ![]() ![]() |
Defining Function Call Output Events
Use a function call output event from a Stateflow block to trigger the execution of a connected Simulink subsystem with the following procedure:
You should avoid placing any other blocks in the connection lines between the two blocks for Stateflow blocks that have feedback loops from a block triggered by a function call.
Note You cannot connect a function-call output event from Stateflow to a Simulink Demux block in order to trigger multiple subsystems. |
Function Call Output Events Example
The following example demonstrates how Stateflow uses function call output events to call Simulink subsystems:
The control Stateflow block has one data input called pulse
and two event Function Call
outputs called filter1
and filter2
. A pulse generator provides input data to the control block. Each function call output event is attached to a subsystem in the Simulink model that is set to trigger by a function call.
Each transition in the control chart has a condition based on the size of the input pulse. When taken, each transition broadcasts a function call output event that determines whether to make a function call to filter1 or filter2
. If the Output to Simulink function call event filter1
is broadcast, the band pass filter1
subsystem executes. If the Output to Simulink function call event filter2
is broadcast, the band pass filter2
subsystem executes. When either of these subsystems is finished executing, control is returned to the control Stateflow block for the next execution step. In this way, the Stateflow block control controls the execution of band
pass
filter1
and band
pass
filter2
.
Function Call Semantics Example
In this example the transition from state A
to state B
(in the Stateflow diagram) has a transition action that specifies the broadcast of event1
. event1
is defined in Stateflow to be an Output to Simulink with a Function Call trigger type. The Stateflow block output port for event1
is connected to the trigger port of the band
pass
filter1
Simulink block. The band
pass
filter1
block has its Trigger type field set to Function Call.
This sequence is followed when state A
is active and the transition from state A
to state B
is valid and is taken:
A
exit actions execute and complete.
A
is marked inactive.
event1
. Because event1
is an event output to Simulink with a function call trigger, the band
pass
filter1
block executes and completes, and then returns to the next statement in the execution sequence. The value of y
is fed back to the Stateflow diagram.
B
is marked active.
B
entry actions execute and complete (x = x + y
). The value of y
is the updated value from the band pass filter1
block.
![]() | Defining a Continuous Stateflow Block | Defining Edge-Triggered Output Events | ![]() |