Need to keep totals in memory for power cycle

Just want to hang out with other Makers and chat about stuff? This is the place to do it.
Post Reply
perrybones
Posts: 3
Joined: Thu Jul 25, 2013 10:59 am

Need to keep totals in memory for power cycle

Post by perrybones » Thu Jul 25, 2013 11:04 am

I just built the "water flow sensor" kit. It works fine. I need to keep the totals in non-volatile memory in case of a power cycle. I have tried inserting the Eeprom library code a few times with no success. I am a PLC programmer so I am not familiar with the C programming at all. I used the code provided on this site (water flow sensor project) to program the project. Can anyone help me modify this code to keep the flow totals from being lost on a power cycle?

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: Need to keep totals in memory for power cycle

Post by andrew » Fri Jul 26, 2013 12:53 am

It's possible however the internal EEPROM on the microcontroller has a finite life, I think Atmel state it's good for around 100k read/writes. My own experience has shown it's good for around 1230163 read/writes (http://tronixstuff.wordpress.com/2011/0 ... -lifespan/)

Will you have the flow meter running 24/7 or just now and again?

perrybones
Posts: 3
Joined: Thu Jul 25, 2013 10:59 am

Re: Need to keep totals in memory for power cycle

Post by perrybones » Fri Jul 26, 2013 7:44 pm

It does need to run until the total reaches the end (tank near empty) which could take up to 4 weeks of run time. I only need to store 2 digits max which increment very slowly as the tank is depleted. When 50 litres is dispensed, the tank is refilled and the counter reset to zero. I dont really care about the overall total, that can be deleted from the program. I only need the current value (millilitresA) to be memorized in case of a power cycle. What about the flash memory?

andrew
Freetronics Staff
Freetronics Staff
Posts: 978
Joined: Sun Jul 14, 2013 7:06 am
Location: Melbourne, Australia
Contact:

Re: Need to keep totals in memory for power cycle

Post by andrew » Sat Jul 27, 2013 7:06 am

Ah every 4 weeks sounds better for your EEPROM. You should check out a new EEPROM library I found yesterday, it will make using it a lot easier for you - http://www.freetronics.com/blogs/news/8 ... or-arduino

Flash - short answer no, long answer it can be done but is a mess to code. There's a bit of recent discussion here:
http://forum.arduino.cc/index.php?topic=149445.0

perrybones
Posts: 3
Joined: Thu Jul 25, 2013 10:59 am

Re: Need to keep totals in memory for power cycle

Post by perrybones » Sat Jul 27, 2013 12:28 pm

Thanks, I will examine the library and see if I can figure out how to insert the code into the sketch I downloaded. I am a PLC programmer which is totally different than this type of programming. The PLCs firmware already has pre-determined "address registers" that you can use for a multitude of functionality. Storing and retrieving data is a snap with ladder logic. I wanted to try one of these Arduinos, just to see if they make sense in cost prohibited situations where a PLC would be overkill, even though you can now buy them for less than a 100 bucks.
I will keep you posted on success of code.

Post Reply