' ======================================================================== ' Program... SCIENCEPROJ.BS2 ' Author.... Brian Lincoln (modified from Jon Williams' code) ' Started... 2/6/02 ' Updated... 2/17/02 6am ' ======================================================================== ' -----[ Program Description ]-------------------------------------------- ' ' Plot six temperatures measured by a DS1620 using Stamp Plot pro v3 Beta from ' SelmaWare Solutions (www.selmaware.com). DS1620 uses common clk and DQ ' Temperature is converted to whole deg F 'RUNS ON SMALL BATTERY POWERED BS2 STAMP ' -----[ Revision History ]----------------------------------------------- '2/9/02 BTL Adjusted scale factor for 10ths '2/10/02 BTL Removed DS1620 write to config register....already in EPROM; ' Will need to be re-inserted if new parts are introduced '2/15/02 BTL Re-adjusted temp for whole deg F (rounded to nearest deg F) '2/15/02 BTL Changed RSTn Pins to 0 to 7 rather than 1 to 8 for Battery Stamp ' Changed timing to 60 seconds (1 minute) between samples '2/16/02 BTL Changed time between samples to a constant (TIMER) '2/17/02 BTL Updated timer to every minute ' -----[ I/O Definitions ]------------------------------------------------ ' rst1 CON 0 ' BSPin 0 - DS1620.3 no. 1 temp sensor rst2 CON 1 ' BSPin 1 - DS1620.3 no. 2 temp sensor rst3 CON 2 ' BSPin 2 - DS1620.3 no. 3 temp sensor rst4 CON 3 ' BSPin 3 - DS1620.3 no. 4 temp sensor rst5 CON 4 ' BSPin 4 - DS1620.3 no. 5 temp sensor rst6 CON 5 ' BSPin 5 - DS1620.3 no. 6 temp sensor Clk CON 6 ' BSPin 6 - DS1620.2 Common Clock pin DQ CON 7 ' BSPin 7 - DS1620.1 Common Data pin ' -----[ Constants ]------------------------------------------------------ ' Timer CON 59850 'Delay between samples in mSec ' DS1620 commands ' RTmp CON $AA ' read temperature WTHi CON $01 ' write TH (high temp) WTLo CON $02 ' write TL (low temp) RTHi CON $A1 ' read TH RTLo CON $A2 ' read TL StartC CON $EE ' start conversion StopC CON $22 ' stop conversion WCfg CON $0C ' write config register RCfg CON $AC ' read config register ' -----[ Variables ]------------------------------------------------------ ' tmpIn VAR Word ' raw data from DS1620 halfBit VAR tmpIn.Bit0 ' 0.5 degree C indicator sign VAR tmpIn.Bit8 ' 1 = negative temperature tempF VAR Word ' degrees F in tenths ' -----[ Initialization ]------------------------------------------------- ' Init_DS1620: 'HIGH Rst1 ' alert the DS1620 no.1 UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** ' use with CPU; free run mode ' SHIFTOUT DQ,Clk,LSBFIRST,[WCfg, %10] UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** 'LOW Rst1 UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** PAUSE 10 ' allow DS1620 EE write HIGH Rst1 ' start temp conversion SHIFTOUT DQ,Clk,LSBFIRST,[StartC] LOW Rst1 'HIGH Rst2 ' alert the DS1620 no.2 UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** ' use with CPU; free run mode 'SHIFTOUT DQ,Clk,LSBFIRST,[WCfg, %10] UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** 'LOW Rst2 UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** PAUSE 10 ' allow DS1620 EE write HIGH Rst2 ' start temp conversion SHIFTOUT DQ,Clk,LSBFIRST,[StartC] LOW Rst2 'HIGH Rst3 ' alert the DS1620 no.3 UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** ' use with CPU; free run mode 'SHIFTOUT DQ,Clk,LSBFIRST,[WCfg, %10] UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** 'LOW Rst3 UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** PAUSE 10 ' allow DS1620 EE write HIGH Rst3 ' start temp conversion SHIFTOUT DQ,Clk,LSBFIRST,[StartC] LOW Rst3 'HIGH Rst4 ' alert the DS1620 no.4 UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** ' use with CPU; free run mode 'SHIFTOUT DQ,Clk,LSBFIRST,[WCfg, %10] UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** 'LOW Rst4 UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** PAUSE 10 ' allow DS1620 EE write HIGH Rst4 ' start temp conversion SHIFTOUT DQ,Clk,LSBFIRST,[StartC] LOW Rst4 'HIGH Rst5 ' alert the DS1620 no.5 UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** ' use with CPU; free run mode 'SHIFTOUT DQ,Clk,LSBFIRST,[WCfg, %10] UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** 'LOW Rst5 UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** PAUSE 10 ' allow DS1620 EE write HIGH Rst5 ' start temp conversion SHIFTOUT DQ,Clk,LSBFIRST,[StartC] LOW Rst5 'HIGH Rst6 ' alert the DS1620 no.6 UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** ' use with CPU; free run mode 'SHIFTOUT DQ,Clk,LSBFIRST,[WCfg, %10] UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** 'LOW Rst6 UN-COMMMENT IF NEW DS1620 CHIPS ARE USED ****** PAUSE 10 ' allow DS1620 EE write HIGH Rst6 ' start temp conversion SHIFTOUT DQ,Clk,LSBFIRST,[StartC] LOW Rst6 Init_Graph: DEBUG "!RSET", CR ' clear graph DEBUG "!CLMM", CR ' clear min/max values DEBUG "!TMAX 500", CR ' 1 hour scale DEBUG "!PNTS 5000", CR ' graph every second DEBUG "!MAXS", CR ' stop when graph full DEBUG "!TSMP ON", CR ' enable time stamping DEBUG "!TITL Juliana's Science Project", CR ' set window title DEBUG "!USRS Temperature in Fahrenheit", CR ' graph legend DEBUG "!CLRM", CR ' clear messages DEBUG "Reset and monitoring temperature", CR ' message box DEBUG "!PLOT ON", CR ' enable plotting ' -----[ Main ]----------------------------------------------------------- ' Main: HIGH Rst1 ' Select or alert the DS1620 no.1 GOSUB GetTempConv ' get the raw temperature LOW Rst1 ' De-Select DS1620 DEBUG DEC (tempF+5)/10,"," ' Send temp to Stamp Plot Pro HIGH Rst2 ' Select or alert the DS1620 no.2 GOSUB GetTempConv ' get the raw temperature LOW Rst2 ' De-Select DS1620 DEBUG DEC (tempF+5)/10,"," ' Send temp to Stamp Plot Pro HIGH Rst3 ' Select or alert the DS1620 no.3 GOSUB GetTempConv ' get the raw temperature LOW Rst3 ' De-Select DS1620 DEBUG DEC (tempF+5)/10,"," ' Send temp to Stamp Plot Pro HIGH Rst4 ' Select or alert the DS1620 no.4 GOSUB GetTempConv ' get the raw temperature LOW Rst4 ' De-Select DS1620 DEBUG DEC (tempF+5)/10,"," ' Send temp to Stamp Plot Pro HIGH Rst5 ' Select or alert the DS1620 no.5 GOSUB GetTempConv ' get the raw temperature LOW Rst5 ' De-Select DS1620 DEBUG DEC (tempF+5)/10,"," ' Send temp to Stamp Plot Pro HIGH Rst6 ' Select or alert the DS1620 no.6 GOSUB GetTempConv ' get the raw temperature LOW Rst6 ' De-Select DS1620 DEBUG DEC (tempF+5)/10, CR ' Send temp to Stamp Plot Pro PAUSE timer ' wait delay between samples (timer is in mSec) GOTO Main ' do it again ' -----[ Subroutines ]---------------------------------------------------- ' GetTempConv: ' Subroutine to get raw temp (C) convert to (F) ' DS1620 must be selected first (rst line) SHIFTOUT DQ,Clk,LSBFIRST,[RTmp] ' Set up DS1620 to read temperature SHIFTIN DQ,Clk,LSBPRE,[tmpIn\9] ' get the temperature (raw in Deg C) ' Convert to Deg F IF sign = 0 THEN NotNeg ' if positive, okay (sign is bit of tempin) tmpIn = 0 ' - otherwise make zero NotNeg: tempF = (tmpIn * 9) + 320 ' convert to 10ths F (ex: 75.2 is 752) RETURN