Shop OBEX P1 Docs P2 Docs Learn Events
Brownouts when Writing to EEPROM — Parallax Forums

Brownouts when Writing to EEPROM

Adam SAdam S Posts: 10
edited 2010-01-01 06:09 in BASIC Stamp
Hi all,

I'm a novice when it comes to electronics and the like, but I'm trying to make a device that senses the temperature and records it to the EEPROM onboard the BS2.

I know EEPROM has a limited lifetime, but I don't plan on anywhere near 1,000,000 writes.

So I'm using the DS1620 temperature chip and the Board of Education. The DS1620 reads the temperature just fine and I can display it on the debug screen, but when I call the method to store the temp data to EEPROM, the code restarts. Or thats what I think it's doing, because a tone is played at the very beginning, and after each write command, the tone plays again.

The board of education is connected to the Boe Bot chassis, but nothing is connected except the servos (and I tried running the program without the servos and it still restarted).

Here's my code. I understand how most of it works, but I am guilty of copying code from here (page 16):

www.parallax.com/Portals/0/Downloads/docs/prod/appkit/ds1620thermometer.pdf

and I do not understand that part of the code (namely the part that involves the "sign bit" according to the comments).
I have a feeling though that the problem doesn't lie within that part of the code though, since the brownout only occurs when I call SaveData.

' {$STAMP BS2}
' {$PBASIC 2.5}

Temp       VAR    Word              ' Word variable to hold 9-bit data.
Sign       VAR    Temp.BIT8       ' Sign bit of raw temperature data.
T_sign     VAR    Bit               ' Saved sign bit for converted temperature.
memloc     VAR    Word              ' the location to store the latest reading.
counter    VAR    Word              ' counter for the main FOR loop

memloc = 0

FREQOUT 0, 2000, 3000

OUTS=%0000000000000000               ' Define the initial state of all pins,
     'FEDCBA9876543210
DIRS=%1111111111111111               ' as low outputs.


'DS1620 has been preprogrammed to setting 3.
'The loop reads the latest temperature from the DS1620 and saves it to EEPROM.

HIGH 13                              ' Select the DS1620.
SHIFTOUT 15, 14, LSBFIRST, [noparse][[/noparse]238]     ' Send the "start conversions" command.
LOW 13                               ' Do the command.

FOR counter = 0 TO 20

  PAUSE 1000

  HIGH 13                            ' Select the DS1620.
  SHIFTOUT 15, 14, LSBFIRST, [noparse][[/noparse]170]   ' Send the "get data" command.
  SHIFTIN 15, 14, LSBPRE, [noparse][[/noparse]Temp]     ' Get the data, assign to DSDATA
  LOW 13                             ' End the command.

  T_sign = Sign                      ' Save the sign bit of the reading.
  Temp = Temp/2                      ' Scale reading to whole degrees C.

  IF T_sign = 0 THEN
    GOTO DisplayData
    GOTO SaveData
  ENDIF

  IF T_sign = 1 THEN
    Temp = Temp | $FF00              ' Extend sign bits for negative temps.
    GOTO DisplayData
    GOTO SaveData
  ENDIF

NEXT


DisplayData:
  DEBUG SDEC Temp," degrees C",CR     ' Show signed temperature in C.
  RETURN

SaveData:
  WRITE memloc,   DSdata.LOWBYTE
  WRITE memloc+1, DSdata.HIGHBYTE
  memloc = memloc + 2
  RETURN




I'm also attaching a picture of the wiring configuration on my board. Could the brownout be caused by a hardware issue (wrong capacitor, etc)? I'm using a 1k ohm resistor and a .1 micro-farad capacitor, per the instructions I found here (page 12):

www.parallax.com/Portals/0/Downloads/docs/prod/edu/WebApplied%20Sensors%20V2.0.pdf

There is a chance that the capacitor that I'm using isn't .1 micro-farads. The case says 104, so based on what I can find on the Internet, that indicates 100000 pico-farads, which is equivalent to .1 micro-farads. I could be wrong though.

Also, I put fresh batteries into the system, but the brownouts still happen.

Any insight is greatly appreciated. Also, let me know if you need more information.

Thanks,
Adam
640 x 480 - 79K
640 x 480 - 81K
640 x 480 - 81K

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-12-31 23:55
    First off you can't 'RETURN' from a GOTO. Fix that and try again. (GOSUB) Then make sure memory location is a valid location to write data. You may need to create a space for the data before writing to it (I don't do this type of thing so I don't know)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Adam SAdam S Posts: 10
    edited 2010-01-01 06:09
    Wow great point. I made those changes and I think it works! I'll run it through some more rigorous tests tomorrow, but I think you found the problem.

    Thanks for the help!

    -Adam
Sign In or Register to comment.