Function block to log program variables to .csv file

Function block to log program variables to .csv file

Easily log time stamped data to a comma separated variable text file on the SMLC flash card.

Many applications require process or quality control data to be logged to a file. This function block allows you to log up to 6 DINT variables to a file with a millisecond time stamp from the start of the log.

One set of data can be logged on every program scan or, one set can be logged on each rising edge of the LogNow input.

The resulting text file is in comma separated variable format suitable for use with spreadsheet programs.
The format is:  Time_ms, Data1, Data2, Data3, Data4, Data5, Data6

To use the DataLog Function Block, download the file and unzip it to a temporary folder.

1)  Open your CoDeSys project and use the Project | Merge menu item to open from the temporary folder.

2)  Select the DataLog (FB) function block as shown below and click OK.

3)  Create an instance of the DataLog (FB) in a location of your program that is being scanned during the times you will want to log data. Your PLC_PRG’s EveryScan action is a good choice.

4)  Immediately before the DataLog instance, place function blocks, usually MC_ReadParameter to obtain the data you want to log. If you want to log data that is not DINT type, you will need to use appropriate …TO_DINT conversions.

5)  If you don't need six data items, leave the inputs you don't need disconnected.

6)  When you want to start logging data, set the Enable input TRUE. If the Continuous input is TRUE, a new set of data will be logged each time your DataLog function block is scanned. If you set the Continuous input FALSE, a new set of data will be logged each time a rising edge is detected on the LogNow input.

7)  It is important to note that the data is stored but not actually written to the file until the Enable input returns false.

You may view the source code for the function block and modify it to suit your needs.


Archive by Years
eNews Signup
Privacy StatementTerms Of UseCopyright © 2008-2015 ORMEC Systems Corp.