RTD to Temperature API

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaHu_285096
Level 5
Level 5
10 likes received 250 replies posted 100 replies posted

I note in the example that the RTD_GetTemperature() API returns a 32 bit unsigned int.

   

I have written code based on the example and find that I cannot display values below 0. Casting the int as a foat does not convert the negative (I assume 2's complement) value into the appropriate negative temperature value.

   

Is there a convenient conversion or do we need to manually do a 2's complement on the resistance value?

   

rtdRes = (rtdVoltage * CAL_REF_RESISTOR / rtdCalVoltage) * 1000;  //convert to mOhms

   

rtdTemp = RTD_GetTemperature(rtdRes);    //Returns 2's complement value when rtdRes < 100,000 mOhms (PT100)

   

tempdisp = (float) (rtdTemp/100.0);

   

sprintf(strbuf,"%3.2f%c",tempdisp,13);

   

RS232_PutString(strbuf);

0 Likes
3 Replies
DaHu_285096
Level 5
Level 5
10 likes received 250 replies posted 100 replies posted

 I found the issue, the return type from GetTemperature should have been int32 and not uint32.

   

Converts to negative value fine now.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

This ap note seems to indicate need for a second polynomial for negative

   

temps -

   

 

   

www.cypress.com/

   

 

   

Regards, Dana.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

This ap note seems to indicate need for a second polynomial for negative

   

temps -

   

 

   

www.cypress.com/

   

 

   

Regards, Dana.

0 Likes