There are several methods to stream signals to the Simulation Data Inspector (SDI) from Speedgoat hardware running a real-time application:
Option 1: Apply signal logging badges for default streaming
You can mark signals in your model for "permanent" streaming to SDI using signal logging badges (resembling blue WiFi symbols):Real-time application signals that are marked for streaming are referred to as "instrumented signals". Note that every time you add or remove a signal logging badge from a signal in your model, a rebuild of the model into a real-time application file (.mldatx) is required for the changes to take effect.
Option 2: Use instruments for dynamic streaming
To dynamically add or remove signals from SDI during the simulation, without rebuilding the model into a real-time application file (.mldatx) , consider the instrument-based approaches listed below:
2.1 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. 2.2 Instrument Buttons in 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 Export and Import Signals in Instrument by Using Simulink Real-Time Explorer for an illustration of the workflow. 2.3 Instrument Objects in your MATLAB code or SLRT app
Instrument objects provide a command-line interface for adding and removing signals in SDI. You can use instrument objects in your MATLAB code or app code. See the following code example:
>> myInst = slrealtime.Instrument;
>> myInst.addSignal('mysignal');
>> tg = slrealtime;
>> tg.addInstrument(myInst);
>> tg.removeInstrument(myInst);
>> tg.removeAllInstruments;
The addSignal function allows you to add signals to an instrument, either by signal name, or by block name and port number. Then, use the addInstrument function to start streaming the signals in the instrument in SDI. See the Instrument Objects documentation for an overview.
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: Export and Import Signals in Instrument by Using Simulink Real-Time Explorer Considerations when using a deployed SLRT app with MATLAB Compiler:
If you design an SLRT app with App Designer, note that the SDI frontend is not available after deploying your standalone app with MATLAB Compiler. In that case, consider binding the instruments to elements in your app (e.g. Axes, EditFields) for immediate display - use the SLRT App Generator tool to facilitate this. Alternatively, you could still access the SDI backend and export and post-process the run data with slrealtime.exportRun (available from R2023a).
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 to globally control the streaming to SDI and create new runs while the simulation is running. See the following answer for more details: