MATLAB Examples

Inspect Simulink® Real-Time™ Data with Simulation Data Inspector

This example shows how to use Simulation Data Inspector (SDI) to log signal and task execution time (TET) data from the real-time application. You can select signals for display from models referenced at arbitrary levels within a model hierarchy.

  • Simulation Data Inspector (SDI) and the third-party calibration tools (Vector CANape® and ETAS® Inca) are mutually exclusive. If you use SDI to view signal data, you cannot use the calibration tools. If you use the calibration tools, you cannot use SDI to view signal data.
  • The real-time application sometimes generates data faster than the kernel can transmit it to the development computer, causing gaps in the output. If gaps occur, consider selecting buffered logging. You can also reduce the number of signals being inspected or increase the sample time.
  • Simulink® Real-Time™ records signals inside enabled subsystems even when they are not running. In while and for iterator subsystems, Simulink® Real-Time™ records only the last data point.

This example uses the model xpcosc (matlab:open_system(fullfile(matlabroot, 'toolbox', 'rtw', 'targets', 'xpc', 'xpcdemos', 'xpcosc'))).

In this example, you control the model from Simulink® Real-Time™ Explorer. You can also access Simulation Data Inspector by using external mode.


SDI Setup

Make sure that you have started the target computer and established communication between the development and target computers.

  1. Open xpcosc.
  2. On the toolbar, increase the simulation stop time to, for example, 10 seconds.
  3. To log signals with SDI, in the model, select and right-click the signals Signal Generator and Integrator1. Select Log Selected Signals. A faint Simulation Data Inspector icon appears next to each signal.
  4. To log task execution time (TET), open the Configuration Parameters dialog box. In the Simulink Real-Time Options tab, select Monitor Task Execution Time.
  5. Build the model and download it to the target computer.

Inspect Signal Data

  1. Click Tools > Simulink Real-Time.
  2. In Simulink Real-Time Explorer, start the real-time application. The Simulation Data Inspector button glows in Simulink Editor, indicating that Simulation Data Inspector has data available for viewing.
  3. Click the Simulation Data Inspector button.
  4. In Simulation Data Inspector, select the signals Integrator1:1 and SignalGenerator:1. Simulation Data Inspector displays plotted signal data.

5. Stop the real-time application.

6. After the simulation, use the toolbar buttons to explore the data. For example, to view the simulation between seconds 0.02 and 0.04, in Simulation Data Inspector, click the Zoom in Time button. Drag the cursor over the range from 0.02 to 0.04.

Inspect TET Data

  1. To view the TET data, clear Integrator1:1 and SignalGenerator:1.
  2. Select TET.BaseRate.minTET, TET.BaseRate.maxTET, and TET.BaseRate.TET.

3. To save the Simulation Data Inspector session as a .mat file, click Save.