Some background information:
I've been working on a project for my studies, which is a 8x8x8 LEDcube controlled only by an arduino.
It uses shift registers and the 3D-array i calculate will be displayed layer by layer on the cube itself.
Everything works fine till now, however some calculations of the 3D-array are way too time consuming..
which delays the process so you see the layers one by one..
So I was thinking..
if I would use a 4D array, which stores the states of the 3D-array of booleans (LEDs),
I could calculate all stuff in the setup-loop and store those states in the 4D array, but this won't give any result at all..
Is this my fault? Or is the arduino not compatible with 4D-arrays?
is it my fault? or is the arduino not compatible with 4D-arrays?
An Arduino could handle a 12D array, if it were small enough. It is likely that the issue you are having is that you 4D array consumes more memory than you have.
PaulS:
An Arduino could handle a 12D array, if it were small enough. It is likely that the issue you are having is that you 4D array consumes more memory than you have.
Counting the bytes used is useful - you only have 2K of SRAM to store variables in.
If you have two 8x8x8 arrays, one that is being displayed and one that is being created to be displayed next,
that is 8x8x8x2 = 1024 bytes of memory used right there.
What other variables do you have?
CrossRoads:
Counting the bytes used is useful - you only have 2K of SRAM to store variables in.
If you have two 8x8x8 arrays, one that is being displayed and one that is being created to be displayed next,
that is 8x8x8x2 = 1024 bytes of memory used right there.
What other variables do you have?
thanks for the "you only have 2K of SRAM to store variables in" =D
that was useful so that's the explanation why i wont work with 4D-arrays for me if i want 5 states that's already 2.5K ... =S
thanks guys =D
No, the ATmega328 is limited without a chance of expansion, the Arduino Mega 2560 could help with more SRAM on chip and the possibility to add external SRAM.
But there are still some possibilities for the ATmega328 left. You have EEPROM and Flash to store (static) data. What do you store in the array? Boolean values? If that's the case you are wasting space. You could pack 8 bits into a byte by changing your data format. Arduino is too slow? Maybe your code should be optimized: digitalWrite() is slow but writing the registers directly is not that complicated.
Marek080 has the right idea. You say you're going to precompute the array in the setup loop. You could just precompute it outside the Arduino program entirely, and store the data in Flash.
You also said 5 states will take 2.5K, which makes me think you're storing each LED state as a byte. As he points out if you're just storing on/off then each matrix entry will only take 64 bytes.
Another option would be to add an SD card -- with that you could either precompute the matrices on a bigger computer, copy them to the card, and stick it in the Arduino, or you could do as you originally suggested and do all the computation in the setup loop, but instead of storing the states in RAM save them to the SD card.
Go with a '1284 based board, 16K of memory.
I am selling bare boards (assembly required) that are comparable to duemilanove but are populated with a '1284 instead.
hey I've just been Google-ing for a way to sore my 3D Boolean array in the flash memory,
but it totally confusing me as everybody only talks about String arrays and more..
I just want to know how i can store an 8x8x8 Boolean 3D array in my flash-memory and call upon it while running the program?
anyone who could give me a quick introduction or a link to a site that explains it well for Booleans?
An 8x8x8 boolean array would still occupy 512 bytes of memory, SRAM or flash.
If you store the values as bits, that reduces to 64 bytes, but you'll have to do some of the addressing legwork yourself, with bitRead operations (or shifts and bitwise-AND operations if you're comfortable with those)
AWOL:
An 8x8x8 boolean array would still occupy 512 bytes of memory, SRAM or flash.
If you store the values as bits, that reduces to 64 bytes, but you'll have to do some of the addressing legwork yourself, with bitRead operations (or shifts and bitwise-AND operations if you're comfortable with those)