How to use MPU9150 magnetometer readings

Hello All,

I got one MPU9150 IMU sensor and plan to use the magnetometer data to estimate my vehicle's heading. I have learnt that the full range of the readings is ±1200μT. My questions are:

  1. Have the 3 readings Mag_x, Mag_y and Mag_z been converted into horizontal plane? If so, can I directly get vehicle's heading by calculating arctan(Mag_y, Mag_x)?

If no, does the 3 readings lie in Earth's magnetic field? Thus I can convert them to horizontal plane axis: H1 and H2 by H1=Mag_x*cos(theta)+Mag_y*sin(phi)*sin(theta)+Mag_z*cos(phi)*sin(theta) and H2=Mag_y*cos(phi)-Mag_z*sin(phi)

  1. In addition, does the magnetometer suffer drifts like accelerometer and gyro such that I need develop a filter for it?

Thanks for your help.

Magnetometers do not drift, but they MUST be calibrated. Here are a couple of procedures (the second is far better, but more complicated): http://www.bot-thoughts.com/2011/04/quick-and-dirty-compass-calibration-in.html http://sailboatinstruments.blogspot.com/2011/08/improved-magnetometer-calibration.html

In order to put the magnetometer readings into the horizontal plane, you must determine what that plane is. Use the accelerometer for that. The general approach is very completely described here: http://cache.freescale.com/files/sensors/doc/app_note/AN4248.pdf but there are simpler implementations.