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.

Open the Model

The procedure starts with the Simulink® model slrt_ex_osc_inlined. To open the model, in the MATLAB® Command Window, type:

model = 'slrt_ex_osc_inlined';
open_system(model);

Configure Model to Tune Inlined Parameters

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

1. Open model slrt_ex_osc_inlined.

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

3. Select the blocks containing the parameters that you want to tune. To represent the amplitude, use the variable A.

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

  • Assign a constant to variable A. In the MATLAB Command Window, type: A = 4. The value is displayed in the MATLAB workspace.

4. Open the Configuration Parameters dialog box. 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.

8. Click Apply, and then click OK.

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

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

11. Build the real-time application for your target computer. On the Real-Time tab, click Run on Target > Build Application.

Initial Value

This procedure assumes that you have completed the steps in #3.

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

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

3. Set the application stop time to inf.

4. To start execution, click Start.

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

6. Select the Parameters tab.

7. 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 #4.

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.

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

3. To stop execution, click Stop.

Close the Model

bdclose(model);

Related Topics