Tilt-compensated heading algorithm


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.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

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 

  • This is why I hate magnetic heading...
  • Very true, Mike. Navigating an aircraft solely by compass, as in the early days of trans-Atlantic flight, was an art form and black science. Just because so many folks here are both pilots and technically precise, I'll point out that compass correction cards are required to be in no more than 30-degree increments, and must show calibration in level flight, with the engines operating, and must state whether the calibration was made with the radios on or off. In addition, if an electrical load causes deviation of more than 10 degrees, the card must state which equipment or combination causes this deviation. (from CFR § 23.1547 Magnetic direction indicator). "Swinging the compass" involves lots of taxiing around over the compass rose painted on the ground, with engine(s) roaring and a tiny brass screwdriver in hand. Man, I'm looking forward to getting my hands on a magnetometer for my EasyGlider. Great work, guys!
  • Don't think "oh, these things are horrible, I wish I could just get an aircraft compass and everything would be ok." Aircraft compasses have all the same issues. There's actually a "compensation card" on every one to tell you how many degrees off it is, in 45 degree increments. And the numbers are different when you start the engine and turn on the radios...
  • Hi Ryan: yes, there's the theoretical magnetic variation, and then there is what you sense with your system and the two can be entirely different. I'm curious if you could describe your calibration procedure? I've done some hacks here in my own work, but there's probably a much better or more systematic way compared to what I came up with?
  • Many of the Unmanned vehicles I use at work utilize the World Magnetic Model file from NOAA. While it's better than nothing and a decent starting point, nothing beats calibrating your compass for hard iron offset before your mission. A tanker could be in port a click away and be biasing our compass a few degrees.
  • Developer
    @Curt That's why you calibrate it airborne to get a nice scaled and shifted mag-out.

    -Ryan
  • Interesting, thanks for the notes Curt!
  • tidbit #4 ... spin your model around 360 degrees and plot the hx,hy from your magnetometer. (You may or may not want to depend on your magnetometer for precise heading information after viewing the results.)
  • 07E would make sense in a magnetic variation context ... 7 degrees to the east. This value changes over time. It changes enough that the runways here at MSP were renumbered from 11/29 to 12/30 a couple years back.

    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.
This reply was deleted.