In the field of industrial automation, the analog input filtering techniques of PLCs are often considered an esoteric art. Some veterans even claim that mastering these filtering techniques can make one a "master" in the control world. Today, let's uncover this mystery and look at those filtering methods that veterans call "magic tools."
The following ten filtering techniques can help you effectively combat various interferences, improve signal accuracy, and make your PLC system more stable. Let's dive right in!
1. Limiting Filtering Method Method : Based on experience, set the maximum allowable deviation value (A) between two samples. If the difference between the new value and the previous value is less than or equal to A, it is considered valid; if it is greater than A, it is considered invalid and replaced with the previous value.
Advantages : Good suppression effect on occasional pulse interference. For example, if you are measuring the liquid level and someone suddenly throws a stone into the water, causing splashes, the limiting filtering method will filter out these "invalid data."
Disadvantages : Ineffective for periodic interference and has low smoothness.
2. Median Filtering Method Method : Continuously sample N times (N is an odd number), arrange the sample values in order, and take the middle value as the valid value.
Advantages : Very effective for slowly changing parameters such as temperature and liquid level.
Disadvantages : Not suitable for rapidly changing parameters such as flow and speed.
3. Arithmetic Average Filtering Method Method : Continuously take N sample values for arithmetic averaging. The larger the N value, the higher the signal smoothness and the lower the sensitivity; the smaller the N value, the lower the signal smoothness and the higher the sensitivity.
Advantages : Suitable for signals with random interference.
Disadvantages : Not suitable for real-time control due to slow calculation speed and potential RAM waste.
4. Recursive Average Filtering Method (Moving Average Filtering Method) Method : Treat N consecutive sample values as a queue, with new data entering the tail and old data removed from the head, then calculate the arithmetic average of the queue.
Advantages : Good suppression effect on periodic interference, suitable for high-frequency oscillation systems.
Disadvantages : Low sensitivity and poor effect on occasional pulse interference.
5. Median Average Filtering Method (Pulse Interference Prevention Average Filtering Method) Method : Similar to a combination of median filtering and arithmetic average filtering. Continuously sample N data, remove the maximum and minimum values, and then calculate the arithmetic average of the remaining data.
Advantages : Effectively eliminates occasional pulse interference.
Disadvantages : Slow measurement speed and potential RAM waste.
6. Limiting Average Filtering Method Method : Combine the limiting filtering method and the recursive average filtering method. First, perform limiting processing on the new data, then perform recursive average filtering.
Advantages : Good suppression effect on pulse interference.
Disadvantages : Also has the issue of RAM waste.
7. First-Order Lag Filtering Method Method : Set the parameter a (between 0 and 1). The filtering result each time is equal to (1-a) times the current sample value plus a times the previous filtering result.
Advantages : Good suppression effect on periodic interference, suitable for high-frequency fluctuation situations.
Disadvantages : Phase lag issue and low sensitivity.
8. Weighted Recursive Average Filtering Method Method : An improvement of the recursive average filtering method, assigning different weights to data at different times, with more recent data having higher weights.
Advantages : Suitable for systems with large pure delay time constants, allowing more timely reflection of changes.
Disadvantages : Ineffective for signals with small delay times and slow changes.
9. Debounce Filtering Method Method : Set a filtering counter. Compare each sampled value with the current valid value; if equal, reset the counter to zero. If not equal, increment the counter. If the counter exceeds the limit, replace the current valid value.
Advantages : Good filtering effect for slowly changing parameters, avoiding frequent switching of the controller near critical values.
Disadvantages : Not suitable for rapidly changing parameters.
10. Limiting Debounce Filtering Method Method : Combine the limiting filtering method and the debounce filtering method. First, perform limiting processing, then perform debouncing.
Advantages : Combines the advantages of both methods, improving some of the shortcomings of the debounce filtering method, and avoiding the introduction of interference values into the system.
Disadvantages : Not suitable for rapidly changing parameters.
Through the introduction of these ten filtering methods, it's evident that each method has its unique advantages and disadvantages. Choosing the appropriate filtering method for your system can enhance signal accuracy and extend equipment lifespan. Whether you're a novice or an experienced engineer, you can find tools that meet your specific needs from these filtering techniques.
After all, PLC filtering is akin to equipping your system with "noise-canceling headphones," allowing you to hear clear "signal sounds" amidst industrial noise.