Storing Data

Hey everyone!

I have a project where in I have to count number of rotations the wheel makes. So i have put up an IR sensor and using Arduino UNo i am counting the rotations made by the wheel. Now after I shut down the board I want to start counting from where i have left from the previous count. Please help me with this.What should be the code for this? I am new to Arduino so I dont know many libraries and the access to it. Please help me asap.. :~ :slight_smile: :slight_smile:

There is just one good way to do that: EEPROM : http://arduino.cc/en/Reference/EEPROM

thanxs.. but can i write at a particular memory location repeatedly?

Atmel has an app. note AN101 regarding EEPROM .

but can i write at a particular memory location repeatedly?

You can. There is a limited number of write cycles available, but that number is greater than 100,000.

Why do you need to keep counting from the same value? Are you implementing some kind of hour-meter?

PaulS:

but can i write at a particular memory location repeatedly?

You can. There is a limited number of write cycles available, but that number is greater than 100,000.

Why do you need to keep counting from the same value? Are you implementing some kind of hour-meter?

Please i need to save data when shudown the board and i use eeprom but i'm worry because i use it 300 time in day i don't know you mean we use it 100,000 for one register nor 100,000 for 256 (all register) and i want to know if it safe or not ,

, if i use SD card ,Is it better than eeprom or not ?
,if SD better ,How i save data with address ?
Thanks :slight_smile:

100.000 times for each location in the EEPROM.
100.000 / 300 times a day = 333 days (less than a year).

An SD card uses a filesystem. So you create a file and you can write to that file. An SD card uses flash memory which is almost the same technology as the EEPROM. So writing the SD card too often could be a problem, perhaps not when writing data, but when updating the file system.

Can you change you sketch ?
If you can detect a power off with an interrupt, you could perhaps still be able to write the EEPROM.

Why do you need to shut it down (or reset) 300 times a day? Why it can't stay on?

One option is to have a count for write times for certain address and once the counter hits the limit, the sketch changes the address it uses to write to the EEPROM.

You will never damage an SD card with an Arduino. The card controller does wear leveling to map different physical blocks to a given logical block.

A 2 GB card has 4,000,000 blocks and each block can be rewritten about 50,000 times. The card will last for about 200 billion 512 byte block writes. This requires 100 terabytes of I/O, not likely with an Arduino.

Hi everyone,

I have a similar issue.

To write on flash memory we can use this PROGMEM - Arduino Reference
But the solution is only for to get more space for our variables, we store and retrieve data in the same running.
I need store data into the flash to retrieve the values any time the board is turned on.
Someone know how to do that?

Thanks

I need store data into the flash

Flash memory is read-only. You can't store data in flash memory at run time.

PaulS:

I need store data into the flash

Flash memory is read-only. You can't store data in flash memory at run time.

So, how firmware and programs are stored in the flash (program memory)?

I want write some bytes in the flash and run a stack machine to process this bytes. The 1 kB of EEPROM is not enough.

If the EEPROM is not enough, and you want to be able to change it, use external I2C EEPROM memory. A normal size is 8kbyte, but more is possible.

Krodal:
If the EEPROM is not enough, and you want to be able to change it, use external I2C EEPROM memory. A normal size is 8kbyte, but more is possible.

I'm looking for a cheapest possible solution. My project is to turn Arduino compatible with Gogo Board, an open source platform for educational robotics (http://br-gogo.sourceforge.net).
Now we have a hardare with PIC 18F4550 and a logo compiler generating bytecodes. The bytecodes are stored in the PIC program memory. I want to do the same.

The idea is to do this without modify firmware, to avoid create a different firmware for each arduino type.