Shop OBEX P1 Docs P2 Docs Learn Events
ds1620 negative temp on lcd — Parallax Forums

ds1620 negative temp on lcd

antonisantonis Posts: 9
edited 2006-02-26 14:21 in BASIC Stamp
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

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-02-26 12:08
    antonis -

    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 -->
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-26 14:21
    Negative values are stored in two's-compliment form.· You can check to see if a number is negative by looking at Bit15.· Try this version of your TempLCD subroutine:

    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
Sign In or Register to comment.