In this illustration we will going to wire the HMC5883 III AXIS Magnetometer, this module is capable of sensing 3 directions. It’s communicate with the HMC5883L Chip onI2c interface with on-board logic level converter. The HMC588L is using 3.3 or 6v should be supplied.
The HMC5883L Chip is develop by Honeywell Aerospace, a multi-chip module designer for low-field magnetic sensing with the digital interface for applications such as compassing and magnetometry. The HMC5883L includes high-resolution HMC118X series magneto-resistive sensors plus an ASIC contacting amplification, automatic degaussing strap drivers, offset cancellation, and a 12 bit ADC that enables 1 degree Celsius to 2 degree Celsius compass heading accuracy.
The i2c serial bus on-board allows for easy interface to the chip. The HMC5883L 3.0×3.0x0.9mm surface mount 16pin leadless chip carrier (LCC). These sensor is a solid-state construction with very low cross-axis sensitivity designed to measure both the direction and magnitude of the Earth magnetic fields.
Application:
The HMC5883L mostly used in Navigation System, Mobile Phones, Netbooks, Consumer Electronics, and Personal Navigation Device.
Note: You cannot get the exact data without calibration. For measuring the magnetic field there will be two categories of distortion.
Hard Iron Distortion – The hard iron distortions refer to the presence of magnetic fields around the sensor the magnets, power supply, cables and wires.
Soft Iron distortion – The soft iron distortion refer to the presence of ferromagnetic materials around the sensor, which skew the density of the earth’s magnetic field locally and related to scaling offset errors.
Magnetometer
A magnetometer is a type of sensor that measures the strength and direction of the local magnetic field. The magnetic field measured will be a combination of both the earth’s magnetic field and any magnetic field created by nearby objects. The magnetic field is measured in the sensor reference frame.
Earth’s Magnetic Field
The earth’s magnetic field is a self-sustaining magnetic field that resembles a magnetic dipole with one end near the Earth’s geographic North Pole and the other near the earth’s geographic South Pole. The strength of this magnetic field varies across the Earth with strengths as low as 0.3 Gauss in South America to over 0.6 Gauss in northern Canada. Although this magnetic field is relatively stable over time, electric currents in the ionosphere can cause daily alterations which can deflect surface magnetic fields by as much as one degree. Normally daily variations in field strength are on the order of 0.25 mGauss, which would equate to about a 0.03 degree variation in heading. This small of a change in heading is on the same order of magnitude as the resolution of most MEMS
based magnetometers, so in most cases the Earth’s magnetic field can be considered constant with respect to time.
Read More > http://www.vectornav.com/support/library/magnetometer
As you may know to get the exact magnetometer data you should calibrate the magnetometer. TO resolve this issue you should apply the bias to the vector of the non-calibrated data of X, Y, Z coordinates and multiply the transformation matrix by the result vector.
Calibrating with a box
Place the HMC5883L on the top of a box shown on the illustration above and click (Point 180) button of the Axix X+.
1. “Point 0”, “Axis X+”
2. “Point 180”, “Axis X+”
3. “Point 0”, “Axis X-”
4. “Point 180”, “Axis X-”
5. “Point 0”, “Axis Y+”
6. “Point 180”, “Axis Y+”
7. “Point 0”, “Axis Y-”
8. “Point 180”, “Axis Y-”
9. “Point 0”, “Axis Z+”
10.”Point 180″, “Axis Z+”
11.”Point 0″, “Axis Z-”
12.”Point 180″, “Axis Z-”
As you can see above the magnetometer calibration is the process of getting the transformation matrix and the bias. To acquire these data you need to use the MAGMASTER.exe software which can be downloaded here.
Wiring Component:
- Arduino Board
- HMC5883L Digital Compass Module Board
- Jumper / DuPont Wires
- Solder less Bread Board
Wiring Diagram:
Arduino Sketch
Using MAGMASTER
You need to fill the table to MagMaster then click “Calculate Transformation Matrix and Bias and get the required matrix & bias. As you can see on the MagMaster Windows the transformation matrix and the bias are acquired. you can now calculate the calibrated magnetometer data in your device in a real time using the matrix and the bias. The test code can be found in TestResult below.
You can now apply the sphere radius stablization algorithm to your program download the RadiusStablization below or can be found inside MagMaster.Zip file.
Below are the calibrated magnetometer vector coordinates in 3D space with radius stabilization
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
/* ****************************************************************************************************** 14CORE --- TEST CODE for MHC5883L Digital Compass Magnetometer Credit to: YURI ****************************************************************************************************** */ #include "Wire.h" //Include Wire library #include "HMC5883L.h" //Include MHC5883L.h Code Library HMC5883L compass; //Copy place the folder "HMC5883L" in the folder <"C:\Program Files\Arduino\libraries"> and restart the IDE. float xv, yv, zv; // Float point variable XV, YV, ZV define numbers with fractional parts. void setup() { Serial.begin(9600); //Start Serial Communication at baud rate 9600 Wire.begin(); compass = HMC5883L(); setupHMC5883L(); } void loop() { getHeading(); Serial.flush(); Serial.print(xv); //Reading floating point xv Serial.print(","); Serial.print(yv); //Reading floating point yv Serial.print(","); Serial.print(zv); //Reading floating point zv Serial.println(); delay(100); } void setupHMC5883L() { compass.SetScale(0.88); compass.SetMeasurementMode(Measurement_Continuous); } void getHeading() { MagnetometerRaw raw = compass.ReadRawAxis(); xv = (float)raw.XAxis; yv = (float)raw.YAxis; zv = (float)raw.ZAxis; } |
Download MagMaster Software here | Zip
Download Arduino Sketch Code Radius Stabilization | Zip
Download Arduino Sketch Code Test Result | Zip
Download Arduino HMC588L Code Library | Zip
Download MHC588X Datasheet here | Pdf
Download MHC588 Module Schematics | Pdf