Magnetometer Guide: Difference between revisions

From Phidgets Support
Line 62: Line 62:
Over long periods of time changes in the Earth's magnetic core have an effect on the Earth's magnetic field.  What this means is that the North Magnetic Pole is not the same as "true" North.  Since compasses measure direction as a function of magnetic field strength, the direction a compass tells you is North is in fact magnetic North.  As you might imagine the amount that magnetic North and true North differ is a function of your location.  It is technically possible for your compass to point in the exact opposite direction from North if you are directly between the North pole and the magnetic North pole.  The most common way to get declination is from a map that has isogonic lines.  Isogonic lines are lines of equal declination similar to contour lines on topographic maps that show elevation.  The lines will give a reasonable approximation of the declination for your region.  For example, take a look at the map below and try to determine what the declination is in your city:
Over long periods of time changes in the Earth's magnetic core have an effect on the Earth's magnetic field.  What this means is that the North Magnetic Pole is not the same as "true" North.  Since compasses measure direction as a function of magnetic field strength, the direction a compass tells you is North is in fact magnetic North.  As you might imagine the amount that magnetic North and true North differ is a function of your location.  It is technically possible for your compass to point in the exact opposite direction from North if you are directly between the North pole and the magnetic North pole.  The most common way to get declination is from a map that has isogonic lines.  Isogonic lines are lines of equal declination similar to contour lines on topographic maps that show elevation.  The lines will give a reasonable approximation of the declination for your region.  For example, take a look at the map below and try to determine what the declination is in your city:


[[File: declination.jpg|1000px|link=]]
[[File: declination.jpg|700px|link=]]


==Glossary==
==Glossary==

Revision as of 17:56, 1 August 2012

Under Construction

Introduction

A compass is a navigational instrument that is used to determine direction relative to the surface of the earth. Compasses measure direction with respect to the 4 cardinal directions (North, East, South, West) with 0 degrees indicating straight North and 180 degrees indicating straight South.

Electronic compasses work in exactly the same way as any other compass: They detect the Earth's magnetic field and respond to it. The difference is that an electronic compass uses a magnetometer to detect the field as opposed to a small magnet. This allows them to be much more accurate and allows them to respond more quickly to changes in direction than a traditional compass ever could.

How Compasses Work

Small compasses found in clocks, mobile phones, and other electronic devices are solid-state compasses, usually built out of two or three magnetic field sensors that provide data for a microprocessor. The correct heading relative to the compass is calculated using trigonometry. Often, the device is a discrete component which outputs either a digital or analog signal proportional to its orientation. This signal is interpreted by a controller or microprocessor and used either internally, or sent to a display unit. The sensor uses highly calibrated internal electronics to measure the response of the device to the Earth's magnetic field.

Basic Use

Compasses are typically mounted on an object that the user wants to monitor the direction of. In order to get the most accurate readings it is recommended to mount the compass to the object in such a way that there is minimal room for shifting. You will need to calibrate the compass as well.

Calibration

Calibration involves setting the compass up to handle the magnetic field characteristics in your particular region of the world as well as disturbances caused by a more localized magnetic fields such as speaker magnets. To calibrate effectively you will need to determine the Earth's magnetic field strength at your location. This data is available on line in the form of magnetic field calculators all you have to do is enter in your zip or postal code.

Calibration is required for any applications needing more accuracy than North, East, South, West.

For more information on calibrating the compass on the 1056 refer to our calibration guide.

Interference

The most common problem compass users can expect to face is interference. Interference will generally cause the compass to behave poorly. Usually this means inconsistent, fluctuating, or inaccurate readings. Luckily most forms of interference are fairly easy to deal with.

What are likely sources of interference and how are they handled?

2 axis magnetic field data with 0 distortion.

There are 4 main categories of interference. Some are easy to get rid of via calibration, others are not easy or even impossible to get rid of.

If you rotate the compass through a full 360 degrees and plot the resulting data on an x-y plane you will get a circle centered at the origin. This can be extended to a 3 axis compass which would generate a sphere. However, certain characteristics of the vehicle and environment can have a distorting effect on this magnetic data often in combination with one another to create significant interference. In fact the magnitude of the interference is regularly many times the that of the actual signal.

"Hard Iron" Interference

Magnetic field with hard iron distortion

So called hard iron interference is caused by static magnetic fields associated with the vehicle. This can include any minor (or major) magnetism in the metal chassis or frame of the vehicle, any actual magnets attached such as speakers etc... This interference pattern is unique to the vehicle but is constant. If you have your compass in an enclosure that is held together with metal screws even these relatively small amounts of ferromagnetic material can cause issues. If we consider the magnetic data circle, hard iron interference has the effect of x/y(/z in the case of 3 axes) shifting the entire circle away from the origin by some amount. The amount is dependent on any number of different factors and can be very large. The important part is that this shift is the same for all points in time so it can be calibrated out very easily with a numeric offset which is taken care of by the calibration process.

"Soft Iron" Interference

Example of soft iron distortion
Magnetic field with soft iron distortion

Soft iron interference is caused by distortion of the Earth's magnetic field due to materials in the vehicle's construction. Think of it like electricity, the magnetic field is looking for the easiest path to get to where it is going. Since magnetic fields can flow more easily through ferromagnetic materials than air, more of the field will flow through the ferromagnetic material than you would expect if it were just air. This distortion effect causes the magnetic field lines to be bent sometimes quite a bit. Note that unlike hard iron interference which is the result of materials which actually have a magnetic field of their own, soft iron interference is caused by non-magnetic materials distorting the Earth's magnetic field. This type of interference has a squishing effect on the magnetic data circle turning it into more of an ellipsoid shape. The distortion in this case depends on the direction that the compass is facing. Because of this the distortion cannot be calibrated out with a simple offset, more complicated math will still let the compass account for this type of interference though.


Dynamic magnetic fields associated with application

Most robots and vehicles have all manner of devices running on them other than just the compass. The wiring associated with these devices will create its own, dynamic magnetic field. Particularly bad offenders are electric motors that are running. The magnetic fields of these devices are constantly changing and calibration will only provide small (if any) benefits. The best thing that can be done to avoid this sort of interference is to mount the compass as far away from other electronics as possible.

Static or Dynamic fields not associated with application

These are the most difficult to handle. A very common cause of this sort of interference is steel or iron re-bar in concrete floors. Steel studs in office or commercial buildings are also a problem. In general any environmental (i.e. external) sources of hard or soft iron distortion can cause issues as the vehicle moves about. There is no practical way to account for this. The best thing you can do is to take a simple handheld compass and move it around in the area you intend the electronic compass to be operating. Does the compass report reasonable directions? If so then your system will likely function well. If not, the area is simply too noisy to use an electronic compass.

Combinations

In practical applications most of these types of interference work in combination. Because of all of this, to use a compass calibration is required.

Declination

  • declination map →
  • difference between true north and magnetic north
  • a simple correction factor to fix it
  • Need to explain this image - it's very simple, but non-intuitive.

Over long periods of time changes in the Earth's magnetic core have an effect on the Earth's magnetic field. What this means is that the North Magnetic Pole is not the same as "true" North. Since compasses measure direction as a function of magnetic field strength, the direction a compass tells you is North is in fact magnetic North. As you might imagine the amount that magnetic North and true North differ is a function of your location. It is technically possible for your compass to point in the exact opposite direction from North if you are directly between the North pole and the magnetic North pole. The most common way to get declination is from a map that has isogonic lines. Isogonic lines are lines of equal declination similar to contour lines on topographic maps that show elevation. The lines will give a reasonable approximation of the declination for your region. For example, take a look at the map below and try to determine what the declination is in your city:

Declination.jpg

Glossary

resolution

  • resolution indicates how fine of a change in the magnetic field the magnetometer is capable of reading. in the case of the 1056 it is 400μG minimum. this means that any change in magnetic field smaller than 400μG will not get measured.

offset from north

  • Offset from north is only valid on a compass that has been well calibrated.
  • This figure assumes a long term measurement - so noise has been greatly reduced / averaged out.
  • Offset from North error comes from non-linearities in the compass, and each axis in the compass being somewhat sensitive to magnetic fields aligned with other axes.
  • There is very little that can be done to reduce this error.


declination

Declination.jpg
  • declination map →
  • difference between true north and magnetic north
  • a simple correction factor to fix it
  • Need to explain this image - it's very simple, but non-intuitive.

Measurement Range

  • Maximum field strength (in gauss) that the compass can measure. Note that hard iron offsets can be calibrated out, but they will still reduce the range of the sensor, as the earth's magnetic field is pushed away from the center. (May be could use a simple image).

Noise

  • This will be a graph of noise (in gauss, std. deviation) compared to sample rate.
  • Could also be allen deviation graph

Sample (Data) Rate

  • This is set for the entire PhidgetSpatial
  • The compass is not able to provide data at this rate
  • Do not forget that the primer is not here to describe individual products.

units

  • occasional confusion, people use gauss and tesla interchangeably in the application of magnetometers. 1 tesla is 104 gauss.

Use Within Code

  • Mention how atan() and atan2() are different when using trigonometry in your code, and how they get used. I.e. atan() is the mathematically correct atan, which goes from -90 to 90 degrees. The function atan2() was developed because humans don't think this way, they think in a whole circle from 180 to -180 degrees. So atan2() takes the signs of the two arguments into account to figure out the quadrant.

How to calculate bearing

  • currently we only show how to calculate compass heading in the C# examples.