How to Calibrate a Magnetometer | Digi-Key Electronics

preview_player
Показать описание
Magnetometers are fantastic sensors that allow you to measure the strength and direction of magnetic fields. With a little bit of math, they can be used as digital compasses to find your absolute orientation on Earth. However, they are very susceptible to extraneous magnetic fields (hard iron distortions) and nearby ferrous materials (soft iron distortions).

In this video, we construct a basic digital compass using a magnetometer, which measures the strength and direction of the Earth’s magnetic field. We demonstrate possible distortion effects and show how to perform hard iron and soft iron calibration.

Due to the moving, liquid metal in the outer core, the Earth acts like a giant magnet. While the magnetic field produced is not very strong, we can still detect it with permanent magnets (how a needle compass works) or magnetometers. If we find the direction of the field, we can find the direction of the magnetic north and south poles. From there, we can calculate our absolute heading.

However, nearby permanent magnets and electric currents produce magnetic fields that can interfere with these readings. This is known as “hard iron distortion.” We can sample the magnetic field strength around the sensor to create simple X, Y, and Z offset values that we subtract from our raw readings.

In the video, we show how to perform the magnetometer calibration process using Adafruit SensorLab and PJRC MotionCal. We then use the offset values from that program to create a calibrated digital compass. Finally, we include magnetic declination so you can see how to convert from a magnetic heading to a geographic heading.

Product Links:

Related Videos:

Related Project Links:

Related Articles:

Learn more:
Рекомендации по теме
Комментарии
Автор

Well done.
Brings back memories of the ArduPilot early days when IMU where implemented. Good source btw.

isojed
Автор

Great video, very very useful for drone builders. Thanks for sharing!

John_Smith__
Автор

Garrett Evans Wow thank you Garrett, you've made my day!

martinbengtsson
Автор

Thanks for a complete explanation with visuals. Much appreciated 🎈

JurassicJenkins
Автор

I have a question, it seems many tuts about hard and soft iron distortion is not quite accurate.
As you can see, you subtract hard iron Vector, and left multiply soft iron Matrix, BASED ON YOUR IMU'S COORD SYS, which means both distortions are coming from the magnetic materials ON YOUR CHIP. Which means where ever you go, your calibration works. what you mentioned at 18:30, means assemble everything up, then calib right?
The distortion from the enviroment, at a certain position, will only be a vector add to the earth mag field vector. And cuz they changes in diffrent position, it's a none linear transformation based on world axis. you simply can not calib them.

leoakimono
Автор

Plz make video on tilt compensation also.

nakulsingh
Автор

> @12:10: "Along one particular axis."
From what I understand, the axis of the ellipse will not necessarily be parallel to any particular magnetometer axis, but could be any possible rotation.

Consider a large MLCC (They have Nickel terminals) directly off (and too close to) one corner of the magnetometer package. This would cause a concentration of magnetic flux that is more or less directly diagonal to some two axis of the chip. This would, in turn, cause higher apparent magnetic intensity aligned with the diagonal and thus the major axis of the ellipse would also be aligned with the diagonal.

JustAnotherAlchemist
Автор

Think I want to neglect the earth magnetic field by placing a strong magnet. Do I need to calibrate the hard iron and soft iron calibration. Another thing is I want to know whether the magnetometer behave as it is soclose to the magnet ?Because I didn't get desired behavior from the magnet.

nadunnilupulliyanawaduge
Автор

Correct on the ellipsoid.
What I think is a better approach is continuous calibration. Every time you get a vector in a particular direction, store the scale. Eventually you get a full sphere of vectors.
I don't think its a good idea having a completely separate calibration and use mode

Nickle
Автор

It would be nice if the Git page was still available. And then there seems so be some typos in the code provided with the writeup.

ShivasiddharthUma
Автор

Great video, I followed all instructions with this video and Adafruit configuration notes from their website and the only sketch that I could get to upload was the Blink sketch. How did you manage to upload imucal nosave? I've tried everything and get Error compiling for Adafruit Feather M0 (SAMD21). If you can help this would be great.

ericchristian
Автор

how to validate the x, y, z, value if its correct or not

sijinahi
Автор

Would the tilt compensation you briefly mention at the end also account for the Earth's magnetic flux lines being more vertical in reference to the ground the closer you get to the magnetic poles?

Sembazuru
Автор

What magnetometer would you recommend for a 3-axis (azimuth, elevation, tilt) Satellite Antenna Tracker? Would it benefit from an accelerometer?

nox
Автор

I can't download MotionCal, anyone has a link please ?

AlbertRei
Автор

so my question is, if you only care about relative difference, do you still need to calibrate - that's an awful lot of trouble to go through. I just want it to tell me that the heading has changed by a few degrees, and then use that to update the car steering to put it back on course. But, I find that even calibrated, it isn't repeatable, or at least not that I can see.

keithschaub
Автор

The PJRC MotionCal software download link (Windows) does not appear to be functional. I supposed there's still the Adafruit Jupyter notebook but it's kinda a bummer.

alkalinemc
Автор

Has anybody gotten MotionCal (or the Adafruit Jupyter notebook) to work? I tried Windows, Linux, and Mac and didn't get anywhere.

quigs
Автор

try making a simple inertial measurement unit (accelerometer) wired mouse, no light/laser or ball sensors

Jkauppa
Автор

great thank you but can you make course arm (spi, i2c, that will be great please😊😊

marwankhaledkasem