Share this

Ten methods for PLC analog input filtering!

2026-04-06 03:43:19 · · #1

Ten methods for PLC analog input filtering!

1. Amplitude limiting filtering method (also known as program-based judgment filtering method)

A. Method:

Based on experience, determine the maximum allowable deviation between two samplings (denoted as A).

Each time a new value is detected, the following judgment is made:

If the difference between the current value and the previous value is less than or equal to A, then the current value is valid.

If the difference between the current value and the previous value is greater than A, then the current value is invalid, discard it, and replace it with the previous value.

B. Advantages:

It can effectively overcome pulse interference caused by accidental factors.

C. Disadvantages

Unable to suppress that periodic interference

Poor smoothness

2. Median filtering method

A. Method:

Sample N times consecutively (N is an odd number).

Arrange the N sampled values ​​in order of size

Take the median value as the valid value for this time.

B. Advantages:

It can effectively overcome fluctuations caused by accidental factors.

It has a good filtering effect on the measured parameters such as temperature and liquid level that change slowly.

C. Disadvantages:

It is not suitable for parameters that change rapidly, such as flow rate and speed.

3. Arithmetic mean filtering method

A. Method:

Take N consecutive sample values ​​and perform an arithmetic average.

A larger N value results in higher signal smoothness but lower sensitivity.

When the N value is small: the signal smoothness is low, but the sensitivity is high.

Selection of N value: For general flow rate, N=12; for pressure, N=4.

B. Advantages:

Suitable for filtering signals with general random interference.

Such a signal has an average value, and the signal fluctuates around a certain range.

C. Disadvantages:

Not suitable for real-time control with slow measurement speed or high data calculation speed.

It's a waste of RAM.

4. Recursive average filtering method (also known as moving average filtering method)

A. Method:

Treat N consecutive sampled values ​​as a queue

The length of the queue is fixed at N.

Each time a new data point is sampled, it is added to the end of the queue, and the data point from the beginning of the queue is discarded. (First-In, First-Out principle)

By performing an arithmetic average on the N data points in the queue, a new filtering result can be obtained.

Selection of N value: Flow rate, N=12; Pressure: N=4; Liquid level, N=4~12; Temperature, N=1~4

B. Advantages:

It has a good suppression effect on periodic interference and high smoothness.

Systems suitable for high-frequency oscillations

C. Disadvantages:

Low sensitivity

It has poor suppression of occasional impulse interference.

It is difficult to eliminate sampling value deviations caused by pulse interference.

Not suitable for situations with severe pulse interference.

It's a waste of RAM.

5. Median average filtering method (also known as anti-pulse interference average filtering method)

A. Method:

This is equivalent to a combination of "median filtering" and "arithmetic mean filtering".

After sampling N data points consecutively, remove one maximum and one minimum value.

Then calculate the arithmetic mean of the N-2 data points.

N value selection: 3~14

B. Advantages:

It combines the advantages of two filtering methods

For occasional pulse interference, the sampling value deviation caused by the pulse interference can be eliminated.

C. Disadvantages:

The measurement speed is relatively slow, similar to the arithmetic mean filtering method.

It's a waste of RAM.

6. Amplitude Limiting Averaging Filtering Method

A. Method:

This is equivalent to a combination of "amplitude limiting filtering" and "recursive averaging filtering".

Each new sampled data is first subjected to amplitude limiting.

Then it is sent into the queue for recursive average filtering.

B. Advantages:

It combines the advantages of two filtering methods

For occasional pulse interference, the sampling value deviation caused by the pulse interference can be eliminated.

C. Disadvantages:

It's a waste of RAM.

7. First-order lag filtering method

A. Method:

Take a = 0~1

Current filtering result = (1-a) * current sample value + a * previous filtering result

B. Advantages:

It has a good suppression effect on periodic interference.

Suitable for applications with high fluctuation frequency

C. Disadvantages:

Phase lag, low sensitivity

The degree of lag depends on the value of α.

It cannot eliminate interference signals with a filtering frequency higher than 1/2 of the sampling frequency.

8. Weighted recursive average filtering method

A. Method:

It is an improvement on the recursive average filtering method, that is, applying different weights to the data at different times.

Generally, the closer the data is to the present moment, the greater the weight it receives.

The larger the weighting coefficient assigned to the new sample value, the higher the sensitivity, but the lower the signal smoothness.

B. Advantages:

Suitable for objects with a large pure time delay constant

and systems with shorter sampling periods

C. Disadvantages:

For signals with a small pure time delay constant, a long sampling period, and slow change...

It cannot quickly reflect the severity of the interference currently affecting the system, resulting in poor filtering performance.

9. Debounce Filtering Method

A. Method:

Set a filter counter

Compare each sampled value with the current valid value:

If the sampled value equals the current valid value, then the counter is reset to zero.

If the sampled value is less than or greater than the current valid value, the counter is incremented by 1, and it is then determined whether the counter is greater than or equal to the upper limit N (overflow).

If the counter overflows, the current valid value will be replaced with the current value, and the counter will be cleared.

B. Advantages:

It has a good filtering effect on slowly changing measured parameters.

This can prevent the controller from repeatedly switching on and off or the numerical value on the display from fluctuating near the critical value.

C. Disadvantages:

Not suitable for rapidly changing parameters

If the value sampled during the counter overflow happens to be a noise value, then the noise value will be imported into the system as a valid value.

10. Amplitude limiting and de-jitter filtering method

A. Method:

This is equivalent to a combination of "amplitude limiting filtering" and "jitter reduction filtering".

First limit the amplitude, then reduce the shake.

B. Advantages:

It inherits the advantages of "amplitude limiting" and "shake reduction".

This method improves upon some shortcomings of the "de-jitter filtering method" and avoids introducing interference values ​​into the system.

C. Disadvantages:

Not suitable for rapidly changing parameters

Read next

CATDOLL Rosie Hard Silicone Head

The head made from hard silicone does not have a usable oral cavity. You can choose the skin tone, eye color, and wig, ...

Articles 2026-02-22