Signal conditioning in the PLC: debounce, filtering, validity

Practical handling of raw signals before they reach control logic: debouncing contacts, filtering noisy analog values, validity checks and substitute values.

Debouncing digital inputs

Mechanical contacts bounce for a few milliseconds; level switches flicker on waves. Use an on/off delay:

tOn (IN := RawLevelHigh,     PT := T#2S);
tOff(IN := NOT RawLevelHigh, PT := T#2S);
IF tOn.Q THEN LevelHigh := TRUE; ELSIF tOff.Q THEN LevelHigh := FALSE; END_IF;

Many input modules also have configurable hardware input delays (e.g. 3 ms) — enough for contact bounce, not for waves.

Filtering analog values

First-order (exponential) filter, executed in a constant-time task:

(* Tf = time constant, Ts = task cycle time *)
Alpha := Ts / (Tf + Ts);
Filtered := Filtered + Alpha * (Raw - Filtered);

Filtering adds delay — do not filter a signal used in a fast control loop more than necessary, and never filter a value for a safety function. Analog modules usually offer hardware smoothing too.

Validity before use

CheckExample
Module status / overflow codesSiemens 32767 / −32768 → invalid
NE 43 failure currents≤ 3.6 mA or ≥ 21 mA → sensor failure
RangePressure below −1 bar(g) is impossible
Rate of changeLevel cannot jump 2 m in one second
Redundant comparisonTwo transmitters differ by more than tolerance

Carry a quality bit with every important value, show it on the HMI, and decide what the logic does when the value is bad: hold last value, use a substitute value, stop the equipment.

Loading the map…

Sources

  1. SIMATIC S7-1500 Analog value processing — Function Manual 06/2014 — Siemens AG
  2. IEC 61131-3:2025 Programmable controllers — Part 3: Programming languages — IEC

Updated 2026-10-02