Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Question regarding DS1820

Status
Not open for further replies.

McMurry

Member level 3
Joined
Feb 16, 2008
Messages
56
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,746
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.
 

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.
 

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
 

    McMurry

    Points: 2
    Helpful Answer Positive Rating
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.
 

    McMurry

    Points: 2
    Helpful Answer Positive Rating
seemanta said:
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. :D

Added after 4 minutes:

banjo said:
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. :|
 

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:

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 :D
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
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top