Tutorial on Filters in Control Systems
What is a Filter?
In a modern control system, a filter is an algorithm (or function block) used mainly for the reduction of noise on a process measurement signal (Figure 1). But that is not its only use as we will see later.
Figure 1. Noise filter.
Types of Filters
Control systems generally provide first-order lag and/or moving-average filters. A few control systems provide higher-order filters. The different types of filters are briefly discussed below.
First-Order Lag Filter
The most common type of filter is the first-order lag filter of which the output approaches the value of the input in an exponential way over time (Figure 2). This is also called a low-pass filter because high-frequencies (fast changes) are attenuated and low-frequencies (slow changes) are passed through. This makes the first-order lag filter ideal to reduce the noise component in a process measurement signal because noise tends to be of higher frequency than process changes.
The time constant of a first-order lag filter is the time it takes for its output to change 63.2% of a sustained change on its input (Figure 2).
Moving-Average Filter
Another type of filter is the moving average filter. This type of filter stores a number of samples in a first-in-first-out buffer. On every execution cycle a new value from the filter’s input is stored in the buffer and the oldest value is discarded. The filter then calculates the average of all the stored values, which then becomes the new output of the filter, as depicted in Figure 3.
The output of a moving average filter approaches the final value linearly and then comes to an abrupt stop, as opposed to a first-order lag that approaches the final value exponentially (Figure 4).
Higher-Order Filters
Higher-order filters consist of multiple lags and leads arranged in a specific way to provide a steeper cut-off or just filter out specific frequencies (such as 60 Hz). Although these filters are much more common in the electronics industry, some control systems also provide at least a subset of them. Higher-order filter types include low-pass, band-pass, notch, and high-pass (although the latter would be very uncommon in process control applications.
There probably are situations in which the use of higher-order filters would be preferable over simple first-order lag filters, but for most cases in general process control, first-order lag filters are adequate for smoothing noisy process measurement signals.
Since higher-order filters are rarely used in control loops, I will not delve deeper into their design and application here.
Should I Use a First-Order or a Moving-Average Filter?
If you have a choice, do not use a moving-average filter for smoothing a noisy process measurement. A first-order lag filter is better suited for smoothing out noise. The reason is as follows: With a first-order lag filter, newly sampled values contribute more to the output than older samples – the newest value contributes the most and the contribution of older samples decreases exponentially over time. With a moving-average filter, all values in the buffer contribute equally to the output.
If there is a spike on the input of a moving-average filter, its contribution stays unchanged until it suddenly disappears when the value drops off the buffer. With a lag filter, the contribution of the spike will wane over time.
Filter Applications
There are three main applications for filters in control systems. These are discussed below.
Noise Filter
Also called a smoother, noise filters are used to smooth out high-frequency noise from a process measurement signal as depicted in Figure 1. These filters are commonly applied to flow-measurement signals, because of the tendency of these signals to have a substantial noise component. A first-order lag filter with a time constant of two to three seconds is normally sufficient for a flow control loop. Longer time constants may be used if needed, but be careful that the filter does not become the dominant lag in the loop.
Some level measurements can also have a large noise component, e.g. where boiling or liquid-gas separation affects the level. Level controllers (except on steam drums and surge tanks) often require a high controller gain, making the controller output very sensitive to noise. In these cases filters with longer time constants (e.g. 10 to 20 seconds) may be required.
An appropriate filter time constant (Tf) can be calculated as follows:
Tf = (Amplitude of Noise) / (Desired Amplitude after Filtering) * (Period of Noise) / (2 x PI)
Where PI = 3.14 and the period of the noise can be determined by counting the number of peaks in a signal over one minute, and then inverting this number, i.e. use 1/x. The equation above will then give you the filter time in minutes. Convert this number to seconds (multiply by 60) if your control system uses seconds as the time unit for filters.
Note that adding a filter in a control loop or changing the filter’s time constant changes the dynamic behavior of the control loop. This requires retuning the controller to accommodate the loop’s new dynamics. Also, use the minimum filtering possible, because a filter introduces lag which will likely result in a slower-performing control loop, and it may hide process problems.
Anti-Aliasing Filter
In process control, anti-aliasing filters are used on analog input signals to remove high-frequency components from the signals before they are sampled by the digital control system. This is done to prevent aliasing problems in which high-frequency components in the original signal appear as low-frequency aliases after sampling by the control system. YouTube has some nice videos demonstrating aliasing. Anti-alias filtering must be done in the transmitter, i.e. before the analog signal is sampled by the A/D converter in the control system’s input module.
The anti-aliasing filter should provide a minimum of -12 dB of attenuation at the Nyquist frequency, but preferably more as explained in a 1994 paper by EnTech. This can be provided by a first-order low-pass filter with a time constant set to at least 1.3 times the slowest sampling period. For example, if the input card samples the analog inputs at a rate of 1 sample per 500 milliseconds, and the controller execution interval is 1 second, a minimum filter time constant of 1.3 seconds should be used.
Setpoint Filter
A setpoint filter passes the control loop’s setpoint through a first-order lag filter before the controller receives the signal. A setpoint filter can be used to reduce or eliminate overshoot on control loops that receive operator-made setpoint changes. This will mostly apply to lag dominant processes that have been tuned for fast disturbance rejection. It can also be used to reduce the amount of abrupt control action as a result of the setpoint change. (However, my preferred solution in both cases is to apply the proportional and derivative modes only on the process variable instead of on error, if the control algorithm supports this.)
Control guru Greg McMillan recommends that the setpoint filter’s time constant be set equal to the integral time in the controller, or 1.5 times the integral time if the controller is tuned more aggressively for minimum settling time.
Setpoint filters should never be used in control loops that are required to closely track their setpoints (such as in cascade, feedforward, and ratio control) because it slows down the controller’s response to setpoint changes.
Final Words
Filters are handy devices in control systems and have multiple uses, the main one being to reduce the noise component on measurement signals. Only use filters when needed, and then as little filtering as possible. And remember that a filter alters the dynamic response of the loop (except for setpoint filters), so the controller has to be retuned after a filter’s time constant has been changed.
Jacques Smuts
Founder and Principal Consultant of OptiControls Inc.
Author of Process Control for Practitioners
Hey Jacques, great article thanks but I do have one question regarding your formula for determiing a time constant of a filter to achieve a desired attenuation. One of the variables is the period of the noise so what would I use there when the noise is white noise with no specific period as we would see on many loops such as flow and even many level loops. Thanks Graham
Graham – The period of the random noise can be determined by counting the number of peaks in the PV signal over one minute, and then inverting this number, i.e. use 1/x for period in minutes.
Hey Jacques, thanks for this article.
Other than First order filter , where you have explained that the out reaches 63.2% in Tf (filter constant) ( and corelating with other articles where i saw a number that in 5xTf , output reaches 99.3% of final value.)
Is there any other Lag filter that delays the output exactly by the filter time , i.e. a lag filter where filter constant will give 100% of final value after Tf>?
AUR: A lag is an exponential function that (in theory) never exactly reaches 100% of a change in input. So the short answer is no. A moving-average filter and a pure delay will reach 100% after the specified time, but they are technically not lags.
[…] wear and possibly to large process disturbances too. (Note that this can be alleviated by using a process variable filter if the frequency of the noise is high, with the downside being a slowdown in loop […]