Control

PLC scan cycle and data sampling error

Before reading a PLC tag for AI, know where in the scan cycle the value was produced and which timestamp describes it.

In short
  • A PLC tag can hold the same value until the next scan, so the recorded time may differ from the physical event time.
  • The read interval must be clearly shorter than the fast change, or a pulse can vanish or look like a slow oscillation.
  • Source time, receive time and latency should be stored as separate fields, because a packet’s arrival time is not the time of the event.

What the scan cycle does

A conventional PLC reads inputs, executes program logic, writes outputs and repeats. A tag inside the program can hold the same value until the next scan. When a monitoring system reads those values, the physical event time and the recorded time can differ.

Tie sampling rate to process speed

To capture a fast change, the read interval must be clearly shorter than that change. If it is too long, a fast vibration or pressure pulse disappears or shows up as a misleading slow oscillation. This is aliasing. Establish the process speed limit first, then choose the monitoring rate.

Timestamp at the source

Where possible, generate the timestamp in the PLC or at the collector nearest the source. The arrival time of a packet is not the time of the event. Store source time, receive time and latency as separate fields. Without clock synchronization, do not interpret two machines’ records as an ordered sequence of events.

Prepare model data against these limits

When engineering features, record the window length, the sampling interval and the behaviour on missing reads. Training on 100 ms data and running on 1 s data turns the same model into a different problem. These steps are a suggested workflow; the real scan time of a specific PLC family must be verified in its product documentation.

Frequently asked

How does a PLC scan cycle affect sampled data for analytics?

A conventional PLC reads inputs, runs its program, writes outputs and repeats. A tag can hold its value until the next scan, so the recorded time may differ from the physical event time. Choose the monitoring rate from the process speed limit, and store source time, receive time and latency as separate fields.

Why does sampling rate matter when a model trained on PLC data is deployed?

Record the window length, the sampling interval and the behavior on missing reads. Training on 100 ms data and running on 1 s data turns the same model into a different problem. Without clock synchronization, do not read two machines’ records as an ordered sequence of events.

Sources and further reading

Pilot steps in this guide are proposed engineering workflows. Examples do not constitute measured field performance.

Questions on this topic