Is the arduino uno compatible with 4D arrays?

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.

Is there anyway to check your memory usage?

Bram:
Is there anyway to check your memory usage?

Look at the variables you’ve declared and count the bytes.

[quote author=James C4S link=topic=100161.msg751230#msg751230 date=1333728921]

Bram: Is there anyway to check your memory usage?

Look at the variables you've declared and count the bytes. [/quote] any usefull tips are appreciated too :P

Ok. If that’s too difficult for you, post the code, and we’ll look at your variables, and count the bytes.

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?

There are also a couple of versions of a freemem or freememory function that are posted in the forums fairly regularly.

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

just to know.. is there anyway of increasing this 2K SRAM? otherwise this topic might be locked ;)

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.

Good luck!

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.

See Reply #282, page 19, in this thread http://arduino.cc/forum/index.php/topic,80483.270.html and Reply #287, page 20 http://arduino.cc/forum/index.php/topic,80483.285.html

$4.50 a card to US locations; international, need to check where its going.

Reply #224 on page 15 for schematic & pics of bare board http://arduino.cc/forum/index.php/topic,80483.210.html

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?

Thanks in advance :)

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)

Here is a useful resource

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)

Here is a useful resource

I tried that site already, but most of the explanations are for String-arrays so I’m getting too confused when reading that… :~

You mean like this:

// save some unsigned ints
PROGMEM  prog_uint16_t charSet[]  = { 65000, 32796, 16843, 10, 11234};
...
...
// read back a 2-byte int
 displayInt = pgm_read_word_near(charSet + k)

?