# Would a digital compass work reliably when installed in a car?

I'm working on a project that needs dead reckoning sensors to combine to GPS readings, and is to be installed under the dashboard of a car. Currently I have an accelerometer and a gyroscope for that.

I'm thinking of getting rid of the gyroscope, since - given it's almost (or completely?) impossible to make sure it is at the axis of the car turns - its readings improve little over what the accelerometer gives. A digital compass would be much more useful, but I'm not sure it'll work OK inside such a big metal body; not to mention the many sources of EM that can interfere with it. And there's no point in shielding it, I'd be shielding away the earth EM field too.

I'm especially worried about making something that appears to work initially, only to have field problems later.

Anyone had similar experiences or information to help me decide?

Gyroscope: I'd have thought that it was worth working on the gyroscope data to see if you can us its known location in the car + car known geometrical performance when turning + what the accelerometers say to interpret the gyro result more appropriately. A "perfect" gyro should give you better results than "perfect" accelerometers. Reality and Murphy will make this less so, but it's still a shame to abandon the gyros.

Magnetometers - aka compass: You'll have problems if you install a compass where it is affected by large items of ferromagnetic material.
Under a car dashboard certainly qualifies as a really bad location.

You can carry out a very low cost test by taking any compass and holding it in various positions under the dashboard (still in sight) and seeing how it changes, Then turn the car 90 degrees and repeat.

Where it matters "real people" perform "compass swinging" to either produce a deviation chart or to make adjustments by the use of either small magnets or pieces of ferromagnetic (usually) metal. (eg Brass is very slightly diamagnetic (~= "anti ferromagnetic") and will also affect the field but much less and oppositely in sense.

If you make a deviation table then it could be adjusted for in software.

They say:

In most cases, these difficulties can be overcome by 'adjusting' the compass. This is the process of placing small magnets around the compass site or of altering the positions of adjustment magnets within the compass body. Traditionally, it has always been considered a task for specialist compass adjusters and beyond the means of the average boat owner.

This is no longer true. With C-Swing, preparing a deviation chart is now simply a question of selecting a suitable shoreside object, entering its true bearing from the chart, then entering its compass bearing as the boat is sailed on a range of headings. With the built-in maths package, headings do not need to be exactly on compass points and, if suitably spaced, as few as 5 are sufficient to prepare a full chart showing deviations at 10� intervals. Furthermore, C-Swing also computes a set of magnetic coefficients and gives guidance on placing corrector magnets and making adjustments.

That sounds hard, and it's not utterly trivial, but a bit of thought about what you are trying to correct for and how external magnets help will show that it's a fairly straight forward process. And, it's likely that intelligence-informed trial and error will allow you to do an OK job. Here are people who do it do it for a living

According to the above page, here are people who didn't do it properly - USS Port Royal grounding in 2009. However, according to Wikipdia report it was not a compass error but a more high tech navigation system error followed by lots of human error that lead to the grounding. I'll leave the picture as it does make the point of what can happen if your navigation system is faulty. Just stay away from coral reefs with your car! :-). (Reef cost them $15M to repair. Ship between$25M & \$40M)

Useful page here

Wikipedia - historical - interesting

They say:

• Diagram of a 19th century binnacle housing a compass. It has two soft iron spheres (Q) to correct for induced magnetization.

Under the dashboard, altough "generic" is IMHO the worst place to put a compass. I can't give you a tech explanation, but I've tried, on at least 10 different cars... results were inconcludent between tests in the same condition.

Eventually, I had to put the compass in the trunk to have consistent readings.

• +1 Thanks, it's nice to know about a real-world case. Could you elaborate more about the anomalies you found? Were they fixed deviations in the compass readings, or was the compass "not turning enough/turning too much" when you changed car orientation? – fceconel Aug 20 '12 at 20:43
• @fceconel in 3 cars, compass simply read a fixed bearing. In every other car, there were deviations from the correct reading. Unfortunately, deviations were not fixed at all. And I've made a deviation table to compensate, but deviations changed with the smallest variation in the test conditions. Speed of vehicle, temperature of the engine, and also time of day. I've had none of these problems with compass sensors put in the trunk. BTW When I've been on vacation in USA, I had a car with a built-in nav. system with magnetic compass. I wondered why the sensor box was in the trunk. Now I know :-) – Axeman Aug 21 '12 at 6:14