saving variables when stamp is not powered
Hello,
I am writing to see if there is a way to save a variable while a basic stamp is turned off? Meaning I want the stamp to run through a routine where a specific number is reduced with each program cycle. If the stamp power is turned off it will store the reduced number and continue where it left of when power is returned. Does this make any since to anyone????? Here is an example of the code I'm using.....
' {$STAMP BS2}
' {$PBASIC 2.5}
scroll_time VAR WORD
scroll_time = 20000
main:
HIGH 14
PAUSE scroll_time
LOW 14
scroll_time = scroll_time - 13
PAUSE 1000
GOTO main
I want the stamp to store whatever variable it arrives at when the stamp is turned off. For example if the program cycles through say 50 times the scroll_time variable will be 19350. I would like to know if there is a way to store 19350 as the new scroll_time value while the stamp is turned off. So that when the stamp is powered up and the program begins again scroll_time = 19350. I'm sure there is a simple way to do this I just have not found it yet.
thank you,
david bowen
I am writing to see if there is a way to save a variable while a basic stamp is turned off? Meaning I want the stamp to run through a routine where a specific number is reduced with each program cycle. If the stamp power is turned off it will store the reduced number and continue where it left of when power is returned. Does this make any since to anyone????? Here is an example of the code I'm using.....
' {$STAMP BS2}
' {$PBASIC 2.5}
scroll_time VAR WORD
scroll_time = 20000
main:
HIGH 14
PAUSE scroll_time
LOW 14
scroll_time = scroll_time - 13
PAUSE 1000
GOTO main
I want the stamp to store whatever variable it arrives at when the stamp is turned off. For example if the program cycles through say 50 times the scroll_time variable will be 19350. I would like to know if there is a way to store 19350 as the new scroll_time value while the stamp is turned off. So that when the stamp is powered up and the program begins again scroll_time = 19350. I'm sure there is a simple way to do this I just have not found it yet.
thank you,
david bowen
Comments
The only non-volatile memory on the BASIC Stamp is the EEPROM, however, if you keep updating a location within a loop like that you will eventually wear it out. If you had some battery-backed external RAM (Such as that commonly found on RTC chips) then you could save it to that every iteration of the loop. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
So I assume using the basic stamp's EEPROM involves using the READ and WRIGHT commands. Because I found I way to do what I needed to with those commands by writing, reading and rewriting the variable on two of the controllers pins. Chris, will doing this shorten the life of the controller or just the two pins? If so how many cycles do you think I can get before the thing quits working? The reason I ask is because the program sample I sent earlier was just a snippet of a much larger routine. This routine could cycle through every minute or it could cycle through in an hour or more. It is dependent on the movements of houseflies combined with the movements of people as they walk throughout a space and therefore extremely random. I'm in a time crunch (the exhibition goes up next week) and there are still many logistics to work out aside from this. I fear I do not have time to order and learn how to incorporate a battery/memory backup like you guys suggest. If the controller will not stand up the writing and rewriting on the pins I will probably just make sure it stays on all of the time.
Thanks again,
david
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ol' Geo
Retired Software Engineer
An oscilloscope is a window of unseen electronic world. - GM