Shop OBEX P1 Docs P2 Docs Learn Events
Save Variables on Power loss — Parallax Forums

Save Variables on Power loss

wildponywildpony Posts: 7
edited 2011-07-23 16:40 in Propeller 1
Finally pulled my PPDB out again the last couple weeks.
I'm working on a project where the user would be able to change a couple parameters.
But I want those changes to stay in effect if loss of power happens

Is there a way to save a couple variables that would retain the information after a power loss?

Is there maybe a way to write data to the DAT section so the new value will stay in the EEPROM memory?

(I know in the PLC world, I just set them as Persistent Variables and they stay at the last value when powered back up)

Only need to Bytes worth.

-David

Comments

  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2011-07-22 09:16
    I've been using an over sized EEPROM. The area above what the Prop needs is free space. Adds no components and works great.
    What hardware are you using?
    Jim-
  • wildponywildpony Posts: 7
    edited 2011-07-22 09:22
    I'm using the Propeller Professional Development Board, it has the 32K EEPROM.
  • CannibalRoboticsCannibalRobotics Posts: 535
    edited 2011-07-22 09:56
    Your in luck! It has a socketed EEPROM. I've been using the AT24C512 EEPROM. I will say though, The DIP package is getting harder and harder to come by. DiGikey is out but I have not checked anyone else lately.
  • wildponywildpony Posts: 7
    edited 2011-07-22 10:03
    My real question is about the code to do this though.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-07-22 10:04
    Use F8 to check your memory map -- you probably have plenty of space in he default EEPROM. When I'm using 32K I tend to use the EE addresses $7F00 - $7FFF for non-volatile data. There are several I2C objects in ObEx; you can use any one of them to write/read EE.
  • wildponywildpony Posts: 7
    edited 2011-07-22 16:09
    duh to me. I scoured all over the forum, but didn't look in the ObEx. I do see them. Now I'll just have to go through and see what parts I need. I only need to store 2 Byte sized variables and only on occasion.
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2011-07-22 16:16
    Simplest (IMO) is just the Basic I2C Driver. Just use the write and read functions.
    But my Memory Storage Management Lightweight can be used too (though it's a bit overkill for 2 bytes)..
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-07-22 19:16
    Attached is a little demo that may be interesting, and may not be without peril.... I'm storing a string as an array of bytes in a DAT section and after it's changed I write it to the same location in the EE as it lives in the DAT. Note that I think this will only work for the main object; the @ parameter may not give the correct address inside a child object. The cool thing about his strategy is that you only have to write the new value, the last save is loaded automatically any time the Propeller reboots.
  • yetiyeti Posts: 819
    edited 2011-07-23 05:24
    http://www.ramtron.com/files/datasheets/FM31xx_ds.pdf could be a nice solution: power monitor + watchdog + rtc + fram.

    Whosoever has tested this chip, please drop some comments.
  • SapiehaSapieha Posts: 2,964
    edited 2011-07-23 06:02
    Hi yeti.

    Look on this post.

    FM31L278-RTC/Mem and FlexMem board's.

    I run that IC's without any problem - Ues them as BOOT device instead for EEProm's as I reprogram them very often


    yeti wrote: »
    http://www.ramtron.com/files/datasheets/FM31xx_ds.pdf could be a nice solution: power monitor + watchdog + rtc + fram.

    Whosoever has tested this chip, please drop some comments.
  • AleAle Posts: 2,363
    edited 2011-07-23 07:54
    You only have to save to EE when the user makes a change and checksum it. That way you know when the last values are correct (to differentiate for instance from first run).
  • wildponywildpony Posts: 7
    edited 2011-07-23 08:37
    JonnyMac wrote: »
    Attached is a little demo that may be interesting, and may not be without peril.... I'm storing a string as an array of bytes in a DAT section and after it's changed I write it to the same location in the EE as it lives in the DAT. Note that I think this will only work for the main object; the @ parameter may not give the correct address inside a child object. The cool thing about his strategy is that you only have to write the new value, the last save is loaded automatically any time the Propeller reboots.
    I did get it working last night using the Basic_I2C_Driver. But I think I'm still going to check out this way when I get a chance. Thanks!

    I just needed it to be saved on the basic EEPROM. This is more of a set and forget type setting. Not one that will be changed often.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2011-07-23 09:34
    set and forget type setting

    That's why I used the DAT strategy: you only have to set the new value (into EE, that is); on the next boot-up the DAT section will contain the last saved value.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-07-23 15:19
    @Sapieha,

    I looked up the micronaut website. But I could not find the FRAM / RTC board

    Do I have tomatoes on my eyes or is it really not available?

    best regards
    Stefan
  • SapiehaSapieha Posts: 2,964
    edited 2011-07-23 16:40
    Hi StefanL38.

    He still have not edited theirs Site to even have all NEW PCB's.
    BUT PM him and ask if he have them to sale. As at start it was my PCB not one planed for sale - Not much people shown interest.



    StefanL38 wrote: »
    @Sapieha,

    I looked up the micronaut website. But I could not find the FRAM / RTC board

    Do I have tomatoes on my eyes or is it really not available?

    best regards
    Stefan
Sign In or Register to comment.