LogFileCSVPLCopen motion icon

FunctionClosedA function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. block - Generate a log file in CSV format for a list of variables

Inputs

LOG : BOOL     Variables are saved on any rising edgeClosedA rising edge is the transition of a digital signal from low to high. It is also called positive 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  Path name of the CSV file

Outputs

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 KAS IDEClosed"Integrated development environment" An integrated development environment is a type of computer software that assists computer programmers in developing software. IDEs normally consist of a source code editor, a compiler and/or interpreter, build-automation tools, and a debugger 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.

When a LOG or RST command is requested, the Q output is set to TRUE if successful see more details here.

In case of error, a report is given in the ERR output. Possible error values are:

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 runtimeClosedIn computer science, runtime (or run-time) describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time). Within KAS, runtime also refers to the virtual machine that manage the program written in a computer language while it is running
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 14h23m (2:23 pm) (see call out )

ST Language

(* MyLOG is a declared instance of LogFileCSV function block *)
MyLOG (b_LOG, RST, LIST, PATH);
Q := MyLOG.Q;
ERR := MyLog.ERR;

FBD Language

FFLD Language

IL Language

(* MyLOG is a declared instance of LogFileCSV function block *)
Op1: CAL MyLOG (b_LOG, RST, LIST, PATH);
FFLD  MyLOG.Q
STClosed"Structured text" A high-level language that is block structured and syntactically resembles Pascal  Q
FFLD  MyLog.ERR
ST  ERR

See also

VLID