how to get more variable space?
Hi fellow stampers:
I was recently programming my BS2pe and I got the error 126.. out of variable space. From what I read you only get 32 bytes of variable space. There is also program space which which must be a few K at least. Is there some way to reduce program space to get more variable space?
thanks, John
I was recently programming my BS2pe and I got the error 126.. out of variable space. From what I read you only get 32 bytes of variable space. There is also program space which which must be a few K at least. Is there some way to reduce program space to get more variable space?
thanks, John
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
You should peruse the post I started asking a similar question with the BS2. I got several very good suggestions for trimming program space and variable definition length. It is located in this forum.
http://forums.parallax.com/showthread.php?p=574717
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
John
READ temperature VAR1 ' read the 'external variable' in to a temp variable (that is reused often)
RESULT = VAR1 * CALIBRATION + OFFSET
WRITE VAR1 temperature ' store the result.. for use later or elsewhere
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
How much of a problem is burning out locations in EEPROM?
What actions can cause that?
What things should you do to prevent that?
Post Edited (RealLax) : 5/1/2006 7:41:44 PM GMT
How do you burn out locations? By programming the Stamp too many times (hard to do) or by using the WRITE instruction in a part of a program that's executed too often (easy mistake to make). Let's say you have a program that reads a digital thermometer, compares the temperature to a value stored in EEPROM, and tries to keep a maximum and minimum and writes all three values to a serial LCD. There's a PAUSE so that this process occurs once a second. Sounds like a practical application! If you update (WRITE) the maximum and minimum values every second, even if they haven't changed, you will burn out the EEPROM locations in 100,000 seconds or so, only 60 days. You need a piece of the program that compares the current minimum and maximum to the EEPROM value and only writes a new value if it has changed like ... (called with GOSUB UPDATE)
UPDATE:
READ 0, VALUE
IF MINV = VALUE THEN SKIP1
WRITE 0,MINV
SKIP1:
READ 2,VALUE
IF MAXV = VALUE THEN SKIP2
WRITE 2,MAXV
SKIP2:
RETURN
There are a few ways you can help mitigate the issue, the easiest is writing programs which reduce the frequency of writing to the eeprom, if you can update a variable in RAM more than once before writing out to EEPROM this will extend the life of the EEPROM. The second·is using an external EEPROM, which you can replace when it goes bad. The third is using more than one location to store a variable, this is the most complex method. Instead of writing to the same location over and over, you use multiple locations. There are many different ways to do this. The easiest approach is if you dont need to remember the last value before a·power cycle (ie·true RAM).
Say you need·4 bytes for·variables and only have room in·RAM for 3. Split two of the·bytes availible into four nibbles, each nibble is an index value into the EEPROM and each nibble can address 16 locations. When you need one of the 4 variables, fetch the value at the base address for that variable in EEPROM + the nibble index value into the 3rd byte availible. Modify the variable as needed, increment the index value, and write the modified value to the base address + incremented index. This method will use 16 values in EEPROM for 1 value, and reduces the number of times a specific location is written to by 1/16th. To reduce the likelyhood of wearing out the first few locations first, start out by randomizing the index nibble so the order isn't 0,1,2,3... everytime you start up the stamp.
If you need to pickup where you left off between bootups (non-volatile storage), the methods can become more complex and which method is best depends on actual methods of use and how often a reboot occurs.
You can combine these methods in any combination to get a multiplication effect on the life of the EERPOM. If you go with an external EEPROM, consider getting an FRAM from RAMTRON. They behave just like an EEPROM, but effectively dont wear out because its a different technology used. They are more expensive that equivalent sized EEPROMs but it may be worth the value for your peace of mind.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1+1=10