This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMAG5273: raw x and y data, flipped negative portion

Genius 17175 points
Part Number: TMAG5273

Hi all

My customer has the below question.

Please review and comment.

Best regards

Ueli

-----------------------------

I have a specific question about the TMAG5273. The raw x and y magnetic data look like the plot below, with the negative portion of the sinusoid appearing at the top of the plot. It does not seem to cause any issue in calculating the angle, but the plots I see on the datasheet and app notes show a continuous curve. Do you know what might be causing this and how I could fix it? Please ignore the clipping that issue has been solved I just don't have a picture without it.

  • Hi Ue,

    Thank you for posting to the sensing forum!

    The reason that this is occurring is because the raw data that you are getting from the sensor is in 2's complement, but is being read by your microcontroller/compiler as a normal binary number so when it reads in a binary value of "1000 0000 0000 0001" from the sensor that value is getting converted to 32769 instead of using the 2's complement conversion to decimal which would have made it -32767. 

    The way you work around this is when reading in the raw data, if you get a value that is greater than or equal to 32767 (0x7FFF), subtract 65536 (0x10000) from that value which should provide you with the negative values for the raw data.

    Best,

    ~Alicia

  • Alicia

    Thank you for the quick reply.

    Please find a 2nd question from the customer copied below.

    Best regards

    Ueli

    -------------------------

    Do you know how the angle is calculated from the raw data? I tried calculating my own arctangent and my values are slightly different. The temperature compensation and magnetic offset registers are not active, so I was wondering if there is some rounding going on?

    -------------------------

  • Hi Ue,

    As shown in the image below, with the Angle Data Definition being composed of the registers ANGLE_RESULT_MSB and ANGLE_RESULT_LSB, the way that the angle is calculated from the raw data is that D00-D03 make up the fractional value of the angle measurement and D04-D12 make up the integer value of the angle with D13-D15 being reserved bits. 

    Further information on the angle calculation can be found on page 23 of the datasheet in section 7.5.2.3.

    Best,

    ~Alicia 

  • Hi Alicia

    Thank you for the clarification.

    Best regards

    Ueli