Stateflow Previous page   Next Page

Define Input Events

Before you can simulate the Stateflow diagram that you finished in Create a Stateflow Diagram, you must define the events on_switch and off_switch that trigger the transitions between On state and Off state. These event triggers are pointed out in the finished diagram:

Events control the execution of your Stateflow diagram. For example, if the state On is active and the on_switch event occurs, the transition from the On state to the Off state takes place and the Off state becomes active.

To define these input events for your Stateflow diagram, do the following:

  1. Select Event from the Add menu of the diagram editor.
  2. In the resulting submenu, select Input from Simulink.

  1. The property dialog for the new event appears.

  1. Enter on_switch in the Name field of the Event properties dialog box.
  2. Select Rising Edge as the Trigger type.

  1. Leave all other fields with their default values.

  1. Select OK to apply the changes and close the window.
  2. Repeat steps 1 through 5 to define the event off_switch except enter Falling Edge as the Trigger type in step 4.

Now that you have defined the on_switch and off_switch events for your Stateflow diagram, take a look at the Stateflow block in the Simulink model.

The Stateflow block now has an input port for the events that you defined. Even though you have defined these events, you must now provide a source for these events in Simulink which you will do in Define the Stateflow Interface.


Previous page  Create a Stateflow Diagram Define Input Data Next page

 © 1994-2009 The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS