1. Limiting filter method (also known as program judgment filter method)
A. Method:
Based on experience, determine the maximum deviation allowed between two samples (set to A).
Every time a new value is detected, make a judgment:
If the difference between this value and the previous value is <= A, then this value is valid.
If the difference between this value and the previous value is > A, then this value is invalid, abandon this value, and use the previous value to replace this value.
B. Advantages:
It can effectively overcome the pulse interference caused by accidental factors.
C. Disadvantages :
It cannot suppress the periodic interference.
Poor smoothness.
2. Median value filtering method
A. Method:
Continuously sample N times (N is an odd number)
Arrange the N sampling values in order and
take the middle value as the current effective value.
B. Advantages:
It can effectively overcome the fluctuation interference caused by accidental factors
. It has a good filtering effect on the measured parameters with slow changes in temperature and liquid level.
C. Disadvantages:
It is not suitable for fast-changing parameters such as flow rate and speed.
3. Arithmetic average filtering method
A. Method:
Continuously take N sampling values for arithmetic averaging.
When the N value is large: the signal smoothness is high, but the sensitivity is low.
When the N value is small: the signal smoothness is low, but the sensitivity is high.
Selection of N value: For general flow, N=12; pressure: N=4
B. Advantages:
Suitable for filtering signals with random interference.
Such signals are characterized by an average value, and the signal fluctuates around a certain range of values.
C. Disadvantages:
Not suitable for real-time control with slow measurement speed or fast data calculation speed. It
wastes RAM
. 4. Recursive average filtering method (also known as sliding average filtering method)
A. Method:
Take N consecutive sampling values as a queue.
The length of the queue is fixed to N.
Each time a new data is sampled, it is put at the end of the queue, and the data at the head of the original queue is discarded. (First-in-first-out principle)
Perform arithmetic average operation on the N data in the queue to obtain a new filtering result
. The selection of N values: flow, N=12; pressure: N=4; liquid level, N=4~12; temperature, N=1~4
B. Advantages:
Good suppression of periodic interference, high smoothness,
suitable for high-frequency oscillation systems
C. Disadvantages:
Low sensitivity,
poor suppression of occasional pulse interference,
difficult to eliminate, sampling value deviation caused by pulse interference
, not suitable for occasions with severe pulse interference,
and wastes RAM.
5. Median average filtering method (also known as anti-pulse interference average filtering method)
A. Method:
Equivalent to "median filter method" + "arithmetic average filter method".
Continuously sample N data, remove a maximum value and a minimum value,
and then calculate the arithmetic average of N-2 data
. Selection of N value: 3~14
B. Advantages:
Combining the advantages of the two filtering methods.
For occasional pulse interference, it can eliminate the sampling value deviation caused by pulse interference.
C. Disadvantages: The measurement speed is slow, and
it is more wasteful of RAM
like the arithmetic average filter method.
6. Limiting average filter method
A. Method:
Equivalent to "limiting filter method" + "recursive average filter method".
Each new data sampled is first limited and
then sent to the queue for recursive average filtering.
B. Advantages:
Combining the advantages of the two filtering methods .
For occasional pulse interference, it can eliminate the sampling value deviation caused by pulse interference.
C. Disadvantages:
It is more wasteful of RAM.
7. First-order lag filtering method
A. Method:
Take a=0~1.
The result of this filtering = (1-a)*this sampling value + a*last filtering result
B. Advantages:
Good suppression effect on periodic interference.
Suitable for occasions with high fluctuation frequency
C. Disadvantages:
Phase lag, low sensitivity.
The degree of lag depends on the value of a.
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, different weights are given to data at different times.
Usually, the closer the data is to the current time, the greater the weight is.
The larger the weight coefficient given to the new sampling value, the higher the sensitivity, but the lower the signal smoothness
B. Advantages:
Suitable for objects with large pure lag time constants
and systems with short sampling cycles.
C. Disadvantages:
For signals with small pure lag time constants, long sampling cycles, and slow changes,
they cannot quickly reflect the severity of the current interference to the system, and the filtering effect is poor.
9. De-jitter filtering method
A. Method:
Set a filter counter
to compare each sampling value with the current effective value:
If the sampling value = the current effective value, the counter is cleared.
If the sampling value <> the current effective value, the counter is +1, and it is determined whether the counter is >= the upper limit N (overflow).
If the counter overflows, the current value will replace the current effective value and the counter will be cleared.
B. Advantages:
It has a better filtering effect for the slowly changing measured parameters,
which can avoid the controller being overloaded near the critical value. Repeated on/off jumps or jitter on the display
C. Disadvantages:
Not suitable for fast-changing parameters
If the sampled value happens to be the interference value when the counter overflows, the interference value will be imported
into the system as a valid value
10. Limiting and de-jittering filtering method
A. Method:
Equivalent to "limiting filtering method" + "de-jittering filtering method"
Limiting first, then de-jittering
B. Advantages:
Inherits the advantages of "limiting" and "de-jittering"
Improves some defects in "de-jittering filtering method" to avoid importing interference values into the system
C. Disadvantages:
Not suitable for fast-changing parameters
The sample program (JKRL) of 10 software filtering methods
assumes that data is read from 8-bit AD (if it is a higher-bit AD, the data type can be defined as int), and the subroutine is get_ad();
1. Limited auxiliary filtering
/* The A value can be adjusted according to the actual situation.
value is a valid value, and new_value is the current sampling value.
The filtering program returns a valid actual value */
#define A 10
char value;
char filter()
{
char new_value;
new_value = get_ad();
if ( ( new_value - value > A ) ( value - new_value > A )
return value;
return new_value;
}
2. Median value filtering method
/* The N value can be adjusted according to the actual situation.
The sorting adopts the bubble method */
#define N 11
char filter()
{
char value_buf[N];
char count,i,j,temp;
for ( count=0;count
value_buf[count] = get_ad();
delay();
}
for (j=0;j
for (i=0;i
if ( value_buf[i]>value_buf[i+1] )
{
temp = value_buf[i];
value_buf[i] = value_buf[i+1];
value_buf[i+1] = temp;
}
}
}
return value_buf[(N-1)/2];
}
3. Arithmetic average filtering method
/*
*/
#define N 12
char filter()
{
int sum = 0;
for ( count=0;count
sum + = get_ad();
delay();
}
return (char)(sum/N);
}
4. Recursive average filtering method (also known as sliding average filtering method)
/*
*/
#define N 12
char value_buf[N];
char i=0;
char filter()
{
char count;
int sum=0;
value_buf[i++] = get_ad();
if ( i == N ) i = 0;
for ( count=0;count
return (char)(sum/N);
}
5. Median value average filtering method (also known as anti-pulse interference average filtering method)
/*
*/
#define N 12
char filter()
{
char count,i,j;
char value_buf[N];
int sum=0;
for (count=0;count
value_buf[count] = get_ad();
delay();
}
for (j=0;j
for (i=0;i
if ( value_buf[i]>value_buf[i+1] )
{
temp = value_buf[i];
value_buf[i] = value_buf[i+1];
value_buf[i+1] = temp;
}
}
}
for(count=1;count
return (char)(sum/(N-2));
}
6. Limiting average filtering method
/*
*/
Refer to subroutines 1 and 3
7. First-order lag filtering method
/* To speed up the program processing, assume the base is 100, a=0~100 */
#define a 50
char value;
char filter()
{
char new_value;
new_value = get_ad();
return (100-a)*value + a*new_value;
}
8. Weighted recursive average filtering method
/* The coe array is the weighted coefficient table and exists in the program storage area. */
#define N 12
char code coe[N] = {1,2,3,4,5,6,7,8,9,10,11,12};
char code sum_coe = 1+2+3+4 +5+6+7+8+9+10+11+12;
char filter()
{
char count;
char value_buf[N];
int sum=0;
for (count=0,count
value_buf [count] = get_ad();
delay();
}
for (count=0,count
return (char)(sum/sum_coe);
}
9 , Anti-bounce filtering method
#define N 12
char filter()
{
char count=0;
char new_value;
new_value = get_ad();
while (value !=new_value);
{
count++;
if (count>=N) return new_value;
delay();
new_value = get_ad();
}
return value;
}
10. Amplitude limiting and de-jittering filtering method
/*
*/
Omitted Refer to subroutines 1 and 9
Previous article:Design of Temperature Detection System Based on ADμC812
Next article:msp430 software installation cracking process
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Transfer-【TWS headphones】Some you really don’t know
- Need help 24V 100mA working current sensorless built-in MOS three-phase brushless motor driver chip
- (A-Current Signal Detection Device) First Prize of Zhejiang Province_Hangzhou Dianzi University
- Is this what the 0 detection is like?
- IAR FOR 430 Failed to re-intialize A possible solution
- Design information for temperature monitoring system
- Speed, frequency, chip instruction set
- The MPU9250 magnetometer ID reading does not get the correct value for the following reasons:
- CircuitPython 6.0.0 Beta 1 released
- Controlling LED brightness under ZSTACK