Anyone who needs to record PLC signals usually has a specific problem: a machine stops intermittently, a part is occasionally picked incorrectly, a measured value jumps for no apparent reason. In the online view of the program everything looks fine – because the fault occurs exactly when nobody is watching and often lasts only a few cycles.

The common engineering environments for controllers include trace functions that log variables at the pace of the controller and display them as curves. For longer periods, data logging to a file or database is added. This guide explains which tool fits which situation, what matters when choosing sampling rate and trigger, and how to turn a recording into a reliable statement about the cause of a fault.

When a recording is worth it

Not every fault needs a recording. If a fault can be reproduced, it can usually be narrowed down with online monitoring, the diagnostic buffer and step-by-step checks. A recording is worthwhile above all when the fault is rare, short or tied to conditions that cannot easily be recreated.

Timing problems are typical: in rare cases two signals arrive in the wrong order, a sensor bounces, a feedback signal arrives a few milliseconds too late. Control loops, drives and analog values can also only be assessed by their behavior over time. Finally, a recording helps when evidence is needed – for example, whether a cycle time is being met or how a program change has affected the process.

  • Intermittent stops or fault messages without a recognizable pattern
  • Suspected timing problems between signals, stations or controllers
  • Unstable analog values, oscillations in control loops or drives
  • Cycle time analysis and comparison before and after a change
  • Faults that only occur under certain conditions, such as with one product or after long running times

Trace functions in engineering environments

Most current programming environments offer a trace function that logs selected variables and displays them as curves – similar to an oscilloscope. Depending on the system it is called trace or scope; examples can be found in CODESYS-based environments, in TIA Portal or in TwinCAT. How many signals can be recorded at once, how long a recording can run and which triggers are available varies by platform, version and controller. It is worth checking the documentation of the environment in use before troubleshooting starts.

The strength of a trace is its time resolution. When recording takes place directly in the controller, values are captured in the cycle of the task in which they are calculated. This makes even very short states visible that slip through during normal online monitoring. The limit is memory: a trace is generally not designed for recordings over days or weeks. That is why it is usually combined with a trigger that captures the decisive moment.

Sampling rate and cycle time: how fine does the recording need to be?

A controller works cyclically: it reads the inputs, executes the program and writes the outputs. It does not see what happens between two cycles. This leads to a simple rule: a recording in the controller cannot resolve more finely than the cycle time of the task in which the signals are processed. If you are looking for a two-millisecond pulse, you may not find it at all in a task with a ten-millisecond cycle time.

For recording, this means: record in the task in which the relevant logic runs, if possible, and at its cycle time. Coarser sampling saves memory but can swallow exactly the short events you are looking for. For very fast processes on drives or measuring devices, many devices offer their own recording functions with a finer resolution than the controller.

Delays along the signal path also need to be considered: input filters, the fieldbus cycle and the update of the process image shift signals relative to reality. For most troubleshooting this is irrelevant, as long as it is taken into account when interpreting the data. When a few milliseconds matter, these delays belong explicitly in the analysis.

  • Know the cycle time of the task involved and use it as the sampling rate
  • Compare signals from different tasks directly only with caution
  • Use the recording functions of the drive or measuring device for very fast processes
  • Take input filters and bus cycle into account when interpreting results

Triggers: capturing the right moment

A trigger starts or stops the recording when a condition occurs – for example when a fault bit is set, a value exceeds a limit or a step sequence reaches a certain step. What happens beforehand is decisive: with a pre-trigger, a period before the event is retained, and that is usually where the cause lies. A fault reported in a particular cycle often originates a few hundred milliseconds or seconds earlier.

If the fault is rare, the recording should stay armed for a longer period and save a capture every time it occurs. If the tool does not support this directly, a small addition to the program helps: a flag that is set at the event and serves as the trigger, or a ring buffer that holds the most recent values and is frozen when the fault occurs. Such aids should be marked as temporary and removed or documented after troubleshooting.

A common mistake is a trigger that fires too late. Triggering only on the fault message shows the consequences, but not necessarily the cause. A better choice is a condition as close as possible to the suspected cause, combined with a generous pre-trigger.

Data logging for longer periods

If a fault only occurs once a week or a gradual trend needs to be observed, a trace is not enough. In that case, selected values are written continuously to a file or database – directly from the controller, via a gateway or via a higher-level system that collects the data, for example via OPC UA, MQTT or a vendor-specific protocol.

Data logging follows different rules than a trace. Sampling is usually coarser, but the recording covers days, weeks or runs permanently. A combination works well: cyclic recording for slow values and event-driven recording for state changes. Instead of storing “valve closed” every second, only the change is recorded with a timestamp. This keeps data volumes manageable.

Consistent timestamps are essential. Anyone comparing data from several controllers, a drive and a SCADA system has to be able to rely on the clocks matching. Time synchronization of the devices involved is therefore part of the preparation. If logging becomes a permanent setup, for example for traceability or KPIs, it is already a task for a proper connection to databases and downstream systems.

  • Cyclic for slow values such as temperatures or fill levels
  • Event-driven for state changes, steps and fault messages
  • A consistent time base across all devices involved
  • Storage location, retention period and access defined in advance

Analysis: from curve to cause

A recording is only as good as the questions you ask of it. It helps to write down an assumption before starting: what do we think the cause is, and which signal pattern would confirm or refute it? This determines which signals need to be recorded. Besides the fault signal itself, these include the inputs and intermediate states from which it arises, the current step of the step sequence and, where relevant, the operating mode and product.

During analysis, it pays to compare fault-free and faulty runs. Do the order or the intervals of signals differ? Does a feedback signal arrive later than usual? Many tools allow recordings to be saved and overlaid. Exported to a common format, the data can also be analyzed further with a spreadsheet or custom software.

At the end, cause, action and evidence are documented: the recording that shows the fault and a second one that proves it no longer occurs after the change. This makes the fix traceable – including for whoever works on the plant two years from now.

In practice: narrowing down intermittent faults systematically

With intermittent faults, a step-by-step approach usually leads to the goal faster than recording every signal across the board. Our guide to PLC troubleshooting describes what other information a service provider needs to find the cause quickly. If a problem shows up mainly as an unclear or overly frequent alarm, it is also worth taking a look at the alarm concept.

  • Describe the fault: what exactly happens, how often, since when, under which conditions?
  • Check the diagnostic buffer and alarm history for patterns such as time of day, product or operating mode
  • Form an assumption and select the signals needed to test it
  • Set up a trace with a suitable sampling rate and a generous pre-trigger
  • Keep the recording armed until the fault has been captured several times
  • Compare faulty and fault-free runs and prove the cause
  • Implement the change, record again and document the evidence
FAQ

Good to know.

As a rule of thumb, the cycle time of the task in which the relevant logic runs. A recording in the controller cannot resolve more finely than that, and a coarser rate can swallow short events. For very fast processes, drives and measuring devices often provide their own recording functions.

A recording uses memory and processing time in the controller or bandwidth on the connection to the engineering PC. With few signals this is usually not critical; with many signals, fast sampling or heavily loaded controllers, the load should be checked beforehand.

A trace records a few signals with high time resolution over a short period, usually started by a trigger. Data logging writes selected values to a file or database over long periods, but usually at a coarser rate or event-driven.

The fault signal itself, the inputs and intermediate states from which it arises, the current step of the step sequence and context such as operating mode or product. A few carefully selected signals reveal more than a cluttered full recording.
Next step

An intermittent fault with no trace?

Describe the fault, the controller and the programming environment. We look at which recording will help and usually get back to you within one business day.