I need to get heading /compass values varies between 0 to 360 to differ from North. Please help to get the angles.
For eCompass, you need more than just a driver. You need magnetic calibration software and the tilt-compensation algorithm. Both are included in the NXP sensor fusion library. Depending on your MCU, there are two options. For FRDM-K64F and FRDM-K22F development boards, use the Version 7.0 sensor fusion kit, which is part of the ISSDK component of the Kinetis SDK. That can be generated and downloaded from Welcome to MCUXpresso | MCUXpresso Config Tools .
FRDM-KL25Z/KL26Z/KL46Z and FRDM-K20D50M boards are supported only via the Version 5.00 software available at http://www.nxp.com/sensorfusion.
Both kits come with full documentation for the sensor fusion algorithms.
Thanks Mike Stanley, I have to design the generic way to implement FXOS8700 as Compass to interface with other micro controllers. I am getting Compass value in the absence of External field/iron material and without tilt. But compass angle is varies when External field induced / tilt the compass. Can you please help to minimize the errors.
Section 6 of Application Note AN5021 describes the math behind an eCompass. It is contained as part of the V7.00 sensor fusion kit I mentioned earlier. AN4248 and AN4246 are also applicable and can be located by searching the NXP web site for "eCompass".
I will note that excluding the device drivers, the code in the sensor fusion kit is fairly portable. And it IS ok for you to port it to other MCUs. Filename magnetic.c in the kit contains the magnetic calibration algorithm. orientation.c contains the functions that compute orientation.
I am also using the same FXOS chip for getting the eCompass heading.
did you solve your problem, i am also facing the same issue. I am getting RAW values from accelerometer x,y,z & magnetic x, y, z data. I am able to convert the rotation, pitch & roll.
But i need the eCompass 0 - 360 degree heading values. how to apply the formula using RAW values. I am not using any Gyro only accel & mag values are getting from the fxos chip.
did you got or have any reference c code for getting or calculating the 0, 90, 180, 270 & 360 angle calculation.
lets please share the magnetic.c and orientation.c files to understand the eCompass algorithm.
As noted above, download the SDK (with ISSDK option enabled) for either FRDM_K22F or FRDM_K64F from Welcome to MCUXpresso | MCUXpresso Config Tools . Once downloaded, look under <sdk_root>/middleware/issdk_1.1/algorithms/sensorfusion for documentation and source files. Example projects are under <sdk_root>/boards/frdmk22f_agm01/issdk_examples/algorithms/sensorfusion (assuming FRDM_K22F).
In general, you should not be using raw magnetometer readings, as there are almost always offsets that need to be subtracted out. Again, please refer to the app notes listed earlier in this thread.
Retrieving data ...