Please help with code for DS18B20


Closed Thread
Results 1 to 40 of 110

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579

    Default Please help with code for DS18B20

    I made the great project of "Digital thermostat (080090-11)" from Elektor july_august 2008 ; unfortunate I do not have DS1820 but DS18B20. The temperature show on display is like "xxx.xx 'C" !.
    I read this : "In order to convert the HEX code to a temperature value, first you need to identify if you are using a DS18S20, or DS18B20 series sensor. The code to read the temperature needs to be slightly different for the DS18B20 (and DS1822), because it returns a 12-bit temperature value (0.0625 deg precision), while the DS18S20 and DS1820 return 9-bit values (0.5 deg precision)".
    I try millions different routines, but the result is verry bad...because of this section, I think :
    "DisplayTemp:
    If V >= 10000 then ' Above 0 C.
    Temperature=V-10000
    Else
    Temperature=10000-V ' Below 0 C.
    EndIf
    LcdOut $FE, $C0, Sign, DEC (Temperature / 100), ".", DEC2 Temperature, " ",223,"C "
    Return"
    All the codes I try change the Temperature set and Hysteresis, and the display show the temperature (ex. 24.56'C) , but useless function of thermostat...(Set temperature = 2000.00 and Hysteresis = 200.00).
    And the temperature is different (+24.67 'C) by other device (DS18B20 + PIC 12F675 + LCD Nokia = 23.1'C ; LM35DZ + mV = 23.1 'C)
    It is possible to increase the accuracy of this thermometer/thermostat ?
    Can somebody help me to modify the source for using DS18B20 ?
    Thanks in advance !
    Attached Files Attached Files
    Last edited by fratello; - 30th December 2008 at 11:00.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink

    Hi, Fratello

    I played a bit with your program ... Elektor won't be anymore what it was ... -cries-

    Note you'll have to comment the Easypic5/16F877A section and uncomment the Elektor section.

    This way you will be able to use the 18B20 in any resolution you like ...

    And OVERALL do not ask a +/- 0.5°C precision sensor to give 1/100° C .... !!!

    Alain
    Attached Files Attached Files
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default

    THANK YOU VERRY MUCH !!!! You make me happy ! I will try the code and I will keep You informed. Thanks again !
    ****** A HAPPY NEW YEAR !!!! ******
    ******* TO ALL !!!! *******
    LE : Now is great, even still remain the 1°C difference...but "OVERALL do not ask a +/- 0.5°C precision sensor to give 1/100° C .... !!!".
    Thanks again !
    B.t.w : what can I use instead of DS18B20 for more accurate measurement ?
    Last edited by fratello; - 30th December 2008 at 18:45.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Talking The Horrible truth ...

    Quote Originally Posted by fratello View Post
    B.t.w : what can I use instead of DS18B20 for more accurate measurement ?
    Hi, Fratello

    I had a look to all the sensors you can find on the market ...

    The best "out of the box" accuracy ( all including ) will be roughly +/- 0.5 °C ... don't be sad !!!

    going further needs multipoint CALIBRATION ... with some really expensive devices.

    Note linearity is "not so bad" in our measuring range ... so, with a two points calibration ( 0 and 100°C ) , you can reach +/- 0.1 °C without too much pain.

    And remember ... DS18x20 in continuous measurement mode like here, without being fixed on a heatsink, has a 1°C self heating value ... ( a look at the Datasheet will confirm !!! )

    Just have a look to the values displayed from the power up ...

    Alain
    Last edited by Acetronics2; - 31st December 2008 at 09:58.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    You missed some Alain.

    We have Industrial Sensors that directly return 16-bit Temperature to two Decimal Places (in the range 0.00C-100.00C).

    It is however a complete waste of time... just breathing in the vicinity, or even just walking nearby create air-currents which wildly change the readings - we just end up ignoring the last digit. If you're trying to distill some moonshine for the New Year festivities, you're not really bothered in monitoring the temperature to hundredths of a degree.

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink

    Hi, Mel

    Happy to read from you !!!

    Of course, those sensors exist ... ( you have forgotten to give us the price ... lol ), but are totally out of our Hobbiysts galaxy ...

    Have a Happy new Year

    Regards
    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Join Date
    Mar 2006
    Location
    Hyderabad (India)
    Posts
    123


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Fratello

    I played a bit with your program ... Elektor won't be anymore what it was ... -cries-

    Note you'll have to comment the Easypic5/16F877A section and uncomment the Elektor section.

    This way you will be able to use the 18B20 in any resolution you like ...

    And OVERALL do not ask a +/- 0.5°C precision sensor to give 1/100° C .... !!!

    Alain
    But DS18B20 is capable of giving a better resolution??
    Regards,
    Sarma

  8. #8
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,827


    Did you find this post helpful? Yes | No

    Default

    Its resolution (its step in other words) is 0.0625 but its accuracy is +/-0.5C

    Ioannis

  9. #9
    Join Date
    May 2008
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Fratello

    I played a bit with your program ... Elektor won't be anymore what it was ... -cries-

    Note you'll have to comment the Easypic5/16F877A section and uncomment the Elektor section.

    This way you will be able to use the 18B20 in any resolution you like ...

    And OVERALL do not ask a +/- 0.5°C precision sensor to give 1/100° C .... !!!

    Alain
    I've been playing with this all day today and it's a great piece of code.
    I used this as I have an easypic 6*

    I have one problem/question that perhaps someone could answer please

    When I program the pic, the sisplay shows * at the end of the 1st line even when no buttons are or have been pressed, I thought the * was only to show a button had been pressed?

    Also if I cycle through the button presses, ie set temp and set hysteresis they both work fine
    however when I press the button again to show the actual temp that also works. but it never seems to update UNLESS I hold the button in, then it updates continually

    I've been trying to get it to update at a regular interval or any interval but it just wont, am I doing something wrong or does it never update the temp?

  10. #10
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink Check Hardware !

    Hi,

    That looks no pullups - or a Pulldown ! - on PORTA.0 input ... the " * " only appears when Porta.0 is tied to ground.

    Everything fine here ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  11. #11
    Join Date
    May 2008
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,

    That looks no pullups - or a Pulldown ! - on PORTA.0 input ... the " * " only appears when Porta.0 is tied to ground.

    Everything fine here ...

    Alain
    I thought that might be the problem, but where would I put
    high portA.0

    If I put it before the mainloop it displays the temperature all the time,
    if I put it at the end of mainloop then it still displays the * and stays on set temperature.

    I can't figure out where to put it, must be easy but I just cant see it.

  12. #12
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by lew247 View Post
    I thought that might be the problem, but where would I put
    high portA.0

    If I put it before the mainloop it displays the temperature all the time,
    if I put it at the end of mainloop then it still displays the * and stays on set temperature.

    I can't figure out where to put it, must be easy but I just cant see it.

    May be you could place The pullup resistorS ( 3 x 47-100k ) between Porta.0,1 and 2 and VCC ...

    No need to place it inside the Pic ... that won't work !

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts