How does the new File Log block work in R2020b and later, and how is it different from the old File Scope block in Simulink Real-Time?

25 visualizaciones (últimos 30 días)
The File Scope block, as well as the "simulinkrealtime.filescope" object, do not appear to be available anymore in Simulink Real-Time R2020b and beyond. How can I do signal logging on my Speedgoat target in R2020b and beyond?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 14 de Nov. de 2023
Editada: MathWorks Support Team el 14 de Nov. de 2023
To write a signal data file log on your target machine SSD hard disk, use the File Log block from R2020b onwards.
An example model that uses the File Log block is "slrt_ex_param_tuning". Here is the related documentation example:Parameter Tuning and Data Logging
This page covers the following topics:
  • How is a File Log different from the old File Scope?
  • How can I control the number of File Log runs on the target?
  • How can I turn off the auto-import for File Logs?
  • How do I manually import File Logs into MATLAB?
  • How can I turn off the logging on the target machine?

How is a File Log different from the old File Scope?

The File Log block is similar to a signal marked for streaming in ‘Buffered’ mode, which was an R2020a (and earlier) feature and is documented here. The File Log block has the following improved capabilities compared to the old File Scope:
(1) By default, data is moved automatically to the host computer at the end of the simulation. At the end of the simulation, if the host computer is connected and the 'AutoImportFileLog' option is enabled, the data is automatically transferred and loaded on the Simulink Data Inspector (SDI). In addition to this, if the 'ExportToBaseWorkspace' option is enabled, the data is also downloaded to the 'logsOut' variable in MATLAB base workspace, as shown in the screenshots below. If the host computer is not connected, the data is stored on the target machine.
(2) The data file is deleted from the target machine after transfer to the host computer before R2022b. The data file is by default deleted from the target machine after successful transfer to the host computer in releases before R2022b. If the transfer is not successful, the data file is not deleted. Note: This means that you have to remember to save the data from SDI or the base workspace before closing MATLAB. If you close MATLAB without saving the data, your logged data is lost. In R2022b, auto deletion of imported file logs does not occur. More details are available in the R2022b release notes for Simulink Real-Time.
(3) The File Log takes into account custom signal labels. Instead of naming the signals only based on the upstream block name, as was the case with the File Scope block, the signals will now be displayed according to the custom signal label that you specified in your Simulink model.
(4) The data file can be transferred to the host machine during runtime. File Scope DAT files could only be copied to the host at the end of the real-time simulation. The File Log block allows import during runtime using the import() function as shown in the "How do I manually import File Logs into MATLAB?" section below. Starting in R2023b, you can import a previously stored file log while recording file log data.
 

How do I control the maximum number of logs stored on the target?

By default, the maximum number of file logs stored on the target is set to 1.
See the following answer for details on how to change the number of stored file logs:
 

How can I turn off the auto-import for File Logs?

See the following answer for details:
 

How do I manually import File Logs into MATLAB?

If the host computer was not connected when the application stopped, or if the auto-import had been disabled, you can use Simulink Real-Time Explorer to import the file logs available on the target machine. Click Import File Log as shown below:
The imported data is automatically loaded to the SDI. Export the data from the SDI to store the data on the host computer.
The file log import operation can be also done using the MATLAB API. Use the target object to get the list of the file logs available on the target machine. The list includes the name of the application, the start date, and the size:
>> tg.FileLog.list
You can selectively import or discard file logs using:
>> tg.FileLog.import(2:3)
>> tg.FileLog.discard("slrt_ex_osc")
Starting in R2021a, there is a supported workflow to copy file log data from the Speedgoat target computer to a host computer without MATLAB. See the following answer for details:

How can I turn off the logging on the target machine?

The File Log block works in an Enabled Subsystem, but there is also a global switch. Use the MATLAB API to disable or enable the logging on a target machine:
>> tg.FileLog.disable
>> tg.FileLog.enable
You can also use an Enable File Log block.

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by