I have an accelerometer and I've written a program for it in the ESP32. The program uses a 750sps ADC sampling rate and an accurate 100Hz interrupt for calculations. P.S. The high-pass filter is at 0.5Hz and the low-pass filter is at 10Hz Butterworth filter.

In the video below, I move the accelerometer through a linear slide to a position about 20cm away. Initially, I use a band-pass filter on the acceleration signal and the calculated displacement is very small (actually about 17cm) as seen in waveform chart 1a and program chart 1b. However, if I do not use the high-pass filter and only use a low-pass filter, and use the median to remove the DC trend, the calculated displacement is much closer to reality (actually about 20cm) as seen in waveform chart 2a and program chart 2b.

My question is whether the high-pass filter could cause errors in the calculation after double integration? And if I do not use the high-pass filter, how can I remove the DC trend (gravity offset) in real-time?"

enter image description here

enter image description here chart 1a. enter image description here chart 1b.

enter image description here chart 2a. enter image description here chart 2b.

  • $\begingroup$ That's seems like an obvious answer is: of course a high pass filter will mess you your displacement. It removes the DC component from the doubly integrated acceleration which IS the static displacement. Am I missing something here? I'm surprised you get any non-zero data for the displacement with high pass filtering. $\endgroup$
    – Hilmar
    Feb 7 at 2:06
  • $\begingroup$ I don't know what happened either. I used the filter library from github.com/berndporr/iir1 and applied a 4th order wave. I am also surprised by the results. $\endgroup$
    – leo_0916
    Feb 7 at 10:11


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.