yes the positive values works just fine,
I dont why you are doing 2,s compliment twice in the zerotemp.
I saw that program , but there was too many things I did not understand, like this line:
Dummy = 625 * R_Temp ' Multiply to load internal registers with 32-bit value
Why multiply by 625..
I also tryed it as is: ( it get stuck at 0.00 C and stays there)
loop:
'24
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
'40
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
'58
Zerotemp: ' cases when zero celcius and positive Fahrenheit
Dummy = 625 * ~temperature+1' Multiply to load internal registers with 32-bit value
TempC = DIV32 10 ' Use Div32 value to calculate precise deg C
TempF = ~temperature / 16 ' Begin conversion from -C to deg +/-F
IF TempF >=18 THEN ' Check for -degrees F "-18 C = -0.4 F"
TempF = ((((TempF + 50) * 9) /5) -122) ' -C to -F below -17 deg C
lcdout $FE,1, "TempF: " ,"-" , DEC TempF,$DF,"F "
lcdout $FE,$C0, "TempC: ", "-",DEC TempC DIG 4, DEC TempC DIG 3,".",DEC3 TempC, $DF,"C "
ELSE ' Else result = +deg F
TempF = ((((-TempF + 50) * 9) /5) -58)' -C to +F below 32.0 deg F to -17 deg C
lcdout $FE,1, " TempF: " , "+", DEC TempF, $DF,"F "
lcdout $FE,$C0, " TempC: ","-" ,DEC TempC DIG 4,DEC TempC DIG 3,".",DEC3 TempC,$DF,"C "
ENDIF
goto loop
end
Bookmarks