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.

TMAG5170: Angle result register and X,Y result result registers

Part Number: TMAG5170

Hi,

we have successfully interfaced TMAG5170 and able to read angle result register and see it's getting updated with shaft movement with CRC checks.

a) To meet ASILB,we want to read x,y channel data(0x89,0x8A) and re calculate the angle in degrees with x and y channel data. what is the formula to do this.(we have done required configurations for this in sensor/system configuration)

b)Can we implement  the following scenario (or) is it mandatory to make chip select high after each command.

- Do chip select low

- send angle read command and read the spi result

- send x channel read command and read the spi result

- send y channel read command and read the spi result

-Do chip select high

Thanks,

P Tulasi Krishna.

  • P Tulasi,

    That's great to see you've got the sensor working and reading angle results.  To calculate the angle you need to use the arctangent function.  Most compiler libraries have an ATAN2 function which will accept the XY data account for the sign and produce an angular output.  There is an example available here:

    https://www.ti.com/tool/download/TMAG5170-CODE-EXAMPLE/1.0.0

    For your read/write commands, it is necessary to return Chip Select to the high state to complete and latch each communication.  

    Thanks,

    Scott

  • Hi Scott,

    Thank you for the response.

    we followed code example and it looks it is matching (angle result and calculation with X,Y data).

    we executed below example at 3 different positions.but there are some questions.

    scenario1:

    int main() {
    float CORDIC_results[2];
    calcCORDIC(CORDIC_results,61424,48528,100,10);

    return 0;
    }

    61424 - Y_RESULT from SPI

    48528- X_RESULT from SPI.

    100  - 100mT is the range configuration

    The result from CORDIC function which is inturn calling atan2CORDIC function is "-166.35" where as angle_result value is 194 degrees.

    S2:The result from CORDIC function of x,y(56,016,51120) which is inturn calling atan2CORDIC function is "-123" where as angle_result value is 236 degrees.

    In all scenarios ,if add 360 to the CORDIC_results[0] ,it is matching with ANGLE_RESULT register value.

    few questions:

    1) Is above understanding is correct.

    2)X,Y are always interpreted as unsigned 16bit .but cordic function has ( int16_t numerator,denominator).so X,Y could be negative values as well?

    3) we sent number of iterations value as 10.How to get this value.

    4)Result of calcCORDIC() is always negative in 3 scenarios we executed .After adding 360 to it .It is matching with ANGLE_RESULT value.Is it true in all cases.

    5)Any simplified method is available to match ANGLE_RESULT and X,Y data other than this.

    6) what is the minimum wait time before making  chip select low from high to execute series of reads

    Thank you,

    P Tulasi Krishna.

  • P Tulasi,

    TMAG5170 will return a result which ranges from 0 to 360, but ATAN2 will typically return a result from -180 to 180.  Because of this, it can be necessary to add 360 degrees to a negative result from ATAN to match.  However, this really depends on your preference when handling position.  If using the MCU calculation exclusively, then there is no need to shift to the 0 to360 domain if you prefer to use -180 to 180.

    The number of iterations for the CORDIC function will set the accuracy of the final result.  CORDIC is very close to a binary search where the goal is to rotate the input vector until is is purely one directional.  The sum of the rotations, either clockwise or counter clockwise is the final output result.  You can read more about it here:

    https://www.ti.com/lit/pdf/sbaa463

    The CS high time between data transfers is listed here:

    Thanks,

    Scott