[Microbit-Python] Accelerometer orientation

M.-A. Lemburg mal at egenix.com
Thu Feb 18 13:56:52 EST 2016


On 18.02.2016 18:33, Radomir Dopieralski wrote:
> 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

I'll have to recheck. When I did the experiments with the MB some
weeks ago, those were the values I found (and it was not moving).

>> 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).

Well, I know the term "acceleration" as referring to a change
in velocity (first derivative of the latter). If a mass doesn't
move, velocity is zero and thus acceleration is zero too.

But I see your point: the accelerometer is not measuring
acceleration, it's measuring g-force and then the readings
make sense again. My misunderstanding :-)

> 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'll try that ... uhm, better not :-)

>> 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.

Right... giving me the orientation in space when the MB is
not moving.

Anyways, it does work nicely for x- and y-axis:

https://www.youtube.com/watch?v=PwbfHcnkmNs

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Feb 18 2016)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> Python Database Interfaces ...           http://products.egenix.com/
>>> Plone/Zope Database Interfaces ...           http://zope.egenix.com/
________________________________________________________________________

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/
                      http://www.malemburg.com/



More information about the Microbit mailing list