Shop OBEX P1 Docs P2 Docs Learn Events
Storing a Nib whilst power is off? — Parallax Forums

Storing a Nib whilst power is off?

MorrolanMorrolan Posts: 98
edited 2008-03-23 14:08 in BASIC Stamp
Hi guys,
I've found myself in a position where I need to save the value of a Nib between power-ups. I've read up on Scratch Pad RAM and that doesn't seem to be an option, and neither does the EEPROM command as it seems that it can only be written to at compile time.

So is it possible to save a variable to the Stamps EEPROM whilst the power is turned off, or do I need a second EEPROM chip?

Many Thanks in advance,
Morrolan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Flying is simple. You just throw yourself at the ground and miss.

"I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image."
Stephen Hawking

Comments

  • JonathanJonathan Posts: 1,023
    edited 2008-03-21 22:33
    You can indeed write to the EEPROM. Look up the WRITE and READ commands. Easy beans to do what you want. Make sure to look at the maximum write cycles of the EEPROM and don't exceed them. You can read as much as you want.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-21 22:36
    A good way to avoid writing too much in one location is to READ the location and compare its value to the one you want to write. If they're the same, you skip the WRITE statement.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-22 00:13
    Morrolan asked...
    So is it possible to save a variable to the Stamps EEPROM whilst the power is turned off?
    No.··If the EEPROM has no power then it's not usable.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-22 00:40
    Morrolan,
    What PJ means is that you have to have power to actually save a variable to an EEPROM, but that only takes a few milliseconds.
    Once the variable is saved, the power can be turned off and the saved value will be retained. Once the power is restored, the
    value can be read from the EEPROM and restored to the variable.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-22 00:47
    Did the guy ask if the EEPROM would retain data written to it?

    Eck.

    Post Edit -- LOL, or something like it.
  • MorrolanMorrolan Posts: 98
    edited 2008-03-23 14:08
    Thanks for the responses guys, I was obviously looking at the wrong thing!

    My wording probably wasn't perfectly accurate, but I have a small circuit driving a servo, and sometimes I want to vary the speed of the servo (using PULSOUT within a FOR - NEXT and changing the size of the STEP value). All I want to do is remember the current speed setting when the circuit is powered down, so the number of write commands to the EEPROM won't be an issue, as I doubt I'll be writing to it very often.

    Many Thanks,
    Morrolan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Flying is simple. You just throw yourself at the ground and miss.

    "I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image."
    Stephen Hawking
Sign In or Register to comment.