ds1620 negative temp on lcd
antonis
Posts: 9
hello,
i have connect a ds1620 to show temp on LCD it works with temperatures 0C - 100C but if the temperature is negative show me· 35 C ·if i say show me 5 digit of this· show me 65535 what i do wrong?
the sign=0 when temp =>0·· and· sign=1 when temp<0
GOSUB clear_lcd
LOW rst
HIGH clk1620
HIGH rst
SHIFTOUT dq,clk1620,LSBFIRST,[noparse][[/noparse]Wconfig,CPU+cont]
LOW rst
HIGH rst
SHIFTOUT dq,clk1620,LSBFIRST,[noparse][[/noparse]startC]
LOW rst
again:
HIGH rst
SHIFTOUT dq,clk1620,LSBFIRST,[noparse][[/noparse]Rtemp]
SHIFTIN dq,clk1620,LSBPRE,[noparse][[/noparse]dsdata\9]
LOW rst
T_sign=sign
dsdata=dsdata/2
IF t_sign=0 THEN no_neg1
dsdata=dsdata|$FF00
no_neg1:
DEBUG SDEC dsdata,"degrees C",CR
GOSUB templcd
dsdata=(dsdata*/$01CC)
GOTO again
templcd:
char = CrsrHm
· GOSUB LCDcmd
FOR index = 1 TO 0···················· ' loop through digits
··· char = (dsdata DIG index)+"0"········ ' convert to ASCII
··· GOSUB LCDwr··························· ' write on LCD
· NEXT
return
i have connect a ds1620 to show temp on LCD it works with temperatures 0C - 100C but if the temperature is negative show me· 35 C ·if i say show me 5 digit of this· show me 65535 what i do wrong?
the sign=0 when temp =>0·· and· sign=1 when temp<0
GOSUB clear_lcd
LOW rst
HIGH clk1620
HIGH rst
SHIFTOUT dq,clk1620,LSBFIRST,[noparse][[/noparse]Wconfig,CPU+cont]
LOW rst
HIGH rst
SHIFTOUT dq,clk1620,LSBFIRST,[noparse][[/noparse]startC]
LOW rst
again:
HIGH rst
SHIFTOUT dq,clk1620,LSBFIRST,[noparse][[/noparse]Rtemp]
SHIFTIN dq,clk1620,LSBPRE,[noparse][[/noparse]dsdata\9]
LOW rst
T_sign=sign
dsdata=dsdata/2
IF t_sign=0 THEN no_neg1
dsdata=dsdata|$FF00
no_neg1:
DEBUG SDEC dsdata,"degrees C",CR
GOSUB templcd
dsdata=(dsdata*/$01CC)
GOTO again
templcd:
char = CrsrHm
· GOSUB LCDcmd
FOR index = 1 TO 0···················· ' loop through digits
··· char = (dsdata DIG index)+"0"········ ' convert to ASCII
··· GOSUB LCDwr··························· ' write on LCD
· NEXT
return
Comments
Here is a web page with everything you ever wanted to know about the application of the DS1620 with a PBASIC Stamp, thanks to Dr. Tracy Allen:
http://www.emesystems.com/OL2d1620.htm
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
TempLCD:
· char = CrsrHm
· GOSUB LcdCmd
· IF (dsData.BIT15) THEN
··· char = "-"
· ELSE
··· char = " "
· ENDIF
· GOSUB LcdWr
· dsData = ABS dsData
· FOR idx = 1 TO 0
··· char = (dsData DIG idx) + "0"
··· GOSUB LcdWr
· NEXT
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 2/26/2006 2:24:36 PM GMT