Shop OBEX P1 Docs P2 Docs Learn Events
Sequential write to EEPROM on the stamp — Parallax Forums

Sequential write to EEPROM on the stamp

ionion Posts: 101
edited 2005-06-19 17:00 in BASIC Stamp
·
Hi ,
I have a problem for which I can not find a solution and I am looking for some help ( code will be highly appreciated)
·
I have a push button and I want to write a value of a word (from an A/D converter) ·in a defined ·memory location each time the button is pressed ( do not jump yet).
At next power up I would like to be able to read the stored data until I press the button again and overwrite the old value with a new one (still just do not jump yet because this is done with a write command).
The EEPROM on the new BS2PX is rated at 1 million write cycles. My counter will go beyond that point, to 10 million counts the max. ( due to the length of other code involved I can not use a BS2 rated at 10 millions write cycles).
The solution that I look for is to write to ·a memory address the A/D word value, and on the other location to write a tracking number (will be two words because I would like to count to 900000,· Whigh=90 ,Wlow=0000) , so I know how many time I used that memory. At 900 thousands I would like to move the storage location of the A/D to the next memory address, and in the same time I would like to move the tracking location too to an other location. In this way, I can write with no problem a value more then 1 million times to the stamp.
Any help or guidance will ?
·
Thank you
Ion
·

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-19 01:07
    ion,

    ·· How often will you be sampling data that you will use up all the write cycles (lifetime) of the EEPROM, and how long do you expect that to take?· Just curious...It would seem you would have to be sampling the data pretty darn quickly, and then what would be done with it?· You better have a pretty fast button-pusing finger too, since you say this will happen·when you·push·a button.· Are you sure you don't mean that you need 10 million memory locations?· That's extremely high, and probably unliekly, but I had to ask.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ionion Posts: 101
    edited 2005-06-19 01:19
    Hi Chris,
    I sample the data every 10 seconds on a 24 hours 7 days a week frequency
    This will give me 5000 samples in a 24 hours interval. The product should last for 5 years in a 24/7/365 configuration.
    I do not need 10 million locations. I need to write to the same one 1 million times , then move to the next one. 10 in total ( actually 20 because it is a word)
    For tracking I need 20 for high word and 20 for low word. With a PX it can be done in one bank with 60 location in total. The trick which I can not solve is how to track and change from one location to the next one when my write cycle ( from tracking words ) read 1 million.
    Ion
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-06-19 02:06
    ion,

    ·· Okay, I understand...Now, two things...One, unless you absolutely must have non-volatile storage of the last data, you could use RAM.· In fact, you could use a Serial RAM chip with Battery Backup and have virtually unlimited write cycles.

    ·· Or you could use an external EEPROM and simply replace it when you wear it out.· Given that you're using the same location(s), I would opt for the Battery Backed RAM.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • ionion Posts: 101
    edited 2005-06-19 02:18
    Thanks Chris, but i would like to use the EEPROM on the stamp. The PCB was designed for a stamp with no provision for external memory chip and i am stuck with that. I have to find a solution to overpass the pcb limitations. I am in the process to experiment with that but i got lost few times and i need to get it done yesterday. Any software help or EXAMPLE will be an end to my sleepless problem. Monday, i have to order 50 PX and i can not do it if i do not get a solution how to use them.
    Thanks
    Ion
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-19 05:24
    Seems like you could solve the "problem" by dedicating 21 bytes of EEPROM: one (at location 0) for the pointer, and ten pairs (20 bytes) for the data.· By rotating the sample between 10 cells you get your 10 million write cycles.· Here's an idea for a subroutine that will save your sample and the pointer so that everything can be restored after a power-up:

    EePntr···· DATA··· 0
    Samples··· DATA··· Word 0 (10)

    Put_Sample:
    · READ·EePntr, idx
    · WRITE Samples· + (idx * 2), Word adcSample
    · idx = idx + 1 // 10
    · WRITE EePntr,·idx
    · RETURN

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ionion Posts: 101
    edited 2005-06-19 05:38
    Thanks Jon.
    I will try it write now
    Ion
  • ionion Posts: 101
    edited 2005-06-19 05:43
    Sorry for "write" now as right now i am to stressed to find my answer.
    I have a question about the sample:
    The pointer is writen every time , so it will not wearout after 1 million writes. How i can switch the location of the pointer after one million write cycle?
    Thanks
    ion
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-19 05:55
    You're right -- just save that one in RAM. It will reset to 0 on every power up, but I don't expect that will pose any real problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ionion Posts: 101
    edited 2005-06-19 05:58
    Thank you Jon for help and guidance
    Ion
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-06-19 16:08
    The following would

    How about something like this,

    ' rotating pointer gives 65535 writes per location, total 24 million with 256 pointer values before repeat
    ' to write ...
    STORE 7
    READ 2047, pointer ' pointer is 0 to 255
    WRITE pointer*4, Word ADCresult
    READ pointer*4 + 2, Word tracking
    WRITE pointer*4 +2, Word tracking+1
    IF tracking=0 THEN ' this location has been used 65536 times
    WRITE 2047, pointer+1 ' move to next location
    WRITE pointer*4, Word ADCresult ' save ADC result in new loc
    WRITE pointer*4+2, Word 1 ' start tracking at number 1
    ENDIF

    That changes the pointer location only 256 times to get 24million total writes, but uses 1k bytes of eeprom in slot 7. It is not hard to make the tracking counter 3 bytes to save memory, if that is tight. I would not try to push it close to the 1 million figure. That is a statistical measure.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • ionion Posts: 101
    edited 2005-06-19 17:00
    Thanks Tracy,
    It is a new interesting way , and i will try it now.
    Thank you again to all of you guys for help
    Ion
Sign In or Register to comment.