To File
Purpose
Write signal values to a file.
Description
While a simulation on the RT Box is running the To File block continuously writes the values of its input signals to a file. The data is written in single precision format. The file format can be either a text file with comma separated values (csv) or a MATLAB data file (mat).
To ensure consistent data the simulation must be stopped before retrieving the data file.
On the RT Box 1 and CE files can only be stored on an external USB flash drive. On the RT Box 2, 3 and 4 files can be stored on the internal SSD or an external USB flash drive. For high data throughput a USB 3.0 device should be used. Removing a USB flash drive during the write process may result in inconsistent files, especially if the MATLAB format (mat) is selected.
To retrieve files from the internal SSD or an external USB flash drive, establish a WebDAV connection to http://<rtbox name>/dav. On Windows and Mac OS this can be done from the operating system directly. As an alternative, a web interface is available at http://<rtbox name>/dav. (Replace <rtbox name> with the hostname of your rtbox, e.g. rtbox-20b0f70361c2.local.)
Parameters
- Filename
The name of the data file to write to. Files are stored in a new directory named after the model currently executed on the RT Box, with four digit number appended. The appended number is increased automatically on each simulation run. A file named
latest.txtis created containing the newest directory name. The file is overwritten each time a simulation is started if it already exists.The maximum file size is limited to
2 GB. If the file size is exceeded, a new file with an increasing number appended is created automatically. File rotation may lead to data loss.If the option literal is chosen, the string that is entered is taken literally as the basename of the data file. A suffix
.csvor.matis added depending on the file type. If the option evaluate is chosen, the string that is entered is interpreted as a MATLAB/Octave expression that must yield a string, which in turn is taken as the basename of the data file. If, for example, the value['MyFile' num2str(index)]is entered and the current workspace contains a variableindexwith a value of2, the file name will beMyFile2.csvorMyFile2.mat.- File Type
The file format to use for the data file. The file can be written as a text file with comma separated values (csv) or as a MATLAB data file (mat). Writing to a MATLAB data file is significantly faster compared to a csv file. The minimum
Sample timesfor different RT Box versions are given in Tab. 20.Table 20 Minmimum supported sample times for different RT Box versions Target
.csv
.mat
RT Box 1/CE
\(100~\mu s\)
\(10~\mu s\)
RT Box 2/3/4
\(10~\mu s\)
\(2~\mu s\)
- Data type
Selects whether the data is stored in single or double precision.
- Write device
Selects whether to store files on the internal SSD (
Internal SSD) or an external USB flash drive (USB Flash Drive).- Sample time
The input data will be written to the data file once in the given time period.
- File rotation
If enabled, the current output file is closed and a new output file is created when a transition from a boolean false to a boolean true is detected at the rotation input port.