| Stateflow User's Guide |
 |
Defining Input Events
An input event occurs outside a chart and is visible only in that chart. This type of event allows other Simulink blocks, including other Stateflow blocks, to notify a particular chart of events that occur outside it. To define an event as an input event, set its Scope property to Input from Simulink.
The following steps describe how to add an input event to a chart in the Model Explorer:
- Add an event to the Stateflow chart.
- You must add an input event to the chart and not to one of its objects. Adding events with the Stateflow diagram editor adds them to the chart open in the diagram editor. In the Model Explorer, you can add an event to any object. This means that you must select a chart object in the left Model Hierarchy pane before adding an input event. See Adding Events for a complete description of both ways to add an event.
- Set the Scope property for the event to Input (short for Input from Simulink).
- A single trigger port is added to the top of the Stateflow block.
- If you want a Simulink block to trigger the Stateflow block through this input event, do one of the following:
- To trigger the Stateflow block through a change in control signal, set the Trigger property to one of the following edge triggers:
Trigger Type
|
Description
|
Rising Edge
|
Rising edge trigger, where the control signal changes from either 0 or a negative value to a positive value.
|
Falling Edge
|
Falling edge trigger, where the control signal changes from either 0 or a positive value to a negative value.
|
Either Edge
|
Either rising or falling edge trigger.
|
-
In all cases, the signal must cross 0 to constitute a valid edge trigger. For example, a change from -1 to 1 constitutes a valid rising edge, but a change from 1 to 2 does not.
An edge trigger triggers execution of a subsystem at the beginning of the next simulation time step, regardless of when triggering actually occurred during the previous time step. If it is not critical that the subsystem be executed immediately, you can define the events as edge-triggered.
- To trigger the Stateflow block through a Simulink block that outputs function-call events, set the Trigger property to Function Call.
If you choose to add an event in the Model Explorer, you can change its Name, Scope, Trigger and Port properties directly in the Model Explorer. See Setting Properties for Stateflow Objects in the Model Explorer for a description.
| Sharing Events with Simulink | | Associating Input Events with Control Signals |  |
© 1994-2005 The MathWorks, Inc.