Upload
humphreylin
View
222
Download
0
Embed Size (px)
Citation preview
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
1/38
Philips Semiconductors
APPLICATION NOTE
Electronic Compass Designusing KMZ51 and KMZ52
AN00022
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
2/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
2
Abstract
The KMZ51 and KMZ52 from Philips Semiconductors are magnetic field sensors, dedicated to compassapplications. Both sensors rely on the magnetoresistive effect and provide the required sensitivity and linearityto measure the weak magnetic field of the earth. While the KMZ51 is a single axis field sensor, the KMZ52comprises a two-dimensional field sensor, as it is required for a compass, within one package. Both devices areequipped with integrated set/reset and compensation coils. These coils allow to apply the flipping technique foroffset cancellation and the electro-magnetic feedback technique for elimination of the sensitivity drift withtemperature.
Besides the sensor elements, a signal conditioning unit and a direction determination unit are required to buildup an electronic compass. The main functions of the signal conditioning unit are amplification of the sensor
signals and offset compensation. For high resolution systems, also the temperature drift of sensitivity should becompensated. Both compensation techniques can be implemented simply by controlling the integrated set/resetand compensation coils of the KMZ51/KMZ52. In the direction determination unit, the azimuth is derived as thedesired compass output quantity.
The given paper shows how to realize signal conditioning and direction determination in conjunction with KMZ51or KMZ52. Also calibration techniques with respect to interference fields, declination and tilt are pointed out.Finally, system accuracy is covered and examples for complete compass systems are given.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
3/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
3
APPLICATION NOTE
Electronic Compass Design usingKMZ51 and KMZ52
AN00022
Author:
Thomas StorkPhilips Semiconductors
Systems Laboratory Hamburg,Germany
Keywords
Earths magnetic fieldMagnetoresistive sensors
8-segment compassHigh resolution compass
Date: 00-03-30
Number of pages: 38
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
4/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
4
SUMMARY
This paper describes how to realize electronic compass systems using the magnetoresistive sensors KMZ51and KMZ52 from Philips Semiconductors. Therefore, firstly an introduction to the characteristics of the earthsmagnetic field is given. In the following, the main building blocks of an electronic compass are shown, which aretwo sensor elements for measuring the x- and y-components of the earth field in the horizontal plane, a signalconditioning unit and a direction determination unit.
To provide an understanding of the sensor elements, the magnetoresistive effect and the optimization of thesensor characteristic by using barber pole structures are described briefly. Also the special features of the
KMZ5x products, such as set/reset and compensation coils are pointed out. The signal conditioning units basicfunction is to amplify the sensor output voltages, in order to provide reasonable input signals for the followingdirection determination unit. Beyond that, offset elimination is an essential task. For high precision systems, alsosensitivity shifts due to temperature variations should be compensated. Practical methods to fulfill all thesetasks either in hardware or software are given. The direction determination unit is the building block for derivingthe azimuth as the desired compass output quantity. The azimuth is the angle between magnetic north and theheading direction. For high resolution compass systems, this has to be done mathematically by applying thearcus tangens function to the ratio of the two sensor signals. It is shown, how to implement this function assoftware. Without this calculation, a more simple 8-segment compass can be realized, which only indicates thenearest cardinal or intermediate point (N, NE, ...).
Besides realization of the basic compass functions, this paper also covers the calibration of electroniccompasses against external error sources like magnetic interference fields, deviation between true and
magnetic north and tilt. Finally, determination of system accuracy and examples for complete compass systemsare given.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
5/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
5
CONTENT
1. INTRODUCTION..............................................................................................................................................7
2. EARTHS MAGNETIC FIELD..........................................................................................................................8
3. BUILDING BLOCKS OF AN ELECTRONIC COMPASS..............................................................................10
4. MAGNETORESISTIVE (MR) SENSORS FOR COMPASS APPLICATIONS ..............................................12
4.1 The Magnetoresistive Sensor Element .........................................................................................12
4.1.1 The Magnetoresistive Effect ..............................................................................................12
4.1.2 Optimization of Sensor Characteristic using Barber Pole Structures ................................13
4.1.3 Bridge Configuration ..........................................................................................................134.2 Set/Reset and Compensation Coils...............................................................................................14
4.3 Philips MR Sensors for Compass Systems..................................................................................15
5. SIGNAL CONDITIONING UNIT (SCU)..........................................................................................................16
5.1 Requirements...................................................................................................................................16
5.2 Offset Compensation ......................................................................................................................17
5.3 Sensitivity Difference (S) Compensation....................................................................................19
5.4 Non-orthogonality compensation..................................................................................................20
5.5 Circuit Design ..................................................................................................................................21
5.5.1 Supply voltage considerations ...........................................................................................21
5.5.2 Flipping generator (block1) ................................................................................................22
5.5.3 Pre-amplifier (block 2) ........................................................................................................23
5.5.4 Offset compensation (block 3) ...........................................................................................23
5.5.5 Synchronous rectifier (block 4) ..........................................................................................23
5.5.6 Integral controller (block 5) ................................................................................................23
5.5.7 Compensation coil driver (block 6).....................................................................................23
5.5.8 SCU without electro-magnetic feedback............................................................................24
5.5.9 SCU with Microcontroller ...................................................................................................24
6. DIRECTION DETERMINATION UNIT (DDU)................................................................................................25
6.1 8-Segment Compass .......................................................................................................................256.2 High Resolution Compass..............................................................................................................26
7. INTERFERENCE FIELD CALIBRATION......................................................................................................27
8. TRUE NORTH CALIBRATION......................................................................................................................30
9. TILT COMPENSATION .................................................................................................................................31
10. SYSTEM ACCURACY...................................................................................................................................34
11. APPLICATION EXAMPLES..........................................................................................................................35
12. REFERENCES...............................................................................................................................................37
APPENDIX 1 List of abbreviations .................................................................................................................. 38
APPENDIX 2 Unit conversions ........................................................................................................................ 38
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
6/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
6
LIST OF FIGURES
Figure 1 Earths magnetic field ........................................................................................................................... 8
Figure 2 Earth field vector ................................................................................................................................... 9
Figure 3 Functional block diagram of an electronic compass........................................................................... 10
Figure 4 The magnetoresistive effect in permalloy ........................................................................................... 12
Figure 5 a) R-H characteristic of a standard sensor, b) R-H characteristic of barber pole sensors ............... 13
Figure 6 Barber pole sensor.............................................................................................................................. 13
Figure 7 Bridge configuration of barber pole sensors ....................................................................................... 14
Figure 8 Fields generated by set/reset and compensation coil......................................................................... 14
Figure 9 Simplified circuit diagram of KMZ 51 .................................................................................................. 15
Figure 10 Effect of flipping on sensor characteristic ........................................................................................... 17
Figure 11 Block diagram of flipping circuit .......................................................................................................... 17
Figure 12 Timing diagram for flipping circuit ....................................................................................................... 18
Figure 13 Typical MR sensor output characteristic (KMZ10).............................................................................. 19
Figure 14 Block diagram of flipping and electro-magnetic compensation circuit ................................................ 20
Figure 15 Signal conditioning circuit for one sensor ........................................................................................... 21
Figure 16 Flip circuit with active current limiting.................................................................................................. 22
Figure 17 Signal conditioning circuit with microcontroller ................................................................................... 24
Figure 18 Direction determination for 8-segment compass................................................................................ 25
Figure 19 Circuit for 8-segment compass........................................................................................................... 25
Figure 20 Typical test diagrams showing hard iron and soft iron effects............................................................ 27
Figure 21 Principle of bidirectional calibration..................................................................................................... 28
Figure 22 Tilt error ............................................................................................................................................... 31
Figure 23 Tilt error magnitudes ........................................................................................................................... 32
Figure 24 Definition of pitch and roll.................................................................................................................... 32
Figure 25 Electronically gimbaled compass........................................................................................................ 33
Figure 26 Analog 8-segment compass ............................................................................................................... 35
Figure 27 Analog high resolution compass......................................................................................................... 35
Figure 28 8-segment compass with microcontroller ........................................................................................... 36
Figure 29 High-end compass with microcontroller .............................................................................................. 36
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
7/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
7
1. INTRODUCTION
The magnetic compass is a crucial navigation tool in many areas, even in times of the global positioning system(GPS). Replacing the old magnetic needle compass or the gyrocompass by an electronic solution offersadvantages like having a solid-state component without moving parts and the ease of interfacing with otherelectronic systems.
For the magnetic field sensors within a compass system, the magnetoresistive (MR) technology is thepreferable solution. Compared to flux-gate sensors, which could be found in most electronic compasses untilnow, the MR technology offers a much more cost effective solution, as it requires no coils to be wound and canbe fabricated in an IC-like process. Due to their higher sensitivity, MR sensors are also superior to Hall elementsin this application field.
The intention of this paper is to give a general introduction of electronic compass design with MR sensors and
also to give detailed realization hints. Therefore, the basic characteristics of the earths magnetic field areexplained and an overview of the building blocks of an electronic compass is given. Following a description ofPhilips magnetoresistive sensors for compass applications, the design of each building block is covered indetail. Here, both hardware and software realisations are shown. Further sections are dedicated to special itemslike interference field calibration, true north calibration, tilt compensation and system accuracy. Finally,examples for complete compass systems are given, consisting of previously described building blocks.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
8/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
8
2. EARTHS MAGNETIC FIELDThe magnetic field of the earth is the physical quantity to be evaluated by a compass. Thus, an understanding ofits basic properties is required, when designing a compass. Figure 1 gives an illustration of the field shape.
Figure 1 Earths magnetic field
The magnetic field strength on the earth varies with location and covers the range from about 20 to 50 A/m. Anunderstanding of the earths field shape can be gained, if it is assumed to be generated by a bar magnet withinthe earth, as pointed out in Figure 1. The magnetic field lines point from the earths south pole to its north pole.Fig. 1 indicates, that this is opposite to the physical convention for the poles of a bar magnet (the background isa historical one, in that a bar magnets north pole has been defined as that pole, that points towards north in theearths magnetic field). The field lines are perpendicular to the earth surface at the poles and parallel at theequator. Thus, the earth field points downwards in the northern hemisphere and upwards in the southern
hemisphere. An important fact is, that the magnetic poles do not coincide with the geographical poles, which aredefined by the earths axis of rotation. The angle between the magnetic and the rotation axis is about 11.5. Asa consequence, the magnetic field lines do not exactly point to geographic or true north.
Figure 2 gives a 3-D representation of the earth field vector He at some point on the earth. This illustrationallows to define the quantities, which are of importance for a compass. Here, the x- and y-coordinates areparallel to the earths surface, whereas the z-coordinate points vertically downwards.
Azimuth The angle between magnetic north and the heading direction. Magnetic north is the direction of Heh, theearths field component perpendicular to gravity. Throughout this paper, Heh will be referred to ashorizontal component of the earths field. Figure 2 shows, that:
Hex
Heyarctan= (1)
MagneticNorth
MagneticSouth
TrueNorth
TrueSouth
EARTHFLD.GIF
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
9/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
9
The azimuth is the reading quantity of a compass. Throughout this paper, is counted clockwise frommagnetic north, i.e. north is 360 or 0, east is 90, south is 180, west is 270.
Inclination or dip The angle between the earths field vector and the horizontal plane. As already pointed out, the inclinationvaries with the actual location on earth, being zero at the equator and approaching 90 near the poles. If acompass is tilt, then inclination has to be considered, as explained in section 9.
Declination The angle between geographic or true north and magnetic north. Declination is dependent on the actualposition on earth. It also has a long term drift. Declination can be to the east or to the west and can reachvalues of about 25. The azimuth measured by a compass has to be corrected by the declination in orderto find the heading direction with respect to geographic north. This is pointed out in section 8.
x(headingdirection)
y(right)y(right)
z(down)
He
Hez
Hex
Hey
magneticnorth
true
northazimuth
inclinationor dip
declination
HEVECTOR.AI
Heh
Figure 2 Earth field vector
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
10/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
10
3. BUILDING BLOCKS OF AN ELECTRONIC COMPASS
Figure 3 shows a functional block diagram of an electronic compass. This is a minimum set-up, i.e. theseelements are principally required for any electronic compass. The functional blocks except the field sensor can be realized either as hardware or as software. In the following, the functions of each block are summarized.A detailed description of each block together with examples for realization are given in the following sections.
2-dimensionalfield sensorKMZ52
Signal Conditioning Unit(SCU)
Direction DeterminationUnit (DDU)
Interface toother system,e.g. navigation
Display
BLOCKDIA.AI
Vx
Vy
- Amplification- Offset elimination
(- Temperaturecompensation ofsensitivity)
- Amplification- Offset elimination
(- Temperaturecompensation of
sensitivity)
azimuth derivation
x-channel
y-channel
Iflip, Icomp
SHex
Iflip, Icomp
SHey
flipcoil
compensationcoil
Hex-Sensor
flipcoil
compensationcoil
Hey-Sensor
Figure 3 Functional block diagram of an electronic compass
Magnetic field sensors
As already pointed out, the task of a compass is to measure the azimuth , i.e. the angle between north andheading direction, as defined by equation (1). Therefore, the strengths of two horizontal earth field componentshave to be measured: one in heading direction (Hex) and one sidewards (Hey). This requires two magnetic fieldsensors, both aligned parallel to the earths surface, but rotated by 90 degrees with respect to each other.
Philips magnetoresistive sensor technology is an optimum choice for measuring weak magnetic fields like theearths field. The KMZ52 is a sensor device, which is perfectly matched to this application, as it comprises twoextremely sensitive field sensors in the required configuration in one SO16 package. Furthermore, the KMZ52comprises for each of its sensors a set/reset coil needed for offset elimination and a coil for the compensation ofsensitivity temperature drift. Thus, the KMZ52 makes any external coils obsolete, which are required when usingother sensor products. Section 4 describes Philips magnetoresistive sensor technology and introduces thoseproducts, which are dedicated to compass applications.
Signal conditioning unit (SCU)
The purpose of this block is to deliver output voltages proportional to the field strengths Hex and Heyrespectively. Therefore, the signals delivered by the magnetic field sensors have to be amplified. Also offsetshave to be eliminated. Beyond that, the amplification of one SCU channel should be trimable in order to allow
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
11/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
11
the compensation of sensitivity differences between the x- and the y- field sensor. Optional features for highperformance systems are temperature compensation of sensitivity and compensation of the error due to non-orthogonality between the sensors. To fulfill these tasks, the signal conditioning unit has to influence thesensors by controlling their set/reset and compensation coils. The SCU is the most crucial part concerningsystem accuracy. Section 5 gives a detailed description of the required functions within the signal conditioningunit as well as solutions in hardware and software.
Direction determination unit (DDU)
The function of this block is to derive the desired azimuth information from the measured field strengths Hey andHex. For high resolution compasses, this can be done by evaluating the arctan function of equation (1) with amicrocontroller. With less effort, a simple 8-segment compass can be built up, which only provides majordirection indication (N, NE, E, etc.). Section 6 gives some more hints on this.
Display / Interface
Finally, the measured azimuth has to be indicated to the user by a display and/or has to be delivered to anotherelectronic system. The latter could be the navigation system of a car, which uses the compass information fordead reckoning, i.e. for determination of the relative position during time intervals, where GPS signals cannotbe received (e.g. when driving between high buildings). Section 11 shows complete application examples, whichgive some hints on display driving and interfacing.
Further features
Figure 3 shows those elements, which are required for any electronic compass. However, depending on theactual application, further features may be demanded. The most important of these are:
Interference field calibrationIn most practical cases, the earth field to be measured is superimposed by other magnetic fields, whichwould cause a significant measurement error, if not compensated. Section 7 gives an introduction on thistopic.
True north calibrationAs pointed out in section 2, there is a deviation between the magnetic north direction (measured by thecompass) and true or geographic north. Section 8 gives more information on this item.
Tilt compensationEquation (1) only yields the correct azimuth, if Hex and Hey are the earth field components in the horizontalplane. Thus, the basic compass sketched in Figure 3 must be held exactly horizontal to work properly.Section 9 discusses the error that occurs, when a compass is tilt and shows how to compensate this errorelectronically.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
12/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
12
4. MAGNETORESISTIVE (MR) SENSORS FOR COMPASS APPLICATIONS
The intention of this section is to describe the basic principles of magnetoresistive sensors, which a compassdesigner should know. A more detailed description of the magnetoresistive effect can be found in [3].
4.1 The Magnetoresistive Sensor Element
4.1.1 The Magnetoresistive Effect
Magnetoresistive (MR) sensors make use of the magnetoresistive effect, the property of a current carryingmagnetic material to change its resistivity in the presence of an external magnetic field. Figure 4 shows a strip offerromagnetic material, called permalloy (19% Fe, 81% Ni).
Hy Magnetization
Current
Permalloy
R = R0
+ R cos
= 0 Rmax
= 90 Rmin
x
y
Figure 4 The magnetoresistive effect in permalloy
During deposition of the permalloy strip, a strong external magnetic field is applied parallel to the strip axis. Bydoing this, a preferred magnetization direction is defined within the strip. In absence of any external magneticfield, the magnetization always points into this direction. In Figure 4, this is assumed to be the x-direction, whichis also the direction of current flow. An MR sensor now relies on two basic effects:
The strip resistance R depends on the angle between the direction of the current and the direction of themagnetization.
The direction of magnetization and therefore can be influenced by an external magnetic field Hy, whereHy is parallel to the strip plane and perpendicular to the preferred direction.
When no external magnetic field is present, the permalloy has an internal magnetization vector parallel to thepreferred direction, i.e. = 0. In this case, the strip resistance R has its maximum value Rmax. If now anexternal magnetic field Hy is applied, the internal magnetization vector of the permalloy will rotate around an
angle . At high field strengths, the magnetization tends to align itself parallel to Hy and the rotation angle approaches 90. In this case, the resistance reaches its minimum value Rmin. The equation next to Figure 4gives the functional dependence between R and , where Ro = Rmin and R = (Rmax-Rmin). Finally, thefunction of R versus Hy is as follows:
+=
2
o
y0
H
H1RRR (2)
Figure 5a shows a diagram for equation (2). Ho is a parameter, which depends on material and geometry of thestrip. Equation (2) is defined for field strength magnitudes of Hy Ho. For Hy > Ho, R equals Ro. R0 and Rarealso material parameters. For permalloy, Ris in the range of 2 to 3% of R0.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
13/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
13
4.1.2 Optimization of Sensor Characteristic using Barber Pole Structures
Figure 5a illustrates the sensor characteristic according to (2). For small magnitudes of Hy, the sensitivity is verylow and non-linear. Furthermore, this characteristic does not allow to detect, whether Hy is positive or negative.Therefore, the basic sensor structure of Figure 4 has to be improved for compass applications.
The desired sensor improvements can be achieved by depositing aluminium stripes (called barber poles) on topof the permalloy strip at an angle of 45 to the strip axis. Figure 6 shows the principle. As aluminium has a muchhigher conductivity than permalloy, the effect of the barber pole is to rotate the current direction by 45,effectively changing the angle between the magnetisation and the electrical current from to ( - 45). Graphb) in Figure 5 shows the impact on the sensor characteristic due to the barber pole structure. For weak fieldslike the earths field, the sensitivity now is significantly higher, the characteristic is linearized and allows todetect the sign of Hy.
a
b
R(Hy)
Ro(Hy=Ho)
Figure 5 a) R-H characteristic of a standard sensor,b) R-H characteristic of barber pole sensors
II
Permalloy
Barber pole (Al)
sensitivedirection
Hy
Magnetization (flip direction)
Current
Figure 6 Barber pole sensor
4.1.3 Bridge Configuration
Practically, it is advantageous to build up a sensor element as a Wheatstone bridge, consisting of fourmagnetoresistive strips, as shown in Figure 7. For compass sensors, barber pole structures are used, whereone diagonal pair is orientated at +45 to the strip axis, while the other pair is orientated at -45. Thus, the
resistance variation R due to a magnetic field is converted linearly into a variation of the differential output
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
14/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
14
voltage V = +Vo (-Vo). Moreover, the inherent temperature coefficients of the four bridge resistances aremutually compensated.
Vcc
GND
Ro + R Ro - R
Ro + RRo - R
+Vo-Vo
Figure 7 Bridge configuration of barber pole sensors
4.2 Set/Reset and Compensation Coils
MR sensors are by nature bi-stable, i.e. the direction of their internal magnetization can be inverted or flipped.This can be achieved by a magnetic field of sufficient strength, if that field is applied parallel to themagnetization, but having opposite direction (refer to Figure 8). Flipping causes an inversion of the sensorcharacteristic, such that the sensor output voltage changes polarity.
MR sensors can be stabilized against unwanted flipping by applying an auxiliary magnetic field parallel to theflipping axis. This field should be pulsed, as a permanent field would decrease the sensitivity. When measuring
weak fields, it is even desired to invert or flip the sensor characteristic repetitively. This allows to compensatethe sensors offset in a way comparable to the chopping technique used in the amplification of small electricalsignals. A set/reset coil near the sensor element is a means to apply the auxiliary field for the flipping.
In high precision compass systems, the sensor must also allow to compensate sensitivity drift with temperatureand to compensate interference fields. Both can be done by means of an auxiliary field in the sensitive direction.This can be generated by a compensation coil near the sensor element.
sensitivedirection
magnetization/flipdirection
field to be measured,
earths field
compensation field,
generated by compensation coil
Vcc
GND
Ro+R Ro- R
Ro+ RRo- R
+Vo-Vo
flipping field,generated by set/reset coil
Figure 8 Fields generated by set/reset and compensation coil
Philips MR sensors dedicated for compass applications are available with integrated set/reset andcompensation coils, saving the additional cost and effort to provide external coils. Furthermore, as integrated
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
15/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
15
coils can be arranged much closer to the sensor element, they require significantly less current to generate therequired field strengths. This reduces expenditure and thus cost at the signal conditioning unit side.
In the signal conditioning section, the techniques of flipping and compensation are described in detail.
4.3 Philips MR Sensors for Compass Systems
Philips Semiconductors offers at present two sensor products, dedicated to this application field. Both productsemploy the previously described barber pole structure with its inherent linearity and high sensitivity.
The primary device is the KMZ52, which comprises all elements of a compass sensor system within onepackage, i.e. two weak field sensors with 90 displacement, each having a set/reset and a compensation coil(ref. to figure 3). The KMZ51 is a single sensor with set/reset and compensation coils. This can be employed
together with a KMZ52 to form a three-dimensional sensor, in order to compensate for tilt, as will be describedin section 9. Figure 9 shows a simplified circuit diagram of the KMZ51, showing the MR resistor bridge as wellas the set/reset and compensation coils. Table 1 provides an overview on Philips compass sensor portfolio.
handbook, halfpage
8 7 6 5
1 2 3 4 MGD793
GND
+VO
+IF +IC
IF ICVO
VCC
set/resetcoil
compen-sationcoil
Figure 9 Simplified circuit diagram of KMZ 51
Table 1 Philips MR sensors for compass applications
KMZ51 KMZ52 UNIT
1- or 2-dimensional sensor 1-dim. 2-dim. -
Package SO 8 SO 16 -
recommended supply voltage 5 5 V
typ. sensitivity 16 16 (mV/V) / (kA/m)1
offset voltage -1.5 ... 1.5 -1.5 ... 1.5 mV/V2
Applicable field range -0.2 ... 0.2 -0.2 ... 0.2 kA/m
Integrated set/reset coils forflipping
yes yes -
Integrated compensation coils yes yes -
1 Thus, the sensor delivers 16mV per V supply voltage and per kA/m field strength.
2 Thus, the maximum offset voltage is 1.5mV per V supply voltage.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
16/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
16
5. SIGNAL CONDITIONING UNIT (SCU)
5.1 Requirements
The SCU consists of two separate channels fulfilling the basic task of amplifying the x- and y-field sensoroutput voltages (refer to Figure 3). Considering a minimum earth field strength in the sensor plane ofapproximately 15 A/m and a sensor sensitivity of typically 80 mV/(kA/m) (at Vcc = 5V, refer to Table 1), an MRsensor will deliver an amplitude of approximately 1.2 mV, when rotated in that field. Therefore, significantamplification is required in order to provide reasonable voltages for the following direction determination stage.
Depending on the desired system accuracy, the SCU has to fulfil up to three further requirements. These arethe elimination of the following error sources:
Offset voltages Vox, Voy at the SCU output:These are caused by the offsets of the sensor elements and the connected amplifier. Offset of a sensorelement arises due to the tolerances and temperature drift of the four magnetoresistive elements, which arearranged as a Wheatstone bridge. Thus, the sensor output voltage deviates from zero, if no magnetic field isapplied.
Sensitivity difference S between x- and y- channel of the SCU:This is due to tolerance and temperature drift of sensor sensitivities and the following amplification.
Non-orthogonality of sensors:Due to mounting tolerances, the real angular displacement between the sensors deviates from the desired90 by an angle .
Equation (3) indicates the effect of these error sources on the azimuth reading. Here it is assumed that the
direction determination unit carries out equation (1) by replacing Hey and Hex with the respective SCU outputvoltages Vy and Vx. As each output voltage equals the measured earths field component times channelsensitivity plus offset, the azimuth reading is:
VoxcosSHe
Voy)sin()SS(Hearctan
Vx
Vyarctan
++++
==
(3)
Equation (3) becomes identical to equation (1), i.e. the real azimuth is derived, if Vox, Voy, S and areeliminated. The azimuth errors caused by offsets, S and are periodic functions of . The amplitudes of thesefunctions, i.e. the maximum azimuth errors, can be assumed as proportional to the magnitude of the respectiveerror source. Table 2 in section 10 states the equations for these azimuth errors together with an indication oftheir maximum value depending on the respective error source:
Offset error: E
offset
0.8 /%,
i.e. an offset to amplitude ratio of 1% causes a max. azimuth error of 0.8 .
Sensitivity difference error: ES 0.3 /%,i.e. a S/S ratio of 1% causes an error of 0.3 .
Non-orthogonality error: E 1 /,i.e. a 1 deviation from orthogonality between the sensors causes a max. azimuth error of 1.
The KMZ52 is specified to have an offset voltage of max. 1.5mV/V and an offset drift of max. 3V/(V/K) (referto Table 1). Thus, at the recommended supply of 5V, the max. offset voltage at 25C is 7.5mV and the max.offset drift, e.g. over a temperature range of 100C, is 1.5mV. Comparing these values with the sensor voltageamplitude of 1.2mV as derived above, it becomes evident, that offset level and even offset temperature drift canbe significantly higher than the desired signal. As a consequence, an efficient in-circuit offset compensation iscrucial for every compass system, even for low end products. Section 5.2 shows techniques to realize this.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
17/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
17
To compensate for sensitivity differences S, the SCU should allow to trim its output voltages for equalamplitudes when rotated in the earth field. If high accuracy is desired over a wide temperature range, also anautomatic compensation of sensitivity temperature drift should be implemented. Section 5.3 shows therealization.
The maximum non-orthogonality specified for the KMZ52 is 2, causing a maximum azimuth error of 2. Forapplications, where this is not sufficient, section 5.4 shows a principle, to correct this error mathematically.
5.2 Offset Compensation
A technique called flipping can be used here, which allows to eliminate the offset similar to the choppingtechnique used for the amplification of small electrical signals: When the bi-stable sensor is subjected to areversible magnetic field in its flipping direction, its internal magnetization Mx and thus its characteristic Vo vs.
Hy is reversed or flipped as shown in Figure 10 (refer also to section 4.2). If the flipping is done repetitively, thedesired output voltage will change polarity, thus appearing as amplitude of an ac signal. However the offsetvoltage does not change polarity, thus appearing as a dc offset of that signal. This allows to compensate thesensors offset by filtering the dc component from its flipped output signal. A subsequent rectification thenallows to convert the ac signal back to the desired dc sensor signal.
Figure 11 shows the block diagram of a flipping circuit. The flipping is generated by applying alternately positiveand negative current pulses to the set/reset coil of the sensor. To avoid loss in sensitivity, the current pulsesshould be short (only a few s). Although the frequency is not critical, some design hints are given later on whencoming to practical solutions. After pre-amplification, a high pass filter removes the sensor offset from theflipped output signal. A synchronous rectifier converts the flipped signal to a dc signal, that is now free of offset.A clock signal is required for controlling the flipping source and the rectifier, which must be synchronized withthe flipping. Figure 12 shows a timing diagram with the signals of the flipping circuit.
MLC764_1
VsensorM x
offset
Hy
M x
Figure 10 Effect of flipping on sensor characteristic
MBH617_1
LF
IF
FLIPPINGSOURCE
PRE-AMPLIFIER
CLOCKT
HIGHPASSFILTER
VoutPHASE
SENSITIVEDEMODULATOR
Figure 11 Block diagram of flipping circuit
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
18/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
18
MBH618_1
Offset Vo
internal
magnetization
flipping current IF
T
time
time
time
time
Hy
T T
(a)
(b)
(c)
pre-ampV
Vfilter
Vout
Vx,y
Vx,y
Vx,y
Vp
Vn
0
0
0
Figure 12 Timing diagram for flipping circuit
(a) voltage at preamp output; (b) voltage at filter output;(c) voltage at rectifier output
The filter and the synchronous rectifier in Figure 11 can be saved, if a microcontroller with A/D converter isavailable. In that case, the desired output voltages Vx,y can be calculated from the high-level voltage Vp andthe low-level voltage Vn of the flipped and amplified sensor signal (refer to Figure 12a) as:
)VnVp(21y,Vx = (4)
Assuming that the offset does not vary rapidly with time, the microcontroller load can be reduced by reading Vpand Vn only after longer time intervals, e.g. minutes, to calculate and store the actual offset voltage Vo:
)VnVp(2
1Vo += (5)
For azimuth calculation, then only one level of the flipped sensor signal has to be read by the microcontroller,e.g. Vp:
VoVpy,Vx = (6)
Section 5.4 gives practical circuit examples and design hints for the flipping circuit. A pure hardware solution aswell as a realisation using a microcontroller are considered.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
19/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
19
5.3 Sensitivity Difference (S) CompensationAt a given temperature, S can be compensated by adjusting the SCU for equal output voltage swings Vy,ppand Vx,pp during compass rotation. The output voltage swings can be equalized by adjusting the amplificationof one SCU channel. An alternative software solution would be to correct one output voltage mathematically: Asthe ratio Vy,pp/Vx,pp equals the ratio of sensitivities Sy/Sx=(S+S)/S, Vy can be corrected as follows:
pp,y
pp,xmeasured,ycorrected,y
V
VVV = (7)
When determining S by measuring SCU output voltage swings, soft iron interference effects have to beavoided carefully, as these would also appear as difference in output voltage swings (refer to section 7).
To maintain high accuracy over temperature, the temperature drift of sensor sensitivity should be compensatedduring operation. Figure 13 shows the output characteristic Vo vs. H of a typical MR sensor element at differenttemperatures. All these curves indicate, that the sensor output is significantly dependent on temperature exceptat its zero point: a field strength of zero always causes an output voltage of exactly zero, independent oftemperature. Of course this is only true disregarding sensor offset. However, offset can be eliminated perfectlyby means of the flipping technique, as described above.
3
0
153 2 2
5
10
10
5
15
01 1
H (kA/m)y
VO
(mV/V)T = 25 Camb
o
25 Co
75 Co
125 Co
operating range
Figure 13 Typical MR sensor output characteristic (KMZ10)
Thus, temperature drift can be compensated by operating the sensors at their zero point. Therefore, the earthfield component at each sensor has to be compensated by an opposing field of equal strength. If now
magnitude and polarity of this compensation field are known, the measurement task is fulfilled, even though thesensor delivers zero output signal. This method is referred to as electro-magnetic feedback.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
20/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
20
Practically, the compensation field can be generated by supplying a current through an appropriate coil near thesensor. As already pointed out, Philips MR sensors for compass applications come with an integratedcompensation coil, allowing to apply the electro-magnetic feedback method without the need for any externalcoils. Due to the well defined field factor of these integrated compensation coils, there is a well definedproportionality between field strength to be measured and compensation current.
Figure 14 shows a block diagram for an SCU channel employing both flipping and electro-magnetic feedback.The electro-magnetic feedback circuit is a closed-loop controller, in which a current regulator feeds thecompensation coil in order to keep the sensor output voltage at zero. In order to achieve a sensor output voltageof exactly zero, a current regulator with integral characteristic is required. The measured field strength can berepresented as voltage, proportional to the compensation current.
MBH619_1
LF
LC
CURRENTREGULATOR
FLIPPING
SOURCE
CLOCK
VOLTAGE & CURRENTOUTPUT
PRE-AMPLIFIERAND
OFFSETFILTER
SYNCHRONOUSRECTIFIER
Figure 14 Block diagram of flipping and electro-magnetic compensation circuit
5.4 Non-orthogonality compensation
Up to this point it has been assumed, that the two magnetic field sensors are displaced at an angle of exactly90. However, in practice the displacement will deviate by an angle from the desired orthogonality due tomounting tolerances. This deviation causes an error in compass reading, which is a periodic function of theazimuth (see Table 2 in section 10). The maximum error is approximately equal to the non-orthogonality .Thus, for the KMZ52 with a specified max. non-orthogonality of 2, the max. azimuth error is also 2.
If a higher accuracy is desired, should be compensated. If the compass is rotated with respect to the earthsfield, then the phase shift between Vx and Vy is 90. Having determined , the error can be eliminatedmathematically:
Assuming, that the SCU delivers the signals cosVVx);sin(VV maxmaxy =+= , where is the azimuth,
that a corrected signal sinVV maxcorrected,y = is desired,
and using the trigonometric relationship +=+ sincoscossin)sin( ,
the corrected Vy is:
tanVcos
V
V xy
corrected,y = (8)
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
21/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
21
5.5 Circuit Design
Figure 15 shows a circuit for one SCU channel (i.e. one field direction Hx or Hy), including pre-amplification,offset compensation by flipping and temperature compensation of sensitivity by electro-magnetic feedback.
handbook, full pagewidth
MBH620_1
Op1
R15
R17
TR2
VCC
Vref Vref
Vref = Vcc/2
C6C4
TR1
R18
C5
R14
C3
R16
OP7 OP1...7
OP2KMZ51or KMZ52
VCC GND
+Vo
VoR4
R5C1
R3R2
R1
block 2
block 3
block 1flipping pulse
Note:R7=R8=R9
block 4 block 5 block 6
R6
R19
R20 C7
C81...87FLIPCOIL
VrefGENERATOR
OP-AMPSUPPLY
FLIPPINGGENERATOR
OFFSETCOMPENSATION
PRE-AMPLIFIER
SYNCHRONOUSRECTIFIER
INTEGRAL-CONTROLLER
COMPENSATIONCOIL
R7
R9
R8 OP4
OP3
R10
R11
C2
VCC
Vout
GNDR12
R13
COMPCOIL
KMZ5xOP5
OP6
S1
+ KMZ5x
+ -
R21C9
R22
FLIPCOIL
-
+-
1)
1) if no electro-magnetic feedback is used
R23
Vref = Vcc/2
Figure 15 Signal conditioning circuit for one sensor
In the following, a design guideline for the circuit blocks is given. A complete, dimensioned SCU circuit based onFigure 15 are given in [3] and [4]. It should be noted, that this is an application example, which is not optimized.For product development, the design hints given here should be considered carefully.
5.5.1 Supply voltage considerations
The recommended supply voltage for the KMZ52 is 5V. As the sensor output voltages are ratiometric, bothsensor elements should be connected to the same supply. For the flip coil driver, a supply of 10V isrecommended to drive the required current of typ. 1A through the series connection of both set/reset coils,which may have a total resistance of up to 6. The supply lines of flipping generator and signal circuitry shouldbe carefully decoupled from each other in order to suppress flipping noise at the signal outputs.
The circuit of Figure 15 only requires a single external supply of Vcc = 10V. The flipping generator is suppliedfrom here via decoupling network R21-C9. C9 should deliver the positive flipping current pulses, thus a
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
22/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
22
capacitor of some F with low series resistance (e.g. Ta Elco) is recommended here. The time constant R21C9must allow C9 to charge up to approximately Vcc between the positive pulses, i.e. during the period of the clockgenerator. The 5V sensor supply is derived from Vcc by series resistors R1 and R2. A symmetrical OP-Ampsupply is provided by connecting the OP-Amp supply pins to Vcc and GND respectively and connecting theirreference inputs to Vcc/2, generated by the Vref generator.
5.5.2 Flipping generator (block1)
This block generates the flipping current pulses at a repetition frequency, determined by R16 and C3. Thefrequency is not critical, considering the flipping function itself. The choice of frequency is a trade-off betweenaverage current consumption on the one hand and response time and output ripple on the other hand. Afrequency of approximately 1 kHz has proved to be a reasonable compromise. As the output of OP1 passes
from high to low, C4/R17 produce a pulse that switches TR2 on. This charges C6 and a short positive pulse ispassed to the flipping coil. For a low-to-high transition at the output of OP1, C5/R18 forces TR1 to conduct,discharging C6 and providing a negative current pulse through the coil. KMZ51 and KMZ52 both require flipcurrent pulses of typically 1A for a duration of 3s. To drive that current controlled by the OP output, TR1 andTR2 should be Darlington transistors. For a complete SCU, the flipping generator is only required once and theflip coils of both sensors are connected in series. The function of decoupling network R21-C9 is described undersupply voltage considerations.
For product development, it is recommended to use an improved flipping circuit like that shown in Figure 16.Here, an active current limiting provides, that the magnitude of the flip current pulses is independent of flip coilresistance. Thus, this circuit is insensitive to spread of flip resistance or supply voltage.
Vcc
D2
BAS32
R1710k
Rflip
0
0
R1010.7
0
R100
0.7
D1
BAS32
0
Q1BST52
0
1
2Q3
BC547A/PLP
C5
10n
R1810k
Q4
BC557A/PLP
C4
10n
Q2BST620
1
2
C6
1uF
Figure 16 Flip circuit with active current limiting
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
23/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
23
5.5.3 Pre-amplifier (block 2)
The flipped sensor signal is amplified here by a factor of R4/Rbridge, where Rbridge is the resistance of thesensor bridge. Due to the electro-magnetic feedback used in this circuit, the pre-amps output will be virtuallyzero, when the closed loop control has settled. However, it should be provided that OP2 is operated in its linearrange during transient processes of the closed loop control, e.g. after turn-on of the system. Thus, the pre-amplification should be set, such that OP2s output is in its linear range, when the control loop is interrupted,even at maximum sensor signal plus max. offsets. An amplification of approximately 100 is a recommendablevalue.
5.5.4 Offset compensation (block 3)
The low pass filter around OP3 extracts the offset, which is the dc component of the flipped output signal (referto Figure 12) and feeds it as negative feedback to OP2. The sensor offset is compensated this way. Principally,this could also be done by means of a capacitor between sensor and pre-amp, however the method shown hereis preferable, as it compensates the offsets of both the sensor and OP2 simultaneously. This allows to use a lowcost op-amp instead of a special low-offset type, thus reducing system cost. The determination of the filter cut-off frequency is a trade-off between smoothing of the output signal and response time.
5.5.5 Synchronous rectifier (block 4)
This block recovers the desired dc signal from the flipped ac signal. Provided that R7=R8=R9, this blockperforms an alternating +1 and 1 amplification, depending on the state of switch S1, which is controlled by theflipping generator. Thus, each time the output of OP2 changes polarity due to the flipping, this block causes anadditional change of polarity, resulting in a rectification.
5.5.6 Integral controller (block 5)
This block forms the integral part of the PI-controller, built together with block 6 to drive the compensation coilfor electro-magnetic feedback. An integral characteristic is required in the control loop, to force the remainingerror - which is the sensor output signal - to zero. Dimensioning the time constant R10C2 is a trade-off betweenresponse time and smoothness of output signal.
5.5.7 Compensation coil driver (block 6)
Forms the proportional part of the PI controller for electro-magnetic feedback including current source for thecompensation coil. When the control loop has settled, i.e. when the compensation coil generates a field with
equal magnitude and opposite sign to the respective earths field component, (Hex or Hey), the output voltageVout is:
Acomp
12RHV )y,x(e)y,x(out = (9),
where Acomp is the field factor of the compensation coil (refer to the data sheet of KMZ5x). Equation (9) showsthe desired effect of the electro-magnetic feedback: Vout is independent of sensor sensitivity and itstemperature drift (KMZ52: typ. 0.31%/K). The temperature drifts of R12 and Acomp, which now affect the outputvoltage are significantly lower. Typical values are 0.02%/K down to 0.005% for standard or precision smdresistors and 0.01%/K for Acomp of the KMZ52. For S compensation, Vout can be made adjustable by using apotentiometer for R12. Note, that due to the asymmetrical OPAMPs supply, Vout in (9) is the output voltage
swing relative to Vref.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
24/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
24
5.5.8 SCU without electro-magnetic feedback
If no temperature compensation of sensor sensitivity is required, the electro-magnetic feedback loop can beinterrupted by omitting the compensation coil driver (block 6). Block 5 is still required as low pass filter in orderto suppress flipping spikes on the signal line. However, a resistor R22 then needs to be connected in parallel toC2 in order to achieve a limited output voltage. The output voltage then is dependent on sensor sensitivity S andSCU amplification. Assuming that the synchronous rectifier (block 4) has an amplification magnitude of 1, theoutput voltage becomes:
10R
22R
R
4RSHV
bridge)y,x(e)y,x(out = (10)
In this case, Vout can be adjusted by varying e.g. R22 or R10.
5.5.9 SCU with Microcontroller
Figure 17 shows a block diagram for an SCU, using a microcontroller. From the analogue circuitry shown inFigure 15, only the flip coil driver, pre-amps and - optionally - compensation coil drivers are required. Theflipped sensor signals are fed to the C via an A/D converter. It should be considered, that the resolution at thisstage must be higher than the final compass accuracy. Principally the same considerations are valid for the D/Aconverter, driving the compensation coil driver. For a low-end compass, where accuracy is not critical, theinternal 8 bit A/D converter of a low-cost C could be sufficient. If higher accuracies are demanded, an externalA/D converter with higher resolution can be the solution.
Offset compensation can be implemented as software, according to the equations shown in section 5.2. Furtheroptional software features could be a control algorithm for electro-magnetic feedback or non-orthogonality
compensation. Besides signal conditioning, the C software will usually also perform the direction determinationand further optional tasks, such as interference field calibration or true north calibration (see respectivesections).
2-dimensionalfield sensorKMZ52
SCU_UC.AI
SHex
SHey
Vx
Vy
Pre-Amps
Microcontroller
I/O
D/A
Conv.
flip
coil
compensationcoil
Hex-Sensor
flipcoil
compensationcoil
Hey-Sensor
A/DConv.
Compens.
coil driver
Compens.
coil driver
D/A
Conv.
D/A
Conv.
Flipcoildriver
Software:- Flipping clockgeneration
- Offset-elimination(see section 5.2)
- T-compens. ofsensor sensitivity
- Interference fieldcalibration(see section 7)
- Azimuth calculation(see section 6.2)
- True northcalibration(see section 8)
Figure 17 Signal conditioning circuit with microcontroller
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
25/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
25
6. DIRECTION DETERMINATION UNIT (DDU)
6.1 8-Segment Compass
If applications require a rough direction indication only, then a compass set-up is sufficient, which identifies thenearest of the eight cardinal or intermediate points (e.g. N, NW, S, SE, ...). This information can be gained fromthe SCU outputs without evaluating the arctan function in equation (1). Figure 18 shows the principle. Here theSCU output signals Vx and Vy are shown for a full clockwise rotation of the compass. By comparing the SCUsignals with the thresholds Vt+ and Vt-, logic signals N, S, E, W can be derived, which contain the desiredinformation. Vt+ and Vt- are equal to +/-sin(22.5). Figure 19 shows a circuit for the direction determination. As adisplay, e.g. LEDs can be driven by the respective outputs.
MLC760_1
SCU Signals
N NWWSWSEE SNE
360Vref
-100%
100%
Vx
Vy 180
Vt+ = 38.3%
Vt- = -38.3%
S
W N
E
N
N
Figure 18 Direction determination for 8-segment compass
S
SE
SW
+
-
o
W
N
N
Vt+
E
NW
+
-
o
Vx+
-
o
Vy
+
-
o
Vt+
NE
Vt-
Vt-E
S
W
Figure 19 Circuit for 8-segment compass
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
26/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
26
6.2 High Resolution Compass
A compass with high accuracy is required for example in navigation systems. Here, the compass together with ameasurement of the travelled distance are used to determine the actual position as long as no GPS signals canbe received, e.g. while driving between high buildings.
If a direction information with high accuracy is required, e.g. 1 degree or better, then a microcontroller isrequired for evaluation of equation (1), where Hex and Hey have to be replaced by the SCU output voltages Vxand Vy respectively. It is assumed, that Vx and Vy are corrected with respect to offset, sensitivity difference and,if required, non-orthogonality. When implementing equation (1), it must be considered that the argument Vy/Vxhas a pole at Vx = 0, and that the arctan function is uniquely defined only in the angular range of /2 to + /2.Thus, the azimuth has to be computed, depending on the actual states of Vx and Vy:
=>
==
180)
Vx
Vy(arctan180)0Vx(
180)
Vx
Vy(arctan)0Vy,0Vx(
180)
Vx
Vy(arctan360)0Vy,0Vx(
90)0Vy,0Vx(270)0Vy,0Vx(
(11)
Equations (11) are based on the convention, that the azimuth is counted clockwise from north to the headingdirection.
A very efficient way of computing trigonometric functions like arctan is the CORDIC (COordinate Rotating DigitalComputing) algorithm. Its efficiency is based on the fact, that it only uses low-end functions like adding, shiftingand reading of look-up tables. Basic information and implementation hints for the CORDIC algorithm can befound in the internet.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
27/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
27
7. INTERFERENCE FIELD CALIBRATION
In practice, the earth field at the compass may be superimposed by other magnetic fields or distorted by nearbyferrous materials. An efficient compensation of such effects is required in order to achieve reliable azimuthreadings.
As for any sensor system, only errors caused by deterministic interference sources can be compensated. In thiscase, deterministic means, that the interference source is at a fixed position relative to the compass and that itsmagnitude is constant versus time. Thus, as an example, a compass in a car could be compensated for theinterference effects caused by the car body. On the other hand, a compass cannot be compensated for non-deterministic error signals, such as the field of another vehicle passing by. However, reading errors caused bysuch effects can usually be accepted, due to their momentary nature. To avoid misleading readings, a low passcharacteristic may help, that suppresses the display of transient azimuth variations. Also a warning signal couldbe generated at the occurrence of such signals.
The influence of deterministic interference fields on a compass can be assessed by inspection of a test diagramas shown in Figure 20. The test diagram is a Lissajous figure, yielded by a 360 rotation of the compass andrecording of the SCU output signals Vy versus Vx. Without any magnetic interference, the diagram appears as acircle, having its centre at (0,0) and a radius equal to the magnitude He of the earth field. All interference effectsappear as a deviation from this shape. Basically, two kinds of interference can occur, called hard iron effectsand soft iron effects. Hard iron effects are caused by magnetized objects, which are at a fixed position withrespect to the compass. These cause a magnetic field, which is vectorially added to the earth field. Thus, in thetest diagram this effect appears as a shift of the circles centre to (Hix,Hiy), where Hix and Hiy are thecomponents of the interference field. Soft iron effects occur due to distortion of the earth field by ferrousmaterials. This effect is dependent on compass angle. Therefore, it appears as a deformation of the circle in thetest diagram. Figure 20 shows the effect of both hard iron and soft iron effects on the test diagram.
-2,00
-1,50
-1,00
-0,50
0,00
0,50
1,00
1,50
-1,50 -1,00 -0,50 0,00 0,50 1,00 1,50
Hx/Hmax
Hy/Hmax no interference
hard iron effect
soft iron effect
Figure 20 Typical test diagrams showing hard iron and soft iron effects
In practice, hard iron effects dominate over soft iron effects, provided the use of ferromagnetic materials near
the compass can be avoided. To minimize the hard iron effects, a compass should never be installed nearobjects producing strong magnetic fields. As an example, loudspeaker magnets near the compass may produce
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
28/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
28
such strong fields, that the amplifiers of the SCU are overdriven. In this case, accurate measurement of theinterference field and thus compensation are not possible.
Interference field compensation ideally means, to convert the shifted and/or deformed test diagram into a circlearound the centre (0,0). Therefore, the interference field effect has to be measured and in the following, thecompass readings have to be corrected considering the measurement results. Generally, this calibrationprocedure should be carried out individually for each compass. As an example, each individual car has its ownfield signature. Even when mounting the same compass into the same environment again, e.g. aftermaintenance, it is recommended to carry out the calibration again. Thus, the calibration procedure should besimple, ideally automatical. Classical calibration methods, such as using a shielded room to measure theinterference field effect without the earth field, or adjusting the compass reading to that of a reference compass,do not fulfill this requirement and will therefore not be discussed here.
Calibration methods become straight forward, if soft iron effects can be neglected compared to hard iron effects.
As already pointed out, in this case only the components of a constant interference field have to be measuredand compensated. In practice, soft iron effects are usually much weaker, provided there are no ferrous materialsat or near the compass. In this case, satisfactory results may be achieved by using the bidirectional calibrationmethod. Figure 21 illustrates the principle: Two measurements have to be carried out with the compass at thesame location, but at a heading difference of 180. For both measurements, the respective field components Hxand Hy have to be stored. Generally, the field at the compass is equal to the sum of earth field vector He andinterference field vector Hi. After a compass rotation of 180, He appears with equal magnitude but oppositesign, whereas Hi appears unchanged as its source is fixed with respect to the compass. Thus, the vector sum ofboth measurements H1 + H2 is:
=
++
+
++
=
+
=+
Hiy2
Hix2
HiyHey
HixHex
HiyHey
HixHex
y2H
x2H
y1H
x1HH2H1 (12)
Rearranging this vector equation, the interference field components as a function of the measured fieldcomponents are yielded as:
( )
( )y2Hy1H2
1Hiy
x2Hx1H2
1Hix
+=
+=(13)
He
-He
Hi
H1
H2
x
y
He earth fieldHi interference fieldH1 1st measurementH2 2nd measurement
(after 180rotation)
He
Figure 21 Principle of bidirectional calibration
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
29/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
29
Once the interference field components have been measured, their effect can be compensated by generatingopposite field components -Hix and -Hiy at the respective sensors. Using Philips magnetoresistive sensorsKMZ51 or KMZ52, this task can be fulfilled straight forward by applying appropriate currents to thecompensation coils of the respective sensors. In systems using a microcontroller, the compensation can bedone by subtraction of the interference field components from the respective sensor output signals.
The bidirectional calibration method can principally be implemented in an analog compass system. In that case,analog storage elements are required and a hardware implementation of equation (13). Using a microcontroller,the implementation of calibration procedures is generally simpler.
In applications, where not only hard iron effects, but also soft iron effects have to be compensated, moresophisticated calibration schemes have to be applied. These will not be covered by this application note,however a range of publications is available on that subject.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
30/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
30
8. TRUE NORTH CALIBRATION
Once the azimuth has been measured with a compass, one has to be aware, that this indicates the headingdirection relative to MAGNETIC north. However, in most practical cases, the heading direction relative toGEOGRAPHIC or TRUE north is required in order to allow navigation by means of a map. As the magnetic andgeographic poles of the earth do not coincide, the direction of true north and magnetic north can deviatesignificantly from each other. This deviation is referred to as declination. Declination is defined as angle fromtrue north to magnetic north. The value of declination varies with the position on earth and can be to the east orto the west. East declination means, that the magnetic north direction indicated by the compass is east of truenorth. Declination also varies over long periods of time, therefore only updated declination data should be usedfor compensation. Such data for locations world wide can be found at the web site of the National GeophysicalData Center NGDC [1].
In order to compensate for true north, the declination angle at the actual location has to be added to orsubtracted from the azimuth reading of the compass. The appropriate operation depends on whether thedeclination is to the east or to the west.
A practical way for compensation of declination at a certain location or area would be to hold a compass in truenorth direction (i.e. along a road which exactly heads toward north). The azimuth reading now gives thedeclination value, that can be used furtheron for compensation.
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
31/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
31
9. TILT COMPENSATION
As pointed out in section 2, it is the horizontal (i.e. perpendicular to gravity) component of the geomagnetic field,that points to magnetic north. To measure this horizontal component, a compass system as described so farmust be positioned, such that the sensitive axes of its field sensors are also in the horizontal plane. If howeverthe compass is tilt, i.e. not held horizontally, a reading error occurs. The error magnitude depends on the tiltangle of the compass and on the inclination or dip angle of the earths field at the respective location.
Figure 22 helps to gain a basic understanding of the tilt effect and allows to derive the maximum tilt error. Here,x and y are the sensitive axes of the compass and the z-axis is normal to the compass plane. To simplify theillustration, the compass axes here are fixed, such that the x-y plane is parallel to the earths surface, whereasthe tilt is simulated as a rotation of the earths field relative to the compass. A further simplification has beenmade, in that without tilt ( = 0) the y-axis coincides with the north-south direction and the x-axis coincides withthe east-west direction. Thus, without tilt, the horizontal component of He has only a y-component and correctlypoints towards north. For a tilt along the north-south axis (i.e. with east-west as rotation axis), the horizontalcomponent of He will vary in magnitude but will still point towards north. Thus, the tilt error is zero. If however atilt along the east-west axis (i.e. with north-south as rotation axis) occurs, as indicated in the figure, the directionof Hes horizontal component deviates from north by an angle . For any tilt along an axis between north-southand east-west, the resulting error depends on the tilt component along the east-west axis. Therefore, a tiltalong the east-west axis, as shown in Figure 22, causes the maximum error.
He
tilt
inclination
tilt error
Hesin
Hesinsin
Hecos
z
y = north-south
x
east-west
Figure 22 Tilt error
Derivation of the maximum tilt error from Figure 22 is straight forward:
( )westeastwesteast
max sintanarctancosHe
sinsinHearctan
=
=
(14)
This equation is independent of heading direction, thus the simplification in Figure 22, that x = headingdirection, causes no restriction. Equation (14) indicates, that the error increases with both inclination and tiltangle and that the error is zero, if inclination and/or tilt are zero. The maximum tilt error occurs for a tilt angleof 90, where sin equals one and therefore the error reaches the magnitude of the inclination . Figure 23
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
32/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
32
shows tilt error versus tilt angle for two loactions on earth. Inclination values for locations world wide areavailable at [1].
0,00
10,00
20,00
30,00
40,00
50,00
60,00
70,00
0 10 20 30 40 50 60 70 80 90
tilt angle in degree
tilterrorindegree
Singapore,
inclination = 13
Hamburg,
inclination = 68
Figure 23 Tilt error magnitudes
A classical method for avoiding tilt errors is to put a compass into a liquid, which provides horizontal levelling ofthe compass due to gravity. This is often referred to as mechanical gimbaling. However, as the compass hereis not fixed within its housing, interference fields caused by this housing are no deterministic signals anymoreand can therefore not be calibrated (refer to section 7).
Tilt error can be compensated without moving parts by converting the measured earth field componentsmathematically into the horizontal components. This technique is often referred to as electronical gimbalingand requires additional sensor elements:
A third magnetic field sensor, as now all three cartesian vector components of the earths field, i.e. Hex,Hey, Hez have to be measured.
Sensors for pitch and roll to detect the tilt status of the compass. Pitch and roll are terms coming fromaviation. As shown in Figure 24, pitch refers to a tilt along the x or heading direction (= rotation around the yaxis), whereas roll refers to a tilt along the y axis (= rotation around the x-axis).
Xe (heading)
Ye (right)
horizontalplanecom-
pass
roll
pitch
com-pass
Zc
XcYc
gravity
Figure 24 Definition of pitch and roll
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
33/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
33
The derivation of the horizontal earth field components Hxe, Hye from the measured field components Hxc, Hyc,Hzc requires a transformation between two rotated cartesian 3-D coordinate systems (refer to Figure 24).Equations (15) are the result of this transformation:
sinHzccosHycHye
cossinHzcsinsinHyccosHxcHxe
+==
(15)
Figure 25 gives a simplified block diagram for an electronically gimbaled compass system. Using Philipsmagnetoresistive sensors, the 3-axes field sensor system can be built up with a dual sensor KMZ52 for the xand y axes and a single sensor KMZ51 for the z axis. For pitch and roll sensing, gravity sensors as compactdevices in IC packages are available, realized by combining micro-machining and integrated circuit technology.
x,y,z-Field Sensors,e.g.KMZ52 + KMZ51
Pitch & RollSensor
Microcontroller
Hxc
Hyc
Hzc A
D
A
D
Figure 25 Electronically gimbaled compass
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
34/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
34
10. SYSTEM ACCURACY
Table 2 summarizes the main error influences on a compass system together with methods for calibration, asdiscussed in the respective sections of this paper. In all equations, is the real azimuth.
Table 2 Summary of errors and calibration methods
Error source Resulting azimuth error( - measured)
Calibration Seesection
Offsets Vox and Voyat SCU outputs
[ ]%V
V
/8.0
VcosV
VsinVarctan
max
y,ox
oxmax
oymax
+
+=
Assumption: oyox VV =
Continuous in-circuit calibration byflipping combined with electronicfeedback or mathematical correction.
5.2, 5.5
Sensitivity differenceS between SCUchannels
[ ]%S
S/3.0
tanS
S1arctan
+=
Trimming of SCU amplification toachieve equal amplitudes of Vout;if required, in-circuit T-driftcompensation by electro-magneticfeedback.
5.3, 5.5
Non-orthogonality, i.e.sensors mounted at90
( )
[ ]
+=
/1
cos
sinarctan
Measure as phase differencebetween SCU output voltages andstore it. Mathematical correctionduring operation.
5.4
Interference fieldHix,Hiy(hard iron effect)
[ ]%H
H/8.0
HcosH
HsinHarctan
e
y,ix
ixe
iye
+
+=
Determine interference fields, e.g.using bi-directional calibrationmethod. Correction mathematicallyor using compensation coils.
7
Declination [ ]= Shift zero-point of azimuth readingby .
8
Tilt ( )westeastsintanarctan =
: inclination angle
Continuous in-circuit calibration byusing 3-dimensional compass, pitch
and roll sensors and mathematicalcorrection.
9
During trimming for compensation of S, soft iron interference fields and tilt should be avoided, as these effectswould also appear as a difference in SCU output amplitudes.
In systems using a microcontroller, further errors occur, mainly due to quantization and non-linearity of the A/Dconverter.
As the individual errors described above are random quantities and independent of each other, the total systemerror can be found by applying the error propagation law:
2n
22
21tot E...EEE +++= (16)
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
35/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
35
11. APPLICATION EXAMPLES
Following block diagrams represent ideas for the realization of complete compass systems. The functionalblocks for signal conditioning and direction determination shown here have been described in earlier sections ofthis paper.
2-dimensionalfield sensor
KMZ52Signal Conditioning Unit
(SCU)
Direction DeterminationUnit (DDU)
LED Display
APPL_EX1.AI
Vx
Vy
x-channel
y-channel
Iflip
SHex
Iflip
SHey
SCU circuit, Figure 12without electro-magnetic feedback,(section 5.5)
8-segmentevaluationcircuit, figure 16;(section 6.1)
SCU circuit, Figure 12without electro-magnetic feedback,(section 5.5)
flipcoil
compensationcoil
Hex-Sensor
flipcoil
compensationcoil
Hey-Sensor
Figure 26 Analog 8-segment compass
2-dimensional
field sensorKMZ52
Signal Conditioning Unit
(SCU)
MeterDriver
Differentialair-core meter
APPL_EX2.AI
Vx
Vy
x-channel
y-channel
Iflip, Icomp
SHex
Iflip, Icomp
SHey
SCU circuit, Figure 12with electro-magneticfeedback,
(section 5.5)
SCU circuit, Figure 12with electro-magneticfeedback,(section 5.5)
flip
coil
compensationcoil
Hex-Sensor
flipcoil
compensationcoil
Hey-Sensor
Figure 27 Analog high resolution compass
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
36/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
36
2-dimensionalfield sensor
KMZ52
Signal Conditioning and Direction Determination Unit (SCU+DDU)(see section 5.5.9)
LED Display
APPL_EX3.AI
SHex
SHey
Vx
Vy
Iflip
A/Dconv.
Flipcoildriver
Pre-Amps
Microcontroller
Octal
LEDdriver
I/O
I/O
Software:- Flipping clock
generation- Offset-elimination
(section 5.2)- 8-Segment
Signal Evaluation(section 6.1)
- Interference fieldcalibration
(section 7)- True northcalibration(section 8)
flipcoil
compensationcoil
Hex-Sensor
flipcoil
compensationcoil
Hey-Sensor
EEPROM for calibration data
Figure 28 8-segment compass with microcontroller
Signal Conditioning and Direction Determination Unit (SCU+DDU)(see section 5.5.9)
APPL_EX4.AI
tonavigationsystem
2-dimensionalfield sensorKMZ52
SHex
SHey
Vx
Vy
Pre-Amps
flipcoil
compensationcoil
Hex-Sensor
flipcoil
compensationcoil
Hey-Sensor
Compens.
coil driver
Compens.coil driver
Flipcoildriver
EEPROM for calibration data
Microcontroller
I/O
Software:- Flipping clockgeneration
- Offset-elimination(section 5.2)
- T-compens. ofsensor sensitivity
- Interference field
calibration(section 7)
- Azimuth calculation(section 6.2)
- True northcalibration(section 8)I/O
I/O
e.g.12 bitA/DConv.
e.g.12 bitD/AConv.
N W
Displayincl. driver
serialinterface
Figure 29 High-end compass with microcontroller
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
37/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
37
12. REFERENCES
[1] Status Report of Repeat Data At the WDC-A,(Summary of data from geophysical observatories world wide)http://www.ngdc.noaa.gov/seg/potfld/mrepeat1.shtml
[2] Data sheet: KMZ52 Magnetic Field SensorPhilips Semiconductors
[3] Data Handbook SC17 including CD-ROM: Semiconductor SensorsPhilips Semiconductors, 1998
[4] Web site of Philips Semiconductors
http://www.philips.semiconductors.com/handbook/various_39.html
8/4/2019 Electronic Compass Design Using KMZ51 and KMZ52
38/38
Electronic Compass Design usingKMZ51 and KMZ52
Application NoteAN00022
Philips Semiconductors
APPENDIX 1 List of abbreviations
H magnetic field vector
H magnetic field strength
He(x,y) magnetic field strength of earths field (x,y component)
Hi(x,y) magnetic field strength of interference field (x,y component)
S sensitivity (of sensor element or SCU channel)
SCU signal conditioning unit
DDU direction determination unit
Voy,x SCU offset voltage (x or y channel)
Vy,x SCU output voltage (x or y channel)
S sensitivity difference between SCU channels
azimuth angle, exception:section 4: angle between current and magnetization within a magnetoresistive element
non-orthogonality of sensor system
dip or inclination angle
tilt error angle pitch angle
declination angle
roll angle
tilt angle
APPENDIX 2 Unit conversions
1 Tesla = 104
Gauss = 109
Gamma = 7,96105
A/m