Perhaps it's some sort of cruel joke we're not in on but everything I've been able to find on the Internet about tilt-compensated headings from magnetometers leads to this paper [warning, it's a PDF]: http://www.ssec.honeywell.com/position-sensors/datasheets/sae.pdf
In it there is an algorithm for tilt-compensation. It's wrong. Here's what it should be: http://gist.github.com/322555
Ryan Beall is the man.
Comments
Hello Tim
I am a student and i am new to Magnetometers
I have been looking for quite a long time for a tilt compensated magnetic equations and i found a lot
Can you tell me how they are derived ??? As i might be using a different axis convention .... Mine is X forward Y left Z down.
Thanks
-Ryan
Google for "World Magnetic Model". I think it is NOAA the publishes a set of coefficients that map out the earth's magnetic field. They also have code there to implement the model. If you feed in a date and location it will compute an approximate magnetic variation for you. The changes in the earth's magnetic field are relatively stable but hard to predict out for too many years, so every 5 years or so they release a new updated set of coefficients.
A random interesting tidbit is that when the FAA installs VOR stations, they are aligned with the local magnetic field at the time of installation. That way when you fly in the 90 degree radial, your compass should read 90 degrees. However, they don't realign the projected radials as the local magnetic variation drifts. If they did realign the stations, then all the intersection points and distances on the charts that reference that station would also need to get changed and that could cause a lot of chaos. The VOR station near me was installed in the 60's and at the time the magnetic variation around here was about 6E, now we are less that 1E (at least according the world magnetic model.)
tidbit #2 ... FlightGear includes the world magnetic model in it's code so it should have a pretty correct idea of the local magnetic varation for where ever you fly.
tidbit #3 ... I included the same world magnetic model code in MicroGear (my open-source embedded autopilot application.) In the configuration file you can specify a set offset (if you know better) or let the system compute the local magnetic offset as soon as a gps fix is established.