# Accelerometer g force/vectors

• IMK
I am trying to find the formula fororientation when device is moving. My math is not great and I am just starting out.

#### IMK

Hello,

I was wondering is someone can help me please with the mathematics of forces/vectors and acceleration. Now I realize that I have a good deal to learn on the subject but as I am starting out on this venture the challenge is find the right reference,. Hence I need more than just a little help; so to the problem.

I have an accelerometer that I can read the x, y, z g forces from, and I have record two sets of data that can be found below. The first set is the static, and the second set are reading taken when the device was accelerating. The device is tiled over at 45 degrees around the y-axis thus the orientation of the device is x=45, y=0, z=45 for both sets of measurements.

I can calculate the total g force from the device thus:
sqrt(x*x+y*y+z*z) and the angle of an axis thus by the cos-1 thus 0.7 g = 45 degrees.
Now this works for the static case, but does not work for the dynamic (accelerating) case. I have tried to scale the x, y, z g forces by the total g force but the cos-1 produces an incorrect result as the orientation of the device has not changed..

Can you help?

Static Data acceleromter at rest
------------------------
X | Y | Z |
------------------------
45 | 0 | 45 | Device Orientation
------------------------
0.7 | 0.0 | 0.7 | x,y,z g's. Thus sqrt(x*x+y*y+z*z)=1.0 (Scale=1/1=1)
------------------------
0.7*1 | 0.0*1 | 0.7*1 | Scale each g value thus
------------------------
0.7 | 0.0 | 0.7 | cos-1 eg acos( 0.7 ) = 45
------------------------
45 | 0 | 45 | Degress
------------------------

Dynamic Data acceleromter moved horizontally
------------------------
X | Y | Z |
------------------------
45 | 0 | 45 | Device Orientation
------------------------
1.2 | 0.0 | 0.45 | x,y,z g's. Thus sqrt(x*x+y*y+z*z)=1.28 (Scale=1/1=0.78)
------------------------
1.2*.78| 0*0.78|.45*.78| Scale each g value thus
------------------------
0.93 | 0.0 | 0.35 | cos-1 eg acos( n ) = are incorrect ?
------------------------
21 | 0 | 69 | Degress
------------------------
As the orientation of the device has not changed these angles should be:
------------------------
45 | 0 | 45 |
------------------------

Not sure I can be of any help, but if it is "moving" horizontally, is it accelerating in this direction? I first tared the static measurements off the dynamic ones.

Doing so, I noted that values were twice tha value along the other, suggesting the horizontal angle (arctan=2) with respect to the 2 axes affected. But I truly have no idea of what either one of us is doing. Oh well sorry to have confused the issue.
I have attached a simple txt file with two sets of test data,
set one is the device rotated around the y-axis at 45 degress,
the other is the device laying flat.
So if anyone can figure it out I would be most greatful.

The question is how do I calculate the orientation of the device when it is moving?

Have a good Easter all the best IMK

#### Attachments

• data.txt
2.7 KB · Views: 288
when moving is it free to spin? Big difference in complexity and basically insoluble I believe w/o gyro that can measure angular acceleration, problem is degenerate.

Last edited:

No the device will not be spinning just simply moving from its point of rest in a direction.

Again many thanks for your help, my maths is not great and I have spent a couple of days reading up on this and have not found a formula yet.

All the best IMK

Last edited:
well if it is not free to rotate, you have already done that by using your static data, as the orientation should not change if movement purely translational. Now to get direction of movement, I believe what I suggested was correct, that you must first subtract effects of gravitational field registered with static data, and then look at relations between x,y,z as I did. It suggests acceleration occurred at angle of 60 degrees in x-z plane.

Last edited:
denverdoc, again many thanks.
I must have mist somthing in your 1st post, I am just on my way out now so I will look at it again on my return.

Many thanks IMK

no problem, I'll be around off and on most of the day.

Hi,

Is anyone still around from this old post?