Go Down

Topic: Is the arduino uno compatible with 4D arrays? (Read 1 time) previous topic - next topic

Bram

Apr 06, 2012, 05:58 pm Last Edit: Apr 06, 2012, 06:01 pm by Bram Reason: 1
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?

PaulS

Quote
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.

Bram


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?

James C4S


Is there anyway to check your memory usage?

Look at the variables you've declared and count the bytes.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Bram



Is there anyway to check your memory usage?

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

any usefull tips are appreciated too  :P

dxw00d

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

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?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

wildbill

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

Bram


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

Bram

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

Marek080

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.
loved the 68000 assembler back then and now I have to deal with THIS 8 bit thingy

magagna

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!
http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

CrossRoads

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
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Bram

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  :)

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
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up