Accelerometer filtered values

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
User avatar
kfricke
Posts: 342
Joined: Mon May 05, 2014 9:13 am
Location: Germany

Accelerometer filtered values

Post by kfricke » Tue Dec 30, 2014 1:03 pm

Reading a little into the C code for the accelerometer i wonder if the method 'filtered_xyz()' does work as expected. Surely, the method name does suggest some sort of filtering. It seems that the C code should return a filtered result over the last four calls to this method. Instead it does return the pure sum of the last four calls to this method.

Dividing the result of this method by 4 (the intended filter depth in the C code: FILT_DEPTH) makes the method result a little more comparable to the pure axis readouts. Then the values are in the usual range of -32 to 31.

Of course i could file a bug report for this, but maybe i do simply miss the real use for this method :?

blmorris
Posts: 348
Joined: Fri May 02, 2014 3:43 pm
Location: Massachusetts, USA

Re: Accelerometer filtered values

Post by blmorris » Wed Dec 31, 2014 3:53 pm

This could be considered more of a documentation issue than a software bug. This kind of average is a legitimate way to increase the precision of a measurement; it is also a very simple (though somewhat crude) way to implement a low-pass filter. Of course the sum could be immediately scaled down to the same range as the original inputs, but any precision gained in the sum is lost unless the new average is converted to a float. Just as easy to keep it as an integer, but note the larger scale.
-Bryan

Post Reply