write command
littlerich
Posts: 27
I have 4 maybe ultimately 8 words I would like to keep track of in the event of a power outage.
Having read the manual I am mindful of the limited write cycles.
For the BS2P there is approx 100k writes. So if I updated every 1/2 hour that gives me a bit over 5 years.
Any suggestions for how to do the write every half hour?
I don't have a real time clock chip and wouldn't mind avoiding that.
Some huge loop maybe that only pops out every now and then to do the write is all I can think of currently.
Cheers
Rich
Having read the manual I am mindful of the limited write cycles.
For the BS2P there is approx 100k writes. So if I updated every 1/2 hour that gives me a bit over 5 years.
Any suggestions for how to do the write every half hour?
I don't have a real time clock chip and wouldn't mind avoiding that.
Some huge loop maybe that only pops out every now and then to do the write is all I can think of currently.
Cheers
Rich
Comments
Just a quick and dirty thought (not that kind )
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Flying is simple. You just throw yourself at the ground and miss.
"I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image."
Stephen Hawking
One way to work around this, if life expectancy of the EEPROM is a concern, is to divide your data up so that each byte is in a separate page.
I know you don't want to mess with a real-time clock, but it might give you exactly what you want. Most have a couple dozen or more bytes of SRAM in conjunction with the RTC function. Writes to SRAM do not contribute to wear, like they do in Flash EEPROM; however, a constant power supply is required. Most units can operate 10+ years off of a lithium coin cell at 25C.
On a different tangent, rather than time your "commit" writes, is there any way they can be event-driven? Example: when a user changes a setting, the setting gets written to EEPROM immediately, so it can be recalled when the system is powered on again.
I doubt I can use NAP as the program will be running continuously and the data I want to save I would prefer to time nicely within reason as I hope to send it to a database later on. But nice thought.
Maybe I am destined for RTC after all. I didn't realise the writes was unlimited in them, not crazy about the battery but I'll keep moving forward and see where it ends up.
Thanks again.
Rich
Or you could buy a RTC module from http://www.microresearch.us/ to save time on building the circuit.
You could also get a DS1307 mounted on a little board with a crystal and battery from Spark-Fun (www.sparkfun.com/commerce/product_info.php?products_id=99). This one has a 64 byte RAM. It requires the use of I2C which is built-in to the BS2p series devices, but has to be programmed explicitly using subroutines on the other Stamp models.
In both cases, you'd have a place to put the data that would be maintained in the case of a power failure and you'd also have a timebase that you could use to determine when to back things up. I would suggest two separate copies of the data if possible ... maybe with a checksum (if you're using the DS1307 with its extra memory). That way, if the power fails while the memory is being updated, you'd have an older, but still valid backup.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Futurelec also sells a DS1307 mini board with a watch battery for backup (similar to the one that Sparkfun has) for only $7.
http://www.futurlec.com/Mini_DS1307.shtml
-- Well after looking closer at the Sparkfun version, the watch battery is on the backside and it is smaller than the $7 one from Futurelec.