Moving Average Filters in PLC and DCS Loops: Noise, Lag, and Validation
Moving-average filters can quiet analog signals while delaying control and alarms. Learn how sample time, window length, input quality, initialization, stack...
A smooth process-variable trend can make a control loop look healthy while quietly delaying the information the controller needs. Moving-average filtering is simple, explainable, and effective against some kinds of noise, but every additional sample in the window changes the loop’s dynamic behavior.
The engineering decision is not whether a filtered trace looks better. It is whether the filter removes measurement noise without hiding real process movement, instrument failure, alarm conditions, or the early evidence of an upset.

A DCS can filter a measurement in several layers, so the complete signal path must be documented.
The calculation is simple; the timing is not
A uniform moving average stores the most recent N samples, adds them, and divides by N. Each new sample enters the window as the oldest sample leaves. If the sample interval is Ts, the filter’s behavior depends on both N and Ts; copying N alone from another controller does not reproduce the same real-time response.
For slowly changing signals, a causal uniform moving average behaves roughly as though the measurement were delayed by half the window. A true step does not appear at full size immediately: the output advances one-Nth of the step as each new sample replaces an old value and reaches the final value only after the window is filled with post-step samples.
That predictable ramp is useful for suppressing random noise but risky in a fast pressure, flow, speed, or protection-related measurement. The PID, alarm, historian, and operator all act on a later representation of the process unless the raw value is also preserved.
Window length must be expressed in time
Ten samples taken once per second describe a very different filter from ten samples taken every 100 milliseconds. Document the sample trigger, task period, window length, effective time span, initialization behavior, and the destination that consumes the filtered value.
Do not assume that the program scan is the sample interval. A function block may execute every scan but accept a new sample only when SampleEnable is true. A DCS control module may also have its own execution period that differs from the I/O update and transmitter update.
Rockwell Automation’s MAVE instruction documentation makes this distinction explicit: NumberOfSamples sets the span, SampleEnable controls when a sample enters storage, and the block reports status for bad input and invalid array sizing.
Periodic noise can be rejected—and misdiagnosed
A moving average has regularly spaced frequency-response zeros. When the window covers an integer number of cycles of a stable periodic disturbance, positive and negative portions can cancel strongly. This is why a deliberately chosen window can reduce repeatable electrical or mechanical ripple.
The result is not universal rejection. If the disturbance frequency changes, the sampling interval drifts, or the signal aliases before it reaches the filter, the cancellation weakens. A smoother trend can also disguise grounding, shielding, impulse-line, sensor, or installation problems that should be corrected at their source.
Before increasing the window, compare the raw signal with an independent reference and examine the noise spectrum or at least its time-domain period. Confirm that the disturbance is noise rather than real process cycling.

The same moving-average principle applies across PLC and DCS platforms, but execution and fault handling are platform-specific.
Moving average and first-order filtering solve different problems
A uniform moving average is a finite-window calculation. Every stored sample has equal weight until it leaves the window. A first-order low-pass filter is recursive: the new output combines the latest input with the previous output according to a time constant.
The moving average gives a finite and visible history, strong rejection at particular frequencies, and a step response that reaches its final value after the window fills. The first-order filter uses little memory and produces an exponential response without the moving average’s periodic notches.
A weighted moving average sits between these choices. Giving newer samples more weight can reduce the apparent delay, but it changes the frequency response and makes the behavior less obvious to maintenance personnel. The weights must be normalized, documented, and tested.
Selection should follow the disturbance and control objective. Use a moving average when a finite window is meaningful or a stable periodic component must be attenuated. Use a first-order filter when an exponential response and a documented time constant fit the loop. Use a notch or another purpose-built filter only when the interference frequency is known and stable enough to justify it.
Avoid hidden filters in series
One measurement can be damped in the transmitter, averaged in an input module, filtered again in PLC or DCS logic, smoothed in the HMI, and compressed by the historian. Each layer may look harmless by itself while the complete chain creates substantial delay.
Build a signal-path record showing the raw electrical input, module scaling and filter, controller filter, alarm source, PID process variable, HMI display value, and historian tag. Decide which consumers need raw, validated, or filtered data. A maintenance diagnostic should usually retain access to the raw measurement even when operators use a filtered display.
Internal links to Honeywell Experion PKS C300 hardware and the ABB PLC series provide platform context, but filter availability and behavior must be checked against the installed controller, software, and execution environment.
Bad-quality data needs a defined response
A moving average must not convert an open circuit, overrange value, stale communication result, or invalid floating-point value into a believable process variable. Store or pass quality separately from the numeric value and define what the block does when quality becomes bad.
Possible strategies include holding the last good filtered value, declaring the output bad immediately, clearing the window, or reinitializing from the first good sample after recovery. The correct choice depends on whether the value drives control, alarming, display, or reporting. It must be visible to operators and downstream logic.
Initialization matters too. Filling an empty array with zeros creates a false startup ramp. Incrementally averaging only the valid samples collected so far avoids the zero bias but changes the effective window during warm-up. Initializing the output to the current valid input gives a bumpless start but initially provides no noise reduction. Choose and document one behavior.
Filtering changes PID and alarm performance
Adding a filter changes the measurement path seen by the controller. A previously acceptable PID tune may become sluggish or oscillatory when additional lag is introduced. Derivative action is particularly sensitive to measurement noise, but filtering the noise and leaving the old tuning untouched is not automatically safe.
After changing a filter, repeat the loop-response test under controlled conditions. Check disturbance rejection, setpoint response, valve movement, overshoot, alarm timing, and the time required to detect a genuine process excursion. Evaluate the loop across normal operating rates, not only at steady state.
Alarm design may need separate raw and filtered paths. A nuisance alarm can benefit from persistence or delay logic, while a protective limit may require faster validated data. Do not solve alarm chattering by silently slowing the control measurement for every consumer.
Implementation and commissioning evidence
For a custom PLC implementation, use a bounded array or circular buffer and a running sum so the calculation replaces the oldest contribution with the newest. Protect the index, define numeric precision, and prevent array-bound faults. If task execution can be interrupted, confirm that the buffer and sum cannot become inconsistent.
Commission with known steady values, a controlled step, bad-quality states, task interruption, sample-enable changes, and runtime changes to the requested window. Compare raw and filtered trends with timestamps on the same scale. Record the observed delay and noise reduction rather than approving the filter because the line looks smooth.
Editorial view: filtering is part of the measurement design, not cosmetic trend formatting. The best implementation exposes raw value, filtered value, quality, sample interval, and window length so another engineer can explain exactly what the controller knew—and when it knew it.
Frequently asked questions
How many samples should a moving average use?
There is no universal number. Choose N together with the sample interval from the noise characteristics and the fastest real event the control or alarm must detect, then validate the resulting delay on the process.
Does a larger window always improve control?
No. It reduces more high-frequency variation but adds measurement delay. Excessive filtering can weaken disturbance rejection, delay alarms, and make a correctly tuned PID appear slow.
Should transmitter damping be disabled?
Not automatically. Document every filter in the signal chain and assign each one a purpose. Avoid stacking undocumented damping and controller filtering that produce more total lag than intended.
What should happen when the input quality becomes bad?
The block should expose bad quality and follow a defined hold, invalidate, or reinitialize policy. A faulted input must not be averaged into a plausible-looking valid process value.
Is a moving average suitable for safety or trip measurements?
Only within a validated architecture that explicitly permits the added delay and diagnostic behavior. Ordinary control filtering should never be assumed to satisfy a safety-function response-time requirement.