ASHEP0002

Application Note:
Multipoint Calibration Primer
Introduction
PNI Corporation's Reference Magnetic Sensor Suites are based on patented technology
that delivers breakthrough, cost-effective magnetic sensing performance. The sensors
change inductance with different applied magnetic fields. This variable inductance
property is used in a patented temperature and noise stabilized oscillator/counter circuit to
detect field variations. PNI’s 2-axis RM2000 Reference Magnetic Sensor Suite is
comprised of two Sen-XY magneto-inductive sensors and the 3D MagIC ASIC
controller. The 3-axis RM3000 Suite adds the z-axis Sen-Z sensor.
The Sen-XY and Sen-Z sensors employ a single solenoid winding and consume roughly
an order of magnitude less power than conventional fluxgate or magneto-resistive
technologies. The sensor coil serves as the inductive element in a very simple, lowpower LR relaxation oscillator, with its effective inductance being influenced by the
magnetic field component parallel to the coil axis. The frequency of the oscillation
changes with the magnetic field.
The 3D MagIC outputs a digital signal that can be fed directly into a microprocessor.
This eliminates the need for signal conditioning or an analog/digital interface between the
sensor and a microprocessor. The simplicity of the sensor circuit combined with the lack
of signal conditioning makes the magneto-inductive sensor easier and less expensive to
use in your product design than fluxgate or magneto-resistive sensors.
This primer covers the basics of how to determine heading, calibrate out hard iron
distortions, and perform sensor gain matching for a 2-axis compass built with the
RM2000 Reference Magnetic Sensor Suite. More detailed information regarding how to
implement the RM2000 Sensor Suite and the underlying technology can be found on
PNI’s website. Please refer to the following:
Manuals – “RM2000/RM3000 Reference Magnetic Sensor Suite Manual”
White Papers – “Magneto-Inductive Technology Overview”
Compass Coordinates
+X
Y
X
-Y
+Y
-X
Figure 1
In Figure 1, the +X axis points to magnetic north, while +Y axis points to magnetic east.
With this arrangement the heading is the clockwise angle from the +X axis. We calculate
the angle to the X axis (+X or –X, and not necessarily the heading) as follows:
angle = atan ( Y / X )
The heading calculation depends on the sign of the X and Y values (the quadrant), and is
calculated as follows:
X Value
Y Value
Formula
≥0
≥0
Heading = angle
+X, +Y
(0 – 90)
<0
≥0
Heading = 180 – angle
-X, +Y
(91 – 180)
<0
<0
Heading = 180 + angle
-X, -Y
(181 – 270)
≥0
<0
Heading = 360 – angle
+X, -Y
(271 – 359)
PNI Sensor Corporation
Multipoint Calibration Primer – September 2010
Quadrant
Doc #1001766 r02
Page 2 of 8
Sensor Orientation
For the heading computation to be valid, the following must be true:
The sensors are at right angles with respect to each other and lie perpendicular
with respect to the Earth’s gravity.
By convention, the positive end of the X axis points north and the positive end of
the Y-axis points east. See Figure 2.
Prior to calibration, the compass must be installed into the host system in its
intended operating configuration and in a horizontally level position.
Front
Y
X
Figure 2
Determine Calibration Values
As the title of this document implies, multiple (X, Y) points must be acquired to properly
calibrate the compass. The sensing circuit is composed of the Reference Magnetic
Sensors, the 3D MagIC, external bias resistors, an external clock resistor, and external
capacitors. (Refer to the RM3000/RM2000 User Manual for the recommended circuit
configuration.) Only one sensor can be measured at a time. The user sends a command
byte to the 3D MagIC through the SPI port specifying the sensor axis to be measured.
The 3D MagIC will return the result of a complete forward - reverse measurement of the
sensor in a 24-bit 2’s complement format with a range from -8388608 to 8388608.
PNI Sensor Corporation
Multipoint Calibration Primer – September 2010
Doc #1001766 r02
Page 3 of 8
The sample code below shows how the acquisition phase of the calibration is done.
Acquisition Code
i nt
Xmax , Xmi n, Ymax , Ymi n;
i nt
Xr aw, Yr aw;
/ / wher e y ou s t or e max i mum and
mi ni mum v al ues f or X & Y
/ / v al ues y ou get f r om t he 3D MagI C
/ / The number s her e wi l l be 24- bi t
s i gned v al ues .
/ / Pos i t i v e = 0x 000000 t o 0x 7FFFFF
/ / Negat i v e = 0x 800000 t o 0x FFFFFF
Xmax = Ymax = - 8388608;
Xmi n = Ymi n = 8388608;
/ / s t ar t wi t h l owes t pos s i bl e v al ue
/ / s t ar t wi t h hi ghes t pos s i bl e v al ue
f or ( ; ; ) {
Get RawXY( ) ;
/ / ac qui r e a ( X, Y) poi nt
/ / now s or t i t
I f ( Xr aw > Xmax )
Xmax = Xr aw
I f ( Xr aw < Xmi n )
Xmi n = Xr aw
I f ( Yr aw > Ymax )
Ymax = Yr aw
I f ( Yr aw < Ymi n )
Ymi n = Yr aw
}
The above code results in an infinite loop; it should be modified so the loop stops when
enough points are acquired. Figure 3 below shows a possible graph of acquired points.
500
400
300
200
100
0
-600
-400
-200
0
200
400
600
800
-100
-200
-300
-400
Figure 3
PNI Sensor Corporation
Multipoint Calibration Primer – September 2010
Doc #1001766 r02
Page 4 of 8
The graph in Figure 3 is elliptical with the major axis along the Y axis. The elliptical
nature is due to the Y values having a greater gain than the X values. The center of the
ellipse is also displaced. The next section of code demonstrates how to compute the
calibration values based on the maximum and minimum X and Y values acquired. These
values will later be used to correct the raw X and Y values acquired when computing the
heading.
Calibration Values
i nt
i nt
Xr ange, Yr ange;
Xof f s et , Yof f s et ;
Xof f s et
Yof f s et
Xr ange
Yr ange
= ( Xmax + Xmi n ) >> 1;
= ( Ymax + Ymi n ) >> 1;
= ( Xmax - Xmi n ) ;
= ( Ymax - Ymi n ) ;
/ / c al c ul at e of f s et s
/ / c al c ul at e t he r ange
Compute Heading
To compute the correct heading a graph of the points (X, Y) should show a circle with the
center in the origin. The following code demonstrates how the raw (X, Y) point is
corrected using the calibration values to get a perfect circle at the origin:
Compute Heading
f l oat pi = at an( 1 ) * 4;
i nt
Xv al , Yv al ;
i nt
angl e, headi ng;
/ / c omput e PI
Get RawXY( ) ;
/ / get c oor di nat es
Xv al = Xr aw - Xof f s et ;
Yv al = Yr aw - Yof f s et ;
/ / s ubt r ac t out t he of f s et s
i f ( Xr ange > Yr ange )
Yv al = ( Yv al * Xr ange) / Yr ange;
/ / per f or m gai n mat c hi ng
el s e
Xv al = ( Xv al * Yr ange) / Xr ange;
/ / per f or m gai n mat c hi ng
angl e = at an( Yv al / Xv al ) * 180/ pi ;
/ / c omput e t he angl e
i f ( Xv al >=0 && Yv al >= 0 )
headi ng = angl e;
/ / quadr ant +X, +Y ( 0 t o 90)
el s e i f ( Xv al < 0 && Yv al >= 0)
headi ng = 180 - angl e;
/ / quadr ant - X, +Y ( 91 t o 180)
el s e i f ( Xv al < 0 && Yv al < 0 )
headi ng = 180 + angl e;
/ / quadr ant - X, - Y ( 181 t o 270)
el s e i f ( Xv al >= 0 && Yv al
headi ng = 360 - angl e;
/ / quadr ant +X, - Y ( 271 t o 359)
< 0 )
PNI Sensor Corporation
Multipoint Calibration Primer – September 2010
Doc #1001766 r02
Page 5 of 8
Figure 4 shows the plot of the corrected X, Y points using the calibration values. The
offsets move the center of the circle back to the origin and the ranges are used to match
the gain so the graph becomes a centered circle instead of the original off-center ellipse.
600
400
200
0
-600
-400
-200
0
200
400
600
-200
-400
-600
Figure 4
PNI Sensor Corporation
Multipoint Calibration Primer – September 2010
Doc #1001766 r02
Page 6 of 8
Notes
Declination
Declination is the angular difference between magnetic north and geographic north
headings. There is a difference between the two directions because Earth's magnetic
north pole is not in the same location as the geographic north pole. A compass
measures Earth's magnetic field, so it points to magnetic north. Also, the difference
between magnetic north and geographic north varies from place to place.
Fortunately, there are many ways to obtain declination. Most hiking topographic
maps provide the declination value. Declination also can be found at web pages such
as the National Geophysical Data Center's site (http://www.ngdc.noaa.gov/geomag/).
Declination is defined as "east" if magnetic north falls to the east of geographic north;
and "west" if magnetic north falls to the west of geographic north. A positive
declination is “east", and a negative declination is "west". For instance, the NGDC
website listed above shows that for Mountain View, CA (37N, 122W) the declination
is "15d 25.7m". First, it is positive, so it is eastward declination. The "d" stands for
degrees; the "m" stands for minutes. 60 minutes = 1 degree, so the declination is
15.4º east.
Once declination is known, the compass heading can be corrected so that heading can
be determined relative to geographic north. Add the declination value to the compass
measurement to get the geographic heading. For example, if the declination is 15 E,
add 15 to the compass measurement. If the declination is 10 W, subtract 10 from
the compass measurement.
EL Backlight Disturbances
When an electro-luminescent (EL) or other backlight is used in a compass system,
turning the backlight on may cause a change in the heading reading. This is because
the backlight system usually draws enough current during operation to cause the
voltage level of a battery-based power supply to drop, and this drop may affect the
zero offset of the ASIC. Additionally, if there is backlight support circuitry, such as
inductors or other current loops, then the magnetic fields generated by these
components can directly affect the sensor readings.
An algorithmic solution to this issue can be implemented during the user calibration
procedure. First obtain the standard calibration values (Xoffset and Yoffset) with the
backlight turned off. Next, turn on the backlight for 1/2 second and take a single
magnetic measurement, Xbacklight_on and Ybacklight_on, and another measurement
PNI Sensor Corporation
Multipoint Calibration Primer – September 2010
Doc #1001766 r02
Page 7 of 8
with the compass orientation unchanged but the backlight off, Xbacklight_off and
Ybacklight_off. Calculate the backlight offsets, Xbacklight_offset and
Ybacklight_offset, as follows:
Xbacklight_offset = Xbacklight_on – Xbacklight_off
Ybacklight_offset = Ybacklight_on – Ybacklight_off
To calculate the corrected X and Y values when the backlight is turned on, take the
raw sensor readings, subtract the standard calibration offsets, and then subtract the
backlight offsets. Thus, the X and Y values used to calculate heading would be:
X = Xraw - Xoffset - Xbacklight_offset
Y = Yraw - Yoffset - Ybacklight_offset
If the backlight is off, then do not subtract the Xbacklight_offset and
Ybacklight_offset when performing the heading calculations.
PNI Sensor Corporation
Multipoint Calibration Primer – September 2010
Doc #1001766 r02
Page 8 of 8
Similar pages