Main Content

Add Instruments to Real-Time Application from Simulink Model

As an alternative to marking signals in your model for logging, connecting a signal to a File Log block in the model, or selecting signals in a real-time application to stream in the Simulink Real-Time explorer, you can stream signal data to the Simulation Data Inspector by using Instrument buttons in the Simulink Editor. You can select a signal for streaming by using the Instrument buttons when the signal is:

  • Available in the model and in the real-time application that is built from the model.

  • Uses specified (not inherited) sample time.

  • Uses globally accessible memory in the real-time application.

  • Not connected to a Send or Message Send block.

Unlike marking signals for streaming or connecting signals to File Log blocks, the Instrument buttons use bind mode in workflows that let you add an instrument to the model and make the instrument available in the real-time application without rebuilding the real-time application. You can export the instrument from the model or import the instrument into the model.

To select signals for streaming to the Simulation Data Inspector by using the Instrument buttons in the Simulink Editor:

  1. Open a model. For example, in the Command Window, type:

    openExample('slrt_ex_osc')
  2. Connect the development computer to the target computer.

  3. To generate the real-time application, build the model.

  4. To put the model in bind mode by using the Instrument buttons, in the Simulink Editor, select Real-Time > Review Results > Add Instrument.

    While in bind mode, a link symbol appears with the cursor, and an exit icon appears in the upper-right corner of the model. When you are ready to exit bind mode, on the model canvas, click the exit icon. Image of bind mode exit icon

  5. To add a signals to an instrument, select a block and select the check box next to the signal.

    When you run the real-time application, the signals that you have added to an instrument are streamed to the Simulation Data Inspector. After you have added an instrument to the model, the label on the Add Instrument button changes to Configure Instrument.

  6. To re-enter bind mode by using the Instrument buttons and add or remove signals from the instrument, select Real-Time > Review Results > Configure Instrument.

  7. To remove the instrument added by using Add Instrument, select Real-Time > Review Results > Remove Instrument.

  8. To highlight all signals in the model that are in the instrument, select Real-Time > Review Results > Highlight Instrument.

  9. To import or export an instrument in the model, select Real-Time > Review Results > Import Instrument or select Real-Time > Review Results > Export Instrument.

  10. To stream signals from the real-time application to the Simulation Data Inspector, after making changes to an instrument:, deploy the real-time application to the target computer and start the application.

    For example, select Real-Time > Run on Target.

The Instrument buttons on the Real-Time tab of the Simulink Editor provide additional workflow options. This table describes the available button operations.

Buttons

Instrument Button Operations

To enter bind mode to add an instrument or enter bind mode to add or remove signals from an instrument, click the Add Instrument button or Configure Instrument button on the Real-Time tab in the Simulink Editor.

The Add Instrument button creates an Instrument object, similar to the operation of the slrealtime.Instrument function. The Add Instrument button puts the model in bind mode to create an Instrument object. You can select any number of signals from the model to include in the Instrument object.

After creating the Instrument, the Add Instrument button changes to the Configure Instrument button. The Configure Instrument button puts the model in bind mode and lets you add or remove signals from an Instrument, similar to the operation of the addSignal function and removeSignal function.

The Remove Instrument button removes the instrument created by Add Instrument or Configure Instrument, similar to the way that the removeInstrument function removes an instrument from the selected target object.

Use the Highlight Instrument button to indicate signals that are included in an instrument in the model.

Use the Import Instrument button to import an instrument (previously saved to a MAT file) into the model.

Use the Export Instrument button to export an instrument (as a MAT file) from the model.

An instrument that you add to a model is retained in the model, unless you remove the instrument with the Remove Instrument button. To remove an instrument that was added in a previous editing session, use the removeAllInstruments function.

To save and restore an instrument in a model, use the Export Instrument button and Import Instrument button. A suggested workflow for saving and restoring an instrument in a model is:

  1. Add an instrument to the model. Use the instrument to stream signals from the real-time application.

  2. Export an instrument from the model for streaming in future real-time application runs.

  3. Remove an instrument from the model before exiting the Simulink Editor.

  4. Import an instrument to the model when needed to stream signals from the real-time application.

See Also

|

Related Examples

More About