Rules | Recent posts | topic RSS | Search | Register  | Log in

Question regarding DS1820

 
Post new topic  Reply to topic    EDAboard.com Forum Index -> Hobby Circuits and Small Projects Problems
Author Message
McMurry



Joined: 16 Feb 2008
Posts: 74


Post22 Jun 2008 18:09   Question regarding DS1820

I am having problem to get the decimal value for the temperature output i.e.
in the form of xx.y

to get that y value... i am currently using this formula in MCU program

temp_dec = 9-(((int)get[6]*9)/16)

which i found to be incorrect after it display the value "0.9" when i disconnect the sensor.

has anyone successfully found the "formula" to obtain the decimal value?


ANOTHER QUESTION..
in its datasheet, it is clearly written that ds18s20 has accuracy of +/- 0.5 degree celcius.
does that mean i should just make the output reading to be just an integer value?

Thanks.
Back to top
banjo



Joined: 24 Dec 2005
Posts: 455
Helped: 86


Post23 Jun 2008 14:37   Question regarding DS1820

According to how I read the datasheet, the decimal portion of the number is just the LSB. If the LSB is a '1' then the temperature has a decimal portion of 0.5. The whole number portion is just the data shifted to the right by 2.
What to do with this decimal portion is up to the user. Personally, I would display it. If the reading is "27.5", then based on the accuracy, I know the temperature is between "27" and "28". If I drop the "0.5" then I do not know if the actual temperature is between "27 and "28" or "26" and "27". Also, the 0.5 degrees C is worst case across the entire temperature range. For more normal room temperatures, it will do much better than that.
Back to top
seemanta



Joined: 10 Jun 2006
Posts: 63
Helped: 2


Post24 Jun 2008 7:28   Re: Question regarding DS1820

Can you please tell me what is the exact specification of your IC?
Is it DS18B20, or DS18S20 ?

I used a DS18B20 with my AT89S52 and the decimal conversion worked without any problem. I can point you to the code if you want.

regards,
Seemanta
Back to top
banjo



Joined: 24 Dec 2005
Posts: 455
Helped: 86


Post24 Jun 2008 13:45   Question regarding DS1820

Another thought, are you trying to output the temperature in F or C? If the LSB is a '1' then it represents 0.5C. If you convert this to F, it does equal 0.9 F. Therefore, if you disconnect the sensor, the pullup resistor should give all '1' for each digit and I would expect the decimal part of the temperature in F to be 0.9.
Back to top
McMurry



Joined: 16 Feb 2008
Posts: 74


Post24 Jun 2008 18:15   Re: Question regarding DS1820

seemanta wrote:
Can you please tell me what is the exact specification of your IC?
Is it DS18B20, or DS18S20 ?

I used a DS18B20 with my AT89S52 and the decimal conversion worked without any problem. I can point you to the code if you want.

regards,
Seemanta



Hi. I am using DS18S20.
but DS18B20 and DS18S20 should not have a lot of difference?

Can you share how you do the conversion to get the decimal value? Thanks. Very Happy

Added after 4 minutes:

banjo wrote:
Another thought, are you trying to output the temperature in F or C? If the LSB is a '1' then it represents 0.5C. If you convert this to F, it does equal 0.9 F. Therefore, if you disconnect the sensor, the pullup resistor should give all '1' for each digit and I would expect the decimal part of the temperature in F to be 0.9.


Hi. I am displaying the temperature in celcius degree.
I think it should be my conversion formula problem.
Not quite sure how to manipulate the temp sensor ic scratchpad correctly. Neutral
Back to top
seemanta



Joined: 10 Jun 2006
Posts: 63
Helped: 2


Post25 Jun 2008 7:54   Question regarding DS1820

I remember once, that I was erroneously referring to some DS1820 variant data sheet and the formula for getting temperature was very different.
I thought to myself, "Whoa! Wait a minute, this can't be the data sheet I was looking at earlier."

Sure enough, I realized it was not DS18B20, the IC I was interfacing. Then I looked up the datasheet for DS18B20 and found the decimal conversion quite simple.

You can get the code for the same at: http://www.edaboard.com/ftopic314427.html

Note that however, this temperature display routine is just a part of a much bigger program, but I am sure you can navigate your way through the code Very Happy
Do let me know, if you need any other help.

regards,
Seemanta

Added after 17 minutes:

And just to let you know how I did the decimal conversion, here is an explanation::

each bit indicates succesive negative powers of 2.
so 0 0 means x.0
0 1 means x.25
1 0 means x.50
1 1 means x.75

This is assuming .25 degree C resolution, of course.
And yes, the data sheet mentions that it works only in degree C. You would need to use a lookup table for converting to degree F or use a conversion formula.

Hope this helps!

regards,
Seemanta
Back to top
Post new topic  Reply to topic    EDAboard.com Forum Index -> Hobby Circuits and Small Projects Problems
Page 1 of 1 All times are GMT + 2 Hours


Abuse
Administrator
Moderators
topic RSS 
sitemap