PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
// get an ADC conversion, and smooth it using a Kalman filter:
/* pseudocode:-
X[n] = (K.Z[n]) + ((1 - K).X[n-1]) , or
X[n] = ((Z[n]) + ((F - 1).X[n-1])) / F , where
X[n] = new result
x[n-1] = previous result
Z[n] = current new value
K = Kalman gain factor (0 < K <= 1)
F = Kalman filter Factor (= 1/K, F >= 1)
note : to avoid integer-rounding errors (usually rounded-down)
the best method is to add (0.5 x the denominator) to the
numerator, before performing the division. This then gives
a result that is rounded to the nearest integer. This method
works most efficiently when F is an integer-power-of 2 :-
X[n] = ((Z[n]) + ((F - 1).X[n-1]) + (F / 2)) / F
*/