How to Calibrate a Magnetometer | Digi-Key Electronics

Описание к видео How to Calibrate a Magnetometer | Digi-Key Electronics

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.

A written version of this guide can be found here: https://www.digikey.com/en/maker/proj...

Example code shown in the video: https://github.com/ShawnHymel/mag-cal...

Adafruit SensorLab: https://github.com/adafruit/Adafruit_...

PJRC MotionCal: https://www.pjrc.com/store/prop_shiel...

NOAA magnetic declination calculator: https://www.ngdc.noaa.gov/geomag/decl...

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.

Additionally, nearby ferrous materials can distort the magnetic fields (known as “soft iron distortions”). We can sample the raw X, Y, and Z values and analytically find the scaling factors to account for this type of distortion. If you’d like to dig into the math, we recommend checking out this application note: https://www.nxp.com/docs/en/applicati...

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:
Adafruit Feather M0 Basic - https://www.digikey.com/en/products/d...
Adafruit Triple-Axis Magnetometer LIS3MDL - https://www.digikey.com/en/products/d...
Adafruit STEMMA JST PH 4-pin to male header cable - https://www.digikey.com/en/products/d...

Related Videos:
Magnetometer Tutorial - https://www.digikey.com/en/videos/n/n...
3D Magnetic Field Sensor IC (Magnetometer) - https://www.digikey.com/en/videos/m/m...

Related Project Links:
How to Calibrate a Magnetometer - https://www.digikey.com/en/maker/proj...

Related Articles:
Adafruit Magnetometer Calibration Tutorial - https://learn.adafruit.com/adafruit-s...
How to Calibrate a Magnetometer? - https://www.appelsiini.net/2018/calib...
Tutorial: How to calibrate a compass (and accelerometer) with Arduino - https://thecavepearlproject.org/2015/...
Magnetometer Hard & Soft Iron Calibration - https://www.vectornav.com/resources/i...
Calibrate an eCompass in the Presence of Hard- and Soft-Iron Interference - https://www.nxp.com/docs/en/applicati...

Learn more:
Maker.io - https://www.digikey.com/en/maker
Digi-Key’s Blog – TheCircuit https://www.digikey.com/en/blog
Connect with Digi-Key on Facebook   / digikey.electronics  
And follow us on Twitter   / digikey  

Комментарии

Информация по комментариям в разработке