I am reading a sensor that gives data. Sometimes some data is false. I can store some samples before and I would like to detect a glitch on the fly.
Process :
- Values are integers (distances in centimeters)
- I get distances from a sensor (~ 200Hz)
- The distance read is not always correct, and have outliers
- There can be up to 10% outliers
- Typical values are [100;2000]
- The standard deviation is about 2
- The process is dynamic up to 150/s
- The measurements follow a gaussian curve (if static)
- Typical outliers are [0;20] U [950;1200]
I need to filter the measurements on the fly to be sure to get at least 100Hz.
I first thought of a Kalman filter, it would be working well if I didnt have the outliers. Indeed, there is no correlation between those and the true value (Communication problems/or bug). The outliers do not carry data at all.
I would like to filter outliers before passing data into the Kalman filter and get more precise values.
Is there a simple way to implement it on a microcontroller? I do not need the solution done in C, I can implement it. What I need is inspiration! :D