Hello and DS1620 Help
Nick Waldvogel
Posts: 71
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
' 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
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
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