Stateflow User's Guide Previous page   Next Page

Simulating a Bound Function-Call Subsystem

To see the control that a state can have over the function-call subsystem whose trigger event it binds, begin simulating the example model in Binding a Function-Call Subsystem. For the purposes of display, the simulation parameters for this model specify a fixed-step solver with a fixed-step size of 1. Take note of model behavior in the following steps, which record the simulating Stateflow diagram and the output of the subsystem.

  1. The default transition to state A is taken.
  2. State A becomes active as shown.

  1. When state A becomes active, it executes its bind and entry actions. The binding action, bind:E, binds event E to state A. This enables the function-call subsystem and resets its state variables to 0.

    State A also executes its entry action, en:E, which sends an event E to trigger the function-call subsystem and execute its block diagram. The block diagram increments a count by 1 each time using a Unit Delay block. Since the previous content of the Unit Delay block is 0 after the reset, the starting output point is 0 and the current value of 1 is held for the next call to the subsystem.

  1. The next update event from Simulink tests state A for an outgoing transition.
  1. The temporal operation on the transition to state B, after(10, tick), allows the transition to be taken only after ten update events are received. This means that for the second update, the during action of state A, du:E, is executed, which sends an event to trigger the function-call subsystem. The held content of the Unit Delay block, 1, is output to the scope as shown.

    The subsystem also adds 1 to the held value to produce the value 2, which is held by the Unit Delay block for the next triggered execution.

  1. The next eight update events repeat step 2, which increment the subsystem output by 1 each time as shown.

  2. On the 11th update event, the transition to state B is taken as shown.

  1. This makes state B active. Since the binding state A is no longer active, the function-call subsystem is disabled, and its output drops to 0.

  1. When the next sampling event occurs, the transition from state B to state A is taken.
  1. Once again, the binding action, bind: E, enables the subset and resets its output to 0 as shown.

  1. With the next 10 update events, steps 2 through 5 repeat, producing the following output:


Previous page  Binding a Function-Call Subsystem Using Stateflow Logic with Binding Next page

© 1994-2005 The MathWorks, Inc.