MAG3110 odd output

Have questions about a SparkFun product or board? This is the place to be.

Moderators: phalanx, TS-Tim

Post Reply
Blade
Posts: 1
Joined: Wed Aug 09, 2017 8:08 am

MAG3110 odd output

Post by Blade » Wed Aug 09, 2017 8:46 am

I have two magnetometers and am trying to get the difference in angle heading between them. Theoretically, if they are oriented the same way (they are also in close proximity to each other), the heading should be the same. That is not the result I am getting, however. Here is an example of the output:

Code: Select all

X1: 658, Y1: 1301, Z1: 1238
X2: 491, Y2: 222, Z2: 64045
X3: 65261, Y3: 67, Z3: 65459
heading1 = 1.10
heading2 = 0.42
heading3 = 0.00
radAngle = 0.42
actualAngle = 24.27
where:
heading2 = atan2(y2, x2)
heading3 = atan2(y3, x3)
radAngle = heading2 - heading3
actualAnlgle = radAngle*(180/PI)

Am I getting incorrect heading data because of the large values? I googled it and someone else had said that "The outputs are 16-bit SIGNED integer (int)", so those large values are actually supposed to be negative numbers. Why is it outputting this data type rather than two's complement, and how do I fix this so that I can calculate the correct heading? Been struggling with this for a while now, any help would be great!

Post Reply