LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get rotation in axis X and Y in 3 axis-accelerometer

Solved!
Go to solution

Hello,

I am using accelorometer with +/-4g and 25hz resolution configuration.

I did one test starting with standing position, rotatiing 90º to face up position and rotating again 90º to vertical inverted position and 90º more to face down position.

In graph I see the gravity in each position.

 

In the first position i see +1g since the X-axis is on gravity axis.

Second position. the -1G since Gravity is on -Z axis

....

....

 

I trying to get the angle or rotation (pitch and roll) of device. I trying to do the arctan and arccos with 

 

R = SQRT( Rx^2 + Ry^2 + Rz^2) and 

 

cosX = cos(Axr) = Rx / R
cosY = cos(Ayr) = Ry / R
cosZ = cos(Azr) = Rz / R

 

But I dont get any angle. I dont know what I am doing wrong.

I would like to view like in this example found on forum: http://forums.ni.com/t5/LabVIEW/Rotate-an-object-around-multiple-axes/td-p/3040927

Thanks,Fred.

0 Kudos
Message 1 of 4
(4,152 Views)
Solution
Accepted by Fonsi

Fonsi, pitch and roll is generally defined in the x and y axis, so I'm a bit confused as to why you only rotated your accelerometer on the y-axis (only did pitch operations) such that you only had changes of reading in the x and z axis.  The indicator you label as arctan(x) I believe is your roll, and it is given in radians, so you will have to convert that to degrees if you want degrees... your roll doesn't really change throughout all the orientations you went through since you only changed your pitch. 

Here's an image to let you know what axis I'm corresponding to what operation:  https://developer.valvesoftware.com/w/images/7/7e/Roll_pitch_yaw.gif

I don't see in your code where you calculate your pitch.  I added some operation to calculate the pitch, and it seems reasonable for the final state that your accelerometer is in. 

You might find this guide useful, especially page 10 and eqn 28 and 29 seem to be what you are using and need.

Message 2 of 4
(4,110 Views)

Thanks Kelle,

You are right. It was the radians, i wanted have it on degrees. In vi example, i put 2 inputs, 1 was the vertical rotation and 2 was horizontal.

Now the angles are ok and I can see the movement.

Thanks for help!.

Regards,

0 Kudos
Message 3 of 4
(4,068 Views)

You're welcome, Fonsi.  Glad that I could help you out!

0 Kudos
Message 4 of 4
(4,048 Views)