Real-time DataLogger - Examples

Available from firmware 2019.3

Since the DataLogger is a versatile tool for a wide array of use cases, there is an overwhelming number of parameters and options to configure a session for best results. In this topic, you will find the settings for a bunch of typical use cases for your convenience, so you can pick one example and start right away with your first DataLogger session. 

In case you can't figure out the best settings for a special task, don't hesitate to ask the experts in the PLCnext Community Forum. Register and log in for asking your questions - don't worry, it's free of charge, no newsletter or ads bugging).

Configuration examples

A single task

  • Logging of variables from a single task with 10 ms task cycle, so it is samplingInterval="10ms"
  • A single data sink on the SD Card, so it is<Datasink type="db" dst="/opt/plcnext/DataSink.db"...
  • All values are to be logged, so it is storeChangesOnly="false"
  • When reaching the defined maximum file size of 5.000.000 byte in the data sink, the oldest 5% of data shall be deleted, so it isrollover="false" and maxFileSize="5000000" and deleteRatio="5"

This would be the XML .config file:

<?xml version="1.0" encoding="utf-8"?>
<DataLoggerConfigDocument
  xmlns="http://www.phoenixcontact.com/schema/dataloggerconfig"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.phoenixcontact.com/schema/dataloggerconfig.xsd">
  <General name="test-session" samplingInterval="10ms" publishInterval="250ms" bufferCapacity="2000"/>
  <Datasink type="db" dst="/opt/plcnext/DataSink.db" rollover="false" maxFileSize="5000000" storeChangesOnly="false" deleteRatio="5"/> 
  <Variables>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer10.IN_DI_000"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer10.IN_DI_001"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer10.IN_DI_002"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer10.IN_DI_003"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer10.IN_DI_004"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer10.IN_DI_005"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer10.IN_DI_006"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer10.IN_DI_007"/>
  </Variables>
</DataLoggerConfigDocument>
Note: From firmware 2021.6 on, the DataLogger supports continuous recording with along with a single ESM task in a project, using the taskContext attribute instead of samplingInterval. So instead of defining a samplingInterval by milliseconds the taskContext can be used to address the ESM task by its name:
<General name="test-session" taskContext="mytask" publishInterval="250ms" bufferCapacity="2000"/>

Tasks with different cycles 

The log will represent the latest minutes and show all changes to the variables over time.

The DataLogger internally uses GDS subscriptions of<SubscriptionKind> Recording which is behaving like RealTime and HighPerformance. This results in values for instance variables that are synchronous to an ESM task. In other words: Within a single record, the values of all instance variables whose related program instance is associated with the same ESM task are stemming from the same execution cycle of that task. This is the only way to get task-synchronous values: Resource-global variables and component ports do not have such ESM task and therefore cannot be synchronous to an ESM task.

  • Logging of variables from different tasks with task cycles of 5 ms, 10 ms, 25 ms and 50 ms, so the common denominator for these cycles leads tosamplingInterval ="5ms"
  • Three data sink files with 1.000.000 bytes each on the SD Card, so it is <Datasink type="db" dst="/opt/plcnext/DataSink.db" maxFiles="3" maxFileSize="1000000"...
  • Only changes are logged, so storeChangesOnly="true"
  • When reaching the defined maximum file size of 1.000.000 byte in the data sink, it will be closed and a another data sink will be opened so it is rollover="true". Due to maxFiles="3", when reaching the defined maximum file size in the third data sink, the oldest data sink file is to be deleted.
  • We want the timestamp to be in the ISO 8601 format, so it is tsfmt="Iso8601"

This would be the XML .config file:

<?xml version="1.0" encoding="utf-8"?>
<DataLoggerConfigDocument
  xmlns="http://www.phoenixcontact.com/schema/dataloggerconfig"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.phoenixcontact.com/schema/dataloggerconfig.xsd">
  <General name="test-session" samplingInterval ="5ms" publishInterval="250ms" bufferCapacity="2000"/>
  <Datasink type="db" dst="/opt/plcnext/DataSink.db" rollover="true" maxFiles="3" maxFileSize="1000000" 
     storeChangesOnly="true" tsfmt="Iso8601"/> 
  <Variables>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer5.IN_DI_000"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer5.IN_DI_001"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer10.IN_DI_002"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer10.IN_DI_003"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer25.IN_DI_004"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer25.IN_DI_005"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer50.IN_DI_006"/>
    <Variable name = "Arp.Plc.Eclr/DIO_Producer50.IN_DI_007"/>
  </Variables>
</DataLoggerConfigDocument>

Note: From firmware 2021.6 on, the DataLogger supports continuous recording with a selected ESM task, using the taskContext attribute instead of samplingInterval. In case the project has several cyclic tasks, there is a critical difference, though:

  • If samplingInterval is used, the variables are recorded synchronous to the task they are instantiated in.
  • If taskContext is used, the variables are not recorded synchronous to the task they are instantiated in.

By specifying an ESM task simply via its name, the values of all kinds of variables listed in the session configuration file will be sampled within this task:

  • resource-global variables and component ports
  • variables instantiated within a program associated to any ESM task

Different use cases

In example 1 and 2, the data sink first collects the data in a RAM database, and later on an SD card.

The attribute maxFileSize determines the size of this database and therefore how much of the RAM is used by the DataLogger session. When the value that is determined in maxFileSize is reached, a copy of the database is written from the RAM to the SD card. The duration of the writing process to the SD card depends on the system load and the size of the file. Consider this when configuring maxFileSize.

Phoenix Contact recommends to assign 1 MB as file size. If more historical data is necessary, Phoenix Contact recommends to split the data into several files with the attribute rollover="true"

Example 1

Logging of 10 variables in endless mode from a task with 100 ms.
Guaranteed storage of 1000 collected data records.
The last seconds are of interest for evaluation.
Configuration: rollover="false", maxFileSize="1000000", dst="/opt/plcnext/log.db"

Example 2

Logging of 10 variables in endless mode from a task with 100 ms.
Guaranteed storage of 1000 collected data records.
The last minutes are of interest for evaluation.
Configuration: rollover="true", maxFiles="10", maxFileSize="1000000", dst="/opt/plcnext/log.db"

 

Examples 3 and 4 show a configuration for high-speed data logging.

Data logging in the low-ms range requires fast write access. This cannot be realized reliably with an SD card. If data logging faster than 5 ms is required, Phoenix Contact recommends to store the data on the RAM disk due to performance reasons (/tmp/). Ensure that the required RAM for the database is available  on the controller. 

Note that in case of a voltage failure or controller reset all data that is stored on the RAM disk will be lost. Phoenix Contact recommends the usage of a Uninterruptible Power Supply (UPS) to prevent the loss of data. 

Example 3

High-speed data logging of variables in endless mode from a task with 5 ms.
The last seconds are of interest for evaluation.
Configuration: rollover="false", maxFileSize="1000000", dst="/tmp/log.db"

Example 4

High-speed data logging of variables in endless mode from a task with 5 ms.
The last minutes are of interest for evaluation.
Configuration: rollover="true", maxFiles="10", maxFileSize="1000000", dst="/tmp/log.db"

 

 


• Published/reviewed: 2024-10-30   ☀  Revision 074 •