Author Topic: AT30TS74 temperature register decoding  (Read 483 times)

0 Members and 1 Guest are viewing this topic.

Offline MrPuhurTopic starter

  • Newbie
  • Posts: 8
  • Country: ee
AT30TS74 temperature register decoding
« on: March 01, 2022, 04:34:56 pm »
The datasheet https://ww1.microchip.com/downloads/en/DeviceDoc/Web_AT30TS74_0217.pdf for AT30TS74 temp sensor has a comprehensive list of examples on register value and temperature pairs. 
1427467-0
I wrote unit tests based on them for my driver and judging from some of them failing, it seems that my decoding is wrong (or the table is incorrect).

Here's some examples hand-decoded:
-55°C:
Register value 0xC900. Last 4 bits are irrelevant. The value is negative. Since it uses 2's complement, a 16-bit int would be 0xFC90, which is -880 in decimal. The resolution is 0.0625 deg with the 0°C point being 0, so -880*0.0625 = -55. Great.

-50.5°C
Register value 0xCE80. Last 4 bits are irrelevant. The value is negative. Since it uses 2's complement, a 16-bit int would be 0xFCE8, which is -792 in decimal. -792*0.0625 = -49.5. What?

The sensor has a +- 1°C accuracy in most ranges. But factoring that into such a table seems way too weird.
 

Offline devinatkin

  • Contributor
  • Posts: 40
  • Country: ca
  • PhD Student at the University of Calgary I2Sense
Re: AT30TS74 temperature register decoding
« Reply #1 on: March 22, 2022, 03:22:19 pm »
Oh man this is a blast from my past. I had very similar issues when I was in undergrad trying to use this chip. My issue which took me WAY too long to notice happened to be that I was interpreting my bits backwards.

looking for it to equal -808

Which doing the binary to twos compliment conversion looks like this: 1111 1100 1101 1000

If we grab the binary from the table we know we want it to look like this: 1100 1110 1000 0000

We then ditch those last 4 bits given they're not relevant: 1100 1110 1000
And then we need to extend out the last bit to make the 16-bit number: 1111 1110 1101 1000
Which is the FCE8 you calculated, which in decimal assuming a 2s compliment int is -296...

Which I initially thought was an issue with  my interpretation of the 2s compliment; however, then I noticed my little tool calls it FCD8 not FCE8. So I'm pretty sure that there's a 1 bit error in the table. It says 1100 1110 1000 0000, but I'm pretty sure it should say 1100 1100 1000 0000.

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf