0
\$\begingroup\$

I am using a magnetometer to detect metal objects. I typically take a reading when the software starts (zero offset calibration) and assuming that there are no metal objects in the vicinity and then periodically start take a reading from the sensor. If a metal object is placed in the vicinity of the sensor, the readings usually exceed a certain threshold and the presence of an object can be detected this way. So far so good.

However, due to other nearby objects (metal objects not directly in the vicinity etc) and thermal drift the magnetometer base reading will drift from the originally taken one. Are there any algorithms/methods suggested in order to try to maintain a good zero offset?

I was thinking of starting with the initial zeroing perhaps and then upon sensing that the object was removed, a new reading for the zero calibration could be taken. This way it always updates whenever there isn't an object.

\$\endgroup\$
6
  • \$\begingroup\$ You may want to search "hard and soft iron calibration". You could try AC-coupling although your use-case sounds like might be better off with a magnetometer that is only sensitive to AC fields rather than DC fields. You could also continuously low-pass filter a reading at a very low cutoff frequency (0.1Hz) and use that as your "zero". \$\endgroup\$
    – DKNguyen
    Commented Jan 24, 2020 at 22:54
  • \$\begingroup\$ @DKNguyen Hi thank you for your answer! I will look up these terms. Can you elaborate further about them please? \$\endgroup\$
    – Luke Galea
    Commented Jan 24, 2020 at 22:57
  • \$\begingroup\$ Hard iron refers to distortions in the magnetic field from actual magnetic sources. Soft iron refers to distortion from materials that alter magnetic fields but are not sources themselves. Reading your question again, this might not be relevant but if you are working with magnetometers you should read about it anyways. \$\endgroup\$
    – DKNguyen
    Commented Jan 24, 2020 at 22:58
  • \$\begingroup\$ @DKNguyen It's still interesting to look up cheers. I think that my question is more related to data analysis? \$\endgroup\$
    – Luke Galea
    Commented Jan 24, 2020 at 22:59
  • 1
    \$\begingroup\$ Yeah your question is. Think about AC coupling or using an extremely low-pass filtered shadow signal as your reference. You could also do stuff like detect the rate of magnetic change rather than the actual level (this is essentially AC coupling done in software). It would mean that something moving very slowly would be overlooked (but this would be true for low-pass filter reference method too which can be done in either hardware or software via FIR filters). \$\endgroup\$
    – DKNguyen
    Commented Jan 24, 2020 at 23:00

1 Answer 1

1
\$\begingroup\$

Here are some possible approaches:

  1. AC couple your sensor.

  2. Continuously produce an extremely low-pass filtered version of your signal (<0.1Hz) and use that as your "zero". You can filter in hardware or in software (using something like FIR filters). If done in software want to seed your filter with the initially measured value as zero so that when you start up you don't have to wait 10 seconds or more for the zero to settle.

  3. Instead of using the magnetic field strength for detection, differentiate the signal and use the rate-of-change/slope of the magnetic field strength for detection. This is basically a software version of #1. Calculating slope can be tricky in practice because of noise. Small amplitude, but rapid noise fluctuations make is so that if you calculate the slope between very closely spaced samples the slope could be enormous but is not actually reflective of the overall slope. Which means you either have to low-pass filter first (in either software or hardware) or just use samples spaced farther apart in time so the rapid fluctuations due to noise aren't interpreted as a severe slope in the signal.

    Take any real world signal with noise (even a flat line) and differentiate it in spreadsheet software and plot it will be very obvious.

All these methods will overlook something moving very slowly.

\$\endgroup\$
1
  • \$\begingroup\$ All of these methods are the same, namely a highpass filter. To prevent the non detection of a strong DC signal, one could add an attenuated lowpass version. This will make the gain at DC nonzero. It can be chosen such that the largest foreseeable drift extent will still not trigger the detection threshold. \$\endgroup\$
    – tobalt
    Commented Mar 27 at 4:36

Your Answer

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

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