Shop OBEX P1 Docs P2 Docs Learn Events
Hello and DS1620 Help — Parallax Forums

Hello and DS1620 Help

Nick WaldvogelNick Waldvogel Posts: 71
edited 2006-05-28 20:09 in BASIC Stamp
Hello Everyone!! I have been reading for a few months now and am still very basic when it comes to stamps. I have run into a little problem with using a DS1620. I got all the info from the Applied Sensors text and it seems to work well except for when the temp goes over 100 degF and then comes back under 100F. At that point it will read 990, 980, 970.... and so on. What did I do wrong?? Any help is welcome!! Thanks for all the great info you guys have given me so far as well! Here is the code I used:

' Applied Sensors - DS1620.bs2
' Obtain Temp reading from DS1620.

' {$STAMP BS2}
' {$PBASIC 2.5}

X VAR Byte
DegF VAR Byte
DegC VAR Byte

'Note: DS1620 has to be preprogrammed for mode 2.

OUTS=%0000000000000000

DIRS=%1111111111111111

FREQOUT 0, 20, 3800
HIGH 13
SHIFTOUT 15, 14, LSBFIRST, [noparse][[/noparse]238]
LOW 13


DO

HIGH 13
SHIFTOUT 15, 14, LSBFIRST, [noparse][[/noparse]170]
SHIFTIN 15,14,LSBPRE, [noparse][[/noparse]x]
LOW 13
DegC = x / 2

DegF = DegC * 9 / 5 + 32
DEBUG HOME
DEBUG ? DegF
PAUSE 1000


LOOP

Comments

  • JonathanJonathan Posts: 1,023
    edited 2006-05-28 18:21
    Nick,

    I have never used the DS1620, but here is a guess...

    Perhaps try declaring degF and degC as word sized variables. If the result of your formula to calc degrees is greater than 255, you will get weird results. Also, are you sure that the DS1620 returns only one byte?

    Hope this helps!

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-05-28 19:56
    The problem is a ghost. Really! The last digit, "0", stays on the screen when the number goes back below 100. Change the display command to,
    DEBUG DEC DegF,32,32,CR
    The 32 is a space and it will exorcise the ghost. Or
    DEBUG DEC DegF,CLREOL,CR
    The debug screen understands CLREOL as clear to end of line.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Nick WaldvogelNick Waldvogel Posts: 71
    edited 2006-05-28 20:09
    Thank you so very much to you both! I knew you guys wouldn't let me down! hop.gif You guys got it fixed!
Sign In or Register to comment.