# Interpreting magnetic compass pitch and roll

1. Jul 19, 2011

### BobbyBear

Hello all,

I have a PNI TCM2 electronic compass module, which has a 3-axis magnetometer and a 2-axis tiltmeter (manual: http://www.mil.ufl.edu/projects/gnuman/spec_sheets/tcm2_man.pdf" [Broken]), and provides heading with tilt compensation.

The module also provides "pitch" and "roll" measurements. What I can't figure out is exactly what it is reporting as pitch and roll. The manual gives the following information (section 3.11 of the manual):

"The TCM2 uses a fluid-filled tilt sensor to measure the orientation of the compass with
respect to gravity. Since the compass also measures the complete magnetic field, the
TCM2 can correct for the tilt of the compass to provide an accurate heading.

You can use the tilt data output by the TCM2 to calculate the orientation of the TCM2 with
respect to the level Earth coordinate frame. Define a vector G that is perpendicular to the
compass board (and therefore is parallel to the z-axis of the compass.) The coordinates
of G = (X, Y, Z) in the level Earth frame will be

Z = (SQRT(1 + tan(P)2 + tan(R)2))-1
X = Z tan(P)
Y = Z tan(R)

where P and R are the pitch and roll reported by the TCM2. ​

I don't understand where these equations come from - are they simplified equations? And anyway, how do you determine the orientation/attitude of the compass module.. and which is the (X,Y,Z) system (presumably X and Y axes form a horizontal plane as its the level earth system, but is x the horizontal projection of X? Are P and R ("pitch" and "roll" values given by the compass module) the angles of the module's x and y axes w.r.t the horizontal plane (the x and y axes being the local axes of the compass that coincide with X and Y when the compass is horizontal) ? But wouldn't the tilt sensor measure, for example, the angle between the x axis and the horizontal line contained in the xz plane (which is not the same as the angle between the x axis and the horizontal plane)?

If anyone has any idea on what P and R are please help, I've never used a compass before so maybe I'm missing something evident.

Thank you!

Last edited by a moderator: May 5, 2017
2. Jul 21, 2011

### viscousflow

-Lay the module flat
-Choose your X and Y axes, (Roll and Pitch respectively) The orientation of the module doesn't matter, as long as you choose one as x and the other as Y

The equations you have are a basic matrix transformation. To prove this to yourself set up a three axis system, place an arbitrary vector and derive its X,Y and Z components.

3. Jul 21, 2011