Shop OBEX P1 Docs P2 Docs Learn Events
Variable Persistence after power failure — Parallax Forums

Variable Persistence after power failure

xanatosxanatos Posts: 1,120
edited 2009-06-24 18:22 in BASIC Stamp
The EEPROM DATA in the BS2SX is nonvolatile, correct?· If I store data there, it will still be there following a power failure, I'm guessing, since the program stays.· I just want to be sure I can write data TO EEPROM on the fly, and if power fails, the data collected by my program will still be available once power returns.

In a related question - does anyone know if the PINK Server's variables 00 to 19 can be written NONVOLATILE (ie., to flash) from the web interface?· I can set a default value from the PINK Setup utility, but can the nonvolatile flash contents be written from my own web page, or only the RAM?

Thanks again!!!

Dave

·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-23 20:58
    Read the Parallax Stamp Basic Syntax and Reference Manual chapters on the READ / WRITE and DATA statements. They have all sorts of examples of the storage of data in the Stamp's EEPROM.

    Read the PINK Manual. It clearly shows how to read and write the variables from the Stamp and from the web pages. The values of the first 20 variables are stored in flash as the Manual states, regardless of whether they're written from the Stamp or a web page.

    Post Edited (Mike Green) : 6/23/2009 9:03:50 PM GMT
  • xanatosxanatos Posts: 1,120
    edited 2009-06-23 21:53
    Thanks. I'm getting bleary eyed reading so many manuals, and on serious overload forgetting what I read where. Thanks for the reminder.

    Dvae
  • xanatosxanatos Posts: 1,120
    edited 2009-06-24 00:03
    I re-checked the PINK manual and it appears that the flash variables can NOT be written to from a created web page, only from the special screen VV_Show.htm:

    From the manual:

    ...The first 20 general purpose variables (0 through 19) can be written to flash memory
    as power-on defaults. The remaining general purpose variables (20 through 99) are RAM variables only and the
    data is lost when power is cycled...

    ...All variables can be accessed and modified through the Modify Variables web interface by browsing to
    XXX.XXX.XXX.XXX/VV_Show.htm ... Only
    from this page can you set the default values for those variables which can be set to default (written to flash)
    by clicking the link to the right of the variable (Set Default Value).

    Reviewing the source code on the VV_Show.htm page shows the link to the page to change a default flash variable: VV_Default.htm?08 (where 08 is the variable number to be edited)

    Reviewing the source code on that page shows a form action of DEFAULTSET.HTM which must be accessed to set the flash default for any given variable. This page is set to get data only via a form post. I tried a get-style URL request using the input names in the form ( DEFAULTSET.HTM?variable_name=08&NewVal=TESTING ) as well as attempting to access the page DEFAULTSET.HTM directly, and both attempts show "Page not found", despite the fact that accessing the default variable setting routine from the page it is supposed to be set from does indeed work.

    So I believe that the actual answer is that you cannot, in fact, write a web page of your own that sets the default value of one of the first 20 variables, but can only set the RAM value for those variables, meaning data in those variables returns to default on power cycling.

    Am I wrong in this?

    Dave
  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-24 04:13
    Page 7 of the PINK Manual shows how to use a FORM tag to change a PINK variable using an HTML POST method. The example shown changes variable 01 which is a flash stored variable.
  • xanatosxanatos Posts: 1,120
    edited 2009-06-24 04:57
    Hi Mike,

    I'm sorry if I seem thick, but the manual is at odds with the documentation embedded on the PINK server itself. The server page VV_Show.htm clearly states that the only way to alter the FLASH content for variables 0 through 19 is from THAT page, but that the RAM values of those same variables may be edited from a constructed HTML page. I'm already quite successfully altering the RAM values of 44 of the RAM values of the variables on the PINK, but they do not persist when power cycles. I can hard-set the flash/default value with the VV_Show.htm page that is resident on the PINK server, and when power cycles, whatever RAM value was in there gets replaced by the flash-programmed value. What I seem unable to actually do is to make a persistent change in teh FLASH value with a constructed HTML page, despite my being able to edit the RAM value of that variable with ease.

    Am I not stating my situation properly? I am looking at page 7 of the manual right now, and all I can see is the information used to change the RAM values in NB01 and NB02 - but this code does not alter the FLASH/Default/Power-on value of NB01 or NB02. This is the type of code I am already using extensively. But there seems to be something entirely different to changing the power-on default value of the Flash variable. That's probably why the VV_Show.htm page has two separate links for setting values - one for RAM, teh other for Flash. I need to know how they set flash...

    I'm hoping I've worded this well enough, I really need this function!

    Thanks very much,

    Dave

    PS., Here's the code I have used to VERIFY that while I can easily set the value of NB_var02 using this code, it does nothing to alter the flash value when power is cycled:


    <HTML><HEAD><TITLE>Flash Write Test</TITLE></HEAD>
    <BODY><FORM ACTION="FlashWrite.htm" METHOD="POST">
    <P><B>02:</B> <Nb_var02></P>

    <INPUT NAME="Nb_var02" MAXLENGTH=64>

    <INPUT TYPE="submit" VALUE="Accept">
    </FORM></BODY></HTML>



    If you run this code on the PINK Server, you will see the variable does get set properly. Power the PINK Server down, wait 5 seconds or so, and power it back up, and the setting is gone, and it's back top whatever you had set in the DEFAULT flash variable. It's very frustrating, there MUST be a way to write to nonvolatile memory from a web page OTHER than teh embedded VV_Show.htm page..............
  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-24 05:26
    I went back and carefully re-read the PINK manual. There's indeed a separate link for storing variables 00-19 in flash once their value has been set. I can't tell from the manual what that might be. If I had a PINK, I'd try looking at the source of the VV_Show.htm page to see what the link was that sets the default values. You might try that or call Parallax Tech Support tomorrow to see if they can give you that text.
  • xanatosxanatos Posts: 1,120
    edited 2009-06-24 05:32
    Hi Mike,

    I think the Parallax call will be in order. I have already followed up on the code in the VV_Show.htm page. Here's an excerpt from one of my earlier posts in this thread:

    Reviewing the source code on the VV_Show.htm page shows the link to the page to change a default flash variable: VV_Default.htm?08 (where 08 is the variable number to be edited)

    Reviewing the source code on that page shows a form action of DEFAULTSET.HTM which must be accessed to set the flash default for any given variable. This page is set to get data only via a form post. I tried a get-style URL request using the input names in the form ( DEFAULTSET.HTM?variable_name=08&NewVal=TESTING ) as well as attempting to access the page DEFAULTSET.HTM directly, and both attempts show "Page not found", despite the fact that accessing the default variable setting routine from the page it is supposed to be set from does indeed work.


    So... unless someone else jumps in... A call to Parallax it is.
  • skylightskylight Posts: 1,915
    edited 2009-06-24 11:49
    I had tried to do the same some time back and was told its not possible, unless the new firmware which i havnt got allows it?
  • xanatosxanatos Posts: 1,120
    edited 2009-06-24 16:31
    Hi all,

    Thanks for the input. That listing of links is great, lots of good info in there! Unfortunately, I am thinking at this point and given the time constraints I am under that attempting to store persistent data on the flash via writes from the BS2sx is just not going to happen. The PINK seems to tie that function STRICTLY to the embedded factory-default setup pages - it seems that the PINK knows if a variable set command is not coming from those pages, even using teh form actions and variable names from the flash-set page itself.... When and if I pick this idea up again, if I find anything useful, I will post it here. Apparently there have been a few people who would have liked to write on-the-fly to the flash for those variables. For me, it would have been a great way to maintain data in the event of a power failure. Other options still exist, however.

    Thanks again all,

    Dave X
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-06-24 16:48
    Dave,

    Backing up to your original question about writing to the EEPROM on the fly on the BS2sx, you should be aware that if you’re updating variables in real-time your EEPROM won’t last very long. Could be hours/days/weeks depending on how often data is written to it. On the other hand if you store this data into a BBRTC w/RAM you can keep refreshing the data as often as you like. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • xanatosxanatos Posts: 1,120
    edited 2009-06-24 17:05
    Hi Chris,

    I did see that the BS2SX only has a 100K write lifespan, but the average write frequency will be more likely along the lines of 1x per hour, and that gives me an 11+ year chip lifespan. These guys will be controlling the status of a drive-in bay rental, most rentals will be in the neighborhood of 6 to 12 hours, and probably no more than 12 to 25 bays for a controller (if I use the the 2p40). Thanks for the heads up though! It's odd that the regular BS2 does 10M writes, but the 2sx only does 100K. Must be smaller individual memory cells...??? smile.gif

    Best,

    Dave
  • xanatosxanatos Posts: 1,120
    edited 2009-06-24 17:17
    Hi again Chris - the BBRTC - I'm guessing that's "Battery Backup Real Time Clock"? Hmmm... I am using the DS1302. Is that what you're referring to? I hadn't thought about that... that might be quite useful, thanks!

    Dave
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-06-24 17:32
    Dave,

    Yes, the DS1302 is a perfect example and I have used it in designs where I did not need the time or date but did need reliable battery backed variables. I have listed example routines for randomly writing variables to the DS1302 RAM in the DS1302 Demo Code in the Completed Projects Forum. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • xanatosxanatos Posts: 1,120
    edited 2009-06-24 17:49
    I'm looking over some code for the 1302 now. I am using two of these - one in a local controller unit, the other in a remote unit. I need timekeeping functions at both locations - but I don't see any reason why I can't do both timekeeping and data storage with these items... this might be the way for me to go here. Thanks again!

    Dave
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-06-24 18:20
    Yeah, you can do both at the same time no problem…in cases where I didn’t necessarily need date/time I would sometimes use the clock as a counter. It’s cheap enough to use and as you said you already have two so you should be set. Also, the DS1302 RAM stores more than the BASIC Stamp has for variable space, so you can also store other settings/flags in the additional memory. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2009-06-24 18:22
    You could also add an external EEProm like the I2C 24LC128 (16k) or 24LC256(32k). they are easy to use.
Sign In or Register to comment.