Main Content

Monitor Test Points in Stateflow Charts

This example shows how to specify data or states as test points that you can plot using a Floating Scope and Scope Viewer (Simulink) block during simulation. You can designate states or data with these properties as test points:

  • Scope — Output or local

  • Size — Scalar, one-dimensional, or two-dimensional

  • Type — Any data type except ml

  • Location — Descendant of a Stateflow chart

For more information about using test points in Simulink®, see Configure Signals as Test Points (Simulink).

Alternatively, you can log values for local, output, and active state data and view this logged output by using the Simulation Data Inspector or the Logic Analyzer. For more information, see Log Simulation Output for States and Data.

Set Test Points for Stateflow States and Data with the Property Inspector

You can specify individual data or states as test points by setting their Test Point property as described in Specify Properties for States or Set Data Properties.

1. Open the model.

In the Stateflow chart, state A and its substate X become active on the first tic event. After 10 tic events, state B becomes active. On the next event, state A and substate X become active again and the cycle repeats.

The substate X is the parent of the local data data. Initially, data is equal to zero. While X is active, the entry and during actions increment data. After 10 tic events, when state B becomes active, data maintains a value of 10. Then, when state A and substate X become active again, the value of X reinitializes to zero and the cycle repeats.

2. Open the Property Inspector. In the Modeling tab, select Property Inspector.

3. Select state A. In the Logging section of the Property Inspector, select Test Point.

4. Repeat step 3 for state X and B.

5. Open the Symbols pane. In the Modeling tab, select Symbols Pane.

6. In the Symbols pane, under states A and X, select the local data data. Then, in the Logging section of the Property Inspector, select Test Point.

Monitor Data Values and State Self Activity Using a Floating Scope

1. In the Simulink model, open the Floating Scope block and select Simulation > Signal Selector.

2. Open the Stateflow chart.

3. Open the Signal Selector by clicking and dragging a box around the chart.

4. In the Signal Selector, select the state or data to connect to the Floating Scope block. In this example, the states A, B, and A.X and the local data data are already selected in the Signal Selector.

5. Click the X button in the upper-right corner of the canvas.

6. Simulate the model.

See Also

(Simulink)

Related Topics