Question

In the custom Android device we are developing the magnetometer is placed really close to the internal speakers. The permanent magnets in the speaker are affecting the values of the magnetometer. The x,y,z values are reaching the maximum values that the magnetometer can report.

Can re-calibrating fix this issue? Should the hard iron calibration technique be used for this? Can this be handled in magnetometer driver or it has to be done in firmware only?

Was it helpful?

Solution

Yes, you can compensate for the effects of hard-iron and soft-iron on an Android device. You would need to determine which one (or both) is skewing the magnetic field around the sensor. Hard-iron offsets are easy to determine and compensate for. Soft-iron skewing of the sphere into an ellipsoid can be much more difficult to deal with. Your implementation will probably depend on what you specifically need to compensate for. The good news is that your sensors are fixed you can probably do the big calculations once and then just apply the offsets.

There are a few different approaches to hard-iron and soft-iron compensation. The most simple approach is this: http://memsense.com/docs/MTD-0802_1.2_Magnetometer_Calibration.pdf. A more difficult approach using least squares fit is described here: http://cache.freescale.com/files/sensors/doc/app_note/AN4248.pdf. The hard iron offset isn't that difficult, but the soft iron offset requires fitting data to an ellipse or ellipsoid and significant amounts linear algebra. I have tried versions of both and they both work. Each has advantages and disadvantages depending on how much processing power you have and how badly the magnetic field is being skewed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top