A. the median average filter method (also known as the average pulse interference filter method)

B. method: it is equal to “median filter method” + “arithmetic average filter”. Take N continuous data, get rid of a minimum and a maximum value, and then calculate the arithmetic mean of N-2 data. N value select: 3~14

C. advantages: blend the advantages of two filtering methods, it can eliminate impulse interference caused by sampling bias for the occasional pulse interference.

D. disadvantages: measured speed is slow and it is wasting RAM the same as arithmetic average filter.

E. test code

int Filter_Value; void setup () { Serial.begin (9600); / / initialize the serial communication randomSeed (analogRead (0)); / / random seed } void loop () { Filter_Value = Filter (); / / get the filter output value Serial.println (Filter_Value); / / serial output delay (50); } / / Used to randomly generate a current value of around 300 int Get_AD () { return random (295, 305); } / / Median average filtering method ( also known as anti- pulse interference average filtering method ) ( Algorithm 1 ) # define FILTER_N 100 int Filter () { int i, j; int filter_temp, filter_sum = 0; int filter_buf [FILTER_N]; for (i = 0; i <FILTER_N; i + +) { filter_buf [i] = Get_AD (); delay (1); } / / Sample values in ascending order ( Bubble Act ) for (j = 0; j <FILTER_N - 1; j + +) { for (i = 0; i <FILTER_N - 1 - j; i + +) { if (filter_buf [i]> filter_buf [i + 1]) { filter_temp = filter_buf [i]; filter_buf [i] = filter_buf [i + 1]; filter_buf [i + 1] = filter_temp; } } } Averaging / / remove the maximum and minimum extremes for (i = 1; i <FILTER_N - 1; i + +) filter_sum + = filter_buf [i]; return filter_sum / (FILTER_N - 2); }

## Leave a Reply

You must be logged in to post a comment.