[Microbit-Python] Accelerometer orientation

Damien George damien.p.george at gmail.com
Thu Feb 18 09:10:29 EST 2016


Hi Andrew,

Your analysis is correct.  It seems that the (universally accepted?)
convention for accelerometer chips is that they give a positive
reading on the axis if that axis is pointing *away* from the centre of
the Earth.  With this convention the axis is right handed.

Basically their convention is that "up" is positive, for all 3 axis.
Since gravity is oriented "down" that makes it inverted in your
analysis.

Note that if you were in free space (free fall, no gravity), then the
axis will read positive in the direction you accelerate.

Cheers,
Damien.






On Thu, Feb 18, 2016 at 12:04 PM, Loop Space <loopspace at mathforge.org> wrote:
> Hi all,
>
> Brief intro: I recently got a microbit as part of the initial roll-out to
> teachers.  I've no experience with python, but plenty of experience with
> other scripting languages so using micropython seemed the easiest of the
> various options available to me.  I'm using the mu editor to write and flash
> scripts to the microbit via USB serial link.
>
> So far, so good.
>
> I'm just testing stuff, and was trying to work with the readings from the
> accelerometer.  When the microbit is just resting, that should basically
> tell me what direction "down" is in.  I can use the following script to get
> its values:
>
> from microbit import *
>
> DELAY=100
>
> while True:
>     sleep(DELAY)
>     x,y,z =
> accelerometer.get_x(),accelerometer.get_y(),accelerometer.get_z()
>     print(x,y,z)
>
> Via the REPL interface in mu, I get a stream of values.  As I turn the
> microbit, obviously those values change.
>
> With the microbit essentially flat (leds uppermost), the vector is heavily
> weighted negatively in its z-component (values of the order of -1000).  This
> says that the z-axis goes vertically up from the leds.  By turning the
> microbit, I can find where the other axes point.
>
> This gets to my question.  It would appear that the x-axis runs across the
> microbit with positive x-axis running out towards the B button, whilst the
> y-axis runs from the leds to the pins.
>
> As far as I can tell, that means that the microbit's orientation is
> left-handed as opposed to the almost universally accepted right-hand axes.
>
> Is my analysis right?  Or am I misinterpreting what the numbers from the
> accelerometer mean?
>
> Thanks,
> Andrew
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit


More information about the Microbit mailing list