I have a sensor (DRV425) which outputs an analog voltage. The voltage level changes to a lower voltage when the sensor pass an object. Please take a look at the screenshot. It shows the output signal of the sensor after passing 6 objects.
The length of the spikes depend on the velocity of the sensor and I want to measure the time between each of this spikes to calculate the velocity of this sensor. My actual idea is to measure the voltage with an ADC and calculate the average of the signal. But this idea is not very robust against some noise or some kind of peaks in the output voltage. So I´m thinking about some better ideas.
- Does it make sense to use a moving average (exponential moving average) filter on this signal? As far as I know the exponential moving acts as a kind of low pass filter and so I don´t know if this works.
- Does it make sense to average the data points and check if the average changes to detect if the voltage is above a threshold. This can start a counter and I stop it when the voltage is under a threshold to measure the length of the peak? With this I can calculate the time, by knowing the sample rate of the ADC and with the width of the measured objects I can calculate the velocity.