Electronic – arduino – Ways to configure and persist settings in Arduino-based hardware

arduino

I'm currently building an Arduino-based LaserTag Game.
After solving a lot of technical challenges I'm now at the point of programming and configuring my first prototype.

Next challenges:

  • The "Taggers" should be customizable to the players needs (damage, bullets in mag..)
  • Rules should be customizable before each game
  • The Player shouldn't be able to reset health and ammo by just restarting the Tagger

Ideas:

  1. My first Idea was to use the arduinos EEPROM but I read that it would only survive around 100k write/delete cycles. Which is not much when I write to it after every shot.

  2. My second Idea was to use an external I2C EEPROM to persist settings and current game data. Atleast I wouldn't break my arduinos when I reach the point when it breaks. Also I can save a lot more data on it.

  3. Another Idea is to customize the firmware for every player (I already have a tool for compiling and flashing firmware to the tagger) and also define the most common game rules in the firmware and just activate it over a serial connection. But then again, how can I persist the current tagger data like health and ammo.

Questions:

  • Are there any best practices out there?
  • Are there any technics I'm not aware of?
  • What about SD Cards? They seem a bit overpowered for my use.

Best Answer

You may want to look into "EEPROM wear leveling". If you had a 32-bit (4 bytes) counter and 1024 bytes of EEPROM you could in theory extend the EEPROM's life time by a factor of 1024/4 = 256, which gives more than 25M write cycles. Even if you only use 50% of the EEPROM for the counter that'd be about 12M 'shots'.

See for example Wear leveling on a microcontroller's EEPROM or https://stackoverflow.com/questions/10667491/is-there-a-general-algorithm-for-microcontroller-eeprom-wear-leveling. I think there are also supporting libraries out there.

An SD card probably is overkill, but should work fine. The same principles apply to (SD-)flash memory as to EEPROMS. Flash has limited write cycles, too, but the integral controllers on SD cards automagically perform the wear leveling so you don't have to deal with that. If you have a 1GB card and write 1MB of new data per game, ideally the controller would have taken care so that after 1000 games played each sector of the card has only been written to once. Assuming only 10k guaranteed write cycles per sector, that should give about 10M guaranteed games.