LogFileCSV
Function block - Generate a log file in CSV format for a list of variables.
(see description for SetCsvOpt function at the end of this page)
Inputs
Input |
Data type |
Description |
LOG |
BOOL |
Variables are saved on any rising edge of this input. |
RST |
BOOL |
Reset the contents of the CSV file. |
LIST |
DINT |
ID of the list of variables to log (use VLID function). |
PATH |
STRING |
Pathname of the CSV file. |
Outputs
Output |
Data type |
Description |
Q |
BOOL |
TRUE if the requested operation has been performed without error. |
ERR |
DINT |
Error report for the last requested operation (0 is OK). |
|
|
Remarks
This function enables to log values of a list of variables in a CSV file. On each rising edge of the LOG input, one more line of values is added to the file. There is one column for each variable, as they are defined in the list.
The list of variables is prepared using the Workbench Studio or a text editor. Use the VLID function to get the identifier of the list.
On a rising edge of the RST command, the file is emptied.
The "SetCsvOpt" function described at the end of this page enables you to customize the format of the CSV file.
When a LOG or RST command is requested, the Q output is set to TRUE if successful. In case of error, a report is given in the ERR output. Possible error values are:
Value |
Meaning |
1 |
Cannot reset file on a RST command. |
2 |
Cannot open file for data storing on a LOG command. |
3 |
Embedded lists are not supported by the Runtime Service. |
4 |
Invalid list ID. |
5 |
Error while writing to file. |
Combined with real time clock management functions, this block provides a very easy way to generate a periodical log file. The following example shows a list and a program that log values everyday at 14h23:
|
|
Example
MyLOG is a declared instance of LogFileCSV function block.
MyLOG (LOG, RST, LIST, PATH);
Q := MyLOG.Q;
ERR := MyLog.ERR;
The SetCsvOpt function
As default, the LogFileCsv block uses semicolons (";") as separators and dots (".") as decimal points. The SetCsvOpt function enables you to change these characters.
Syntax:
OK := SetCsvOpt (strSeparator, strDecimal);
Parameters:
StrSeparator (STRING) : single character string to be used as separator
strDecimal (STRING) : single character string to be used as decimal point
OK (BOOL) : TRUE if successful. FALSE if inputs are not single character strings.
|
LogFileCSV |
IEC 61131-3 Automation platform > Programming - Reference guide > Advanced operations > LogFileCSV |
Created with the Personal Edition of HelpNDoc: Don't Let Unauthorized Users View Your PDFs: Learn How to Set Passwords