日本語 English

The Simplest Way to Log to a CSV File

How CSV Logging Works

Structure data is converted to a comma-separated CSV string with the AddDelimiter instruction and written to the SD card with the FilePut instruction

CSV logging diagram

Functions used

Uses only standard FBs

Structure for logging

Example structure definition for logging

Ladder program example

CSV logging ladder program example

When the LogFlg contact turns ON, AddDelimiter runs and outputs Data as a comma-separated string to WriteLine
The FilePut instruction writes the contents of WriteLine to the SD card with a file name of the date of Data.DateTime + ".csv"

Advantages and disadvantages of this method

ItemDescription
AdvantagesSimple configuration that is easy to understand
AdvantagesCSV format opens in Excel
DisadvantagesNot suited to high-speed sampling
DisadvantagesAffected by SD card write time

FAQ

Can the CSV file be opened in Excel?

Yes. It is in CSV format, so it can be viewed in Excel or a text editor.

Can it be used for fast logging?

It is affected by SD card write time, so it is not suited to fast logging. The ring buffer method is recommended for fast collection.

What applications is it suited to?

Collecting equipment data and saving operation history at intervals of a few seconds to tens of seconds.

Download

Comments