FB_CTRL_LOG_DATA
This function block allows a log file to be created in *.csv format (comma separated values), in which a maximum of 10 variables may be recorded. The column headings specified by the user are written in the first row of this file. The input data is written at equal time intervals in the following lines. The individual entries are separated by a comma. 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 2s. The files that were generated can be analyzed with a spreadsheet program, for example.
The time stamp of the log entry, in s, is stored in the first column of the file. The other columns contain the data of the function block input fLogData
.
![]() | When the mode is set to It is essential that the file is closed by switching into |
The function block makes it possible to work with or without an external buffer.
Operating without an external buffer: | The |
Operating with an external buffer: | The user must create a buffer larger than 255 bytes and with the type |
![]() | 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 255 bytes is used. |
Inputs
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
Name | Type | Description |
---|---|---|
fLogData | T_CTRL_ | Array containing the values that are to be written into the log file. |
eMode | E_CTRL_MODE | Input that specifies the operation mode of the function block. |
Outputs
VAR_OUTPUT
eState : E_CTRL_STATE;
bFileOpen : BOOL
bFileClosed : BOOL
fBufferUsage : FLOAT
bBusy : BOOL
eErrorId : E_CTRL_ERRORCODES;
bError : BOOL;
END_VAR
Name | Type | Description |
---|---|---|
eState | E_CTRL_STATE | State of the function block |
bFileOpen | BOOL | A TRUE at this output indicates that the file has successfully been opened. |
bFileClosed | BOOL | A TRUE at this output indicates that the file has successfully been closed. |
fBufferUsage | FLOAT | Current fill level of the external buffer as a percentage |
bBusy | BOOL | A TRUE at this output indicates that logging a row is active. |
eErrorId | E_CTRL_ERRORCODES | Supplies the error number when the output |
bError | BOOL | Becomes TRUE, as soon as an error occurs. |
Inputs/ outputs
VAR_IN_OUT
stParams : ST_CTRL_LOG_DATA_PARAMS;
END_VAR
Name | Type | Description |
---|---|---|
stParams | ST_CTRL_LOG_DATA_PARAMS | Parameter structure of the logging function block |
stParams
consists of the following elements:
TYPE ST_CTRL_LOG_DATA_PARAMS:
STRUCT
tLogCycleTime : TIME := T#0ms;
tTaskCycleTime : TIME := T#0ms;
sFileName : STRING;
sNetId : T_AmsNetId := '';
tFileOperationTimeou : TIME := T#3s;
nNumberOfColumn : INT(1..10);
arColumnHeadings : ARRAY [1..10] OF STRING;
bAppendData : BOOL := FALSE;
bWriteTimeStamps : BOOL := TRUE;
bWriteColumnHeadings : BOOL := TRUE;
bWriteAbsoluteTimeStamps : BOOL := FALSE
pLogBuffer_ADR : POINTER TO BYTE;
nLogBuffer_SIZEOF : UDINT;
END_STRUCT
END_TYPE
Name | Type | Description |
---|---|---|
tLogCycleTime | TIME | Cycle time with which entries are written into the log file. This must be greater than or equal to the TaskCycleTime. |
tTaskCycleTime | TIME | Cycle time with which the function block is called. If the function block is called in every cycle this corresponds to the task cycle time of the calling task. |
sFileName | STRING | Name and path of the log file, for example: d:\Logfile.csv |
sNetId | T_AmsNetId | The log file is written to the system with the NetId specified here. |
tFileOperation | TIME | Timeout for all file operations |
nNumberOf | INT | Number of columns written into the file (maximum 10) |
arColumn | ARRAY | Array of strings that contain the column headings. |
bAppendData | BOOL | If this parameter is TRUE, then new data sets are appended when a file is opened again. Otherwise the file is overwritten without query, and this will delete any content that already exists. |
bWriteTime | BOOL | If this parameter is set to TRUE, the time stamp of the measurement is written into the first column of the file. |
bWriteColumn | BOOL | If this parameter is set to TRUE, the column headers are written into the first row of the file. |
bWriteAbsolute | BOOL | If this parameter is set to TRUE, the local NT time is used as timestamp. In this case the minimum |
pLogBuffer_ADR | POINTER TO BYTE | Address of the external |
nLogBuffer_ | UDINT | Size of the |
Notice | |
Error during file handling The parameter set can only be changed when the file is closed (bFileClosed = TRUE). Otherwise errors can occur during file handling. |