Electronic – Discarding divergent sensor data from running average

filtersensorsignal processing

I'm building a inductive vehicle loop detector. By measuring the frequency of a LC-oscillator where the cars will pass over the inductor of the LC-Oscillator.

If the cars pass over the inductor the frequency will change over time according to one of the following profiles.

Frequency over time

The frequency will also slightly change / drift based on environmental variables: like temperature, humidity or other variances in the environment of the loop.
To filter these last variations out, I used running average and std_variation based on: This post/comment on stack exchange. And was planning to detect vehicles when the frequency would go too many standard deviations away from the average.

The measurements made when there is a vehicle present shouldn't be added to the average calculation. This is easy to do when a certain threshold is passed.

But the problem is when a car is approaching the frequency will start to change but hasn't yet passed the threshold so these samples are added to the statistics. When a car approaches very slowly the standard deviation will be changed so much that the car will never be detected.

What solutions / alternatives / suggestions do you have to detect approaching cars and discard the values from the statistics for the reference empty loop.

Thanks in advance


Update

Link to the post in the DSP section

Best Answer

You have built a system that is by design rate sensitive, to allow it to reject large but slow environmental changes. So it is now insensitive to slow target changes, as when a car approaches very slowly.

There is no magic that you can apply to discriminate between these. You have got the classic binary classificiation problem. If you could get a clear measurement difference between your detect and no detect measurements, then you can get 100% success rate with 0% false positives or false negatives. If you have overlapping measurements (which you allow for by having a car approach very slowly) then any rate of change threshhold you set will allow at least one or the other error to occur. A very low threshhold would get falsely triggered by sudden temperature changes, a high threshold will miss slow cars.

You either need to specify the present behaviour in terms of rate threshhold versus false negative and false positive rate, or take some steps to incorporate your knowledge of the system to reduce the allowance you need to make for environmental effects. Perhaps measure temperature, and if it correlates with frequency drift, use this to reduce the allowance you make for it. The ideal system, as used in food metal detection which has to be extremely sensitive, is to use two loops, and detect differentially, however you might not have the freedom to modify the road in this way.