Shop OBEX P1 Docs P2 Docs Learn Events
can you store varibles in spin so that they stay in there when power is cycled? — Parallax Forums

can you store varibles in spin so that they stay in there when power is cycled?

radialrandyradialrandy Posts: 78
edited 2011-08-24 18:59 in Propeller 1
Im wanting to store varibles using spin and these varibles not be erased when the power is turned off then back on.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-08-24 15:47
    Yes. You can store them in the EEPROM. If you have a ProtoBoard or other Prop board with a 64K byte EEPROM (24LC512) or bigger, you have the entire 2nd 32K (or more) to do with as you please. If you have a Prop board with only a 32K EEPROM (24LC256), that's used for the program. Whenever you download a new program to the EEPROM, that 1st 32K is cleared. Once a program is downloaded though, you can use everything past the end of your program to save information. You can use an object like Basic_I2C_Driver from the Object Exchange to do the actual reading and writing of the EEPROM. There are simple examples in the code comments there.
  • TappermanTapperman Posts: 319
    edited 2011-08-24 15:50
    Im wanting to store varibles using spin and these varibles not be erased when the power is turned off then back on.

    Try this link http://forums.parallax.com/showthread.php?97625-PE-Kit-Lab-Applications-%E2%80%93-EEPROM-Datalogging-and-I2C

    ... Tim
  • RonPRonP Posts: 384
    edited 2011-08-24 15:51
    This thread might help.

    -Ron
  • radialrandyradialrandy Posts: 78
    edited 2011-08-24 16:07
    I tried to use VarBackup to copy 2 of my varibles but it locks up my whole program. The 2 varibles are example log[500] and psi[500] so they are really 1000 varibles that i try to backup. Im guessing it must take too long to back up all those varibles. What Im trying to do is store live datalogs. So i store them in a vaible array. And then later in the program I have the instruction to varbackup. Is this a bad way to try to do this. Can I just save my varible array directly to the part of the eeprom that does not get erased?
    thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2011-08-24 16:27
    It's impossible to tell you why your program locks up without more information. At a minimum, you need to post your source program as an attachment to a message. Follow these instructions ...
    attachment.php?attachmentid=78421&d=1297987572

    Each write operation to EEPROM takes 5-10ms. It's possible to write larger blocks of information with a single operations (page writes). Do keep in mind that writing repeatedly to the same area of EEPROM will eventually wear out that section of EEPROM. We're talking about 100,000 times or more, but it's possible to exceed that in a tight loop in a few minutes.
  • radialrandyradialrandy Posts: 78
    edited 2011-08-24 17:43
    I just got the varbackup to work. I moved it to cog0. i had it in another cog and it did not work good.
    thanks guys
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2011-08-24 18:59
    Rather than use a specialized method I much prefer the standard eewrite(@variable,variable) form. This saves the contents of the variable in the same location in EEPROM which is automatically restored when the Prop boots and copies the first 32K of EEPROM into RAM. You don't need a special place in the EEPROM for backup as this space is already reserved for the variable. It really is a much neater way of doing things.

    Of course you would not want to be constantly updating the variable in EEPROM itself as they do have a limited write endurance per location/page of around 1 million <minimum> (old tech had less). The update to EEPROM should be made at the time a change to the variable is made such as when a user changes the variable or if this variable is not a configuration variable but a constantly changing reading then you might to elect to have a background function check this every so often and only back it up if there is a change between it and the EEPROM. But of course we don't really know the operating parameters of your application so it's a bit had to advise.
Sign In or Register to comment.