Problem with DS1620- some kind of wierd cycling of temp.
Cogburn
Posts: 62
Hey guys- I am trying to get a DS1620 to read temperature values and I am using the program SW21-EX30-DS1620-HiRes.BS2 that appears in the StampWorks 2.1 experiment 30. The values are being displayed with debug. Something is goofy because if I have any temperatures above 80F or so, things are ok but when the temp drops to around 76F, the chip recycles or something. It jumps back to 82 and then drifts slowly back to 75 after heat is removed and then jumps back to 82 without any heat added. This repeats unless heat is added until the temp is above 80 or so and it seems to work fine.
Here is the link to the code and the program explanation.
www.parallax.com/Portals/0/Downloads/docs/books/sw/Web-SW-v2.1.pdf
I am wondering if the chip is bad or is it software.
Post Edited (Cogburn) : 1/10/2009 12:35:15 AM GMT
Here is the link to the code and the program explanation.
www.parallax.com/Portals/0/Downloads/docs/books/sw/Web-SW-v2.1.pdf
I am wondering if the chip is bad or is it software.
Post Edited (Cogburn) : 1/10/2009 12:35:15 AM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] Program Description ]
'
' This program measures temperature using the Dallas Semiconductor DS1620
' temperature sensor. Resolution is <0.05 degrees Celsius.
'
' NOTE: After downloading program, power must be cycled for proper
' operation.
'
[noparse][[/noparse] I/O Definitions ]
DQ CON 0 ' DS1620.1 (data I/O)
Clock CON 1 ' DS1620.2
Reset CON 2 ' DS1620.3
'
[noparse][[/noparse] Constants ]
RdTmp CON $AA ' read temperature
WrHi CON $01 ' write TH (high temp)
WrLo CON $02 ' write TL (low temp)
RdHi CON $A1 ' read TH
RdLo CON $A2 ' read TL
RdCntr CON $A0 ' read counter
RdSlope CON $A9 ' read slope
StartC CON $EE ' start conversion
StopC CON $22 ' stop conversion
WrCfg CON $0C ' write config register
RdCfg CON $AC ' read config register
DegSym CON 186 ' degrees symbol
'
[noparse][[/noparse] Variables ]
tempIn VAR Word ' raw temperature
config VAR Byte ' configuration register
done VAR config.BIT7 ' 1 when conversion done
tHiFlag VAR config.BIT6 ' 1 when temp >= THi
tLoFlag VAR config.BIT5 ' 1 when temp <= TLo
busy VAR config.BIT4 ' 1 when EE update writing
cRem VAR Word ' count remaining
slope VAR Word ' slope (counts per degree)
tC VAR Word ' Celsius
tF VAR Word ' Fahrenheit
'
[noparse][[/noparse] Initialization ]
Setup:
HIGH Reset ' alert DS1620
SHIFTOUT DQ, Clock, LSBFIRST, [noparse][[/noparse]WrCfg, %11] ' with CPU, one-shot mode
LOW Reset ' release DS1620
PAUSE 10
DEBUG CLS,
"DS1620-HR ", CR,
"
"
'
[noparse][[/noparse] Program Code ]
Main:
DO
GOSUB Read_DS1620_HR ' get hi-res temperature
Display_C:
DEBUG CRSRXY, 0, 2,
(tC.BIT15 * 13 + " "),
DEC (ABS tC / 100), ".", DEC2 (ABS tC),
DegSym, " C", CLREOL
Display_F:
DEBUG CRSRXY, 0, 3,
(tF.BIT15 * 13 + " "),
DEC (ABS tF / 100), ".", DEC2 (ABS tF),
DegSym, " F", CLREOL
LOOP
'
[noparse][[/noparse] Subroutines ]
Read_DS1620_HR: ' get hi-resolution temp
HIGH Reset ' alert the DS1620
SHIFTOUT DQ, Clock, LSBFIRST, [noparse][[/noparse]StartC] ' start conversion
LOW Reset ' release the DS1620
DO
HIGH Reset
SHIFTOUT DQ, Clock, LSBFIRST, [noparse][[/noparse]RdCfg] ' read config register
SHIFTIN DQ, Clock, LSBPRE, [noparse][[/noparse]config\8]
LOW Reset
LOOP UNTIL (done = 1) ' wait for conversion
HIGH Reset
SHIFTOUT DQ, Clock, LSBFIRST, [noparse][[/noparse]RdTmp] ' read raw temperature
SHIFTIN DQ, Clock, LSBPRE, [noparse][[/noparse]tempIn\9]
LOW Reset
HIGH Reset
SHIFTOUT DQ, Clock, LSBFIRST, [noparse][[/noparse]RdCntr] ' read counter
SHIFTIN DQ, Clock, LSBPRE, [noparse][[/noparse]cRem\9]
LOW Reset
HIGH Reset
SHIFTOUT DQ, Clock, LSBFIRST, [noparse][[/noparse]RdSlope] ' read slope
SHIFTIN DQ, Clock, LSBPRE, [noparse][[/noparse]slope\9]
LOW Reset
tempIn = tempIn >> 1 ' remove half degree bit
tempIn.BYTE1 = -tempIn.BIT7 ' extend sign bit
tC = tempIn * 100 ' convert to 100ths
tC = tC - 25 + (slope - cRem * 100 / slope) ' fix fractional temp
IF (tC.BIT15 = 0) THEN
tF = tC */ $01CC + 3200 ' convert pos C to Fahr
ELSE
tF = 3200 - ((ABS tC) */ $01CC) ' convert neg C to Fahr
ENDIF
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Showing up to school doesn't·mean you are a student any more than crawling up in an oven means that·you are a biscuit.
Post Edited (Cogburn) : 1/10/2009 1:37:01 PM GMT