Shop OBEX P1 Docs P2 Docs Learn Events
saving values through power off cycles — Parallax Forums

saving values through power off cycles

grouchygrouchy Posts: 16
edited 2009-08-22 04:01 in Propeller 1
Could someome point me to a snippet of code or a thread that shows the use of the settings object.

I need to save a floating point value though power off cycles, so far it's not working for me

thanks




▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Rudy's CNC Freeware·· http://www.enter.net/~schleinkofer

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-20 16:20
    Post your code. It's probably something simple. (Use the Post Reply button and the Attachment Manager ... DO NOT cut and paste ... it loses the formatting).
  • Agent420Agent420 Posts: 439
    edited 2009-08-20 17:12
    Haven't had to address this yet, but I'm glad the question came up...

    Is there a memory space in the eeprom used for code storage that you can use to store non-volatile data, or do you need a seperate eeprom for this?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-08-20 17:33
    Agent420 said...
    Haven't had to address this yet, but I'm glad the question came up...


    Is there a memory space in the eeprom used for code storage that you can use to store non-volatile data, or do you need a seperate eeprom for this?

    In the propeller tool. If you hit F8 it will bring up a informational window with used space. Above the program and variable space is stack space. This can be used (in EEPROM or RAM) as general storage. It is best to start at the highest bytes and work your way back (to give the best chance of not interfering with the program's functionality).

    @grouchy: I am working on an object that will let you easily store values to the EEPROM based on a name...a beta version is up on the OBEX, but a much better version is in the works as I type (well, before and after I type here). This may be all you need. A simple way to do it (based on EEPROM addresses) is to grab the basic i2c driver object and use it's read/write commands.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Post Edited (Bobb Fwed) : 8/20/2009 5:51:24 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-20 17:41
    The main problem with storing non-volatile information in the same 32K EEPROM section used to hold your program is that it all goes away if you download a new version of your program. If you have a choice, it's much better to use a 64K EEPROM and store your data above the 1st 32K where it won't be touched by the bootloader (that does the actual writing of the program from RAM to EEPROM).
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-08-20 19:30
    I have just released a new version of my Memory Storage Management system (mentioned above). It is much faster than previous versions of the program, and should be completely compatible with versions to come. It can be used with both 32KB (by default is setup for 32KB) EEPROMs and easily used with 64KB EEPROMs as well.

    Read more here: obex.parallax.com/objects/493/

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
  • Jim FouchJim Fouch Posts: 395
    edited 2009-08-20 19:39
    Another option is to use a DS1302 or DS1307 RTC and use the extra battery backed up RAM for values you want to store from power cycle to power cycle. I've done this to some projects and it works for small amounts of data. I used it on my bike display project to store the odometer & trip odometer readings. Also, you can write to them as many times as you like w/o wearing them out like an EEPROM. And you get a clock as an extra feature..... lol

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jim Fouch

    FOUCH SOFTWARE
  • Agent420Agent420 Posts: 439
    edited 2009-08-20 19:39
    Thanks!

    Not every project requires eeprom storage, but many do - configuration info, data logging etc.· I'm still warming up to the Prop, and occasionally I have to figure out ways to accomplish things like this that I've taken for granted for so long with uc's like the avr.

    Am I correct that a cog needs to be dedicated to the I2C communication?

    edit -

    @ Jim Fouch : That's a good suggestion.· I knew those chips had some free user ram, but never had to use it because I had easy access to eeprom.· Of course, eeprom has finite write limitations as you point out, so any non-volatile data that is frequently updated may be better housed in something like that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (Agent420) : 8/20/2009 7:46:34 PM GMT
  • SamMishalSamMishal Posts: 468
    edited 2009-08-21 03:36
    Hi All,

    I have a question about this topic.

    On·the PPDB development board there is a 32K EEProm chip (24LC256)that can be easily replaced.

    My question is can I just remove it and put a 64K one instead (24LC512)???


    Sam
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-21 04:38
    Agent420,
    You don't need to dedicate a cog to I2C. Basic_I2C_Driver is written in Spin and works fine just called from your program. It doesn't start another cog.

    There are I2C assembly routines that use a separate cog for speed like sdspiFemto.spin which is used by FemtoBasic.

    SamMishal,
    Yes, you could directly substitute a 24LC512 or Atmel 24C512 for a 24LC256. You can even substitute an Atmel 24C1024B for a 24LC256 and get 128K of EEPROM.
  • SamMishalSamMishal Posts: 468
    edited 2009-08-22 03:38
    Thanks Mike,

    Now the next question is this:

    If you have a larger EEPROM than 32K and you have data in the
    memory below 32K...does it get erased if you reprogram the propeller?

    Does the Propeller tool erase the entire EEPROM or does it just overwrite
    the top 32K and leaves any extra memory alone?

    Cheers!

    Sam
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2009-08-22 03:44
    He mentioned earlier it is not touched by the bootloader.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!
  • SamMishalSamMishal Posts: 468
    edited 2009-08-22 04:01
    Bobb Fwed said...
    He mentioned earlier it is not touched by the bootloader.

    Oh...my bad...I reread the posting and I see that Mike has already answered my question...sorry.blush.gif··
    Now I can see that the solution is to just replace the 32K for something bigger and use that
    over pins 29 and 28 with an I2C driver and there would be no need to add any other chips.
    ·
    Of course you have to be careful to only write to memory below 32K and you won't have
    to worry about finding out the size of your program etc.
    ·
    However on some dev boards you do not have the option to change the EEPROM since it is
    soldered in. In these cases you need to either add another chip or just use the remaining
    memory below your program.
    ·
    This is another example why a separate replaceable EEPROM is actually a good idea....more versatility.
    ·
    Sam
    ·
Sign In or Register to comment.