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
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
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
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