Celsius -55.00 C to +125.00 C
Fahrenheit -67.0 F to +257.0 F
Readtemp12 example
convert is just converting the sensor data as a word in original form
its easier than converting the bytes seperately will be the same for 9,10,11,12 bit reading
but if our convert code is not as good we can also loose resolution in the maths also
luckily our ds18b20 scales easily.
(when using above owin commands)
by default is set to 12 bit which we get as soon as we can read it
if using other functions alarm and eprom this will take longer
if using external supply and requiring read time slots
this can take up to a MAX 750ms for 12bit
if we need this quicker we can reduce the bit read.
the above code is abit of trick lol because we are not waiting for the conversion
we are infact reading from the previous one so if we update every minute
the data is one minute old.
it was found a PAUSE 510 was needed after the convert command
owout c.7,%1001,($CC,$44) to get the instant update
and when first powered up you would need longer
its probaly why readtemp12 takes 750ms you dont need to pause
and it guarentees instant update even when first powered up.
Code:
Celsius:
owout c.7,%1001,($CC,$44) ' reset(send skip rom ,send convert t)
owout c.7,%0001,($CC,$BE) ' reset(send skip rom ,send read lsb msb)
owin c.7,%0000,(b2,b3) ' read in result ds18b20
Convert: ' info + 125 degrees / 0.0625 = 2000
let b9 =43 ' Display + (43) space (32)
IF W1 > 64655 THEN ' info - 55 degrees = 64656
let b9 =45 ' Display - (45)
W1 = - W1 ' info if - ie w1=5500 Display - 55.00 C
ENDIF
W1 = W1 * 25 / 4 ' info + ie w1=12500 Display + 125.00 C
BINTOASCII w1,b8,b7,b6,b5,b4
IF b8 = "0" THEN : b8 = " " :ENDIF ' zero blanking b8
IF b8 = " " AND b7 = "0" THEN : b7 = " " :ENDIF ' zero blanking b7
SERTXD (CR, LF, "Temperature ",b9,b8,b7,b6,".",b5,b4," Degrees C", CR, LF) ' resolution to 0.06
pause 1000
goto celsius
Code:
Fahrenheit:
owout c.7,%1001,($CC,$44) ' reset(send skip rom ,send convert t)
owout c.7,%0001,($CC,$BE) ' reset(send skip rom ,send read lsb msb)
owin c.7,%0000,(b2,b3) ' read in result ds18b20
Convert: ' info + 225 degrees / 0.1125 = 2000
let b9 =43 ' Display + (43) space (32)
W1 = W1 +880 * 9 / 8 -670 ' info + ie w1=2570 Display + 257.0 C
IF W1 > 64865 THEN ' info - 67 degrees = 64866
W1 = -W1 ' info if - ie w1=670 Display - 67.0 C
let b9 =45 ' Display - (45)
ENDIF
BINTOASCII w1,b8,b7,b6,b5,b4
IF b7 = "0" THEN : B7 = " " : ENDIF ' zero blanking b7
IF b7 = " " AND b6 = "0" THEN : B6 = " " : ENDIF ' zero blanking b6
SERTXD (CR, LF, "Temperature ",b9,b7,b6,b5,".",b4," Degrees F", CR, LF)'resolution to 0.1
PAUSE 1000
GOTO fahrenheit
Code:
Celsius:
Readtemp12 c.7,w1 'read in result ds18b20
convert:
let b9 =43 'Display + (43) space (32)
IF W1 > 64655 THEN ' info - 55 degrees = 64656
let b9 =45 'Display - (45)
W1 = - W1 ' info if - ie w1=1000 display - 10.00 C
ENDIF
W1 = W1 * 25 / 4 ' info + ie w1=8500 display 85.00 C
BINTOASCII w1,b8,b7,b6,b5,b4
IF b8 = "0" THEN : b8 = " " :ENDIF ' zero blanking b8
IF b8 = " " AND b7 = "0" THEN : b7 = " " :ENDIF ' zero blanking b7
SERTXD (CR, LF, "Temperature ",b9,b8,b7,b6,".",b5,b4," Degrees C", CR, LF)'resolution to 0.06
PAUSE 1000
GOTO celsius
its easier than converting the bytes seperately will be the same for 9,10,11,12 bit reading
but if our convert code is not as good we can also loose resolution in the maths also
luckily our ds18b20 scales easily.
(when using above owin commands)
by default is set to 12 bit which we get as soon as we can read it
if using other functions alarm and eprom this will take longer
if using external supply and requiring read time slots
this can take up to a MAX 750ms for 12bit
if we need this quicker we can reduce the bit read.
the above code is abit of trick lol because we are not waiting for the conversion
we are infact reading from the previous one so if we update every minute
the data is one minute old.
it was found a PAUSE 510 was needed after the convert command
owout c.7,%1001,($CC,$44) to get the instant update
and when first powered up you would need longer
its probaly why readtemp12 takes 750ms you dont need to pause
and it guarentees instant update even when first powered up.
Last edited: