Log Signal Data into Multiple Files

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.

  1. In Simulink® Real-Time™ Explorer, in the Scopes pane, expand the xpcosc node.

  2. Select File Scopes and expand node File Scopes.

  3. Expand Scope 1 and then click the Properties button  on the toolbar.

  4. In the Scope Properties pane, click File.

  5. 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).

  6. Select the Dynamic File Mode check box.

  7. 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.

  8. 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.

  9. To start execution, click the real-time application and then click the Start button  on the toolbar.

  10. Caution

    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.

  11. To stop Scope 1, click Scope 1 in the Scopes pane and then click the Stop Scope button  on the toolbar.

  12. To stop execution, click the real-time application and then click the Stop button  on the toolbar.

  13. To view the files that you generated, in the Targets pane, expand the target computer, and then double-click File System.

  14. 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.

  15. Drag each file from the target computer File System pane to the MATLAB® Current Folder pane or to a Windows® Explorer window.

See Also

| |

Related Topics