I looked through lots of questions, but I didn't find a suitable answer for the project I'm working on. The project can be thought of as a simple control box, water valve, and scale.
The mcu control board inside the valve receives a binary on/off signal to control the flow. The mcu control board inside the scale has an ADC which interfaces with a load cell, and it sends the digital reading over a long shielded cable. The scale control board has appropriate lowpass filters and proper shielding, so the ADC readings themselves are very clean.
My problem has been infrequent spikes in digital readings. I believe it is due to the noisy environment the cable is routed through, and inductive spikes in the cable. The digital communication is simply using GPIO pins with a driver/buffer chip on each end of the cable.
My initial approach was to keep a 5 frame rolling average, and reject a reading if it is outside the mean of the readings +/- a predetermined value. This had issues with the third graph shown being entirely rejected, and didn't account for increases in flow rates. I was considering using a calculated flow/delta rate as the threshold, but decided to see if a better solution exists before trying to reinvent the wheel. The main controller needs to retain a good time response to shut off the valve accurately, and the ADC is selectable to be 10 or 80 samples per second.
I am wondering if anyone has encountered a similar problem and fixed it with a simple solution. All I need to implement is a way to throw out signal readings if it is a temporary spike, but keep the readings if it remains high. I am partly asking in case someone in the future searches the internet and finds this question.
Here are some graphs which demonstrate:
This is a typical operating cycle. Valve turns on, and when the reading hits the fill threshold (blue), it turns off.