More RAM?
larryp1
Posts: 8
I am creating a sensor package for a weather balloon and while attempting to add a Thumbdrive to log the data to I am getting the error that I am out of space for variables, If I buy an EPROM,can I make the problem go away? How do I instruct the chip there is more memory?
Comments
There are only 26 bytes of variable space on the Stamps. There's no way to increase this. The way this is usually handled is to identify which variables are used in which portions of the program. Commonly many variables are used in only a limited portion of a program and can be reused for some other purpose in other portions of the program. You can assign several different names to the same portion of variable storage. You can assign those names to different portions of the same variable storage, like two bytes can be allocated to the same storage as a single word or two 4-bit nibbles can use different halves of the same byte. Look at the section of the Stamp Manual that discusses aliases.
The thumbdrive software tends to use a lot of variable space, particularly for receiving status messages. Often that variable area can be used for other temporary functions in-between read/write operations.
These are called aliases in PBasic. They're a little like constant pointers where the only thing you can do is define another name for a specific address (variable). Strictly speaking, you could treat all of variable space as a byte array or word array (or even bit array) and the subscript you'd use would effectively act as an address (pointer).
Numerous times in the past I have worked with individuals to help optimize code and variable use to make things more efficient. Many time a program that was too big or used too many variables would later fit just nicely on the BASIC Stamp. As Mike said, you must often reuse your variables and one thing you can do with the Datalogger is use the non-verbose (reduced?) mode to reduce the receive buffer size required. Not long ago I wrote a GPS Datalogger using the same device and was able to create a KML file on the drive which could be directly used with Google Earth. Things can get tight, but quite often are achievable. A quick look at your code might offer some insight.
I don't think another Stamp model would "solve" the problem. There's the same amount of variable space. The ScratchPad RAM area is not usable as variable storage although it could be used for receiving some of the responses from the Memory Stick Datalogger ... not a bad thing. It would still take some work to modify the program to make use of it and I think larryp1 was hoping for a fix that would not require a significant amount of work other than a simple hardware change.
buffer(1) VAR wadospace1
or
axis VAR wadospace(1)
The error is "expecting end of line or ;" and its pointing at the open parenthesis.
I'm not getting an error if its a single variable loading into another single variable. Just when I'm trying to do arrays.
bits VAR foo.bit2
You'd reference the bits with subscripts starting at 0 with bits(i)
I figure you use BS2 that has just 2k EE memory. Did you look at BS2e or BS2sx - they both have 8 times more memory than plain BS2...
Why won't you recommend using SP-RAM for variable storage? In a project I save values using PUT-statements, then the loop goes through many different slots and back again and I still can GET the variables back again without any problems.
I wanted to make clear that the ScratchPad RAM is separate from the memory used for variable storage. You can certainly use it and it's handy for receiving strings using SERIN and some other input statements, but you have to use special statements (PUT and GET) to access the storage. You can't directly use the values stored there in other statements, etc. ScratchPad RAM can make some things possible that might not be so otherwise, but its use tends to make programs larger because of the extra statements needed and it sometimes makes programs more difficult to write and understand because of the need to constantly copy values back and forth between ordinary variables and the ScratchPad RAM.