You can acquire signal data to store in multiple, dynamically named files on the target computer. You can then examine one file while the scope continues to acquire data to store in other files. To acquire data for multiple files, add a file scope to the real-time application, and then configure that scope to log signal data to multiple files.
Using model xpcosc
, complete the setup tasks
in Create File Scopes with Simulink Real-Time Explorer.
In Simulink® Real-Time™ Explorer, in the Scopes pane, expand the xpcosc node.
Select File Scopes and expand node File Scopes.
Expand Scope 1 and then click
the Properties button on the toolbar.
In the Scope Properties pane, click File.
Select the AutoRestart check box.
When you select the AutoRestart box, the file scope collects data up to Number of samples and then starts over again reading new data. Setting AutoRestart enables the following parameters: Dynamic file name enabled and Max file size in bytes (multiple of WriteSize).
Select the Dynamic File Mode check box.
To enable the file scope to create multiple log files
based on the same name, in the File name box,
enter a name like scope1_<%>.dat
.
This sequence directs the software to create up to nine log
files, scope1_1.dat
to scope1_9.dat
,
on the target computer file system.
You can configure the file scope to create up to 99999999 files
(<%%%%%%%%>.dat
). The length of a file name,
including the specifier, cannot exceed eight characters.
In the Max write file size box,
enter a value to limit the size of the signal log files. This value
must be a multiple of the Write Size value. For
example, if the write size is 512
, enter 4096
to
limit each log file size to 4096 bytes.
To start execution, click the real-time application
and then click the Start button on the
toolbar.
Before starting the scope, copy previously acquired data to the development computer. When the file scope starts, the software overwrites previously acquired data in files of the specified name or name pattern. A partially overwritten file or a file that is opened but left unwritten loses its original contents.
To start Scope 1, click Scope
1 in the Scopes pane and then click
the Start Scope button on the
toolbar.
Let Scope 1 run for up to a minute.
To stop Scope 1, click Scope
1 in the Scopes pane and then click
the Stop Scope button on the
toolbar.
To stop execution, click the real-time application and then click the Stop button on the
toolbar.
To view the files that you generated, in the Targets pane, expand the target computer, and then double-click File System.
Select C:\
. The dialog box looks
like this figure.
The software creates a log file named SCOPE1_1.DAT
and
writes data to that file. When the size of the first file reaches 4096
bytes
(Max write file size), the software closes the
first file and creates the second file, SCOPE1_2.DAT
.
When the size of the second file reaches 4096
bytes,
the software creates the third file, the fourth file, and so on.
If the real-time application continues to collect data after
the software closes SCOPE1_9.DAT
, the software
reopens SCOPE1_1.DAT
, SCOPE1_2.DAT
,
and so on, overwriting the existing contents.
Drag each file from the target computer File System pane to the MATLAB® Current Folder pane or to a Windows® Explorer window.
File
System
| SimulinkRealTime.utils.bytes2file
| SimulinkRealTime.utils.getFileScopeData