Tune Parameters with Simulink Real-Time Explorer

You can use Simulink® Real-Time™ Explorer to change parameters in your real-time application while it is running or between runs. You do not need to rebuild the Simulink model, set the Simulink interface to external mode, or connect the Simulink interface with the real-time application.

This procedure uses the model xpcosc.

Set Up Host Scope

Before tuning parameters, do the following:

  1. Open model xpcosc. Set property Stop time to inf. On the Real-Time tab, select Run on Target > Stop Time and set Stop Time to inf.

  2. Connect to the target computer. On the Real-Time tab, toggle the Disconnected indicator to Connected.

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

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

  5. In the Scopes pane, expand the xpcosc node.

  6. To add a host scope, select Host Scopes, and then click the Add Scope button  on the toolbar.

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

  8. Double-click the xpcosc node.

  9. To add signal Signal Generator to Scope1, drag signal Signal Generator from the xpcosc signal list to the Scope1 properties workspace.

    Add signal Integrator1 to Scope1 in the same way.

  10. Expand Scope 1, and then click the Properties button  on the toolbar.

    To display the host scope signals, in the Scope Properties pane, click Signals.

  11. To open the host scope display, select Scope 1, and then click the View Scope button  on the toolbar.

See Create Host Scopes with Simulink Real-Time Explorer.

Initial Values

  1. To view the initial parameter values, in the Applications pane, expand both the real-time application node and node Model Hierarchy.

  2. Select the model node, and then click the View Parameters button  on the toolbar.

  3. Start Scope 1( on the toolbar).

  4. Start execution ( on the toolbar).

Updated Values

To update a parameter value:

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

  2. Select the model node, and then click the View Parameters button  on the toolbar.

    The Parameters workspace opens, showing a table of parameters with properties and actions.

  3. To change the value of the Gain for block Gain1 to 100, type 100 into the Value box, and then press Enter.

    To revert the Gain for block Gain1 to its previous value, click the Revert button .

  4. Click the Apply parameter value(s) changes button .

    Simulink Real-Time Explorer looks like this figure.

  5. Stop Scope 1 ( on the toolbar).

  6. Stop execution ( on the toolbar).

Simulink Real-Time does not support parameters of multiword data types.

To make both workspaces visible at the same time, drag one workspace tab down until the  icon appears in the middle of the dialog box. Continue to drag the workspace until the cursor reaches the required quadrant, and then release the mouse button.

To save your Simulink Real-Time Explorer layout, click File > Save Layout. In a later session, you can click File > Restore Layout to restore your layout.

Related Topics