Main Content

Tune Inlined Parameters by Using 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 procedure starts with the Simulink model slrt_ex_osc_inlined. To open the model, in the MATLAB Command Window, type:

open_system(fullfile(matlabroot, 'toolbox', 'slrealtime', ...
'examples', 'slrt_ex_osc_inlined')))

Configure Model to Tune Inlined Parameters

This procedure makes the Amplitude parameter of the Signal Generator block tunable.

Open model slrt_ex_osc_inlined.

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

Select the blocks containing the parameters that you want to tune. 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 MATLAB Command Window, type:

    A = 4

    The value is displayed in the MATLAB® workspace.

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

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

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

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

Click Apply, and then click OK.

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

Save the model as slrt_ex_osc_inlined. On the Simulation tab, from Save, click Save As. For example, save it as slrt_ex_osc_inlined.

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.

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

Load the slrt_ex_osc_inlined real-time application. Click Load Application, select the application, and click Load.

Set the application stop time to inf.

To start execution, click Start.

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

Select the Parameters tab.

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.

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.

The Simulation Data Inspector display changes to show the new signal amplitude.

To stop execution, click Stop.

Related Topics