ds18s20 reads incorectly


Results 1 to 40 of 43

Threaded View

  1. #23
    Join Date
    May 2008
    Location
    Florida
    Posts
    64


    Did you find this post helpful? Yes | No

    Default

    jcleaver

    Here is a couple of files for you to play with.

    pbptc.txt is your program that correctly displays the temp C and changes when the temp changes. You will need to change the LCD port, I use an easypic5 and you are using a different port.

    I also have a program for MikroB attached, again it is for the ep5 board.

    Take a few minutes and look at how the temp is being read in both. Once you figure that out you will see where the problem is.

    BTW the formula is from the DS18S20 datasheet.





    In your Mikro file did you notice that the temp was calculated before it is converted?

    if j2 = $FF then
    tmp_sign = "-" ' temperature sign
    j1= j1 or $FF ' complement of two
    j1= j1 + $01
    else
    tmp_sign = "+"
    end if
    j2 = (j1 and $01) * 5 ' Get decimal value
    j1 = j1 >> 1 ' Get temp value
    j1 = ((j1*9/5)+32) 'Convert C to F

    And in your PBP file nothing is calculated until after the conversion.

    TEMP = ((TEMP*9/5)+32 )
    Lcdout $fe, 1, dec (temp >> 1),".",dec(temp.0 * 5)," degrees C"

    Good Luck!

    Acetronics: May I play around with the thermostat program you posted?
    Attached Files Attached Files
    Last edited by manwolf; - 23rd July 2008 at 23:18. Reason: Brain Bubble

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