Need Assistance w/DS1620 Final touches
Frank Matthews
Posts: 8
I would like to add data storage for temperature approximately once every 15 minutes (sleep 900) over a twenty four hour period. I've used parts of other codes to offer a few bells and whistles, but I don't have a good grasp on DATA, READ, and WRITE in EEPROM for ongoing data collection. Any assistance would be appreciated. I'd like to be able to download the data in DEBUG then transfer the data to Excel.
Thanks,
Frank
Here is the code I have so far.
'
[noparse][[/noparse] Title ]
' Applied Sensors - DS1620MorseCode.bs2
' Talking thermometer, using Morse code.
'{$STAMP BS2}
'{$PBASIC 2.5}
'
[noparse][[/noparse] Constants ]
Dit CON 70 ' Milliseconds for Morse dit.
Dit2 CON 2*Dit ' Constants related to Dit.
Dah CON 3*Dit ' Ditto.
'
[noparse][[/noparse] Declarations ]
mc VAR Byte ' Temporary for Morse pattern.
xm VAR Byte ' Morse input variable.
j VAR Nib ' Index for digits to send.
i VAR Nib ' Index for dits and dahs.
x VAR Byte ' General purpose variable, byte.
degC VAR Byte ' Variable to hold degrees Celsius.
degF VAR Byte '·· Variable to hold degrees F.
'
[noparse][[/noparse] Initializations ]
' Note: DS1620 has been preprogrammed for mode 2.
' If not, uncomment the instructions on the next line on the first RUN
' HIGH 13: SHIFTOUT 15,14,[noparse][[/noparse]12,2]: LOW 13
OUTS=%0000000000000000 ' Define the initial state of all pins
'FEDCBA9876543210
DIRS=%1111111111111101 ' as low outputs,
'^
except P1, an input for pushbutton.
FREQOUT 0, 20, 3800 ' Beep to signal that it is running.
PAUSE 3000
HIGH 13 ' Select the DS1620.
SHIFTOUT 15, 14, LSBFIRST, [noparse][[/noparse]238] ' Send the "start conversions" command.
LOW 13 ' Do the command.
'
[noparse][[/noparse] Main Routine ]
DO ' Start of the main loop.
HIGH 13 ' Select the DS1620.
SHIFTOUT 15, 14, LSBFIRST, [noparse][[/noparse]170] ' Send the "get data" command.
SHIFTIN 15, 14, LSBPRE, [noparse][[/noparse]x] ' Get the data.
LOW 13 ' End the command.
degC = x / 2 ' Convert the data to degrees C.
degF = degC * 9 / 5 + 32 'Convert the data to degrees F.
DEBUG ? degC ' Show the result on the PC screen.
xm = degC ' Morse routine expects data in xm.
FREQOUT 0, 200, 3000
PAUSE 1500
GOSUB Morse ' To the subroutine.
PAUSE 1000
'
Fahrenheit
DEBUG ? degF
xm = degF ' Morse routine expects data in xm.
FREQOUT 0, 200, 5000
PAUSE 1500
GOSUB Morse ' To the subroutine.
SLEEP 900
LOOP ' Back to wait for button again.
'
[noparse][[/noparse] Subroutines ]
Morse: ' Emits byte xm as Morse code.
FOR j=1 TO 0 ' Send 2 digitS, Tens then ones.
mc = xm DIG j ' Pick off the (j+1)th digit.
mc = %11110000011111 >> mc ' Set up pattern for Morse code.
FOR i=4 TO 0 ' 5 dits and dahs.
' Send pattern from bits of mc.
FREQOUT 0, Dit2*mc.BIT0(i) + Dit, 2200
PAUSE Dit ' Short silence.
NEXT ' Next I, dit or dah of five.
PAUSE Dah ' Interdigit silence.
NEXT ' Next j, digit of two.
PAUSE 5000
RETURN ' Back to main program.
Thanks,
Frank
Here is the code I have so far.
'
[noparse][[/noparse] Title ]
' Applied Sensors - DS1620MorseCode.bs2
' Talking thermometer, using Morse code.
'{$STAMP BS2}
'{$PBASIC 2.5}
'
[noparse][[/noparse] Constants ]
Dit CON 70 ' Milliseconds for Morse dit.
Dit2 CON 2*Dit ' Constants related to Dit.
Dah CON 3*Dit ' Ditto.
'
[noparse][[/noparse] Declarations ]
mc VAR Byte ' Temporary for Morse pattern.
xm VAR Byte ' Morse input variable.
j VAR Nib ' Index for digits to send.
i VAR Nib ' Index for dits and dahs.
x VAR Byte ' General purpose variable, byte.
degC VAR Byte ' Variable to hold degrees Celsius.
degF VAR Byte '·· Variable to hold degrees F.
'
[noparse][[/noparse] Initializations ]
' Note: DS1620 has been preprogrammed for mode 2.
' If not, uncomment the instructions on the next line on the first RUN
' HIGH 13: SHIFTOUT 15,14,[noparse][[/noparse]12,2]: LOW 13
OUTS=%0000000000000000 ' Define the initial state of all pins
'FEDCBA9876543210
DIRS=%1111111111111101 ' as low outputs,
'^
except P1, an input for pushbutton.
FREQOUT 0, 20, 3800 ' Beep to signal that it is running.
PAUSE 3000
HIGH 13 ' Select the DS1620.
SHIFTOUT 15, 14, LSBFIRST, [noparse][[/noparse]238] ' Send the "start conversions" command.
LOW 13 ' Do the command.
'
[noparse][[/noparse] Main Routine ]
DO ' Start of the main loop.
HIGH 13 ' Select the DS1620.
SHIFTOUT 15, 14, LSBFIRST, [noparse][[/noparse]170] ' Send the "get data" command.
SHIFTIN 15, 14, LSBPRE, [noparse][[/noparse]x] ' Get the data.
LOW 13 ' End the command.
degC = x / 2 ' Convert the data to degrees C.
degF = degC * 9 / 5 + 32 'Convert the data to degrees F.
DEBUG ? degC ' Show the result on the PC screen.
xm = degC ' Morse routine expects data in xm.
FREQOUT 0, 200, 3000
PAUSE 1500
GOSUB Morse ' To the subroutine.
PAUSE 1000
'
Fahrenheit
DEBUG ? degF
xm = degF ' Morse routine expects data in xm.
FREQOUT 0, 200, 5000
PAUSE 1500
GOSUB Morse ' To the subroutine.
SLEEP 900
LOOP ' Back to wait for button again.
'
[noparse][[/noparse] Subroutines ]
Morse: ' Emits byte xm as Morse code.
FOR j=1 TO 0 ' Send 2 digitS, Tens then ones.
mc = xm DIG j ' Pick off the (j+1)th digit.
mc = %11110000011111 >> mc ' Set up pattern for Morse code.
FOR i=4 TO 0 ' 5 dits and dahs.
' Send pattern from bits of mc.
FREQOUT 0, Dit2*mc.BIT0(i) + Dit, 2200
PAUSE Dit ' Short silence.
NEXT ' Next I, dit or dah of five.
PAUSE Dah ' Interdigit silence.
NEXT ' Next j, digit of two.
PAUSE 5000
RETURN ' Back to main program.
Comments
Thanks
Sid
Hmmm I guess the comments dont line up like they should.......
Post Edited (metron9) : 11/4/2005 3:59:49 PM GMT
·· given that the main page states that the DS1620 can read to 0.5 degrees C, then this would indicate it can go down to 1/2 degree increments in C.· 0.9 degree increments in F.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
http://www.parallax.com/dl/docs/cols/nv/vol6/col/nv123.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
http://forums.parallax.com/showthread.php?p=544667
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax