How to calculate the value of the smoothing parameter for lowpass filter (in case of smoothing of compass sensor data)

StackOverflow https://stackoverflow.com/questions/20777726

Question

I want to smooth the compass sensor data of a smartphone using the low pass filter and want to calculate the smoothing parameter for the low pass filter implementation.

I have a question concerning one of the question/post available on this forum

In the above post, author wants to smooth the sensor data using low pass filter and suggested to set the smoothing parameter (ALPHA) according to the needs. The smoothing parameter should lie between 0-1. The value near to 0 is smooth in the data.

Therefore, the author used the ALPHA = 0.15.

According to my opinion and scientifically one can not do this by closing the eyes and picking a random value from 0 to 1.

So my question is how to calculate the smoothing parameter (ALPHA), while my sampling rate is 100Hz. According to my opinion this smoothing parameter is different for different sampling rate. Therefore the guess or analysis of the smoothing parameter will not work in real time.

Therefore, I am looking for how to calculate the smoothing parameter for low pass filter. In this regard, I have seen this interesting presentation

On page 13 one can see the formula to calculate the smoothing parameter if one know the Time constant(Tau)

The formula to calculate the Tau= Capacitance * Resistance

from the data sheet of the electronics compass AK8974, I have calculated the Resistance and capacitance and calculated the (Tau)

knowing the Tau let easily calculation of the smoothing parameter using the following formula

ALPHA=Tau/Tau+deltaT

The value of ALPHA in my case is (0.00714)

I want opinions about the calculation of the time constant (Tau) and smoothing parameter. Is this the correct way to do justify the smoothing parameter? Is there any other way?

No correct solution

OTHER TIPS

According to my opinion and scientifically one can not do this by closing the eyes and picking a random value from 0 to 1.

Maybe, maybe not. Tuning a smoothing filter is usually an empirical task, you pick a value that works "well enough" in practice. You're trading-off smoothness of result against speed (i.e. ability to respond quickly to changes in the input).

On the other hand, if there is a specific time-constant you're aiming for, then yes, just use that! *

You can analyse the filter expression to determine its frequency response. However, that basically requires the discrete-time Fourier transform (and maybe the Z transform as well). That's a little out of the scope for a Stack Overflow answer, I'm afraid!


* However, I'm not sure what you read from that datasheet that led you to believe that that particular value of tau is what you should be using...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top