Ds18b20


Closed Thread
Results 1 to 25 of 25

Thread: Ds18b20

  1. #1
    Join Date
    Aug 2008
    Posts
    31

    Default Ds18b20

    i have a problem i made temp sensore project based on ds1820 but i want to replace it with ds18B20 for high resolution but when i change it i got strange readings , i think that i have to change something in code can some one help me do that attached is code
    Attached Files Attached Files

  2. #2
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default

    OWOut DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit] '


    OWOut DQ, 1, [$CC, $44] ' Start conversion
    WaitLoop:
    While not DQ
    Wend

    OWOut DQ, 1, [$CC, $BE]
    OWIn DQ, 2, [Temperature.Lowbyte, Temperature.Highbyte]

    Convert_Temp:

    If Temperature.15 then
    Temperature= ~Temperature +1
    Twist = 1
    Endif

    TempC = (Temperature & $7FF) >> 4
    Float = ((Temperature.Lowbyte & $0F ) * 25 )>>2
    Temperature = TempC*100 + Float

    If Twist then
    V= 10000 - Temperature ' 25 C=12500 0 C=10000 -10 C=9000
    Twist = 0
    else
    V= 10000 + Temperature
    EndIf



    ' SUBROUTINES:
    '----------------------------------------
    SelectSign:
    If v = 10000 then ' Temperature = 0 C.
    Sign=" " ' No sign
    Else
    If v < 10000 then ' <> 0
    Sign="-" ' Temperature below 0 C.
    Else
    Sign="+" ' Temperature above 0 C.
    EndIf
    EndIf
    Return

    '----------------------------------------
    DisplayTemp:
    If V >= 10000 then ' Above 0 C.
    Temperature=V-10000
    Else
    Temperature=10000-V ' Below 0 C.
    EndIf
    LcdOut $FE, $C0, Sign, DEC (Temperature / 100), ".", DEC2 Temperature, " ",223,"C "
    Return

  3. #3
    Join Date
    Aug 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    hi,
    thanks for replay but i am beginner in pbp so can u guide me where is the part i have to replace in my old code

  4. #4
    Join Date
    Aug 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    hi,
    i update the code u send me before can u check it please soi can begin testing
    Attached Files Attached Files

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


    Did you find this post helpful? Yes | No

    Wink

    Hi, Ahmed

    This subject in the SEARCH function of the Forum Gives 72 Hits ... including working programs for the 18B20

    so, just use it !!!

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

  6. #6
    Join Date
    Aug 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    hi,
    no replies nothing work tell now i got blank screen

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


    Did you find this post helpful? Yes | No

    Default

    Put here the schematic, please.

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


    Did you find this post helpful? Yes | No

    Wink

    Hi, Ahmed

    Just comparing the 18B20 Datasheet, page 5 to the 1820 Data., Page 4 will help you to understand how temperatures are coded in both cases ...

    and what you have to modify to get a nice result ...

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

  9. #9
    Join Date
    Aug 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    hi,
    thanks for replay please find attached schematic
    i am trying also to get rom id for ds18b20 but i got only 8 hex digit attached is the code
    Attached Images Attached Images  
    Attached Files Attached Files

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


    Did you find this post helpful? Yes | No

    Wink

    At first, try

    Code:
    ...
    
    for i = 0 to 7
    LcdOut HEX2 ID[i] 
    next i
    ...
    should print missing Zeroes ...

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

  11. #11
    Join Date
    Aug 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    hi,
    acetronics , still got 8 characters only

  12. #12
    Join Date
    Aug 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    hi,
    i update the code to read rom id and i can read it now working code attached , but still can not read temp. any update
    Attached Files Attached Files

  13. #13
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

  14. #14
    Join Date
    Aug 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    hi,
    thanks for help i update the code and i can read temp now but the resolution is 0.5 degree even when i set resolution to 12 bit , attached is the code
    Attached Files Attached Files

  15. #15
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default

    Try this, please and post the results.
    Attached Files Attached Files

  16. #16
    Join Date
    Mar 2006
    Location
    Hyderabad (India)
    Posts
    123


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by fratello View Post
    Try this, please and post the results.
    the file had four Minor errors. corrected file and a complied hex are attached
    Attached Files Attached Files
    Regards,
    Sarma

  17. #17
    Join Date
    Aug 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    hi,
    can u please send me picbasic code so i can know where is the error cause i am not god in assembely

  18. #18
    Join Date
    Aug 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    hi,
    i try the code u send me but still the same result nochange the resolution still 0.5

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


    Did you find this post helpful? Yes | No

    Talking

    Hi, Ahmed

    No surprise ... you do not write tte DS Config Word in the right registers ...

    our friend Fratello saw that ( and corrected it ... )

    a pair of zeros is missing in your command line ...

    Alain
    Last edited by Acetronics2; - 14th June 2009 at 13:03.
    ************************************************** ***********************
    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 " !!!
    *****************************************

  20. #20
    Join Date
    Aug 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    hi,
    still the same resolution 0.5 even after i update the code , attached is the code u send me if u want to check
    Attached Files Attached Files

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


    Did you find this post helpful? Yes | No

    Question Where's the bug ???

    Hi, Ahmed

    I must admit Fratello's program only shows half degrees ... ( just tested on an EasyPic 5 )

    but still have not found Why !!!

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

  22. #22
    Join Date
    Aug 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    hi,
    i am using pic basic pro 2.44 do u think this the problem

  23. #23
    Join Date
    Mar 2006
    Location
    Hyderabad (India)
    Posts
    123


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ahmed_salah View Post
    hi,
    can u please send me picbasic code so i can know where is the error cause i am not god in assembely
    complied code and also the corrected .asm are attached.

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


    Did you find this post helpful? Yes | No

    Wink

    Hi, Ahmed

    I Finally got it !!!

    the problem is in the Waiting loop ... that doesn't wait !!!

    sooo... add :

    Code:
     Busy VAR BIT
    at the top of the program

    and change :

    Code:
    WaitLoop:
     
    ' While not DQ                      ' NOT Working !!!
    ' Wend
    by

    Code:
    WaitLoop:
    
    OWIn DQ, 4, [Busy] 			' Check for still busy converting
    
    'PORTC.4 = 1				' Show waiting for conv complete
    
    If Busy = 0 Then 
    
     GOTO waitloop
     
    ENDIF
    
    ' PORTC.4 = 0
    Port C.4 was chosen to show the time the DS is Busy ... very useful tool to verify conversion is really complete !!!

    Have fun,

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

  25. #25
    Join Date
    Aug 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    hi,
    so thanks for help now i got resolution 1/100 i am so happy but i want to underestand what no 4 in statement OWIn DQ, 4, [Busy] means ???
    i have another question i want to read the o/p to pc serial port i connect 1k resistance to portb.1 and send it to pc rx pin (2) and circuit ground to pc gnd pin (5)
    note : i am using usb to serial converter
    i update the program just for testing to send a message but i notice that the Rx led on usb to serial converter flashes and nothing out on hyberterminal ????
    attached is code
    Attached Files Attached Files

Similar Threads

  1. Reading temperature using multi DS18B20
    By KVLV in forum Code Examples
    Replies: 16
    Last Post: - 3rd November 2017, 19:48
  2. Please help with code for DS18B20
    By fratello in forum mel PIC BASIC Pro
    Replies: 109
    Last Post: - 28th April 2013, 21:12
  3. Help with DS18B20 program
    By presario1425 in forum mel PIC BASIC Pro
    Replies: 38
    Last Post: - 22nd August 2012, 00:50
  4. Multi DS18b20 Code help.
    By sccsltd in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th December 2009, 06:13
  5. DS18B20 error reading
    By Gaetano in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th August 2007, 16:21

Members who have read this thread : 1

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