Not sure if the logic is correct but this works
[code]
'Get and display the temperature
GIE = 0
owin DQ, 1, [],NoDevice
OWOUT DQ, 1, [$CC, $44] ' Start temperature conversion
OWOUT DQ, 1, [$CC, $BE] ' Read the temperature
OWIN DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE]
GIE = 1
temperature = temperature */ 1600
lcdout $FE,$D4+0,"TEMP ",dec(temperature / 100),$DF,"C"
'************************************************* ****************************** '
fan:'check to see if fan is needed
fantrigger=fanset
if (temperature / 100)> fantrigger then
high portA.4
endif
**********************************************
NoDevice:
lcdout $FE,$D4+0,"TEMP N/C "
GIE = 1
goto fan
**********************************************
[code]
The NoDevice section is outside of the main part of the program. The logic being that the PIC sends a reset pulse and if it's not received back then jumps out to the NoDevice section, and then goes to the next part of the code but skips the temperature reading section. Seems to work when I pull out the DS18B20 and then plug it back in![]()
Bookmarks