Shop OBEX P1 Docs P2 Docs Learn Events
126-Out of Variable Space - Need help!!! — Parallax Forums

126-Out of Variable Space - Need help!!!

kingspudkingspud Posts: 128
edited 2008-10-22 02:56 in BASIC Stamp
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

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-10-19 07:43
    kingspud -

    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.
  • GICU812GICU812 Posts: 289
    edited 2008-10-20 18:36
    Yep, there just isnt that much ram.

    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
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-10-20 20:29
    Why do you need an array with size 64?
  • kingspudkingspud Posts: 128
    edited 2008-10-21 03:05
    I am working on a project that can control all the LED's on the 8x8 matrix using the MAX7219 chip.

    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
  • Mike GreenMike Green Posts: 23,101
    edited 2008-10-21 03:13
    Parallax Basic allows bit arrays, an 8 x 8 matrix needs only 8 bytes of variable space that way. Look in the Stamp Basic Manual around page 90.

    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)
  • kingspudkingspud Posts: 128
    edited 2008-10-21 04:48
    so... how would I write code for a FOR NEXT loop to cover the 8 rows and 8 col?

    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
  • GICU812GICU812 Posts: 289
    edited 2008-10-21 04:53
    we are working with logic, so you always start with 0, not 1. That might be your problem

    For row = 0 to 7
  • kingspudkingspud Posts: 128
    edited 2008-10-21 05:04
    This program works but I can't get matrix(row).Bit(col) = 1 to work???? It says, Expected '='


    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
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-10-21 05:15
    kingspud -

    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.
  • kingspudkingspud Posts: 128
    edited 2008-10-21 05:30
    What I am really trying to do is be able to light a single LED on an 8x8 matrix display.
    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
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2008-10-21 05:46
    Syntax:
    matrix.bit0(row * 8 + col)
    That turns it into a one dimensional array starting with bit 0 of byte 0.

    main:
    matrix VAR BYTE(8)   ' 64 bits
    row VAR Nib    ' nibbles index
    col VAR Nib
    FOR row = 0 to 7  ' zero based
    FOR col = 0 to 7
    matrix.Bit0(row*8+col) = 1
    DEBUG matrix.Bit0(row*8+col)
    NEXT
    NEXT
    END
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Jesse HastyJesse Hasty Posts: 29
    edited 2008-10-21 13:04
    Do you only need to have one LED lit at a time?
    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?
  • Jesse HastyJesse Hasty Posts: 29
    edited 2008-10-21 13:09
    If you only need one LED lit at a time you only need 6 bits of memory to point to that LED. You would have one group of 3 bits be the·octal pointer for the row and another 3 bits point to the column. For ease of coding you could use 2 bytes,·one for column and one for row. You only need the matrix if at some future time you intend to expand into full control of every LED simultaneously.

    Post Edited (Jesse Hasty) : 10/21/2008 1:21:38 PM GMT
  • Jesse HastyJesse Hasty Posts: 29
    edited 2008-10-21 13:27
    Actually declaring

    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
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-10-21 14:23
    Jesse -

    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
  • kingspudkingspud Posts: 128
    edited 2008-10-21 21:33
    I'm trying to:

    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
  • Jesse HastyJesse Hasty Posts: 29
    edited 2008-10-22 02:56
    With an 8 element byte array, say display(8), ·and a few push buttons it should be practical.· An up button will reduce your row number that is go from display(n) to display(n-1).· Another button will raise the number.· Two buttons will raise and lower· which bit you are working on.· And 1 button will·change the state of the·LED you are on.·· Your can flash the LED··as a sort of cursor so you can see on which LED you are located, and you can change the duty cycle of the flash to indicate if the LED is on or off.· The slowness is probably in the serial output to the
    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.·
Sign In or Register to comment.