Main Content

Signal Logging Basics

Signal logging acquires signal data during a real-time run and stores it on the target computer. After you stop the real-time application, you transfer the data from the target computer to the development computer for analysis. You can plot and analyze the data, and later save it to a disk on the development computer.

Simulink® Real-Time™ signal logging samples at the base sample time. You can log signals to the Simulation Data Inspector by:

  • Mark signals for immediate logging to the Simulation Data Inspector.

  • Connect signals to File Log blocks for buffered logging to the Simulation Data Inspector.

With regards to logging:

  • Simulink Real-Time Explorer works with multidimensional signals in column-major format.

  • Some signals are not observable.

How Application is Run Affects Signals Logged

The Run on Target button provides slightly different data logging support than running the real-time application by using the start(tg) command:

  • When you run the real-time application by using the start(tg) command, only signals marked for data logging or connected to a File Log block are logged to the Simulation Data Inspector.

  • When you run the real-time application by using the Run on Target button on the real-time tab in the Simulink Editor or the Start button in the Simulink Real-Time Explorer, signals marked for logging, signals connected to File Log blocks, and signals connected to Scope blocks are logged to the Simulation Data Inspector.

File Logging and Streaming Workflow

You can get signal data into the Simulation Data Inspector through logging by using a File Log block or through streaming by marking a signal for logging in the model or selecting a signal for streaming in the Simulink Real-Time Explorer.

Signal logging through a File Log block provides options that let you control:

  • The number of file logs that are retained on the target computer

  • Whether file log data is auto imported into the Simulation Data Inspector

  • Whether file log data is exported into the base workspace

You can configure these options by using the option for the real-time application start(tg) function or by using the Run in Real-Time selection in the Simulink Real-Time Explorer or the Simulink Editor. The File Logging and Streaming Workflow figure shows how these options configure operation of the real-time application start(tg) function.

File Logging and Streaming Workflow

Image of file log workflow

While the real-time application is running, you can control file logging from File Log blocks:

  • Default logging logs signal data for the entire simulation run.

  • Enable or disable file logging by using the Enable File Log block in the model.

  • Enable or disable file logging by using the enable(tg.FileLog) function or disable(tg.FileLog) function.

  • Enable or disable file logging by using the startRecording function or stopRecording function. These function also enable or disable streaming.

After file logging stops, which occurs:

The configuration of the AutoImportFileLog option selects whether file log data is auto imported into the Simulation Data Inspector or whether you use the import(tg.FileLog) function to import the data.

Auto import of the file log is handled differently by the workflows in the File Logging and Streaming Workflow figure:

  • For all the workflows, the auto import operation occurs when the real-time application stops.

  • For the recording workflow, the auto import operation also occurs when the stopRecording function is called.

Related Topics