By Yuan Fude
Mobile navigation and positioning play an increasingly important role in today's mobile software services, making multi-axis motion sensors an indispensable core component of mobile and consumer electronic devices. Among these multi-axis motion sensors, the magnetometer provides absolute directional positioning by sensing the Earth's magnetic field. When combined with an accelerometer and a gyroscope, it can fully complete navigation and positioning functions.
Because the Earth's magnetic field strength is only about 0.3 ~ 0.4G, the magnetometer is highly sensitive to magnetic interference in its environment. In modern, ultra-thin, and compact electronic products, internal space is highly compressed. Many magnetic components—such as various jacks, capacitors, lithium batteries, and even printed circuit boards—are placed very close to the magnetic sensor. As a result, the magnetic interference is often much greater than the Earth's magnetic field it intends to measure. Additionally, sudden external strong magnetic fields, such as passing cars or trains, close proximity to other electronic products, or nearby magnets, can also interfere with the magnetic sensor and affect the accuracy of its heading determination.
To improve the accuracy of geomagnetic positioning, many electronic products require users to manually calibrate the device when the electronic compass is activated to initialize the magnetic sensor. When sudden magnetic interference occurs, manual calibration must also be used to reset the magnetic sensor and return it to a normal measuring state. However, because individual differences in gestures and habitual movements during manual calibration are significant, the resulting distribution of data points is often poor, which affects the sensor's accuracy and can even exacerbate measurement errors.
Furthermore, because most magnetic sensors on the market operate in a continuous measurement mode, errors will continuously accumulate, leading to misjudgments in heading angles. Therefore, whether in terms of accuracy or operational convenience, current magnetic sensors still have a lot of room for improvement. This article will introduce the principles and applications of anti-interference technology.
Comprehensively Considering Internal and External Interference: Targeted Magnetometer Design Magnetic interference can be divided into internal interference and external interference based on its source and its relative position to the electronic device equipped with the magnetic sensor. The impact of these two types of interference on measurement results and the errors they generate are different, meaning the required calibrations also differ.
Soft Iron / Hard Iron Interference Originates from the Electronic Device Itself Internal interference mainly comes from the inherent magnetism of the internal components within the electronic product itself, which cause interference by being too close to the magnetic sensor. Because this interference is located inside the product, its direction of effect relative to the magnetic sensor can be considered constant; it does not change as the user rotates the device, and therefore it can be eliminated through calibration.
Based on its characteristics, interference can be categorized into Soft Iron interference and Hard Iron interference. Soft iron interference refers to the deflection effect of high-permeability materials on the magnetic field in space. As shown in Figure 1a, the magnetic field/magnetic field lines in space converge toward the high-permeability material internally, resulting in an uneven distribution of magnetic field strength. Different shapes, uneven permeability distributions, and differing directions of the target magnetic field relative to the high-permeability material have a significant impact on the convergence state of the magnetic flux. In a magnetic sensor subjected to soft iron interference, the interaction between the geomagnetic field and the high-permeability components causes the spatial trajectory of the obtained geomagnetic vector to form an ellipsoid surface rather than a perfect sphere, as shown in Figure 1b.

Figure 1: Schematic of Soft Iron Interference
Hard iron interference is a constant magnetic field generated by internal components, typically caused by magnetic parts with relatively low permeability. Its value can be the sum of vectors produced by one or multiple components at the sensor's location. As shown in Figure 2a, due to its low permeability, it does not interact with the target magnetic field but merely adds a constant value to the target magnetic field's vector. Under this type of interference, the measured geomagnetic trajectory in space remains a perfect sphere, but the position of its center will shift away from the origin, as shown in Figure 2b. The amount of this shift represents the magnitude of the hard iron interference.

Figure 2: Schematic of Hard Iron Interference
Constant / Sudden Strong Magnetic Fields are the Main Sources of External Interference Unlike internal interference, external interference shares the same spatial orientation as the Earth's magnetic field, and its vector is superimposed on the target magnetic field vector. Therefore, it cannot be calibrated or separated out; the interference source must be removed before measurements can resume. This can be a constant interference source or a sudden strong magnetic interference. This type of interference will not change the perfect spherical trajectory of the measured magnetic field vector in space, nor will it cause the sphere's center to shift from the origin. Instead, it causes the vector's length—that is, the sphere's radius—to change, as shown in Figure 3.
In practical examples of constant interference, if the magnetometer is located in an environment with numerous or large magnetic substances—such as steel-framed buildings, iron towers, iron bridges, or inside elevators—the Earth's magnetic field will interact with these environmental magnetic substances or superimpose on them. Once the resulting geomagnetic vector length falls outside the sensor's dynamic range, the sensing function will still exist, but the heading determination will be inaccurate. The device must be moved away from the interference source to position correctly.
Sudden strong magnetic fields are another common form of external interference that easily occurs. When a product equipped with a magnetic sensor gets close to an object with a strong magnetic field, such as a motor, a transformer, or a high-strength permanent magnet, the sensor will fail because the local magnetic field value far exceeds its dynamic range.

Figure 3: Schematic of External Interference
After the strong magnetic field is removed, even if it returns to the measurable range, two factors can lead to inaccurate sensing. First, the magnetic state of the sensor itself has been altered. After experiencing a strong magnetic field, the alignment of magnetic moments inside the magnetic material changes, resulting in measurement failure. This type of interference produces a signal trajectory in space similar to Figure 2b. This phenomenon is more pronounced in 3-axis Hall sensors and Magnetoresistance sensors.
Another scenario is that the internal magnetic environment of the device equipped with the magnetic sensor has changed. Specifically, the strong magnetic field alters the internal soft and hard magnetic structures of the device, causing it to deviate from its factory calibration value and fail. This type of interference produces a signal trajectory in space similar to Figure 1b.
As previously mentioned, the combined effect of internal soft and hard iron interference causes the spatial trajectory of the measured external magnetic field vector to present as an offset ellipsoid, as shown in Figure 4a. Therefore, its calibration must encompass two parts: the perfect sphere correction and the offset correction. The primary method is to place the device equipped with the magnetic sensor on a 3-axis rotating turntable, rotating it 360 degrees across three mutually perpendicular planes to collect data and outline the spherical contour, as shown in Figure 4b. Then, algorithms are used to calculate and correct the sphere's geometry and return the center to zero, as shown in Figure 4c.

Figure 4: Magnetic Sensor Calibration Methods
After experiencing strong magnetic interference, the generation of irreversible magnetization causes the sensor's output response to the external magnetic field to follow the dashed line shown in Figure 5b. Not only are the maximum and minimum output values reduced and the response trajectory deviates from linear behavior, but an output of VaA or VbA is also produced even when the external magnetic field is zero. This result leads to inaccurate sensor measurements.
Hysteresis Affects GMR/TMR Output Response Paths
The output response of Giant Magnetoresistance (GMR) or Tunneling Magnetoresistance (TMR) sensors to an external magnetic field is shown in Figure 5c, which is similar to the relationship between magnetization intensity and magnetic field shown in Figure 5a. Before interference, GMR or TMR exhibits a reversible linear output within the saturation magnetic field range, as indicated by the solid line in the figure. Upon reaching magnetic saturation, the output also saturates and remains at its maximum and minimum values; when the external magnetic field is zero, the output value rests at a level of VoGT. The operating range of the sensor is equal to its saturation magnetic field. After experiencing magnetic interference, the emergence of hysteresis alters the output response path, as shown by the dashed line in the figure. This generates an output of VaGT or VbGT when the external magnetic field is zero, resulting in sensing failure.
Hall Component Permeability is Influenced by External Magnetic Fields
The output response of a Hall sensor is shown in Figure 5d. The Hall component is a semiconductor and is not inherently magnetic. The function of its internal magnetic structure is to utilize its high permeability to deflect the external magnetic field into a specific measurement direction, rather than sensing the magnetic field directly. This role is vastly different from the aforementioned magnetoresistive sensors. However, the response of its magnetic structure's magnetization intensity to an external magnetic field in a specific measurement direction is similar to that of the magnetoresistive sensors. Because the magnetic field measured by the Hall component relies on deflection by the magnetic structure, as it gradually approaches a state of saturated magnetization in the measurement direction, its permeability in that direction approaches zero. Consequently, it can no longer deflect the external magnetic field, and the sensor output will approach zero.
It is worth noting that although the Hall component itself has no operating range limits, the magnetic structure it relies upon does possess a saturation magnetic field, which in turn establishes an operating range. As shown in Figure 5d, its operating range is much smaller than the saturation magnetic field due to its relatively narrow linear response region. However, because the saturation magnetic field of the internal magnetic structure within the Hall component is more than an order of magnitude larger than that of a magnetoresistive structure, the actual dynamic range of the sensor remains larger than that of a magnetoresistive sensor. Before interference, the output value rests at a level of VoH when the external magnetic field is zero. After experiencing magnetic interference, the presence of hysteresis changes the output response path, as shown by the dashed line in the figure, generating an output of VaH or VbH when the external magnetic field is zero, leading to sensing failure.

Figure 5: Magnetization states of various magnetic sensors and their output responses to external magnetic fields.
Because the magnetic structures within Hall components are too large, they cannot be effectively initialized by any means within an acceptable power consumption range. As a result, after suffering from external strong magnetic interference, the only way to restore a normal measurement state is through manual calibration by the user. Therefore, they suffer from insurmountable limitations in terms of both accuracy and convenience of use.
Magnetic Initialization / Two-Directional Magnetic Setting Overcomes Inaccuracy Issues To address the problem where external strong magnetic fields acting on the sensor itself change the magnetization state of its internal magnetic structure and cause failure, magnetic setting (reset) technology can assist in sensor correction. This technology's methodology can be divided into two forms: first, magnetic initialization, and second, magnetic alternating reset. The principles and characteristics of these two different working mechanisms will be introduced below.
Magnetic initialization is primarily applied in Giant Magnetoresistance (GMR) magnetic sensors. Its approach involves placing a coil at the sensor's location. Every time the electronic compass is activated or after it encounters external strong magnetic interference, a current is passed through the coil to generate a magnetic field. The direction of this magnetic field is perpendicular to the sensor's measurement direction, thereby initializing the magnetic properties of the sensing unit. This resetting magnetic field can restore the response trajectory of the magnetization intensity to the external magnetic field from the dashed line containing irreversible magnetization back to the pre-set measurement state and solid line trajectory. The output will also revert to a linear solid line trajectory passing through the origin, completing the initialization.
The timing relationship between its magnetic resetting and data sampling is shown in Figure 6a. After the reset current passes through the coil, continuous data sampling begins until the next reset mechanism is activated. While this method can effectively recover errors caused by external magnetic interference, because magnetic initialization is only performed once, errors caused by the hysteresis phenomenon may gradually accumulate as measurement time increases. If intermittent magnetic interference occurs during long-term sensing, accuracy will gradually degrade.
Two-directional magnetic setting is applied in Anisotropic Magnetoresistance (AMR) sensors. Similar to initialization, a coil covers the area of the sensing unit, and a drive current creates a magnetic field to magnetize the sensing unit, reverting the output drift caused by hysteresis back to the origin. However, the difference lies in the fact that the driving current in the coil is bi-directional rather than unidirectional. This means the resulting magnetic field alternates between positive and negative directions, applying alternating forward and reverse magnetization to the sensing unit perpendicular to its measurement direction.

Figure 6: Timing Relationship Between Magnetic Resetting and Data Sampling
This two-directional magnetic setting causes the output signal to reverse. By subtracting these two obtained, oppositely phased signals from one another, double the output intensity—meaning double the sensitivity—can be obtained. Additionally, subtracting the two signals can cancel out effects caused by circuit asymmetry and the vast majority of noise, especially low-frequency noise, achieving an extremely low-noise sensor.
The timing relationship between its magnetic resetting and data sampling is shown in Figure 6b. After a reset current passes through the coil, one data sample is taken; upon completion, a reverse reset current is passed through the coil to magnetize the sensing unit in the opposite direction, and another data sample is taken. Subtracting the two obtained signals yields the final measured signal.