Electronic – Simple low pass digital filter implementation for non-uniform sampling

digital filterlow passrandomsampling

I have a system sampling an analog input and I want to filter that value using a simple, first order filter. EG something of the form:

Yn = A*Xn + B*Yn-1

However I have no control over the underlying process and the sampling period is non-uniform, and varies (randomlyish) somewhere between 25ms and 29ms. In addition I want to use a 30 minute time constant, and can't keep a running buffer of 72,000 sample values.

Given that a typical filter implementation requires a uniform sampling period, is there any simple algorithm that takes into account the time difference between Yn-1 and Xn? (which I guess really means a time varying version of my "constants" A and B)


Note that I'm inclined to simply take the average sample time over an extended period and using that to calculate my constants, however there is also the possibility of the final system not running at the same average rate as my test system, so I want to come up with a solution that is somewhat adaptable.


answering questions

  1. The filtered signal is being used as a part of a vibration monitoring system in some industrial equipment. It will be used for more of as a qualitative than quantitative purpose.
  2. The customer requirements are 30 minute rolling average for the data.
  3. I have zero control over the sample rate.
  4. And the sample rate varies every second
  5. And the sample rate defines the speed at which my code runs
  6. The final system should run at about the same speed as my test system, however it could be somewhat slower, maybe down to a 35ms rate

Best Answer

You say you have no control over the input sampling rate. That is understood but you are not considering the fact that you can resample once inside your digital system AND, I'm presuming you do have control over that else why would you be asking this question. So, resample your digital data like this: -

enter image description here

Now "real sample" 1 took 25 ms and "real sample" 2 took 29 ms but who cares if you internally resample that data? Yes, you have to process at a much higher rate but it's not like you are having to do major recalculations each time because \$A*X_n\$ is static for 25 to 29 samples.