Stateflow User's Guide Previous page   Next Page

Adding a Trigger Event to the Stateflow Diagram

A Stateflow diagram updates (executes) only in response to an event that it receives from Simulink. In Drawing Transitions in a Stateflow Diagram you provide transitions for the On and Off states to alternately become active and inactive during execution of the Controller Stateflow diagram. Now you need to provide events to Stateflow to update the Stateflow diagram and power its transitions.

In this topic, you define trigger events for the example Stateflow diagram. There are other ways to send events that update Stateflow diagrams. For example, you can tell the Stateflow diagram to execute every time Simulink samples the model. However, trigger events give you the greatest individual control over individual events sent to a Stateflow diagram, and that makes them the best events for studying Stateflow behavior.

Use the following steps to define a trigger event for updating the Controller diagram:

  1. In the Stateflow diagram editor, from the Add menu, select Event.
  2. In the resulting submenu, select Input from Simulink.
  1. The property dialog for the new event appears.

    By default, the name of the event is set to event in the Name field of the Event properties dialog.

  1. Select Either as the Trigger type.
  2. Click OK to apply the changes and close the Event properties dialog.

The Stateflow block in Simulink now has a trigger port for the event event as shown.


Previous page  Drawing Transitions in a Stateflow Diagram Sending a Trigger Event to the Stateflow Chart Next page

© 1994-2005 The MathWorks, Inc.