SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By jku
#179778
I'm trying to get the 9 degrees of Freedom Edison block (with LSM9DS0 sensor) to work acceptably and am having some problems: the magnetometer seems uncalibrated and I don't see easy ways to work around that.

Here's a plot of the X and Y values of the magnetometer while turning the device 360 degrees around z axis:
lsm9ds0-magnetometer-datarange.png
If I use the normal atan (x/y) code to calculate heading from that, it'll be pretty bad... but applying a bias of ~65 to the X axis would make it pretty good.

Obviously I can use that plot to calibrate my own device manually, but let's assume I'm trying to create software that works on all Edisons. Should I consider the unit defective or have I missed something and there is a way to calibrate the magnetometer without user interaction (or alterntively a way to get useful heading data without calibration)?
You do not have the required permissions to view the files attached to this post.
By jremington
#179779
That looks awful, but it can be fixed!
Magnetometers must be manually calibrated, and fairly frequently.
Here are two methods. The second is more involved but much more accurate.
http://www.bot-thoughts.com/2011/04/qui ... on-in.html
http://sailboatinstruments.blogspot.com ... ation.html

Here is a 2-D version based on the latter post:
https://forum.sparkfun.com/viewtopic.php?f=42&t=36399
By jku
#179782
Thanks a lot for the pointers, that looks sensible. In fact, it could maybe even be done over normal use if done carefully...
jremington wrote:Magnetometers must be manually calibrated, and fairly frequently.
Aw, really? They drift that much?

As a software guy, hardware sometimes seems magical ("h264 decoding with 0 cpu load, whaa?") and sometimes it just makes me go "could that be any worse?"... This motion sensor is in both categories currently.
By jremington
#179783
Magnetometers are extremely sensitive devices, and exposing them to stray magnetic fields (from just about anything even weakly magnetized) can induce offsets or even latch them up.