Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Accelerometer

Status
Not open for further replies.

beakie

New Member
OK,

I don't think my question (https://www.electro-tech-online.com/threads/processing-accelerometer-data.116380/) was clear enough. So here it is rephrased.

I get 0-255 for X, Y and Z from the Chronos EZ430.

When I line up X and Y and keep the watch static, I get 80 for Z... therefore the value for gravity must be 80.

So I divide these values by 80 which gives me a total of 1 when I add up X, Y and Z.

I have created an windows application with a projection of a 3D object which I intend to represent the rotation of the watch on.

To work out the angles (degrees) for X, Y and Z to do this rotation, I do the following.

x = (Math.Asin(X) / Math.PI * 180)
y = (Math.Asin(Y) / Math.PI * 180)
z = (Math.Asin(Z) / Math.PI * 180)


The 3D object moves almost as I would expect but there are clear bugs in my working out of these angles.

The code for the 3D object is very much proven and I use it in many other bits of code. So what is wrong with the above please?
 
To determine the effect of gravity, orient any given axis upwards, then turn the device over, and divide the difference in readings by two. For example, if +Z reads 80, and -Z (180 degrees from first position) reads 60, the difference is 20, so 2g causes a Δ reading of 20 counts, so 1g is 10 counts.
 
To determine the effect of gravity, orient any given axis upwards, then turn the device over, and divide the difference in readings by two. For example, if +Z reads 80, and -Z (180 degrees from first position) reads 60, the difference is 20, so 2g causes a Δ reading of 20 counts, so 1g is 10 counts.

I did this and got 76.5 which seems reasonable. When I rotate the object with the watch now it seems better.



The way the object moves now gives me the impression these sums are the issue. Ummmmm

OK,

To work out the angles (degrees) for X, Y and Z to do this rotation, I do the following.

x = (Math.Asin(X) / Math.PI * 180)
y = (Math.Asin(Y) / Math.PI * 180)
z = (Math.Asin(Z) / Math.PI * 180)
 
Last edited:
The way the object moves now gives me the impression these sums are the issue. Ummmmm

I am convinced that bit is wrong now. This is the graph that I get when I rotate the watch when its laying face side down. No change on X, Y or Z at all!

accoutput-png.51109


Clearly I have misunderstood what I need to do to get a rotation vector from the sampled data.
 

Attachments

  • ACCOUTPUT.png
    ACCOUTPUT.png
    29.7 KB · Views: 395
Last edited:
Clearly I have misunderstood what I need to do to get a rotation vector from the sampled data.

I realise now that because gravity is only acting on one axis, I will only see 1 on that axis and 0 on the rest... so what do I need to do to get the tilt?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top