126-Out of Variable Space - Need help!!!
kingspud
Posts: 128
Hello All,
I am working on a project and I need to use an array statement with the size (64)
When I use the Variable:
state_bit··· VAR···· Byte(64)
I get a "126-Out of Variable Space" error, does anyone know why I am getting this error and how to fix it?
Thanks
Joe
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“Intellectual growth should commence at birth and cease only at death”
Albert Einstein
I am working on a project and I need to use an array statement with the size (64)
When I use the Variable:
state_bit··· VAR···· Byte(64)
I get a "126-Out of Variable Space" error, does anyone know why I am getting this error and how to fix it?
Thanks
Joe
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“Intellectual growth should commence at birth and cease only at death”
Albert Einstein
Comments
I presume you're using a BS-2, and if that's the case there are only 26 BYTES of variable storage in a Stamp BS-2. Other Stamps (BS-2SX and on up) have what's known as SRAM which can also be used for data storage, but it not the same "ready" storage that variable space offers.
Additionally, you can read and write to EEPROM which all Stamps posses. That requires additional access time though, so it's not as fast as ordinary variable space, but there is a lot more of it. Just remember that your program is loaded at one end of memory (in EEPROM) and EEPROM assignments come from the other end of memory. Thus, if you're not careful, a memory CLASH can occur.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.
If you have a model with scratchpad, you can use "Put 0, X" to put the variable X into byte 0, then "Put 1, X" for the next byte. Then go back around and use "Get 0,Y" to read the contents of byte 0 and put it into Y.
bs2e and BS2sx both have 63 bytes you can use, 0-62. The BS2,2pe and, 2px has 127 bytes you can use, 0-126
I wanted to use a size 64 array so I could monitor which LED's are on or off and write them in for memory and be able to call them back at any time.
Does anyone know a better way of doing this? I am able to move the LED around the 8x8 matrix using buttons; up/down/left/right/diag up-right/diag up-left/diag,diag down-right/diag down-left!
I want to be able to move to an LED position hit a button and turn the LED status ON then move to another position and do the same thing until I save the entire status of all the lit LED's.
Joe
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“Intellectual growth should commence at birth and cease only at death”
Albert Einstein
You'd declare: matrix VAR BYTE(8)
Then you'd reference your matrix as: matrix(row).bit(col)
row would be the row (0-7) of the matrix while col would be the column (0-7)
I tried this but it doesn't work
main:
matrix VAR BYTE(8)
row VAR Byte
col VAR Byte
FOR row = 1 to 8
FOR col = 1 to 8
matrix(row).Bit(col) = 1
DEBUG matrix(row).Bit(col)
NEXT
NEXT
END
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“Intellectual growth should commence at birth and cease only at death”
Albert Einstein
For row = 0 to 7
matrix VAR Byte(8)
row VAR Byte
col VAR Byte
main:
FOR row = 1 TO 8
matrix(row) = row
DEBUG DEC matrix(row)
NEXT
END
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“Intellectual growth should commence at birth and cease only at death”
Albert Einstein
You haven't provided the program which "didn't work" so it's a bit difficult to show you what was wrong. Even with that in mind, you should probably have 2 FOR ... NEXT loops - one for the horizontal, and one for the vertical.
I may be missing what you're trying to do however.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.
So that would mean I need to move the cursur around the 8x8 matrix and hit a button and then the LED would stay on.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“Intellectual growth should commence at birth and cease only at death”
Albert Einstein
matrix.bit0(row * 8 + col)
That turns it into a one dimensional array starting with bit 0 of byte 0.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Are you using this to learn about the controller and do you plan to expand the control in the future so that you can turn any grouping of LEDs on or off?
Post Edited (Jesse Hasty) : 10/21/2008 1:21:38 PM GMT
state_bit VAR Byte(8)
Would create a standard array. Each byte would contain the status of every LED in a row. You would only need 1 for next loop to step through this, saving a lot of program steps.·
It might be easier to work with especially if you are communicating with the 7219 chip serially. Your data is all properly encoded.
Somewhere along the way I'd save this data to with a write command so it was located in non-volatile memory (SRAM). Then you can access it at start up.
Post Edited (Jesse Hasty) : 10/21/2008 1:35:20 PM GMT
If I understand what you're trying to do in reserving data space in EEPROM, take a look at the @address parameter of the DATA compiler directive. Here is the general syntax, and more can be found in the PBASIC Help file, or the PBASIC Reference Manual.
Quote
Syntax: {Symbol} DATA {@Address,} {Word} DataItem {, DataItem ...}
Function
Write user data to the EEPROM location(s) during program download.
Symbol is an optional, unique symbol name that will be automatically defined as a constant equal to the location number of the first data item.
Address is an optional starting location for subsequent DataItems
DataItem is a constant/expression (0 - 65535) indicating a value or how to store a value.
End quote
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.
Post Edited (Bruce Bates) : 10/21/2008 2:50:37 PM GMT
1. Learn how to use the MAX7219 chip affectively with an 8x8 matrix display and 8- 7segment displays since they both work so differently!
2. I want to be able to move a single led around the entire 8x8 matrix with 8 directional buttons and at any time push a button and save the location of that LED as ON, then continue to move around the 8x8 matrix all the while saving different LED locations to an ON state and when I have the picture I want I want to save it as a frame. This way I can save multiple frames and run through them later like a movie one frame at a time!
I think this would be really cool because you could write each LED location and save the full 8x8 matrix display when finished, then do it again and save that page, and so on until you have maybe 8 or 10 frames. You would then push a button and watch each frame flash by and whatever time interval you like!
Is this even possible?
I wrote a program that would move the LED around the 8x8 matrix but the program I wrote was huge and don't think I did it correctly. Also it was realy slooooooooooow!
Thanks for any help!
Joe
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“Intellectual growth should commence at birth and cease only at death”
Albert Einstein
7219 chip.· I didn't read very far into the specs for that chip, but if it is possible to manipulate only 1 LED at a time that will shorten that process.·I guess you could forgo the cursor effect and simply watch the 8 X 8 display to·see which LED changes state when you push the change state button.·