hi all, back onto the project after the holidays and this is how far ive got. After lots research i came across this page
http://www.picbasic.co.uk/forum/archive/index.php/t-17975.html and decided to use and mod their code. the result is
Code:
lcdinit p0\p1\p7\p6\p5\p4,p2
Lcdwrite p0\p1\p7\p6\p5\p4,p2, [lcdclear,homelcd,scr,twoline," temp orig "]
count_remain var byte
R_Temp VAR WORD ' RAW Temperature readings
TempC VAR WORD ' Temp in deg C
Float VAR WORD ' Holds remainder for + temp C display
Cold_Bit VAR R_Temp.Bit11 ' Sign-Bit for +/- Temp. 1 = Below 0 deg C
Real_Cold CON 1 ' Define Real_Cold = 1
Deg CON 223 ' Data to display Deg ° symbol
Sign VAR BYTE ' +/- sign for temp display
Dummy VAR BYTE ' Dummy for Div32
clear
main
owout P13,1,main,[$cc,$4e,$00,$00,$1f] 'writes configreg 9bit
owout P13,1,main,[$cc,$44] 'skip then convert temp
wait
owin P13,0,[count_remain] 'check for busy converting
if count_remain = 0 then wait 'wait loop
owout P13,1,main,[$cc,$be] 'skip then read scratch pad (temperature)
owin P13,0,[R_temp.LOWBYTE, R_temp.HIGHBYTE]
gosub convert_temp
'LCDWRITE p0\p1\p7\p6\p5\p4,p2, [lcdclear,homelcd,scr,twoline, "Temp=", real convert," t0=",dec tofloat temp.byte0]', SCRRAM+40, real convert, " C"]
'LCDWRITE p0\p1\p7\p6\p5\p4,p2, [scr,scrram+40,"config=",bin configreg] '"t1=",dec tofloat temp.byte1," th=",dec tofloat th," tl=",dec tofloat tl,
pause 500
goto main
Convert_Temp: ' +32.0 to +257 F
IF Cold_Bit = Real_Cold THEN Yikes ' If Cold_Bit = 1, it's below "0" deg C
Sign = "+"
Dummy = 625 * R_Temp ' Multiply to load internal registers with 32-bit value
TempC = tempc/ 10 ' Use Div32 value to calculate precise deg C
Dummy = 1125 * R_Temp
TempC = (R_Temp & $0FF0) >> 4 ' Mask middle 8-bits, shift into lower byte
Float = ((R_Temp.Lowbyte & $0F) * 625)/100 ' Lower 4-bits of result * 625
LCDWRITE p0\p1\p7\p6\p5\p4,p2, [lcdclear,homelcd,scr,twoline, "Temp= ",Sign,DEC TempC,".",DEC2 Float,Deg,"C"]
LCDWRITE p0\p1\p7\p6\p5\p4,p2, [scr,scrram+40,"Raw ", IBIN16 R_Temp]
RETURN
Yikes: ' Display full range -C to -F conversion
Sign = "-" ' Display - symbol for negative temp
Dummy = 625 * ~R_Temp+1' Multiply to load internal registers with 32-bit value
TempC = tempc/ 10 ' Use Div32 value to calculate precise deg C
LCDWRITE p0\p1\p7\p6\p5\p4,p2, [lcdclear,homelcd,scr,twoline, "Temp= ",Sign,DEC TempC DIG 4,DEC TempC DIG 3,".",DEC TempC,Deg,"C"]
lcdwrite p0\p1\p7\p6\p5\p4,[scr,scrram+40, "Raw ", IBIN16 R_Temp]
RETURN
END
it seems to work after changing their
TempC = DIV32 10 ' Use Div32 value to calculate precise deg C
to
TempC =TempC/10
dont know if this is correct but seems to give me a room temperature of 20 deg
the problem now is that the negative part does not work or half works. i can see the raw binary value change when it goes below 0. but the temperature reading stays at -00.0c.
i am using a can of air duster, upside down which sprays a very cool liquid.
Any idea?