CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem with temperature readings using DS1631.c driver

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
acobo



Joined: 01 Nov 2003
Posts: 2

View user's profile Send private message

Problem with temperature readings using DS1631.c driver
PostPosted: Fri Jul 16, 2004 3:21 pm     Reply with quote

Hello to all,
I'm using the DS1631.c driver as is provided by CCS, just deleting the conversion from celsius to farenheit degrees and dividing the result /100 to a float.
Everything seems to be ok with the temperature readings, but I have notice that I never get values between two specific temperature range: 21.46C and 22.00C, 22.46 and 23.00, and so on (that is, fractions between .46 and .00 are always missing, temperature seems to jump from xx.46 to yy.00 when rise, or from xx.00 to yy.46 when temp. decreases. For other values outside this "forbidden" range, temperature is provided with 0.03 degrees resolution: 21.00, 21.03, 21.06, and so on.

I suspect that the provided conversion method could be wrong is some cases:
Code:

   data=(signed long)datah*100;
   data=data+(((datal >> 4 )*(long)50)/16);
   //added to scale to real celsius degrees.
   temp=(float)data/100.0;

But looking at it, and according to previous posts about ds1631 temperature readings, it seems that only is using the integer part of the temperature, so I shouldn't get fractional values. it makes no sense for me at all.

Any help on this proble will be greatly appreciated.
Thanks in advance,
Adolfo.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 16, 2004 3:33 pm     Reply with quote

If you go to http://www.google.com, and do a search for DS1631,
you find a link to the data sheet.
http://pdfserv.maxim-ic.com/en/ds/DS1631-DS1731.pdf

At the top of the data sheet, it says the accuracy is +/- 0.5 degrees C.

If you look at your results, they are approximately 0.5 degrees apart.

OK. Then you might have a question about why 21.46 instead of 21.50 ?

So then, do a search on this forum for: floating point accuracy
Be sure to set the search options for "Search for all terms".
You will then see lots of posts about this topic.
magix
Guest







PostPosted: Sat Feb 12, 2005 6:31 am     Reply with quote

i dont think so PCM, accuracy is 0.5 but resolution is 0.0625!!!
acobo, I think that, you are right ..something is wrong in ds1631.c ...
Regards
Mark Weir



Joined: 11 Sep 2003
Posts: 51
Location: New Zealand

View user's profile Send private message

That's Right
PostPosted: Sun Feb 13, 2005 1:43 pm     Reply with quote

Hi I have used this driver on a project, with the setup provided you get results 4 units each side of the result. If you delete the data = data>>4 bit and just use datah for your result calc you will get the correct temp.
One other side issue, be careful with this device, I used it within a machine and had big problems with I2C buss lock up.

Hope this helps

Mark
magix
Guest







PostPosted: Mon Feb 14, 2005 6:59 am     Reply with quote

Hi Mark,

Quote:

.
.
.
data=(signed long)datah*100;
data=data+(((datal >> 4 )*(long)50)/16);

data=data*9;
data = (data / 5) + 3200;

return(data);
}


what do you mean? there is no "data = data>>4" line in the driver.
if you mean "datal >> 4 " line... We can lose resolution?
Could you show modified code?
Thanx for helps.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group