edit/tl;dr: The set/reset strap driver is an H-bridge circuit to deliver 10 mA of DC current to a strap which temporarily produces about a 1.1 gauss magnetic field offset. A change in the measurement before and during this field offset can be used to confirm that the device is functional, as a manufacturing test. However, these straps are also said to work for degaussing, but I have still not found clear instructions how to use them to degauss the sensor. Usually degaussing of macroscopic objects is done with an AC field that slowly decreases in amplitude.

When I hear degaussing I think of the application of an oscillating (AC) external magnetic field to a magnetized ferromagnetic material, then slowly ramping the amplitude of the oscillations field down to zero to remove almost all residual magnetization. Automatic (and manual) degaussing magnetic heads on tape recorders and magnetic shielding on CRTs are some examples.

However, a quick read of that article shows that the term degaussing also applies to the cancellation of the external fields resulting from magnetization of materials through the careful use of one or more coils excited by a DC current to "cancel" the field within some finite region. The example there is large coils on ships to cancel the fields resulting from the ferromagnetic hulls producing external fields excited by the Earth's magnetic field.

In the cases of the HMC5883L 3-Axis Digital Compass chip - or any similar type of Magnetoresistive sensor, how does the degaussing feature work? Are there actually coils inside the chip that are intended to carry DC currents to cancel some fields? How is this done - how are the currents correctly calculated and applied?

Here is HMC5883L_3-Axis_Digital_Compass_IC.pdf where it says:

Feature: Built-In Strap Drive Circuits

Benefit: Set/Reset and Offset Strap Drivers for Degaussing, Self Test, and Offset Compensation

enter image description here

above: screenshot from the datasheet. There are separate OFFSET STRAP DRIVER and SET/RESET STRAP DRIVER circuit blocks, and they appear to be separately controllable.

  • \$\begingroup\$ Try reading the data sheet - it seems clear enough. Hint: it's called self-test. \$\endgroup\$
    – Andy aka
    Aug 1, 2016 at 15:01
  • 1
    \$\begingroup\$ @Andyaka Please read the question again also. I have explained two types of degaussing. I assume it is the second kind that this function is designed for of course, not the first. I think you are asking about the first kind. \$\endgroup\$
    – uhoh
    Aug 1, 2016 at 15:21
  • 2
    \$\begingroup\$ @Sparky256 degaussing in this context is not demagnetizing. I think the constant insistence that degaussing must always and only mean demagnetizing is muddying the water. I think spending the first two paragraphs explaining this in the question (anticipating this confusion) and then patiently reiterating this several times in the comments is very nice of me. The three functions listed are "Degaussing, Self Test, and Offset Compensation" and this question is on the first of those three. It is not related to demagnetization in any way. \$\endgroup\$
    – uhoh
    Aug 1, 2016 at 22:06
  • 1
    \$\begingroup\$ @uhoh. Understood. The degaussing maybe nothing more than an offset null for the internal ADC, or bias currents for the sensor cell. I think the manufacture should have chosen another term besides 'degaussing', which is misleading in this case. \$\endgroup\$
    – user105652
    Aug 1, 2016 at 22:23
  • 3
    \$\begingroup\$ @Sparky256 I appreciate your time very much - I'm asking a questions that is not already answered in the data sheets that I link to in my questions. I don't think that makes the question too broad. I think it makes it a good question. It may turn out that a stepped, monopolar 1.1 gauss field is sufficient for "traditional" degaussing of the magnetoresistive device itself, even if it seems way too low for everyday degaussing. I've also asked about the physics here. Let's get to the bottom of this! \$\endgroup\$
    – uhoh
    Aug 2, 2016 at 0:17

4 Answers 4


I know this is an old thread, but I encountered it while trying to resolve a problem with my quadcopter compass. I think the confusion about "degaussing" the HMC5883L comes from what appears to be two functions associated with the strap/H bridge circuitry. One function is self test wherein the strap/H bridge generates 1.1 gauss based on a 10ma current; the second function of the circuitry is to pulse a much higher current to "degauss". This current is sourced from an external capacitor (nominally 0.22uf) and is implied to be quite high and short duration (note in the datasheet the requirement for low ESR capacitor). It also appears (though less clear from the data sheet) that the sensor is "pulsed" then read and then "reset pulsed" and read again and the two reads are subtracted to account for residual magnetism and temperature drift. That would imply that the "degauss" action occurs for each and every read. This would seem to suggest that it cannot be commanded on demand but rather happens automatically as part of each read. What I am now wondering how well the internal degauss function really works if the chip is exposed to very high fields and how long it takes (how many read cycles) to work (assuming I correctly understand the operation).

  • \$\begingroup\$ Hey this is great!! I remember reading, not really understanding, then forgetting the use of the word "pulsed". OK with this help I'll go back and re-read the data sheet more thoroughly. Thank you for taking the time to post this! \$\endgroup\$
    – uhoh
    Nov 14, 2017 at 16:47
  • \$\begingroup\$ I'll contribute a small retro-active bounty. I think a few more people will up-vote as well, bringing you to 100 reputation so you can start leaving comments. \$\endgroup\$
    – uhoh
    Nov 14, 2017 at 16:49

Why it's called degaussing...

Degaussing is traditionally thought of as a demagnetizing procedure. It's apt here, but you have to think of that magnetization in terms of its super-posed components.

Consider this magnet in a magnetic field:

enter image description here

This is what the sensor elements in the earth (or other external field) experience. The "measurement" is actually the deflection of the needle from a known reference point (the center of the scale in this example) to a point on the scale created by the strength of the external field(s).

If a constant (or unequal) external field is applied over time, eventually the "spring" will lose some restoring force (tension). If you then remove the external force, the needle won't return all the way back to center.

In the magneto-resistive device case, the equivalent is a shift in the magnetic alignment vector. The domain of the sub-atomic particles is aligned with the origin field and when you add an additional field the particles are oriented away from this domain altering the electrical resistance of the device.

However, like the mechanical spring, the long term consistent exposure results in a gradual realignment of the origin domain and sensor stops being able to detect the external field as being different from it's reference "original" one.

To fix this, degaussing coils are present to provide a strong local impulse (momentary force) to remove any of these external influences and reset the magnetic domain to its original alignment, thus recalibrating the transducer.

So in a sense it is demagnetizing the device... by re-magnetizing it to the original orientation and removing the excess magnetization.

Usage in Magnetoresistive applications

For any specific device, you can find the actual activation procedure for the degauss coils in the datasheet. Typically it consists of two lines that are driven in opposition to run current in one direction through the coil, then in the reverse direction by flipping the polarity of the two signals. There is often an internal amplifier in the part between the control pin(s) and the actual coil(s) so that the inputs may safely remain high impedance and not pull too much current from whatever is driving the control pins (typ. microcontroller).

The harder questions are when and how frequently to perform this procedure -- that's the core of the question and the source of the OP's frustration.

Datasheets don't include answers to these questions because they are application-specific. Degauss operations have a high energy and interference (EMC) cost. You need to degauss when your sensor loses enough performance that it impacts your application.

Performance is the combination of sensitivity and tolerance. The rate at which the sensor drifts (loses sensitivity or adds offset) is a function of the environment (how strong and unbalanced are the external fields). The amount of drift (error) that you consider tolerable is a function of your application (how deep is your ADC noise floor, how error-tolerant are your algorithms, etc).

If you don't have an external event available to use as a warning sign of reduced performance, the common practice is to simply reset at regular intervals.

  • \$\begingroup\$ I didn't ask what is degaussing or why is it necessary, I asked specifically "How is the degaussing feature in the HMC5883L 3-Axis Digital Compass chip correctly used?". That is a nice big color vote-attracting picture though :) Here is a related question I've also asked in Physics SE; What is actually happening when a magnetoresistive magnetometer degausses itself?. I have a hunch that the material used in the sensor is extremely susceptible to becoming magnetized. Your answer might also be helpful there, but I'm looking for specifics! \$\endgroup\$
    – uhoh
    Mar 19, 2017 at 17:56

Here is an application note explaining the set/reset functionality: https://aerospace.honeywell.com/~/media/aerospace/files/application-note/an213_set_reset_function_of_magnetic_sensors.pdf

  • \$\begingroup\$ Super! Thank you very much! I'll give this a good read today. \$\endgroup\$
    – uhoh
    Jan 8, 2018 at 7:49

Digging into the details, this IC does have real degaussing/calibration coils, which are more of a strip then a coil. The calibration procedures are the last several paragraphs. This is quoted directly from the datasheet you posted.


www.honeywell.com 9


Anisotropic Magneto-Resistive Sensors
The Honeywell HMC5883L magnetoresistive sensor circuit is a trio of sensors and application specific support circuits to measure magnetic fields. With power supply applied, the sensor converts any incident magnetic field in the sensitive axis directions to a differential voltage output.

The magnetoresistive sensors are made of a nickel-iron (Permalloy) thin-film and patterned as a resistive strip element. In the presence of a magnetic field, a change in the bridge resistive elements causes a corresponding change in voltage across the bridge outputs. These resistive elements are aligned together to have a common sensitive axis (indicated by arrows in the pinout diagram) that will provide positive voltage change with magnetic fields increasing in the sensitive direction.

Because the output is only proportional to the magnetic field component along its axis, additional sensor bridges are placed at orthogonal directions to permit accurate measurement of magnetic field in any orientation.

Self Test

To check the HMC5883L for proper operation, a self test feature in incorporated in which the sensor is internally excited with a nominal magnetic field (in either positive or negative bias configuration). This field is then measured and reported. This function is enabled and the polarity is set by bits MS[n] in the configuration register A.

An internal current source generates DC current (about 10 mA) from the VDD supply. This DC current is applied to the offset straps of the magnetoresistive sensor, which creates an artificial magnetic field bias on the sensor. The difference of this measurement and the measurement of the ambient field will be put in the data output register for each of the three axes.

By using this built-in function, the manufacturer can quickly verify the sensor’s full functionality after the assembly without additional test setup. The self test results can also be used to estimate/compensate the sensor’s sensitivity drift due to temperature. For each “self test measurement”, the ASIC:
1. Sends a “Set” pulse
2. Takes one measurement (M1)
3. Sends the (~10 mA) offset current to generate the (~1.1 Gauss) offset field and takes another measurement (M2)
4. Puts the difference of the two measurements in sensor’s data output register:

To check the HMC5883L for proper operation, a self test feature in incorporated in which the sensor offset straps are excited to create a nominal field strength (bias field) to be measured.

To implement self test, the least significant bits (MS1 and MS0) of configuration register A are changed from 00 to 01 (positive bias) or 10 (negetive bias). Then, by placing the mode register into single or continuous-measurement mode, two data acquisition cycles will be made on each magnetic vector. The first acquisition will be a set pulse followed shortly by measurement data of the external field.

The second acquisition will have the offset strap excited (about 10 mA) in the positive bias mode for X, Y, and Z axes to create about a 1.1 gauss self test field plus the external field. The first acquisition values will be subtracted from the second acquisition, and the net measurement will be placed into the data output registers.

Since self test adds ~1.1 Gauss additional field to the existing field strength, using a reduced gain setting prevents sensor from being saturated and data registers overflowed. For example, if the configuration register B is set to 0xA0 (Gain=5), values around +452 LSb (1.16 Ga * 390 LSb/Ga) will be placed in the X and Y data output registers and around +421 (1.08 Ga * 390 LSb/Ga) will be placed in Z data output register.

To leave the self test mode, change MS1 and MS0 bit of the configuration register A back to 00 (Normal Measurement Mode). Acceptable limits of the self test values depend on the gain setting. Limits for Gain=5 is provided in the specification table.

Below is an example of a “positive self test” process using continuous-measurement mode:

  1. Write CRA (00) – send 0x3C 0x00 0x71 (8-average, 15 Hz default, positive self test measurement)

  2. Write CRB (01) – send 0x3C 0x01 0xA0 (Gain=5)

  3. Write Mode (02) – send 0x3C 0x02 0x00 (Continuous-measurement mode)

  4. Wait 6 ms or monitor status register or DRDY hardware interrupt pin

  5. Loop Send 0x3D 0x06 (Read all 6 bytes. If gain is changed then this data set is using previous gain) Convert three 16-bit 2’s compliment hex values to decimal values and assign to X, Z, Y, respectively. Send 0x3C 0x03 (point to first data register 03) Wait about 67 ms (if 15 Hz rate) or monitor status register or DRDY hardware interrupt pin.


  1. Check limits – If all 3 axes (X, Y, and Z) are within reasonable limits (243 to 575 for Gain=5, adjust these limits basing on the gain setting used. See an example below.) Then All 3 axes pass positive self test Write CRA (00) – send 0x3C 0x00 0x70 (Exit self test mode and this procedure)
    Else If Gain<7 Write CRB (01) – send 0x3C 0x01 0x_0 (Increase gain setting and retry, skip the next data set)

Else At least one axis did not pass positive self test.
Write CRA (00) – send 0x3C 0x00 0x70 (Exit self test mode and this procedure)

End If
Below is an example of how to adjust the “positive self” test limits basing on the gain setting:

  1. If Gain = 6, self test limits are: Low Limit = 243 * 330/390 = 206 High Limit = 575 * 330/390 = 487

  2. If Gain = 7, self test limits are: Low Limit = 243 * 230/390 = 143 High Limit = 575 * 230/390 = 339

  • \$\begingroup\$ This is the part about self-testing. The benefits of the "Set/Reset and Offset Strap Drivers" are 1) "Degaussing", 2) "Self Test", and 3) "Offset Compensation". I'm asking specifically about 1) "Degaussing" and you've pasted a section on 2) "Self Test". I really appreciate your help, but I'm not interested in Self Test. I'm asking about something that is not explained in the PDF. If the answer was explained in the PDF, I would not have asked here. \$\endgroup\$
    – uhoh
    Aug 1, 2016 at 23:28
  • \$\begingroup\$ @uhoh. If you would read the details, they are all the same thing. The procedures account for all 3 operations you mentioned. That is why you could not find a section on "Degaussing", as it is part of these calibration procedures. For once, please read ALL the details. \$\endgroup\$
    – user105652
    Aug 1, 2016 at 23:35
  • \$\begingroup\$ Applying a fixed ~10ma current to produce a repeatable field of about 1.1 gauss is a testing procedure. It's either on or off. If it is meant to somehow cancel or compensate for another arbitrary field, the current would have to be continuously variable and include both signs, and I don't see that here. I'm beginning to wonder if the word "degaussing" should never have been used in the product description to begin with. \$\endgroup\$
    – uhoh
    Aug 1, 2016 at 23:47
  • 1
    \$\begingroup\$ Here is an interesting clue! - bottom of page 2: http://www.digikey.tw/Web%20Export/Supplier%20Content/HoneywellSSEC_342/pdf/honeywell-mps-faqs.pdf \$\endgroup\$
    – uhoh
    Aug 1, 2016 at 23:51
  • \$\begingroup\$ It turns out the data sheet is just not clear about this, but there is a degauss procedure that is separate from the calibration feature; electronics.stackexchange.com/a/339877/102305 \$\endgroup\$
    – uhoh
    Nov 15, 2017 at 3:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.