A. method: it is equal to ” amplitude limiting filter method” + ” eliminate shake filter method ” amplitude limiting first and eliminating shake after
B. advantages: inherit “limiting” and “Xiao shook” the advantages of improved “eliminating mechanically dithered filter method” certain deficiencies, avoiding interference into the system.
C. disadvantages: it is not suitable for quick change parameters.
D. test code
int Filter_Value; int Value; void setup () { Serial.begin (9600); / / initialize the serial communication randomSeed (analogRead (0)); / / random seed Value = 300; } 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); } / / Debounce filtering # define FILTER_N 12 int i = 0; int Filter () { int new_value; new_value = Get_AD (); if (Value! = new_value) { i + +; if (i> FILTER_N) { i = 0; Value = new_value; } } else i = 0; return Value; }...
Leave a Reply
You must be logged in to post a comment.