I'm are woking on an embedded device that needs to know the compass heading. I'm using FXOS8700 for this along with sensor fusion library (thankfully!) for calibrating magnetometer and finding compass heading.
But, the results of calibration are not always reliable. By this, I mean that the compass headings are drifting by +/-40 degrees from correct values after certain calibrations. After some instances of calibration we do get correct compass heading, but after some instances of calibration we don't get correct the compass heading.
In our application, we are not using the calibration function continuously, since it is an application where, unlike a smartphone, the device will not experience change in tilt or intensity of magnetic-field after the device is installed. We do the calibration once initially and store the compensation vectors and matrices, and apply them later.
So, is the calibration algorithm that is implemented in the sensor fusion library expected to return correct calibration values always? If yes, any idea what I could be missing here or how I can get to the bottom of the issue? If no, is there a way to identify a poor calibration and get around it?
A note of some observations, in case they are of help:
1. After a calibration with fit error 2%, compass headings are inaccurate, while after a calibration with fit error 5%, compass headings are quite correct.
2. It is observed that almost always if compass heading is incorrect while pointing device to the north, then while pointing to the south also it is incorrect. Similarly, if the compass heading on pointing to the east is incorrect, then the compass heading on pointing to the west is also incorrect.
3. Test was conducted on the same device, PCB - no hardware changes.
Thanks in advance,