EEPROM, I think

I have a counting code. The number is store as "count." Count can be up to 9999.
When I turn power off the "count" value is lost. 1. To keep the value of count over power loss, do i have to store in the EEPROM or is there another method. 2. Do you have a link or maybe even better some example code that might work?

Just out of curiosity, what are you counting that matters if the power is lost?

EEPROM is the only place to store data that persists through a power outage.

Tracking how many times a customer presses a button.

would it simply be something like:

EEPROM.write(addr, COUNT);
and then to recall
COUNT = EEPROM.read;

Also, I saw somewhere the EEPROM can only take 100,000 writings. I am using a ProMini, is that leveltrue for all of the arduinos? Is there another way to store it over 100,000. For example can I add a memory to the circuit. May be stupid question, but new.

Also, I saw somewhere the EEPROM can only take 100,000 writings.

100,000 writes are guaranteed. It is entirely possible that a given processor will work reliably past that amount.

I am using a ProMini, is that leveltrue for all of the arduinos?

Yes.

Is there another way to store it over 100,000.

You can store the number in different cells each time. The technique is called "wear leveling".

For example can I add a memory to the circuit. May be stupid question, but new.

Yes. There are external EEPROMs (and other memory varieties like FRAMs and SD cards) that can be interfaced with an Arduino.

doe anyone have a link to any info on wear leveling? I am new and am not sure how to do this.

I did find some external chips like the AT24C64C that is supposed to be rated for 1,000,000 writes.

in addition I found several SD shields that use the memory cards from cameras. Arduino Playground - SDMMC

I need this to last for at least 1,000,000+ writes. What would you recommend?

Atmel has it in their application notes

Udo

I need this to last for at least 1,000,000+ writes. What would you recommend?

Tracking how many times a customer presses a button.

100000 / 365 / 24 = 11

Your customer will have to press the button at least 11 times an hour 24 hours a day for a year to reach 100,000 writes. Are you sure 100,000 writes is not enough?

doe anyone have a link to any info on wear leveling?

I have a library that takes care of the details but it's not far enough along to publish.

In addition to Atmel's application note, I believe Microchip has one as well.

I read somewhere about someone testing the internal eeprom to destruction, it actually ran to 3+ million writes before it began giving errors.

coding, our current system averages 1000+ pushes per day. This is a system I hope to have in place for several years. So at 1000+ pushes a day that is about 1/3 year so significantly short.

I was thinking about trying to adding a smaller backup battery to but a few minutes. Then if the voltage drops on the main battery have it write to the EEPROM. Does this sound do able?

I will have to search on the EEPROM but glad to hear it can probably take more the than the 100,000.

Instead of switching the board off, you could investigate the low power modes.

RAM is maintained, but supply current is drastically reduced.

any starting point or just search low power arduino modes?

Have a look at the datasheet. It contains everything you need. My current experiments show that it is feasible to get the power consumption of the CPU well below 10uA. This implies that you can buffer it with a 1000uF Cap for more than 100 seconds. If you use a 1F buffer cap you can buffer for more than 1 day. of course assuming that you do not waste any power with your peripherals.

Google will find some examples of people doing this. Even with Arduino like setups. However the datasheet is the best resource around. I post my findings here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1273507808.

Udo

Do you think backup power or to add one of those mini memory cards? I have never interacted with a SMD card before but it looks like most of the serial communication I have already seen.

What exactly is your system about? Unless the context is known it is very hard to give reasonable advice. How critical is an outage?

Udo

power outage isnt the issue. Loosing the count is the issue.

This is a system to track how much a customer uses. Not everyone is as honest as they should be. We built a system around an LED display but have swapped to LCD now for power and ease of reading. During our first testing we found some of the not-most-honest people would actually remove the battery to reset the count back to zero and then use some more. So instead of displaying the 150 they used, they showed 100.

through personal messages with a few and what I am getting from you on this thread, I think I have decided to go with a hybrid. Monitor the battery and if it disconnects write to the EEPROM.

Also, can I send decimal to the EEPROM or only binary or hex?

Better yet, say I want to send 9768, do I have to break it down into 4 sets of numbers and store the 9, store the 7...8 and then when recalling reconstruct it?

... on a side note got to love todays technology. sitting in a graduation and still able to surf.

Further down the following posting you will see how any integer value can be saved and read back using two byte writes and reads from the eeprom:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1273948295/6#6

Lefty

How come that the customers can remove the battery? If the customers can manipulate your device, how do you assume that they will not tamper with the switch? Or with your processor?

I still do not understand what kind of device this is. Unless the context is clear any security measure will fail. You might want to have a look into Anderson's book on security engineering. The first edition is free for download here Security Engineering - A Guide to Building Dependable Distributed Systems. This edition will probably suffice to give you an idea.

Besides that I would like to understand this application to satisfy my curiosity. If you do not want to discuss this in public due to your security constraints I suggest to switch to personal mail.

Udo

OKay, got my SPI EEPROMs on order this morning. Now the fun part. I have tried finding something to explain EEPROM to me but not much luck. I know it stores information. I know it can only take 2 bytes at once so my 4 digit number will need to broken down into two pieces. Got that.

I see where I write to various addresses.
How do I know which addresses to read back?

So say one time I write to address 1-2, next time 3-4...512. once They have all been written to data is in each address. So how do I tell the arduino where to read? That kinda makes sense in my head but if I am asking it poorly let me know. If no direct answer do you have any links I might have missed to better illustrate this?