**By Michael Stanley**

*Originally posted on Freescale’s The Embedded Beat Blog*

No, the title does not refer to the forces of good versus those of evil. Nor am I referring to my stance when chopping firewood with an axe. Instead, let’s see if we can straighten out some of the terminology that you’ll hear when people start to talk about sensors. Even folks in the business sometimes get it wrong, so here is my attempt to establish a common language.

**Degrees of Freedom** – AKA DOF, this term gets misused more than any I can think of. It is often confused with “number of axes”, which I’ll discuss below. But if you consult any text on the dynamics of rigid bodies, you will quickly learn that any movement of any rigid body from point A to point B can be characterized as a translation plus a rotation.

It takes six numbers to characterize that movement: change in X, Y, and Z and rotations about X, Y and Z axes. Notice that we’re talking about the minimum set of numbers required to unambiguously specify a given movement. We are NOT talking about the number of sensors required to measure that movement.

So now, let’s talk about sensors. A basic **3-axis accelerometer** returns values for linear acceleration in each of 3 orthogonal directions.

A 3-axis accelerometer returns X, Y & Z acceleration in the sensor’s frame of reference

When you look at the figure, you can immediately see where the terms axis/axes come from. They refer to the sensor coordinate system axes.

There’s an important thing you should consider about accelerometers at rest. When one of the axes associated with the sensor frame of reference is parallel to the gravity vector, as it is in the figure above, you will get no additional information from the other two acceleration numbers. They will both be zero, and you will be unable to tell if the accelerometer is rotated about the axis parallel to gravity.

The next device in our toolbox is the gyro which returns rates of rotation about each of the 3 sensor axes. Notice that I’m talking about *sensor*axes here. As the sensor rotates, so does its frame of reference for the next measurement.

A 3-axis gyro returns rotation rates about each of X, Y & Z axes

A 3-axis magnetometer will return the X, Y & Z components of the ambient magnetic field. This is nominally the earth field for many applications, but may include significant offsets and distortions due to hard/soft iron effects. The magnetometer is subject to the same issue as an accelerometer – if one of the sensor axes is parallel to the ambient magnetic field vector the other two sensor axes will return values of zero. The good news is that since the earth magnetic field and gravity are never colinear, between our accelerometer and magnetometer, we have enough information to figure out the current device orientation, regardless of how we rotate the sensor.

A 3-axis magnetometer will allow you to align yourself with the earth’s magnetic field.

Our 1st three sensors each returned a 3-dimensional vector. But the pressure sensor returns just a single scalar value. As discussed in previous postings, pressure can be used to infer changes in altitude, which adds another source of information when computing vertical locations.

Pressure is our 10th axis.

Combine an accelerometer with a gyro and you get a **6-axis Inertial Measurement Unit, or IMU**.

6 Axis IMU = gyro + accelerometer

Add a magnetometer to an IMU, and you have a **MARG (Magnetic, Angular Rate, and Gravity) sensor**. Add a compute engine to a MARG, and you get an **AHRS (Attitude and Heading Reference System)**.

9-Axis MARG

Add a pressure sensor to a MARG or AHRS, and you get a slightly smarter MARG or AHRS – I haven’t found any standard terms. I simply refer to them as “10-axis solutions”.

A full 10-axis sensor subsystem = accelerometer + gyro + magnetometer + pressure

So remember, use “DOF” when describing motion. Use “axis” or “axes” when describing sensor configurations. And when in doubt, draw a picture.

**References**

- Xtrinsic pressure sensor/altimeter Part 1, Part 2 and Part 3
- Hard and soft iron magnetic compensation explained
- Freescale Magnetic Sensors page
- Freescale AN3461: Tilt Sensing Using Linear Accelerometers
- Freescale AN4246: Calibrating an eCompass in the Presence of Hard and Soft-Iron Interference
- Freescale AN4248: Implementing a Tilt-Compensated eCompass using Accelerometer and Magnetometer

Sensors

*Original post: http://blogs.freescale.com/2012/03/29/degrees-of-freedom-vs-axes/*