Hi Darrel
well I only have DS18S20 or DS1820
The DS1820 works with the following code but ofcourse in 12bit
the DS18S20 does not return a valid temperature or some value chaning by it temperature
any idea ?
this is the working code with a DS1820
DS18B20_9bit CON %00011111 ; 93.75ms, 0.5°C
'DS18B20_10bit CON %00111111 ; 187.5ms, 0.25°C <-- My favorite
'DS18B20_11bit CON %01011111 ; 375ms, 0.125°C
'DS18B20_12bit CON %01111111 ; 750ms, 0.0625°C (default)
OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_9bit]
DS18S20:
OWOut DQ, 1, [$CC, $44] ' Start temperature conversion
waitloop: OWIn DQ, 4, [count_remain] ' Check for still busy converting
IF count_remain = 0 Then waitloop
OWOut DQ, 1, [$CC, $BE] ' Read the temperature
OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]
' Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature)
temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c)
HSerOut [#Temperature.Lowbyte," ",#Temperature.Highbyte," ",DEC (temperature/100),".",DEC2 temperature," C",13]
goto test




Bookmarks