Pages: [1] 2   Go Down
Author Topic: Is the arduino uno compatible with 4D arrays?  (Read 1258 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some background information: smiley
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.. smiley-wink
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?
« Last Edit: April 06, 2012, 11:01:12 am by Bram » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 46113
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there anyway to check your memory usage?
Look at the variables you've declared and count the bytes.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-razz
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 19
Posts: 3114
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 439
Posts: 23797
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

New Jersey
Offline Offline
Faraday Member
**
Karma: 49
Posts: 3420
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink if i want 5 states that's already 2.5K ... =S
thanks guys =D
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

just to know.. is there anyway of increasing this 2K SRAM?
otherwise this topic might be locked smiley-wink
Logged

Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 89
Walking on Nails
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

loved the 68000 assembler back then and now I have to deal with THIS 8 bit thingy

Southern California
Offline Offline
God Member
*****
Karma: 5
Posts: 539
I like blinky lights
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 439
Posts: 23797
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 239
Posts: 24371
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

Pages: [1] 2   Go Up
Jump to: