Instrument a Stateflow Subsystem

A Simulink® Real-Time™ model that uses Stateflow® blocks can present special circumstances. For example, if the model implements a control algorithm as a Stateflow subsystem, the Stateflow signals are not visible to Simulink Real-Time by default.

This procedure uses the model ex_slrt_sf_car (open_system(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples', 'ex_slrt_sf_car')))).

Configure Stateflow States as Test Points

To make Stateflow signals visible to Simulink Real-Time, mark them as test points:

  1. Open the ex_slrt_sf_car model.

  2. Double-click the shift_logic chart.

  3. In the Modeling tab, click Model Explorer.

  4. In the Model Explorer, expand ex_slrt_sf_car, then expand shift_logic.

  5. Expand gear_state, and then select first.

  6. To create a test point for the first state, in the State first pane Logging tab, select the Test point check box.

  7. Click Apply.

  8. Repeat steps 8–10 for gear_state values second, third, and fourth.

  9. Build and download the real-time application to the target computer. On the Real-Time tab, click Run on Target.

Monitor Stateflow States with Simulink Real-Time Explorer

  1. Open Simulink Real-Time Explorer. On the Real-Time tab, click Prepare > SLRT Explorer.

  2. Connect to the target computer in the Targets pane ( on the toolbar).

  3. In the Applications pane, expand the real-time application and the Model Hierarchy node.

  4. To view the test point, select shift_logic and click the View Signals button  on the toolbar.

  5. In the Signals workspace, select the Monitor check box for gear_state.first, gear_state.second, gear_state.third, and gear_state.fourth. The values of the signals are shown in the Monitoring Value column.

  6. To start execution, click the real-time application. On the toolbar, click the Start button .

  7. To stop execution, click the real-time application. On the toolbar, click the Stop button .

Related Topics