-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Magnetometer Calibration #9
Comments
Yes, and the algorithm described here
<https://github.com/kriswiner/MPU6050/wiki/Simple-and-Effective-Magnetometer-Calibration>
does a pretty good job of both, you might have to collect data long enough
to get a good sampling of the response surface. You are moving the sensor
to sample the entire 3D sphere during the calibration, aren't you?
If you just leave the sensor flat on a table during the calibration, you
aren't doing it right...
…On Wed, Dec 20, 2017 at 1:32 PM, dmamalis ***@***.***> wrote:
@kriswiner <https://github.com/kriswiner> i have been using your code to
make an ecompass and I have had a few problems which I am trying to pin
down. Seeing issues on other repos of yours I decided to put some more
effort on calibrating the magnetometer before posting.
According to my results, unless I am doing something terribly wrong, the
magcal algorithm seems to be inadequate.
First I run it multiple times and found out that the magBias results are
completely different. Then I plotted some experiments to make this a bit
more concise. In the next screenshots you can see three views of the same
experiment.
[image: screenshot from 2017-12-20 23-21-00]
<https://user-images.githubusercontent.com/5211553/34229620-a6aa83ec-e5dd-11e7-91a0-529e5e26f512.png>
[image: screenshot from 2017-12-20 23-20-39]
<https://user-images.githubusercontent.com/5211553/34229621-a6cc9496-e5dd-11e7-8bf7-1e8fb937c8bb.png>
[image: screenshot from 2017-12-20 23-20-22]
<https://user-images.githubusercontent.com/5211553/34229622-a6f025aa-e5dd-11e7-8e1a-5b85c79f4dbe.png>
It looks like there is need for both soft and hard iron calibration.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qof7gDvZrG_83wV92UrUgDU0BgURks5tCXzygaJpZM4RI_Sl>
.
|
That was a quick reply! Thank you. I also used the MotionCalc calibration tool to visualize data and I realized that the previous screenshots MUST be wrong, at least with regards to the soft iron issue. I am guessing my gnuplot script is faulty. Here is the MotionCalc screenshot with shows much better soft iron results No I am definitely not leaving it flat but I guess a few more samples might be a better solution. Last but not least, could you please explain to me why the magBias is commented out in these lines? |
Because this sketch is using the mag offset bias registers internal to the
LSM9DS1:
//write biases to accelerometermagnetometer offset registers as counts);
writeByte(LSM9DS1M_ADDRESS, LSM9DS1M_OFFSET_X_REG_L_M, (int16_t) mag_bias[0]
& 0xFF);
writeByte(LSM9DS1M_ADDRESS, LSM9DS1M_OFFSET_X_REG_H_M, ((int16_t)mag_bias[0]
> 8) & 0xFF);
writeByte(LSM9DS1M_ADDRESS, LSM9DS1M_OFFSET_Y_REG_L_M, (int16_t) mag_bias[1]
& 0xFF);
writeByte(LSM9DS1M_ADDRESS, LSM9DS1M_OFFSET_Y_REG_H_M, ((int16_t)mag_bias[1]
> 8) & 0xFF);
writeByte(LSM9DS1M_ADDRESS, LSM9DS1M_OFFSET_Z_REG_L_M, (int16_t) mag_bias[2]
& 0xFF);
writeByte(LSM9DS1M_ADDRESS, LSM9DS1M_OFFSET_Z_REG_H_M, ((int16_t)mag_bias[2]
…> 8) & 0xFF);
On Wed, Dec 20, 2017 at 2:33 PM, dmamalis ***@***.***> wrote:
That was a quick reply! Thank you.
I also used the MotionCalc calibration tool to visualize data and I
realized that the previous screenshots MUST be wrong, at least with regards
to the soft iron issue. I am guessing my gnuplot script is faulty.
Here is the MotionCalc screenshot with shows much better soft iron results
[image: screenshot from 2017-12-21 00-26-24]
<https://user-images.githubusercontent.com/5211553/34231781-0b411188-e5e6-11e7-8a48-791f9d233b51.png>
No I am definitely not leaving it flat but I guess a few more samples
might be a better solution.
Last but not least, could you please explain to me why the magBias is
commented out in these lines?
https://github.com/kriswiner/LSM9DS1/blob/master/LSM9DS1_
MS5611_BasicAHRS_t3.ino#L437
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGY1qmz_QfeoiRVFr2pdQB_g6J9C0XRBks5tCYsvgaJpZM4RI_Sl>
.
|
I changed the samples to 512 to give some extra data and the calibration is much better now. I consider this closed. Thank you. |
@kriswiner i have been using your code to make an ecompass and I have had a few problems which I am trying to pin down. Seeing issues on other repos of yours I decided to put some more effort on calibrating the magnetometer before posting.
According to my results, unless I am doing something terribly wrong, the magcal algorithm seems to be inadequate.
First I run it multiple times and found out that the magBias results are completely different. Then I plotted some experiments to make this a bit more concise. In the next screenshots you can see three views of the same experiment (mx, my, mz being printed)
It looks like there is need for both soft and hard iron calibration.
The text was updated successfully, but these errors were encountered: