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:
Open a model. For example, in the Command Window, type:
openExample('slrt_ex_osc')
Connect the MATLAB® development computer to the Speedgoat® target computer.
To generate the real-time application, build the model.
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.
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.
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.
To remove the instrument added by using Add Instrument, select Real-Time > Review Results > Remove Instrument.
To highlight all signals in the model that are in the instrument, select Real-Time > Review Results > Highlight Instrument.
To import or export an instrument in the model, select Real-Time > Review Results > Import Instrument or select Real-Time > Review Results > Export Instrument.
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 | |
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 | |
The Remove Instrument button removes the instrument
created by Add Instrument or Configure
Instrument, similar to the way that the | |
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:
Add an instrument to the model. Use the instrument to stream signals from the real-time application.
Export an instrument from the model for streaming in future real-time application runs.
Remove an instrument from the model before exiting the Simulink Editor.
Import an instrument to the model when needed to stream signals from the real-time application.
See Also
Simulink Real-Time
Explorer | Instrument
Related Examples
- Add App Designer App to Inverted Pendulum Model
- Control Color of Lamp on Instrument Panel by Using MATLAB®