cembeddedvhdl360-degrees

How to convert unsigned magnometer data to Degrees


I know there are a lot of topics in different forums in the web, I understand the differnce between atan and atan2 and how to solve this problem with signed data.

I am using the digilent CMPS2 module which uses the Memsic MMC34160PJ magnetometer. In the datasheet of chip CMPS2 there is a formula with actan(x/y)*180/pi It‘s clear that I only get values between 0 and 90 degrees because the sensor delivers only unsigned values. When I use atan2 I get values between 0 and 180 degrees.

I know it would be easier if I had signed data. But unfortunately the sensor delivers only unsigned values.

How is such a conversion form of unsigned magnometer data 0 to 360 degrees possible?


Solution

  • I haven't used that particular magnetometer myself, but there are a lot of sensors that work in similar ways.

    The magnetometer datasheet, page 2, states that the "Null field output" value (that means, the output when there's no magnetic field) is not zero.

    Let's say you use 14-bit resolution mode, the null field output value is 8192. That means 8192 is your reference point for zero value, everything above that value is positive, and everything below that value is negative. You should subtract this null field value from each measurement, and you should be ready to go.