How can I stream signals from Speedgoat hardware to Simulation Data Inspector (SDI) using Simulink Real-Time R2020b and beyond?

18 views (last 30 days)
I would like to monitor and visualize signals in Simulation Data Inspector (SDI) while the real-time application is running on the Speedgoat hardware. Ideally, I would like to dynamically add/remove signals from SDI during the simulation, without having to rebuild the application. How can I do this in R2020b and beyond?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 30 Nov 2022
Edited: MathWorks Support Team on 30 Nov 2022
There are several different approaches to stream signals to Simulation Data Inspector (SDI) from Speedgoat hardware running a real-time application. For more information about the streaming workflow, see Signal Logging and Streaming Basics .
 

(1) Using Signal Logging badges:

You can mark signals in your model for "permanent" logging to SDI using Log Signal badges:
NOTE: Every time you add or remove the Log Signal badge from a signal in your model, a rebuild of the real-time application is required for the change to take effect. To dynamically add/remove signals from SDI during the simulation, without having to rebuild the application, consider the other Instrument-based approaches (2)-(4) below. 
 

(2) Using Instrument Buttons in Simulink Editor:

Starting in R2021b, when using the "Run on Target" button in your Simulink model to start your simulation in External Mode, you can add or remove signals for live streaming to SDI by using the Add/Configure/Remove Instrument buttons in the Simulink Editor:
See Add Instruments to Real-Time Application from Simulink Model for an illustration of the workflow.
 

(3) Using Simulink Real-Time Explorer:

When you use Simulink Real-Time Explorer to control your real-time application, you can select signals for streaming to SDI in the "Signals" panel. Click the Add Instrument and Remove Instrument (formerly "Start Streaming" and "Stop Streaming") buttons to add and remove the selected signals from SDI.
See Monitor Signals by Using Simulink Real-Time Explorer for an illustration of the workflow.
 

(4) Using Instrument Objects command-line interface:

Instrument objects provide a command-line interface for adding and removing signals in SDI. See the following code example:
>> inst = slrealtime.Instrument;
>> inst.addSignal('mysignal'); % or inst.addSignal('fullblockpath', portIdx)
>> tg = slrealtime;
% start streaming to SDI - If the real-time application is already running, you will immediately see the signal in SDI.
>> tg.addInstrument(inst);
% To stop streaming the signal, you can do the following:
>> tg.removeInstrument(inst);
>> tg.removeAllInstruments;
You can learn more about instrument objects here:
Note that Simulink Real-Time Explorer has a handy "Generate MATLAB code to create Instrument programmatically" button that will allow you to auto-generate the code needed to create your instrument object. Refer to the "Get MATLAB Code for Signals" section at:
 

Control streaming to SDI using Start/Stop Recording API:

As an overlay to all the options mentioned above, there is an additional Start/Stop Recording API (available from R2022a) that allows you globally control the streaming to SDI and create new runs while the simulation is running. See the following answer for more details:

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!