Please help with code for DS18B20


Closed Thread
Results 1 to 40 of 110

Hybrid View

  1. #1
    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?

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

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

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

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

  6. #6
    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?

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

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