putting the 2,s compliment just befire works best:
but the temperature seems to cut in half,, showing -5C when it is -10C
Just getting +655 when I get to zero degrees.
loop:
'23
waitfor55:
serin portb.2 , n2400 , temp : if temp <> $55 then goto waitfor55
waitforaa:
serin portb.2 , n2400 , temp : if temp <> $aa then goto waitforaa
serin portb.2, n2400, encoded11.HighBYTE : serin portb.2, n2400, encoded11.LowBYTE
serin portb.2, n2400, encoded22.HighBYTE : serin portb.2, n2400, encoded22.LowBYTE
serin portb.2, n2400, encoded33.HighBYTE : serin portb.2, n2400, encoded33.LowBYTE
serin portb.2, n2400, encoded44.HighBYTE : serin portb.2, n2400, encoded44.LowBYTE
For counter=0 TO 7 'decoding
encoded1.0[counter]=encoded11.0[counter*2] : encoded2.0[counter]=encoded22.0[counter*2]
encoded3.0[counter]=encoded33.0[counter*2] : encoded4.0[counter]=encoded44.0[counter*2]
Next counter
'41
temperature= encoded1 ' putting back together as the original temperature
For counter=0 TO 7
temperature.0[counter+8]=encoded2.0[counter+8]
Next counter
temperature.LowBYTE = encoded1
temperature.HighBYTE = encoded2
count_remain = encoded3
count_per_c = encoded4
IF temperature.11 = 1 Then goto Zerotemp
temperature = ((( temperature >> 1) *100)- 25) + (((count_per_c - count_remain) * 100) / count_per_c)
tempF = (((temperature /5) *9 ) + 3200)
lcdout $FE,1, "TempC: ", "+", dec (temperature / 100) , ".", dec2 temperature," ",$DF,"C"
lcdout $FE,$C0, "TempF: ", "+", dec2 (tempF / 100) , ".", dec2 (tempF // 100)," ",$DF,"F"
goto loop
Zerotemp: '------------- cases when zero celcius and positive Fahrenheit
temp1 = temperature
temperature = ((( temperature >>1 ) *100)- 25) + (((count_per_c - count_remain) * 100) / count_per_c)
if tempF <= 0 then goto ZeroF
temperature = ( ~ temperature ) + 1 ': tempf = ( ~ tempF ) + 1 ' added this
tempF = 3200 - ((temperature /5) * 9)
lcdout $FE,1, "TempC: ", "-", dec (temperature / 100) , ".", dec2 temperature," ",$DF,"C"
lcdout $FE,$C0, "TempF: ", dec (tempF / 100) , ".", dec2 tempF ," ",$DF,"F"
goto loop
ZeroF: '---------------- cases when zero celcius and 0 Fahrenheit
tempF = 3200 - ((temperature /5) * 9)
lcdout $FE,1, "TempC: ", "-", dec (temperature / 100) , ".", dec2 temperature," ",$DF,"C"
lcdout $FE,$C0, "TempF: ", "-", dec (tempF / 100) , ".", dec2 tempF ," ",$DF,"F"
goto loop
end
Bookmarks