|
|
View previous topic :: View next topic |
Author |
Message |
acobo
Joined: 01 Nov 2003 Posts: 2
|
Problem with temperature readings using DS1631.c driver |
Posted: Fri Jul 16, 2004 3:21 pm |
|
|
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
|
|
Posted: Fri Jul 16, 2004 3:33 pm |
|
|
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
|
|
Posted: Sat Feb 12, 2005 6:31 am |
|
|
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
|
That's Right |
Posted: Sun Feb 13, 2005 1:43 pm |
|
|
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
|
|
Posted: Mon Feb 14, 2005 6:59 am |
|
|
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. |
|
|
|
|
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
|