Shop OBEX P1 Docs P2 Docs Learn Events
Need Assistance w/DS1620 Final touches — Parallax Forums

Need Assistance w/DS1620 Final touches

Frank MatthewsFrank Matthews Posts: 8
edited 2005-11-06 12:24 in BASIC Stamp
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.

Comments

  • NewzedNewzed Posts: 2,503
    edited 2005-11-04 15:41
    In reading the sheet and the sample code in the documentation for the DS1620, I gather that the temperature can only be read in whole degrees.· Reading temp to the nearest tenth of a degree, which can be done with the Senserion, is not possible with the DS1620.· Am I correct?

    Thanks

    Sid
  • metron9metron9 Posts: 1,100
    edited 2005-11-04 15:52
    Could you use the "code and /code " so your indents and code is more readable when posting code?

    ' -----[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. 
      FREQOUT 0, Dit2*mc.BIT0(i) + Dit, 2200                 ' Send pattern from bits of mc.
      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.
    
    
    




    Hmmm I guess the comments dont line up like they should.......

    Post Edited (metron9) : 11/4/2005 3:59:49 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-11-04 15:54
    Newzed said...(trimmed)
    In reading the sheet and the sample code in the documentation for the DS1620, I gather that the temperature can only be read in whole degrees.· Reading temp to the nearest tenth of a degree, which can be done with the Senserion, is not possible with the DS1620.· Am I correct?
    Sid,

    ·· 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
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-04 15:56
    The DS1620 returns temperature in 0.5 degrees C -- with a little extra code you can get down to 0.05 degrees C.· This article shows how:

    http://www.parallax.com/dl/docs/cols/nv/vol6/col/nv123.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-11-06 05:25
    Also remember that there is still a little bug in the high resolution code printed in the PDF file. Due to the offset around zero degrees C. Discussed and resolved in this thread:
    http://forums.parallax.com/showthread.php?p=544667

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-06 12:24
    I'll make sure that error doesn't make it into the N&V book -- thanks for reminding me, Tracy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.