メインコンテンツ

Add Instruments to Real-Time Applications by Using MATLAB Language

R2026b

Simulink® Real-Time™ user interfaces help you visualize signals by using:

There are programmatic options for collecting signal data that do not require adding File Log blocks or marking signals for logging in the model. These options include:

  • You can apply the addForFileLog function to add signals to an instrument in a Target object. The instrument transfers the signal data from the target computer to the development computer in the same manner and with the same controls (for example, AutoImportFileLog option for the start function) as when file log data is collected through a File Log block.

  • You can apply the addForSDI function to add signals to an instrument in a Target object. When added to a Target object, the instrument transfers of signal data from the target computer to the development computer in the same manner and with the same controls (for example, the startRecording and stopRecording functions) as streaming signal data. The streaming data is available in the Simulation Data Inspector during the simulation run, and the data is not saved on the target computer.

  • You can apply the addForMATLAB function to add signals to an instrument in a Target object. When added to a Target object, the instrument transfers of signal data from the target computer to the development computer in the same manner and with the same controls as streaming signal data; same as with the addForSDI function. The difference is that the streaming data is accessible through apps written in MATLAB rather than being accessible through the Simulation Data Inspector.

Tip

This additional signal logging and streaming support is dynamic. You can modify signal logging and streaming selections in your real-time application without re-building your model.

These steps show how to add a signal to an instrument then add the instrument to a Target object for file logging.

  1. Create a target object and connect to target computer. Open a model and configure model for target computer. Build a real-time application from the model. Create an instrument object and add a signal from real-time application.

    objTarg = slrealtime;
    connect(objTarg);
    model = 'slrt_ex_osc';
    openExample(model);
    modelSTF = getSTFName(objTarg);
    set_param(model,"SystemTargetFile",modelSTF);
    slbuild(model);
    mldatxname = 'slrt_ex_osc.mldatx';
    objTargInst = slrealtime.Instrument(mldatxname);
    objTargInst.Name = 'TargetInstrument';
    addSignal(objTargInst,'SigGen');
  2. Add an instrument to the Target object for file logging.

    addForFileLog(objTarg.Instruments,objTargInst);
  3. Load and run the real-time application. After the simulation runs, import the file log data to the development computer and visualize signals in the Simulation Data Inspector.

See Also

| | | | | | | | | | |

Topics