Shop OBEX P1 Docs P2 Docs Learn Events
Frequent writes to EEPROM of BS2 - how long it will last? — Parallax Forums

Frequent writes to EEPROM of BS2 - how long it will last?

CuriousOneCuriousOne Posts: 931
edited 2013-04-03 07:04 in BASIC Stamp
Hello. I'm doing a basic stamp controllable wildlife observation camera which will use several number of servos for movement, zoom and focus. I want to add a function to memorize current settings (position, focus, zoom) when power is off, so when power is applied, last settings restored. I can do this in two ways:

Simple way: As any button being released, write current settings to eeprom and read on power-up.
Harder way: Add a software "shutdown" mode, and write to eeprom only in this case.

The first way is simple to do and relatively safe in case of power failures, but eeprom may fail. The harder way needs additional hardware, may not be proof to accidential power offs, but will save the eeprom.

Which one you'd reccomend?

Comments

  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-04-02 00:09
    Well EEPROMs are funny little beasts. They do fail and fail more easily if you write to the same address over and over again.

    If the EEPROM has a lot more space than is being used, the BasicStamp can increment the address to where the EEPROM writes and snake along to a new location rather than writting over and over again to one address.

    If you prepare the EEPROM before you do with with all blanks, you can search backwards to find the last entry.

    And when full, the EEPROM can reformat and start all over. It is a bit more code to write, but a heck of a lot longer lasting. It is called wear leveling.
  • CuriousOneCuriousOne Posts: 931
    edited 2013-04-02 02:49
    What if I hook an external EEPROM IC ?
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-02 07:08
    Most EEPROMs are good for something over 100,000 writes to any given location. If you only change a byte when the new value is different from the saved value and that value depends on something the user does (like a setting), it's going to take a long time for that byte to wear out. READ the location and compare the value in an IF statement to the new value and only do the WRITE if they're unequal.

    You can connect an external EEPROM to a Stamp, but it's not treated the same as the internal Stamp EEPROM and takes a bit of code to use. There are examples in the Nuts and Volts Columns. It's much easier to use READ, WRITE, and DATA.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2013-04-02 09:15
    A real time clock chip with a backup battery might be useful addition to the wildlife camera. If so, get one with a bit of RAM. It is a great place to back up settings like that.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-04-03 03:01
    The Real Time Clock chip that Tracy Allen refers has a persistent RAM because it runs on a separate battery and is extremely low power. It is a good alternative to using an external EEPROM. There are also LDC displays with extra RAM space, but they don't have the separate battery and extreme low power features that make this so easy to do.

    Of course, just using an EEPROM is going to be the cheapest. And there are some tiny ones. But you can easily get larger ones for about the same cost these days.
  • CuriousOneCuriousOne Posts: 931
    edited 2013-04-03 06:19
    Yes I know how RTC works. But camera module has own clock, so adding one extra will not be feasible. These 100000 guaranteed writes are per cell, right?
  • Mike GreenMike Green Posts: 23,101
    edited 2013-04-03 07:04
    Yes. Each location written has to be erased first to all one bits, then the zero bits are written. Eventually, electrons get trapped in the silicon oxide insulator that is part of the bit cell and these can't be completely removed during the erase operation so you get false zeros where you want ones.
Sign In or Register to comment.