Documentation

Configure and Control a Real-Time Application

You can configure and control a real-time application using the Simulink® Real-Time™ Explorer and Simulink external mode. This tutorial focuses on interaction using Simulink Real-Time Explorer. The model is a real-time model of a damped oscillator, ex_slrt_rt_osc (matlab: open_system(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples', 'ex_slrt_rt_osc')))).

Execute Real-Time Application with Simulink Real-Time Explorer

To perform this procedure, you must have already created a Simulink Real-Time boot disk and started the target computer. See Start Target Computer). This procedure begins with the real-time application ex_slrt_rt_osc (matlab: open_system(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples', 'ex_slrt_rt_osc')))) already downloaded to the target computer. See Build and Download Real-Time Application.

  1. In the Simulink Editor, click Tools > Simulink Real-Time.

  2. In the Targets pane, click the target computer icon for which you have downloaded the real-time application and click the Connect button  on the toolbar.

    The target computer icon turns to Connected .

  3. In the Applications pane, select the real-time application.

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

    The application starts running. The dialog box looks like this figure.

    If you have a monitor connected to your target computer, you can view output that looks like this output.

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

    The real-time application on the target computer stops running. The target computer displays messages like these messages.

    minimal TET: 0.0000006 at time 0.001250
    maximal TET: 0.0000013 at time 75.405500

Change Stop Time and Sample Time

This procedure is for changing the stop time and sample time in the real-time application configuration. You must have already downloaded the real-time application ex_slrt_rt_osc (matlab: open_system(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples', 'ex_slrt_rt_osc')))) to a target computer.

  1. In Simulink Real-Time Explorer, expand the node of the loaded real-time application in the Applications pane.

  2. On the toolbar, click the Properties button .

  3. In the Application Configuration workspace, under the Properties arrow, enter a new value for Stop time. For example, enter inf and press Enter.

    The real-time application now runs until you stop it.

  4. Enter a new value for Sample Time. For example, enter 0.00010 and press Enter.

    Note

    Some blocks produce incorrect results when you change their sample time at run time. If you include such blocks in your model, the software displays a warning message during model build. To avoid incorrect results, change the sample time in the original model, and then rebuild and download the model.

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

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

    The dialog box looks like this figure.

If you specify a sample time that is too small, a CPU overload can occur. If a CPU overload occurs, the target object property CPUOverload changes to detected. In that case, change Fixed step size to a larger value and rebuild the model.

See Also

|

Related Topics

Was this topic helpful?