Is there a way to see if a DS18B20 is present


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Location
    Denmark
    Posts
    9

    Default Is there a way to see if a DS18B20 is present

    Hi

    I have to know if a DS18B20 is "brokken" missing, so is there a way to see this?

    I have try this but is just say "yes a sensor" even if I have taken the DS18B20 of?

    check_sensor:

    Low comm_pin1 'Set the data pin low to initialize
    PauseUs 500 'Wait for more than 480us
    TRISA.0=1 'Release the data pin (set to input for high)
    PauseUs 100 'Wait for more than 60us
    IF comm_pin1=1 Then
    LcdOut $FE, $1, " NO " ' Show message
    Lcdout $fe, $c0, " sensor "
    pause 2000
    Else
    LcdOut $FE, $1, " yes a " ' Show message
    Lcdout $fe, $c0, " sensor "
    pause 2000
    EndIF
    return

    Kent

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


    Did you find this post helpful? Yes | No

    Default Re: Is there a way to see if a DS18B20 is present

    the only way is to read the sensor chip ID ...

    something like that:
    Code:
    '*****************************************************************************
    SensID:' Sensor Identification
    '*****************************************************************************
    
      OWOUT DQ, 1, [ $33 ]								' Read Chip Family code
      OWIN  DQ, 2, [ FAM,ID[6],ID[5],ID[4],ID[3],ID[2],ID[1],CRC]
      
      													' PAR Device ???
      OWOut DQ, 1, [$55, FAM,ID[6],ID[5],ID[4],ID[3],ID[2],ID[1],CRC, $44 ]
      OWOut DQ, 1, [ $55, FAM,ID[6],ID[5],ID[4],ID[3],ID[2],ID[1],CRC, $BE ]  
      PAUSE 750	 
      OWIN    DQ, 2, [R_Temp.Lowbyte, R_Temp.Highbyte]	' Read two bytes 
      
      IF FAM != $FF THEN 
      
      	IF R_Temp = $0550 OR R_Temp = $AA THEN 
      	
      		PAR = 1
      	  	
      	ELSE
      
      	PAR = 0
      	
      	ENDIF
      
      ELSE
      
      	LCDOUT $FE,$80, 				"NO SENSOR   "
      	LCDOUT $FE,$C0,					"Chk Sens & Reset"
      	STOP
      	
      ENDIF
      
      IF FAM = $05 THEN
      
       	LCDOUT $FE,$80,   				"DS 2405     "
       	
      	PAUSE 1000
      	
      	LCDOUT $FE,$80, 				" CRC: ",HEX2 CRC," FAM: ", HEX2 FAM
      	
      ENDIF
      
      IF FAM = $10 THEN
      
      	LCDOUT $FE,$80, 				"DS 18S20/1820"
      	IF PAR THEN LCDOUT $FE,$88," PAR " : PAUSE 1000
      	
      	Tempo = 250     	
      	PAUSE 1000
      	
      	LCDOUT $FE,$80, 				" CRC: ",HEX2 CRC," FAM: ", HEX2 FAM
      	
      ENDIF
      
      IF FAM = $22 THEN
      
       	LCDOUT $FE,$80, 				"DS 1822      " 
      	IF PAR THEN LCDOUT $FE,$88," PAR " : PAUSE 1000
      	      	
     	OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_bit]    'Skip ROM search and write N_bits
      	'                                                 resolution to scratch pad
      	PAUSE 1000
      	
      	LCDOUT $FE,$80, 				" CRC: ",HEX2 CRC," FAM: ", HEX2 FAM
      	
      ENDIF
      	  	
      IF FAM = $28 THEN
      
       	LCDOUT $FE,$80, 				"DS 18B20     " 
      	IF PAR THEN LCDOUT $FE,$88," PAR " : PAUSE 1000
      	   
     	OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_bit]    'Skip ROM search and write N_bits
      	'                                                 resolution to scratch pad
      	PAUSE 1000
      	
      	LCDOUT $FE,$80, 				" CRC: ",HEX2 CRC," FAM: ", HEX2 FAM
      	
      ENDIF
      
    
      	  	
      	LCDOUT $FE,$C0," ID:",HEX2 ID[1],HEX2 ID[2],HEX2 ID[3],HEX2 ID[4],HEX2 ID[5],HEX2 ID[6]
    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
    May 2004
    Location
    Denmark
    Posts
    9


    Did you find this post helpful? Yes | No

    Default Re: Is there a way to see if a DS18B20 is present

    Thanks Alain

    This give me some things to work with, And I got it now

    I look at the ID if all is 0 the no sensor.

    Kent

  4. #4
    Join Date
    Nov 2011
    Posts
    18


    Did you find this post helpful? Yes | No

    Post Re: Is there a way to see if a DS18B20 is present

    This I use and it works well:

    Code:
    Start:
    
    OWOUT DQ, 1, [ $33 ]                 'send read Rom command
    
    OWIN DQ, 2, [ FaM,skip 7]            'read sensor family code, skip ID and CRC
       if FaM = $28 then SkipOver        'if FaM = 28 then sensor is present
    
         LCDOUT $FE,$80,        "NO SENSOR "
         LCDOUT $FE,$C0,        "Chk Sens & Reset"
    
       goto Start                              'sensor not present so do again
    
    SkipOver:                                  'continue your code here
    Regards
    Hebe

Similar Threads

  1. Please help with code for DS18B20
    By fratello in forum mel PIC BASIC Pro
    Replies: 109
    Last Post: - 28th April 2013, 22:12
  2. Replies: 2
    Last Post: - 16th September 2011, 05:38
  3. Ds18b20
    By ahmed_salah in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 14th June 2009, 16:21
  4. Ds18b20..
    By karenhornby in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th June 2008, 17:29
  5. using the DS18B20
    By lerameur in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd December 2006, 14:09

Members who have read this thread : 2

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