0

Adafruit_HMC5883_U Magnetometer cal.
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit_HMC5883_U Magnetometer cal.

by mbal on Tue Sep 22, 2020 4:25 am

Hi. I think this might be a typical novice question.
I have been using a MPU6050 breakout with a HMC5883L breakout and I'm following the "How to Fuse Motion Sensor Data into AHRS Orientation" tutorial. So far I'm running the Adafruit AHRS sensor unified code, and have adapted it with the Adafruit_HMC5883_U library, and the Adafruit_MPU6050 library along with "MotionCal.exe" from PJRC. Its working great but I'm confused on how some magnetometer conversion constants are worked out. I'm looking into the HMC5883L data sheet Table 9: Gain Settings, and I cant see how the code in the file Adafruit_HMC5883_U.cpp, uses the following.

event->magnetic.x = _magData.x / _hmc5883_Gauss_LSB_XY * SENSORS_GAUSS_TO_MICROTESLA;
event->magnetic.y = _magData.y / _hmc5883_Gauss_LSB_XY * SENSORS_GAUSS_TO_MICROTESLA;
event->magnetic.z = _magData.z / _hmc5883_Gauss_LSB_Z * SENSORS_GAUSS_TO_MICROTESLA;

Then later in the main loop, its multiplied by 10? What's the code converting to, and how does that relate to the HMC5883L data sheet Table 9? What being calculated?

Serial.print(int(mag_event.magnetic.x * 10));
Serial.print(",");
Serial.print(int(mag_event.magnetic.y * 10));
Serial.print(",");
Serial.print(int(mag_event.magnetic.z * 10));

How is _hmc5883_Gauss_LSB_XY & (_Z) ( worked out, with all the different parameters that can be selected in the setMagGain() function?

Thanks for your help, and for the great samples available.

mbal
 
Posts: 2
Joined: Tue Sep 22, 2020 4:09 am

Re: Adafruit_HMC5883_U Magnetometer cal.

by mbal on Wed Sep 23, 2020 4:36 am

anybody want to have a go at explaining what's being done?

mbal
 
Posts: 2
Joined: Tue Sep 22, 2020 4:09 am

Please be positive and constructive with your questions and comments.