Tune Inlined Parameters with Simulink Real-Time Explorer

This procedure describes how you can tune inlined parameters through the Simulink® Real-Time™ Explorer.

Note

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

The following procedure starts with the Simulink model xpcosc and produces the model ex_slrt_inlined_osc (open_system(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples', 'ex_slrt_inlined_osc')))).

Configure Model to Tune Inlined Parameters

  1. Open model xpcosc.

  2. In the Simulink Editor, select the input to the Scope block and mark it for data logging with the Simulation Data Inspector.

  3. Select the blocks containing the parameters that you want to tune. For example, this procedure makes the Amplitude parameter of the Signal Generator block tunable. To represent the amplitude, use the variable A.

    1. Double-click the Signal Generator block, and then enter A for the Amplitude parameter. Click OK.

    2. Assign a constant to variable A. In the Command Window, type:

      A = 4

      The value is displayed in the MATLAB® workspace.

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

  5. Select Code Generation > Optimization > Default parameter behavior > Inlined.

  6. Click Configure.

    The Model Parameter Configuration dialog box opens. The MATLAB workspace contains the constant you assigned to A.

  7. Select the line that contains your constant. Click Add to table.

    Add the remaining global parameters that you want to tune.

  8. Click Apply, and then click OK.

  9. In the Configuration Parameters dialog box, click Apply, and then OK.

  10. Save the model as ex_slrt_inlined_osc. On the Simulation tab, from Save, click Save As. For example, save it as ex_slrt_inlined_osc. For example model, see open_system(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples', 'ex_slrt_inlined_osc'))).

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

Initial Value

This procedure assumes that you have completed the steps in Configure Model to Tune Inlined Parameters.

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

  2. Select the real-time application in the Applications pane (for example, ex_slrt_inlined_osc).

  3. To start execution, click the real-time application, and then click the Start button  on the toolbar.

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

  5. 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.

  6. Open the Simulation Data Inspector and view the signals you marked for signal logging. On the Real-Time tab, click Data Inspector.

Updated Value

This procedure assumes that you have completed the steps in Initial Value.

  1. Change the value of the MATLAB variable A to 2. In Simulink Real-Time Explorer, type 2 into the Value box, and then press Enter.

    To revert the value of A to its previous value, click the Revert button .

  2. Click the Apply parameter value(s) changes button , and then click the Start button  on the toolbar.

    The Simulation Data Inspector looks like this figure.

  3. To stop execution, click the real-time application, and then click the Stop button  on the toolbar.

Related Topics