Please help with code for DS18B20


Closed Thread
Results 1 to 40 of 110

Hybrid View

  1. #1
    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 " !!!
    *****************************************

  2. #2
    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 !!!!

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


    Did you find this post helpful? Yes | No

    Wink

    Hi, Fratello

    Too wide a question ... It's on your own now.

    Here it's yours to take :

    1) your Datasheets, and do not mix different sensors ( ! ), see how values are coded for each.

    2) your PbP Manual, and look at how PbP can calculate and see where roundings can lead to ( small ...) outputted value differences.

    ...

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

  4. #4
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    I use the same sensor, the same circuit, just I re-write the code...the results are never the same...

  5. #5
    Gabestarting's Avatar
    Gabestarting Guest


    Did you find this post helpful? Yes | No

    Unhappy

    I intend to start tomorrow with the same project, using the same sensor DS18S20. May i use it without changing the code?

  6. #6
    Gabestarting's Avatar
    Gabestarting Guest


    Did you find this post helpful? Yes | No

    Default

    Sorry, reading the text again i observed that i have the right sensor, i was lucky...So, the thermostat works fine, i am happy for the bas-file, however it is easier to understand than assembler. I made the circuit on a stripboard. Have a nice evening!

  7. #7
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    I want now to try to read the temperature with two sensors DS18B20 ; one for IN and other for OUT. It is possible ? How can I display both temperatures ?
    Help, please !

Similar Threads

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