Search code examples
androidaccelerometerlowpass-filter

low pass filter android accelerometer measurements for given cut off frequency


I was reading a research paper which deals with gait monitoring using android accelerometer sensor data values at 50 Hz. It uses a low pass filter to filter the noise with a cut-off frequency of 8 Hz.
This is the pseudo code for Low Pass Filter i got from wikipedia:

for i from 1 to n
   y[i] := y[i-1] + α * (x[i] - y[i-1])

how should i set the value of α so that this works at 8 Hz.


Solution

  • You can use this formula to calculate alpha.

    α := dt / (T + dt)
    T = 1/fc, dt = sampling interval

    In your case

    dt = 1/50Hz = 0.02 sec ms

    T = 1/fc = 1/8 = 0.125 sec ms

    α = 0.02/(0.02 + 0.125) = 0.137931034

    Take a look at this link for further explanation

    EDIT:

    Units are updated from msec to sec. Thanks to @IR_IR for pointing out this mistake.