ds18s20 reads incorectly - Page 2


Closed Thread
Page 2 of 2 FirstFirst 12
Results 41 to 43 of 43
  1. #41
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: ds18s20 reads incorectly

    these two lines are commented out?

    ' SignF = Positive 'Sign is +
    ' TempF = ((TempC * 18) / 10) + 3200 'Convert from C to F

    so I guess you will get 0 deg F

  2. #42
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default Re: ds18s20 reads incorectly

    Steve-
    Dunno what I had thought I was looking at, but when I un-commented those other lines, I now get correct readings!
    This is now what seems to be working:
    BTW, going to be in your neck of the woods this Wednesday, 2 days in London, then take a boat out from South Hampton on a cruise through the Baltics.
    Thanks for pushing me in the right track!
    Regards,
    Steve

    Code:
    ReadDS18S20:' Works, Thanks 'Kid' and Steve from the UK....from Forum-----------
                      owout Tsensor,1,[$CC, $44]                                    'Send Start Temperature Conversion command
                      owout Tsensor,1,[$CC, $BE]                                    'Send Read Temperature command
                      owin Tsensor,0,[STR dq\9]                                     'Retrieve all 9 bytes of data
                      RawTemp.Byte0 = dq[0]
                      RawTemp.byte1 = dq[1]
                      if RawTemp.8 = 1 then                                         'Check if temperature is a negative reading
                         SignC = Negative                                            
                         RawTemp.lowbyte = RawTemp.lowbyte ^ 255                    'Invert data
                      else
                         SignC = Positive
                      endif
                      dummy = RawTemp.0                                             'Store the half degree indicator bit
                      TempC = ((RawTemp.lowbyte) >> 1) * 100                        'Divide raw data by 2 to give real temperature
                      TempC = TempC + (dummy * 50)                                  'Add the half degree is present
                     if SignC = Negative then                                      'Only proceed if temperature is negative - doesnt work for F, fine for C
                        if TempC => 1770 then   
                           SignF = Negative
                           TempF = (TempC + 5000) * 900
                           TempF = div32 500
                           TempF = TempF - 12200
                        return 
                      else
                          SignF = Positive
                          TempF = (TempC + 5000) * 900
                          TempF = div32 500
                          TempF = 12200 - TempF
                          return 
                       endif    
                     endif
                      SignF = Positive                                              'Sign is +
                      TempF = ((TempC * 18) / 10) + 3200                            'Convert from C to F
                      return
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

  3. #43
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: ds18s20 reads incorectly

    It is Wednesday you are in England the weather is cold, wet and windy. I am so sorry but what do you expect in England on a summers day.

    Have a nice cruise to the Baltic.

Similar Threads

  1. DS18B20 VS DS18S20 & multiple
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 7th February 2008, 22:43
  2. Using A Ds18s20 And Servo
    By CrazyCooter in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th September 2007, 09:41
  3. DS18S20 displays wrong temperatures
    By Shozo Kanamori in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th August 2007, 03:18
  4. DS18s20 - negative teperature
    By Ceug2005 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 2nd February 2005, 12:40
  5. 16F877, DS18S20 and Serial Comm Problem
    By YellowTang in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th April 2004, 10:36

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