Animate Stateflow Charts with Simulink External Mode

The Simulink® Real-Time™ software supports the animation of Stateflow® charts in your model to provide visual confirmation that your chart behaves as expected.

You must be familiar with the use of Stateflow animation. For more information on Stateflow animation, see Animate Stateflow Charts (Stateflow).

You must have already set Stateflow states as test points in model ex_slrt_sf_car (open_system(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples', 'ex_slrt_sf_car')))). If you have not, see Configure Stateflow States as Test Points.

  1. Open the external mode control panel. In the Simulink Editor, in the Real-Time tab, click Prepare > Control Panel.

  2. Select Signal & Triggering.

  3. In the Trigger section of the External Signal & Triggering window:

    • To direct the trigger to re-arm after the trigger event completes, set Mode to normal.

    • To select the number of base rate steps for which external mode uploads data after a trigger event, in the Duration box, enter 5.

    • To direct data upload to begin immediately after the trigger event, select the Arm when connecting to target check box.

  4. Click Apply. For more information about signal and triggering options, see Configure Host Monitoring of Target Application Signal Data (Simulink Coder).

  5. Open Configuration Parameters. On the Real-Time tab, click Hardware Settings.

  6. Select Simulink Real-Time Options > Miscellaneous options > Enable Stateflow animation.

  7. Click Apply.

  8. Verify that Stateflow animation is enabled for Simulink Real-Time. In the MATLAB Command Window, type:

    get_param('ex_slrt_sf_car','xPCEnableSFAnimation')
    ans =
    
        'on'
  9. Connect to the target computer. On the Real-Time tab, toggle the Disconnected indicator to Connected.

  10. Build and download the model to the target computer. On the Real-Time tab, click Run on Target.

    The simulation begins to run. You can observe the animation by opening the Stateflow Editor for your model.

  11. To stop the simulation, on the Real-Time tab, click Stop.

Note

Enabling the animation of Stateflow charts also displays additional Stateflow information. The Stateflow software requires this information to animate charts. You can disregard this information.

Related Topics