Main Content

Tune Parameters by Using 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 slrt_ex_osc.

Set Up the Simulation Data Inspector

Before tuning parameter values, set up the Simulation Data Inspector:

  1. Open the Simulation Data Inspector ().

  2. Click Layout ().

  3. Select two horizontal displays.

  4. Open model slrt_ex_osc. Set property Stop time to inf. In the Simulink Editor, on the Real-Time tab, select Run on Target > Stop Time and set Stop Time to inf.

  5. Connect to the target computer. Toggle the Disconnected indicator to Connected.

  6. Build the real-time application for the target computer. Click Run on Target > Build Application.

  7. Deploy the real-time application to the target computer. Click Run on Target > Deploy to Target.

  8. Connect to the target computer and run the real-time application. In the MATLAB Command Window, type:

    tg = slrealtime;
    start(tg);
  9. Open the Simulation Data Inspector. In the MATLAB Command Window, type:

    Simulink.sdi.view
  10. In the Simulation Data Inspector, drag the MuxOut(1) signal to the top display and drag the MuxOut(2) signal to the bottom display.

    Compare MuxOut signals in the Simulation Data Inspector with initial values, before tuning.

View Initial Parameter Values

To view the initial parameter values:

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

  2. Select the Parameters tab. The tab lists parameters Amplitude, Frequency, A, and C with their values.

Modify Parameter Values

To update a parameter value:

  1. Select the parameter value for the Amplitude parameter and change the value to 0.5.

  2. Select the parameter value for the Frequency parameter and change the value to 15.

  3. After each change, the signal display in the Simulation Data Inspector alters to match the effect of the parameter change. You can change multiple parameters at the same time by using The Hold Updates button. For more information, see Tune Parameters by Using Hold Updates and Update All Parameters.

Related Topics