[Microbit-Python] Accelerometer orientation

Radomir Dopieralski radomir at dopieralski.pl
Thu Feb 18 09:31:05 EST 2016


On Thu, 18 Feb 2016 15:13:20 +0100
"M.-A. Lemburg" <mal at egenix.com> wrote:

> On 18.02.2016 13:04, Loop Space wrote:
[snip]


> The values of the meter go from -1024 to +1024.

Actually no, this is not true. The measurements are not normalized,
they just give you the acceleration measured in 1/1000th of a g. Thus,
with it lying flat and not moving you get 1g down.

See https://en.wikipedia.org/wiki/Gravity_of_Earth

> Now, let's assume you are holding the MB horizontally,
> with the LED panel up and the pins pointing to you.
> 
> For the x-axis, it's +1024, if you hold the MB vertically with
> the B button pointing down and -1024 if you hold it in the
> other direction, with button A down. It's 0 if you hold the MB
> horizontally.

It's actually +1000 and -1000. Provided it doesn't otherwise move.
 
> For the y-axis, you get -1024 if you turn the MB up, so that
> the pins point to the sky, 0 when it's held horizontally and
> +1024, when turning the MB so that the pins point down.

Same here.

> The "accelerate" part in accelerometer doesn't seem to
> have much meaning for x- and y-axis, i.e. they don't seem to
> measure acceleration, but instead orientation. Only the z-axis
> appears to actually work in terms of acceleration, since it
> changes its value depending on how you whether the MB up and
> and down.

Of course they measure acceleration. This is the whole point. The thing
is, gravity is impossible to tell from acceleration (Einstein even
claims it's pretty much the same thing), so you end up also measuring
gravity. Which can be used to tell the orientation while you are within
the gravity field of Earth (and not in a free fall).

All axes actually work in terms of acceleration -- you can see that by
shaking the microbit sideways. And you can see you can get much higher
values than 1024.

Maybe we could even make a game that records the highest acceleration.
Then again, maybe not, because then kids would throw it against the
wall...

> I haven't found a good use for the z-axis yet.

All the axes are equally useful. You can use atan2 function to get
actual angle from them.


-- 
Radomir Dopieralski


More information about the Microbit mailing list