radiosparks
Active member
I've been given a hand full of these (DS18B20) temperature sensors. They are known to be counterfeit. During testing with readtemp12 they are all resolving 11BITs or a step of 0.125. This could mean the EEPROM has been set or the configuration register cannot be written to.
I've probably answered the question myself from testing the temperature sensors ... I would to hear it from (the horses mouth) ...
Does the configuration register get set to 12BITs when using the function readtemp12?
Sorry, I don't seem the get the correct code colouring. There is no BASIC selection.
I've probably answered the question myself from testing the temperature sensors ... I would to hear it from (the horses mouth) ...
Does the configuration register get set to 12BITs when using the function readtemp12?
Sorry, I don't seem the get the correct code colouring. There is no BASIC selection.
C:
' /**************************************************/
' /* Read DS18B20 Temperature 12 bits - (08M2 chip) */
' /* radiosparks - rhb.20231202 */
'/**************************************************/
#PICAXE 08M2
#Terminal 4800 ; start terminal as needed
' /**********************/
' /* PORT/PIN */
'/**********************/
Symbol OneWirePORT = C.4
' /**********************/
' /* Register Variables */
'/**********************/
symbol TemperatureWORD = w0
symbol varPREV = w1
symbol varTEMP2 = w2
symbol varTEMP3 = w3
' /*********************/
' /* Main Program Loop */
'/*********************/
INITcode:
pause 3000 ; Delay to allow terminal to startup
Sertxd ( "Program Start: READY", CR, LF )
Main:
Do
Gosub showSignedTemperature
Loop
' /***************/
' /* Subroutines */
'/***************/
showSignedTemperature:
readtemp12 OneWirePORT, TemperatureWORD
pause 800
if TemperatureWORD <> varPREV then
if TemperatureWORD < $8000 then
sertxd( "+" )
varTEMP2 = TemperatureWORD
else
sertxd( "-" )
varTEMP2 = -TemperatureWORD
end if
varTEMP3 = varTEMP2 & 15 * 625
bintoascii varTEMP3, b15,b14,b13,b12,b11
varTEMP3 = varTEMP2 / 16
Sertxd( #varTEMP3, ".", b14,b13,b12,b11 )
Sertxd( " C", cr, lf )
end if
varPREV = TemperatureWORD
return