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
    582


    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.

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


    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 " !!!
    *****************************************

  3. #3
    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.

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


    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Happy New Year to you and everyone too...

    Aa a rough guide about 25 Euro's in singles, falling to below about 18 Euro's at 100 pcs, and about 10 Euro's at 1000 pcs.

    Yes of course, you can't beat the few cents a DS1820 costs, but then it's not a bare chip, but a fully enclosed product with attached leads and connectors, post sensor processor, integral noise immunity, etc etc with integral seals all ready to bolt straight into your pipework or manifold.

    If you want cheap, then just use an NTC Thermistor and plot it's curve into a PIC. You can easilly get better than 0.1C accuracy through simple interpolation across 90% of the curve. It's the way it's done in 99.9% of the cheaper Industrial and domestic Controls. I really don't see the point of DS1820's, LM35's etc, they're a waste of money for something that can be done so much simpler if only folks stopped and thought about the problem. OK, if you've only got a single I/O and a dozen items on the interconnecting bus, then fine, but otherwise why?

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


    Did you find this post helpful? Yes | No

    Wink

    Ok, Mel

    You're talking resolution while I'm talking accuracy ...

    DS already give .0625°C resolution ... but that do not mean anything because you only know you are inside the +/- 0.5 °C error gap.
    LM 335 have your ADC resolution ... but always an "out of the box" +/- 0.5 °C precision

    That is why I say ( and repeat ... ) you can't get a better reading WITHOUT a calibration ... or comparison with a known reference.

    Even the MS5534 ( 16 bits! ) which comes with its calibration coeffs ... is given for a GUARANTEED +/- .8°C accuracy ...

    For NTC's the problem is the +/- 5 to 20% value tolerance ... that need an individual curve adjustment to each sensor ( only 1 point ... yes... but one point calibration ! )


    The only **predictable** High accuracy sensors are Platinium RTD's ... But , ... How much to pay for a class A probe ??? ...

    Temp and Thermal measurements are always funny ... and make you humble !!!

    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
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Thank you for replays !!!
    I wish to all a happy NEW YEAR 2009 !

    I think I go crazzy with this little thermostat probleme ; I write ( based on Yours great codes) four routines ; everyone display a different temperature. Which of them is -in yours opinion - the best ?

    1.OWOut DQ, 1, [$CC, $BE]
    OWIn DQ, 2, [Temperature.Lowbyte, Temperature.Highbyte]
    Convert_Temp:
    Dummy = 625 * Temperature
    TempC = DIV32 10
    TempC = (Temperature & $7FF) >> 4
    Float = ((Temperature.Lowbyte & $0F ) * 25 )>>2
    Temperature = TempC*100 + Float

    2.OWOut DQ, 1, [$CC, $BE]
    OWIn DQ, 2, [RAWTEMP.Lowbyte, RAWTEMP.Highbyte]
    Convert_Temp:
    dummy = RAWTEMP * 625
    TempC = DIV32 100
    Temperature = TempC

    3.OWOut DQ, 1, [$CC, $BE]
    OWIn DQ, 2, [Temperature.Lowbyte, Temperature.Highbyte]
    Convert_Temp:
    TempC = (Temperature & $7FF) >> 4
    Float = ((Temperature.Lowbyte & $0F ) * 25 )>>2
    Temperature = TempC*100 + Float

    4.OWOut DQ, 1, [$CC, $BE]
    OWIn DQ, 0, [Temperature.LowByte, Temperature.HighByte, Skip 4, Count_Remain, Count_Per_C]
    Convert_Temp :
    Temperature = (((Temperature >> 1) * 100) - 25) + (((Count_Per_C - Count_Remain) * 100) / Count_Per_C)
    if Temperature > 32767 then '32767 check if BIT12=1
    Temperature= ~Temperature
    temperature=temperature>>3 ; divide by 8

    Thanks in advance for your support ; I hope I don't became boring !!!!

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

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