Magnetic sensor

Table of contents
3.Introduction
4.Specification requirements
5.Solutions suggestions
6.The magnetic fields sensors
7.The inclination measurement system
8.The gyroscope
9.The data acquisition system
10.Communication system
11.The power supply
12.Realisation of the PCB
13.The embedded system
14.Static Library Util.a
15.ViewPort
16.Xcompass
17.Sensors controller commands
18.Test
19.Future improvements
20.Conclusion
21.References

6.    The magnetic fields sensors

These sensors are the central components in the compass applications. The different categories of magnetic field sensor can be classified between:

  • Mechanical magnetic: It consists of a ring magnet or pair of bar magnets attached to be graduated mica readout disk. The magnet and disk assembly floats in a mixture of water and alcohol, such that it is free to rotate around the jewelled pivot.
  • Fluxgate: it measures the horizontal component of the earth magnetic field from a variation in the sensing coil.
  • Hall Effect: It is based on the observations that a DC voltage develops across a conductor or semiconductor when in the presence of an external magnetic field.
  • Magnetoresistive: The magneto resistors are sensible to the earth magnetic field. If a magnetic field is detected, the magneto resistance varies that drives a voltage variation to its poles.
  • Magnetoelastic: It is based on the magnetic sensitivity of some materials. A magnetic field drives a change of the material’s length that can be then measured to evaluate the ambient magnetic field.
    • We orientate our choice on magnetoresistive sensors, which offers the advantage

    • to be cheap
    • without internal moving parts
    • easy to interface with other electronic systems
    • fabricated in an IC-like process
    • due to their higher sensitivity, they are superior to Hall effect sensors

6.1.                     The principle of operation

The aim of a magnetic sensor is to evaluate the physical quantity of the earth’s magnetic field. This quantity varies according to the location on the earth and from the nearby environment.

6.1.1.      The magnetic field on the earth

The magnetic field could be compared to a bar magnet within the earth, oriented from the north to the south. The magnetic field lines generated point from the earth’s South Pole to its North Pole. The field lines are perpendicular to the earth surface at the poles and parallel at the equator.

Note: The magnetic poles do not coincide with the geographical poles, which are defined by the earth’s axis of rotation. The angle between the magnetic and the rotational axis is about 11.5°. Consequently, the magnetic field lines do not exactly point the geographic north.

Figure 5: Earth field vector

6.1.2.      The detection of the magnetic field

The magnetoresistive sensors are based on the Barber pole structures. The resistance of this strip changes in function of the magnetic field, which causes, in the nickel-iron’s film deposited on a silicon wafer, the magnetization vector to rotate.

MR1

Equation 1

The magnetoresistive strip, are assembled in a Wheatstone bridge (Figure 6). This structure presents the advantage to linearize the variation of the magnetic field and to compensate mutually the temperature drift and to detect the sign of Hy.

Figure 6: Wheatstone bridge on-chip component

If a voltage is applied between the poles of the bridge, the sensor can then measure the ambient magnetic field in the sensitive axis. This last one causes a change in the bridge resistance that corresponds to a change in a voltage output:

            ?V = Vo+ - Vo-

Three magnetoresistive sensors will detect the earth field vector (see Figure 5). From this vector, the azimuth can be calculated.

6.2.                      Additional feature

6.2.1.      Set / Reset trap

The magnetoresistive sensors are by nature bi-stable: the direction of their internal magnetization can be inverted. This flipping causes an inversion of the sensor characteristic, such that the sensor output voltage changes polarity. The components can be stabilised against unwanted flipping by applying an auxiliary magnetic field parallel to the flipping axis.

A “Set/Reset” coil circuit near the sensor element is a means to apply the auxiliary filed for the flipping. It can be pulsed with a high current to:

  • force the sensor to operate in the high sensitivity mode
  • flip the polarity of the output response curve
  • be cycled during normal operation to improve linearity and reduce cross-axis and temperature effects.

6.2.2.      Compensation coil

In addition, some magnetoresistive sensors allow the compensation the sensitivity drift or the interference fields. To do so, any ambient magnetic field can be cancelled by driving a current on a compensation coil. The sensor has to be equipped of a pin for driving this current.

This solution is very useful to counter-act the effects of hard iron interference resulting from the magnetic signature of the MMR (ex: from the antenna). Once evaluated, the value of the interference field could then be magnetically subtracted.

6.3.                     The selection of the magneto sensors

           

We have selected the following components from two different manufacturers: Philips and Honeywell. All the components selected presented the advantages to have a Set/Reset coil.

The Honeywell’s devices present the following characteristics:       

Name Field range[G] Sensitivity [mV/V/G] Resolution [mG] Coil compensation coil current [A] Price  [$]
HMC1022 ± 6 1 85 Yes 0.5 20.00
HMC1052 ± 6 1   No 0.5 20.00
HMC1002 ± 2 3.2 27 Yes 3.2 22.00

Table 1: Honeywell’s devices comparison

HMC1002 has a higher sensitivity, however it will require a 5-20 DC/DC converter (ex MAX662A) to drain the 3,2A coil current.

The Philips’s devices[4] present the following characteristics:

Name Field range [G] Sensitivity [mV/V/G] Resolution [mG] Coil Compensation coil current [A] Price [$]
KMZ52 ± 2.5 1.28   Yes 1 5.16

Table 2: Philips’s devices comparison

To reduce the choice between the previous components we have keep only those with a good sensitivity: the KMZ52 and the HMC1002. In addition, the other characteristics are sufficient for our application.

To increase the overall accuracy, a third magnetic sensor could be added to compensate the inclination value. The KMZ51 for Philips and HMC1001 for Honeywell present the equivalent characteristic to respectively KMZ52 and HMC1002.

As the technical characteristics of the components HMC1001 and 1002 from Honeywell and the KMZ51 and KMZ52 from Philips are closed, we have analysed the source of error possible for these components:

Source of error Error estimation Remark Correction
Offset error » 0.8° / %   Hardware correction using the flip coil.
Temperature sensitivity » 0.3° / %   Software correction and electromagnetic feedback
Non orthogonality » 1° / % KMZ52 have a 2° error. HMC10xx have a 0.01° error. Software correction.
Declination 25° It depends on the location in the earth => a GPS may be useful Software correction.
Tilt »1° / ° It depends also on the location. Software correction, a third magnetic sensor and a 2 axis accelerometer.
Hard Iron effect » 0.8° / %   Calibration may be compensate with a gyro
Soft Iron effect » variable They increase in indoor application.  

Table 3: Error quantification

We can observe from this table that the Honeywell sensors are more sensitive than the Philips’ ones. They also have a less important non-orthogonality error. Moreover, we had good feedback on the Honeywell component from independent forum on Internet. Consequently, the HMC1002 and the HMC1001 sensors occur to be the best choice for our application. They match to our requirements and many of their error could be reduced by program and by other sensors.

6.4.                     Design of the magneto sensors circuit

To be functional, the differential output of the magneto sensors has to be amplified. To increase the overall accuracy of the system, a coil flip circuit and a compensation coil circuit have to be envisaged.

6.4.1.      Amplification

The magnitude of a magnetic field similar to the earth field will lead to a variation at the output of the sensor comprised between:

V0± = Vcc / 2 ± S * Vcc * (H – Hc)

V0± = 2500 ±8 mV

H: magnitude of the field on the sensitive axis (magnetic earth field » 0.5 Gauss)

Hc: compensation field (0 Gauss)

S: sensibility of the HMC100x sensor (3.2 mV/V/Gauss)

V0±: output + or - of the magneto sensor 

Equation 2

The gain Gm is then:

Gm = Vadc / (V0+ - V0-)

Gm = 256

            Vadc:  ADC voltage range (4096 mV)

Equation 3

A circuit based on instrument amplifier is required to adjust that gain.

6.4.1.1. Suggestion 1

Ampli2

Figure 7: Amplification schematic 1

The gain of this stage is defined by: G = R / Rgain

So we can adjust the gain by varying the resistance Rgain.

The output of this schematic is expressed by the following expression:

Vout = G * (Vin - Vref) + Ref   

           

Ref: Voltage reference (Vadc / 2)

Vin±: Voltage input

G: amplification gain

The AMP04 from Analog Devices realize this schematic. It can be supply by a mono-polar voltage 0-5V. However, this amplifier cost 22$ and we look a cheaper solution.

6.4.1.2. Suggestion 2

Ampli1

Figure 8: Amplification schematic 2

The gain of this stage is defined by: G = 5 + 80k / Rgain

As for the suggestion 1 we can adjust the gain by varying the resistance Rgain.

The output of this schematic is expressed by the same following expression as previous:

Vout = G * (Vin - Vref) + Ref   

           

Ref: Voltage reference (Vadc / 2)

Vin±: Voltage input

G: amplification gain

Equation 4

The INA2126 from Texas Instrument implement the schematic. This chip has the same characteristic than the previous amplifier and it is cheaper: 5.24$. This device contains two amplifiers in the same package.

Additionally, the first schematic can be obtained by an adaptation on the recommended circuit for the INA2126:

·         Pins 14 and 3 no connected

·         Pins 12 and 5 connected to Ref instead of AGND

·         Connected together the pins 15 and 16, 1 and 2 ® Vin+

·         Connected Rgain to the pin 4 and to the pin 13 ® Vin-

6.4.2.      Flip coil circuit

The on-chip Set/Reset of the HMC100x should be pulsed with a high current (>3A) to realign the magnetic domains in the sensor and to eliminate indirectly the offset. The field value is the difference between the magnitude read after a Set and Reset.

  This pulse can be as short as possible (3us) and on average consumes less than 1mA when pulsing continuously.

They are many ways to design the flip coil circuit. We used the recommended one on the application note about the HMC1002[1]:

pulse

Figure 9 : The pulse circuit

The current pulse is drawn from the 4.7 µF capacitor. Two Mosfets (IRF7105) trigger the pulse. This circuit is supply in 20V. The SET and RESET signals are generated by the microprocessor and control the P and N channel of the Mosfets. The purpose of creating a delay d (>5µS) between is to make sure that one Mosfet is off before the other one turns on.

Figure 10: Set/Reset command

6.4.3.      Compensation coil circuit

The purpose of this circuit is to generate a current to drive the compensation coil of the magneto sensor.

The Compensation field is defined by the Equation 2.

Hc = Sc * Ic

 

            Sc: coil compensation sensitivity (100ma/Gauss)

            Ic: compensation current

Equation 5

           

So we need first to realise a transconductance amplifier

We decided to be able to compensate a magnetic field lower than 0.5 Gauss. Therefore, the value maximal of Ic is about 50mA. There are many ways to obtain this current.

Figure 11: Compensation driver

6.4.3.1. Commanded by an operational amplifier

A simple circuit based on an operational amplifier could drive small current to the magneto sensor. However, this current is not strong enough to compensate 0.5 Gauss.

 

6.4.3.2. Commanded by a push pull with a cross distortion

A model based on two-mirrored push pull stage of a common amplifier could drive the current needed for the compensation coil.

This circuit presents the advantage to have a null current offset around 2,5V. However, the output signal will not be linear: a cross distortion appears.

Figure 12: cross distortion

6.4.3.3. Commanded by a push pull without offset

To reduce the cross distortions due to the dead zone during which one none of the two transistors conduct. The following circuit could reduce this effect:

transconductance anplifier2

Figure 13: current driver based on a push-pull

However, we no introduce an offset in the signal:

 Figure 14: offset

Between the two versions of the push pull we choose to not compensate the cross distortion.

6.4.4.      Command from a microcontroller

We know have to generate the voltage from the microcontroller. There are three main ways to do so.

6.4.4.1. A DAC to generate the signal

If a DAC is present on the microcontroller, the port could be directly used to generate wanted voltage. If not, a cheap 8 bits ADC could be implemented on the card. The inconvenient will be to require eight ports on the microcontroller if a parallel DAC is used.

6.4.4.2. To filter the PWM

If a PWM port is available on the microcontroller, a simple solution could be to filter the output. The voltage is then obtained by changing the duty cycle.

The problem with this solution is that even filtered, the signal will oscillate introducing a variation on the measure.

6.4.4.3. To use a digital potentiometer

A third solution consists to use a digital potentiometer to divide Vcc voltage. Xicor manufacturer proposes some interesting ones: the X9316 that can be commended by three wires (up or down, increment, chip select). This potentiometer has the advantage to keep the position of the cursor on EPROM when and restore the value when they are powered. We decided to choose this solution.

We have a circuit for each axis to compensate each axis separately and they can be unconnected of the rest of the system by removing the jumper if no compensation is needed.

 
digipot

Figure 15: Digital potentiometer

contact - link to this site