主要内容

Add Instruments to Real-Time Application by Using Simulink Editor

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 MATLAB® development computer to the Speedgoat® 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 For SDI or select Real-Time > Review Results > Add For File Log.

    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. 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 or to the file log. After you have added an instrument for the Simulation Data Inspector to the model, the label on the Add For SDI button changes to Configure For SDI. After you have added an instrument for file logging to the model, the label on the Add For File Log button changes to Configure For File Log.

  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 For SDI or . select Real-Time > Review Results > Configure For File Log

  7. To remove the instrument added by using Add For SDI, select Real-Time > Review Results > Remove For SDI. To remove the instrument added by using Add For File Log, select Real-Time > Review Results > Remove For File Log.

  8. To highlight all signals in the model that are in the instrument, select Real-Time > Review Results > Highlight For SDI or select Real-Time > Review Results > Highlight For File Log.

  9. To import or export an instrument in the model for the Simulation Data Inspector, select Real-Time > Review Results > Import For SDI or select Real-Time > Review Results > Export For SDI.

    To import or export an instrument in the model for file logging, select Real-Time > Review Results > Import For File Log or select Real-Time > Review Results > Export For File Log.

  10. To stream signals from the real-time application to the Simulation Data Inspector or to record signals in the file log, 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 for the Simulation Data Inspector or enter bind mode to add or remove signals from an instrument for the Simulation Data Inspector, click the Add For SDI button or Configure For SDI button on the Real-Time tab in the Simulink Editor.

To enter bind mode to add an instrument for file logging or enter bind mode to add or remove signals from an instrument for file logging, click the Add For File Log button or Configure For File Log button on the Real-Time tab in the Simulink Editor.

The add-instrument buttons create an Instrument object, similar to the operation of the slrealtime.Instrument function. The add-instrument buttons put 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 for the Simulation Data Inspector, the Add For SDI button changes to the Configure For SDI button. The Configure For SDI 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.

After creating the Instrument for file logging, the Add For File Log button changes to the Configure For File Log button. The Configure For File Log 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 For SDI button removes the instrument created by Add For SDI or Configure SDI, similar to the way that the removeInstrument function removes an instrument from the selected target object.

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

Use the Highlight For SDI button and the Highlight For File Log button to indicate signals that are included in an instrument in the model.

Use the Import For SDI button to and the Import For File Log button import an instrument (previously saved to a MAT file) into the model.

Use the Export For SDI button and the the Export For SDI 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 For SDI button or the Remove For File Log 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 For SDI button, Export For File Log button, Import For SDI button, and Import File Log 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

|

Topics