PLC-API Requirements 5.7.3 FB_CTRL_LOG_MAT_FILE (only on a PC system) This function block allows a log file to be created in Matlab 5 (*.mat) format, in which a maximum of 10 magnitudes may be recorded. Two variables are created in the file, a double array and a cell array. The recorded magnitudes are recorded, line-by-line, in the double array. The identifiers of the individual rows are stored in the cell array. The user can specify the name used for the double array in the function block's parameter structure. The name of the cell array is derived from the name of the double array by appending "_Info" to the variable name.
The input data is written at equal time intervals in the columns of the data array. A time stamp for the relevant entry, in s, can be stored in the first column. The time interval between the entries is specified in the tLogCycleTime parameter. If, for instance, tLogCycleTime := T\#2s is chosen, then an entry is made in the file every 2 s. When the mode is set to eCTRL_MODE_ACTIVE the log file is opened and entries are written into the file. The file remains open until the function block's mode is set to eCTRL_MODE_PASSIVE. It is essential that the file is closed by switching into eCTRL_MODE_PASSIVE before attempting to analyze the log file.
If this is not done, it is possible that not all the entries will be written into the file, which will then not be consistent. The function block makes it possible to work with or without an external buffer. The external buffer is used if a buffer address and a buffer size greater than zero are parameterized. In the absence of an external buffer, an internal buffer with the size of 1500 bytes is used. VAR_INPUT VAR_INPUT fLogData : T_CTRL_LOGGER_DATA; eMode : E_CTRL_MODE; END_VAR VAR_GLOBAL CONSTANT nCTRL_LOGGER_DATA_ARRAY_SIZE :UINT := 10; END_VAR TYPE T_CTRL_LOGGER_DATA :ARRAY [1..nCTRL_LOGGER_DATA_ARRAY_SIZE] OF FLOAT; END_TYPE TS4100 116 Version:
1.1 Development Environment Target System PLC libraries to include TwinCAT v2.8 PC (i386) TcControllerToolbox.lib Operating without an external buffer: The bBusy output is TRUE when the logging of a row has been started. The following data set will not be logged until the bBusy output is FALSE again. The fBufferUsage output indicates how full the internal buffer is. Operating with an external buffer: The user must create a buffer of the type ARRAY OF BYTES, which is larger than 1500 bytes. The individual messages are temporarily stored in the external buffer and this buffer is written to the file as soon as possible. The fBufferUsage output indicates how full the buffer is.
The function block is stopped and an error is output if the buffer overflows.