ds18s20 reads incorectly


Closed Thread
Results 1 to 40 of 43

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    maybe you should check the math.
    With a change to the math the program works correctly. Running on a EasyPIC5 board.

    Sorry I was sleeping that day in class, so I can't explain why PBP and MBasic work differently.

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


    Did you find this post helpful? Yes | No

    Wink


    Why not use PBP's built-in OWIN/OWOUT commands?
    The solution simply is here ...

    MKB reads Byte by Byte and Pbp ... as you want !

    just need to program a correct reading with Pbp !



    Further ... TempF = TempC *9/5 + 32 ...

    Remember PbP works with UNSIGNED INTEGERS ...

    Alain

    PS: Ski, MKB has a built-in timing adjustment,( you check an option in the project window instead of writing a DEFINE ) and The "conversion complete" polling built-in. That surprised me a bit at first time, not to see it in the source listing ...
    Last edited by Acetronics2; - 23rd July 2008 at 10:01.
    ************************************************** ***********************
    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


    Did you find this post helpful? Yes | No

    Default attempt

    the osc is correct dont know why it did not show caps
    tried going with 4 still read low
    ? what changes in math
    TEMP = ((TEMP*9/5)+32 ) is what i am using
    thanks for the inputs

    have not found any samples using owin with this chip

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


    Did you find this post helpful? Yes | No

    Thumbs down

    Hi,

    Did you ever try SEARCH with the 1820 Keyword ???

    Surely NO !!!

    I remember having posted a while ago for the DS1820 ...

    Gives ... 22 Hits !

    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
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    I remember having posted a while ago for the DS1820 ...
    Gives ... 22 Hits !
    Alain
    23 Hits now!
    But, he's also using the DS18S20.
    I know...I know...not a lot of difference between the two that can't be handled by a simple read of the datasheet.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jcleaver View Post
    the osc is correct dont know why it did not show caps
    tried going with 4 still read low
    ? what changes in math
    TEMP = ((TEMP*9/5)+32 ) is what i am using
    thanks for the inputs

    have not found any samples using owin with this chip
    Ok, try this:
    Code:
    @ DEVICE pic16F877A, HS_OSC
    @ DEVICE pic16F877A, WDT_ON
    @ DEVICE pic16F877A, PWRT_ON
    @ DEVICE pic16F877A, BOD_ON
    @ DEVICE pic16F877A, MCLR_on
    @ DEVICE pic16F877A, LVP_OFF
    @ DEVICE pic16F877A, CPD_OFF
    @ DEVICE pic16F877A, PROTECT_OFF
    define osc 20
    define loader_used 1
    define lcd_dreg portd
    define lcd_dbit 4
    define lcd_rsreg portd
    define lcd_rsbit 2
    define lcd_ereg portd
    define lcd_ebit 3
    define lcd_lines 2
    define lcd_bits 4
    define lcd_commandus 2000
    define lcd_dataus 50
    command var byte:i var byte:temp var word:dq var porta.5:dq_dir var trisa.5
    adcon1=255:porta=255:portb=0:trisa=255:trisb=0:cmcon=7
    Lcdout $fe,1,"Temp in degrees C"
    mainloop:	Gosub init1820:command=$cc:Gosub write1820:command=$44
    Gosub write1820:Pause 2000:Gosub init1820:command=$cc:Gosub write1820
    Pause 2000:command=$be:Gosub write1820:Gosub read1820:TEMP=((TEMP*9/5)+32)
    Lcdout $fe,1,dec(temp>>1),".",dec(temp.0*5)," degrees C":Goto mainloop
    init1820:	Low DQ:Pauseus 500:DQ_DIR=1:Pauseus 100
    If DQ=1 Then Lcdout $fe,1,"DS1820 not present":Pause 500:Goto mainloop
    Pauseus 400:Return
    write1820:	For i=0 to 7:low dq
    If command.0[temp] = 0 Then
    	Pauseus 60:DQ_DIR = 1
    Else
    	@ nop
    	DQ_DIR = 1:Pauseus 60
    Endif
    Next i:Return
    read1820:	For i=0 to 15:low dq
    		@ nop
    		dq_dir=1:temp.0[i]=1:if dq=0 then temp.0[i]=0
    		pauseus60:next i:return
    End

  7. #7


    Did you find this post helpful? Yes | No

    Default Update 2

    Tried This And Get Better Reading Only 6 Deg Low

    However It Does Not Respond To Any Temperature Changes

    Thanks

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by jcleaver View Post
    Tried This And Get Better Reading Only 6 Deg Low
    However It Does Not Respond To Any Temperature Changes
    Thanks
    Ok, what DOES it put out for a temperature?

    What happens if you heat it up, read the temperature, shut it off, put it in the freezer for a few minutes, take it out, power it up and read the temp right away?

  9. #9


    Did you find this post helpful? Yes | No

    Question Answer

    Read 65.xxxx

    Does Not Update Hold Sensor And Nothing Changes

    Reloaded Several Programs And They Work However Still Get Low Tmp Reading

    Dont Think Its A Hardware Problem Because It Works Perfectly In Mikroe

    Guess I Could That But Have Better Luck With Pbp As For As Adding My Stuff

Similar Threads

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