01-31-2024 11:38 AM
hello.
I use the X-axis and Y-axis data obtained from the BMM150 to do the following
Compass = atan2f (mag_mx, mag_my);
if (compass < 0)
{
compass+= 2 * PI;
}
if (compass > 2 * PI)
{
compass-= 2 * PI;
}
TCompass = compass * 180 / PI;
When the X-axis points north, I get zero degrees, and I can rotate it to get an Angle from 0 to 360
But as I move horizontally north, my Angle slowly increases. Is that normal?
What causes it?
What do I need to fix this?
01-31-2024 11:12 PM
Hi,
Thanks for your inquiry.
It is good that you can obtain BMM150 x/y/z raw data in the unit of uT. But you cannot directly run your atan2f function to get the heading, because every magnetometer needs to be calibrated first to remove the hard-iron and soft-iron distortions. For more details you may refer to online article at https://learn.adafruit.com/adafruit-sensorlab-magnetometer-calibration?view=all. After you calibrate BMM150 and get the normalized BMM150 x/y/z data in the unit of uT, you can use your atan2f function to get the heading.
In addition, when you move BMM150 horizontally straight for example on a long table from point A to point B, the heading may change. This is because the environmental magnetic field at point A is different from the one at point B. This means that you need to calibrate BMM150 at both point A and point B in order to get accurate heading.
Thanks.
02-01-2024 02:49 AM
HI,
Thank you very much for your reply
Since this project is very urgent, I do not have more time to study the calibration of magnetometer. Could you please provide the example or procedure of BMM150 calibration?
02-02-2024 04:02 AM
HI,
In the online article you provided, the BMM150 is not one of the types of magnetometer that supports calibration
02-02-2024 05:40 PM
Hi,
BMM150 calibration is integrated in BSX (Bosch sensor fusion) and BSX is embedded inside BHI360 smart sensor chip. This means that if you use BHI360 + BMM150, you will immediately get 9DoF sensor fusion results including heading/pitch/roll Euler angles. You don't need to develop your own calibration algorithm and heading calculation algorithm.
In addition, BMM150 is end of life as shown in the attched PDN. You may switch to BMM350 TMR technology based magnetometer. This means that if you use BHI360 + BMM350, you will get everything right away. There are APP3.0 base board and BHI360 shuttle board available in Digikey, Mouser, etc. distributors for your quick evaluation.
Thanks.