1284P - lack of SRAM but I need a high speed accessable memory for a POV-display

Hello

I´ve been working the last few days on my arduinos to get a proper solution for my problem.
I want to make an 3D-POV-Display with 8 "layers" and 16 LEDs on each layer. Resulting in 128 LEDs in total to control.
(some time ago - that was my first attempt... which was very fail... check it outhttp://arduino.cc/forum/index.php/topic,87694.0.html)
So to create a good looking volume I slice one rotation into 128 segments.
That would lead to 2048 Byte of data only to fill just a single rotation.
But for a smooth image I would need the whole thing spinning at least at 1800 RPM . Hence - that is a datastream of around 60kBytes/s out of a memory.
Dumping data on the Atmegas 328PU´s internal SRAM (2048Byte) and simustainisly reading from it and shifting the data to the leds - would be fast enough to reach that needed 60kBytes/s.
For simple real time renderd animations - there would be almost no problem using just the 2kb of the internal SRAM, but I want to display prerendered animations or load data from an Bluetooth or SD-Module.
First I tried to create an alternating stream of data from an SD-Card to the arduinos SRAM. (Arduino displays 1024 Bytes and reads the next 1024 Bytes from SD and then changes to that buffered data). But that method was too slow - I was only able to stream the data at a speed of around 5kBytes/s from an .txt file on the SD-Card to an int array on the arduino.
My second try was to use two arduinos, and let one do the display - and the other do the render - over I2C I came close to speeds around 28kBytes/s dumping data from an array on the master to an new array to the slave arduino.

Now I am almost out of ideas - I am thinking to use the Atmega 2560 - because it has 8kBytes of SRAM, that would slove my problem - but I dont know first how to solder an FTQP100- chip and second it seems kind of scary to me that there is no other more efficient solution for my problem.

I want to ask you, if an external SRAM like the 23K256 (Arduino Playground - SpiRAM) or even an EEPROM would be fast enough to feed the arduino fast enough with data to display it.

Hope you guys can help me - My english is kind of strange and please ask if something in my explaination is unclear to you

thx a lot in advance!

You might try using the SPI port [SCL,MISO,MOSI] to transfer between the 2 Arduino
boards you already have, as SPI can go much faster than I2C.

Use an SPI SRAM, or a RAMTRON FRAM even so you don't need battery backup.
Or a '1284 based board with 16K of SRAM (twice the '2560, chip available as a DIP,and 1/3 the price too).
I have bare boards available now, see my signature link for an example of one built up.

Wow thank you a lot for that hint with the 1284! I didnt knew that chip before, and it seems to be powerfull enough!.
I´ve ordered some and hope I can get em to work. I read many tutorials how to burn the bootloader on that chip, but many people complain about problems.
The wiring bootload should work original on that chip - what would you recomand?

Thx anyway for that great hint!

I'd recommend a board that is ready to go, here's an example of one that is built up:


Bare boards are available from me, packed up by my widfe & shipped to your US location for $4.50.
Schematic, parts list at Cross Roads Electronics
Bootloader & core files to add to the IDE are here from maniacbug:
GitHub - maniacbug/mighty-1284p: Mighty 1284P Platform for Arduino
Once setup, select Bobuino as the board type.

Something I would recommend, just from a safety standpoint: An acrylic shield of some sort around that spinning contraption, and while you are testing it, wear eye protection. Maybe an e-stop button/switch or something. All it would take for that thing to shake itself apart with fairly catastrophic results would be for one solder joint to fail and throw the whole thing off-balance. Even if it isn't that bad, an LED or other part launched at high-speed in a random direction (toward your's or another's face?) could be a problem all on its own. It does look neat, what you got so far, though, and I hope you are able to make it work like you want it in the end. Good luck with it!

Sounds like you need to add 8 resistors, a ULN2803, and write your own code.

@cr0sh:

Thanks for that advice - safety is always the most important law inhopefully every hacker's basement...
I was wearing protective glasses when spinning my construction up the first time. - after about 3 Minutes of 2000RPM spinning the Arduino (328P) came loose, and flew fast from one end of the room to the other and hit the wall quite strong. - But it is still working (my eye and the 328P)
After my project is finished, I want to place an clear acryllic dome (costs around 50$) over my 3DPOV.

@CrossRoads:

The Atmga 328P was not powerfull enough for the qoals I set anyway - hence a complete redesign is neccassary (your advice comes a little too late =() - thx anyway

The board looks nice, but I already ordered an Sanguino Rip-Off board in the bay (10 bucks or so).
The 1284P arrived yesterday, and I burnt that mighty bootloader.
The burning was successfull, and a led on pin 1 flashed every time I pressed reset - so bootloader should been fine - but i wasnt able to upload a sketch...
it said " avrdude: stk500_getsync():not in sync: resp=0x00 " - I know that this is a common problem - I tried pressing reset before upload and I selcted the proper port and the arduino´s UNO COM Drivers are installed as well (I used an Arduino UNO board without the 328P to upload the sketch).

... So i swapped over to the Sanguino Bootloader - burning was successfull aswell (i think so). But I cant uplad sketches as well. This time it says:
on Arduino 1.0: error: Arduino.h: No such file or directory
on Arduino r23: avrdude: AVR Part "atmega1284p" not found. (...and makes a list of all valid AVR Parts)

I dont know what I mistake I would have made...?
Hopefully someone of you genius can help a burning noob out of his problem.

I was only able to stream the data at a speed of around 5kBytes/s from an .txt file on the SD-Card

I would hope that the txt file on the SD-card was not Ascii readable integers; parsing that would really slow things up.
Tell me it was really a binary file, and that you were only using "stream.readBytes(buffer, length)" and nothing byte-by-byte!
Please! :slight_smile:

I am sorry techylan.... I am quite new to all that stuff, and I read numbers (ACII) from an.TXT file on the sd card, and substracted '0' to get the real '0' and '1' out of the .TXT and then I shifted that boolean into a 16 Bit number and stuffed an array fith lots of loops and counters.
I´ve never seen such a method like you mentioned before... Can I anywhere look up for more details how to use that?

But my main problem is still getting the 1284P to life :frowning:
Today I spent many order with burning different bootloaders and filtering the web for good answeres.
So far, I cant spot any mistakes
-I use a fresh install of the Arduino 1.0 IDE
-I use the Mighty 1284P (GitHub - maniacbug/mighty-1284p: Mighty 1284P Platform for Arduino)
-I followed the instruktions on Arduino on ATmega1284P | maniacbug
-The bootloader led (on PIN 1) also flashes when I press reset.
-I have an 16MHz external crystal with two 22pF tied to ground
-I want to use an Arduino UNO board to upload the sketches (as an serial adapter) (of course I removed the 328P)
--> I connected the RXD0 to the RX of the arduino UNO board and the TXD0 to the TX

It says "bootloader burn done", but when I want to upload a simple sketch (e.g. "Blink"), I get no response from the 1284P
Here is the log from the AVRDUDE:

Using Port                    : \\.\COM5
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: 
avrdude: stk500_getsync(): not in sync: resp=0x00

avrdude done.  Thank you.

I have also tried to look if the fuse bits are set properly. - I did this by a tool created by Nick Gammon (http://arduino.cc/forum/index.php?topic=105089.0)

Here is the result:

Atmega fuse calculator.
Written by Nick Gammon.
Entered programming mode OK.
Signature = 0x1E 0x97 0x05 
Processor = ATmega1284P
Flash memory size = 131072
LFuse = 0xFF 
HFuse = 0xDE 
EFuse = 0xFD 
Lock byte = 0xCF 
Clock calibration = 0x9D 
OCD Enable.............................. [ ]
JTAG Enable............................. [ ]
Enable Serial (ICSP) Programming........ [X]
Watchdog Timer Always On................ [ ]
Preserve EEPROM through chip erase...... [ ]
Boot into bootloader.................... [X]
Divide clock by 8....................... [ ]
Clock output............................ [ ]
Bootloader size: 4096 bytes.
Start-up time: SUT0: [ ]  SUT1: [ ] (see datasheet)
Clock source: low-power crystal.
Brownout detection at: 2.7V.

So far the fuses are set properly.

I hope you guys have an idea....
grz mx

This should work with your original single Arduino Uno, a single 1024 bytes of memory shifted out at a time.
The SD class returns a File object, which you then read using stream reads rather than single char read();
This should be at least 10 times faster than your Ascii single character stuff.
Look at:

This ought to dump even Gigabytes (or the full size of any file) to your display more than fast enough!

File mySDBinaryFile = SD.open(myFilePath);
while (true)
{ 
     if (mySDBinaryFile.stream.readBytes(myBuff, 1024) == 0)
           break;
     myShiftOutRoutine (myBuff, 1024);
//  delay(10);     // Add slow down as needed!
}
mySDBinaryFile.close();

Now you just need to write the binary files from your PC.
By the way, once you have this working, you are free to create your own binary file format that is a series of "display records".
You'd know better than me, but I'm thinking of something where each display record has a header, which is a bunch of int fields to specify:
size of Frame
number of Frames
delay ms per Frame
repeat factor for this set of Frames

Your Arduino code would "execute" the file.
You would use mySDBinaryFile.seek() to go back to the beginning to implement the repeat factor.

I think the use of an SD card with your POV is a splendid idea. Pop a different chip in and ... Voila! New stuff!
You can time the above code first just to satisfy yourself that the speed is sufficient.

You are connecting the Reset pin as well? And the power & ground pins - I think there are 2 of each?

When you get the sketch downloaded:
Try all the IO pins, I believe D13 is in a different location than you might be looking.
If you use Bobuino as the board type, D13 is the SCK pin.
If you use one of the others, I don't know which pin it is. You'll have to review the '1284 pins_arduino.h file to see where they are assigned.

wow thx crossroads - you finally make me feel a little better after that senseless day of trying to get it run.
Now I connected the reset as well, and it at least pops out another error.
It compiles successfull, and avrdude starts to send data (RX flashes) it also gets response from the 1284p, but it never finishes the upload successfull...
it stops at an random point at upload (I think its never the same) and pops me that error:

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
avrdude: Send: V [56] @ [40] . [00] . [00] . [0c]   [20] 
avrdude: Recv: 
avrdude: stk500_cmd(): programmer is out of sync

maybe there is something wrong with the bootloader? or is there a wrong fuse setting?

grz mx

That error I think usually indicates a mismatch between bootloader speed and IDE speed. I think.
If it's fuse settings, NickGammon has a sketch that can be used to read them.
I hvae an Atmel AVR ISP MKii and I use that.

I have already read the fuse settings with Nick Gammon´s tool -please look my reply #9
Now I tried the same to completely virgin 1284p - same thing happens...

I gonna get mad....

I followed that tutorial to set the 1284 up on a breadboard : http://wiki.wiring.co/wiki/Creating_your_own_Wiring_board_with_a_DIP_atmega1284p_using_Duemilanove
Can it be a problem that i use ceramic disk capacitors?
I dont know what I am doing wrong! - I followed all instruktions properly.
Please tell me what I can do.
Is there any way that I can check if the speeds are identical (I have no osciloscope here)?

BTW.: I would like to buy a Atmel AVR ISP MKii aswell. The genuine from avr costs around 40$ and a rip of clone from the bay around 15$ - can I buy the rip of clone? - or should I better buy the original from AVR direktly?

grz mx

finally got that damn chip to life!
I used many different bootloader and only this one worked:

its a mix out of many different packages available, and it work very well.
Something strange is, that the 1284p works about 20% faster than my atmega2560 running the same sketch
(i did a shift out demo for an 16bit regsister to steer the leds)
the 1284 does update the 16bit LED display at 13,5khz and the 2560 at 11,6khz (calculated on 50000 cycles each)

now I need to port my current sktches to that baby. Hopefully the flash library will work.
thx for your help!

"BTW.: I would like to buy a Atmel AVR ISP MKii aswell."
I bought mine from mouser.com for ~$33.
I don't trust e-bay for tools like that, nor the 3 week delivery times.

mzure,
I updated my code (Reply#10) so it can handle any size SD file.
You can test it out for speed immediately.
You can use any file, even a text file or jpg, and you can even shift out to a non-connected device.

I'm claiming it should be blazingly faster than current, 5-10x or more.
Techylah

@techylah

I totally agree to your idea! The sd card interface was always supposed as an animation memory. But I dont understand how to use your code snippet to read it binary.
I think it would do the same job, if I just read a binary file, and instead of an ASCII character I get the byte I want directly (8x Times faster). Is there any way to stream that bytes directly into my array - without the use of counters, comperators, and so on - (that decrease speed extremely)?
But what is a shame, that I cant find ANY binary level file editor for windows! All "binary" editors show the value only in HEX, DEC, or ASCII! I tried a bunch of them and no one has the function to display it really binary!
Here is how I did it before (reading the ASCII):

myFile = SD.open("data1.txt")
 if (myFile) {  //does if file exists
    sd_member = 0;  //resets for array mergeing
    sd_position = 0;
    sd_layer = 0;
    while (myFile.available()) {   // reads from the file until there's nothing else in it
      data1[sd_layer][sd_member] = data1[sd_layer][sd_member] << 1;  //shifts it one position to the left
      data1[sd_layer][sd_member] |= (myFile.read() - '0');   //myFile.read acts like a serial communication - all fetched data is ASCII (for this reason -'0' : 48-48 = 0 ; 49-48=1 
      sd_position++;  //counts up position
      if (sd_member == 32) { 
        sd_member = 0; //resets member that new layer starts being written at the beginning member
        sd_layer++; //counts up layer to acces trough array
      }
      if (sd_position == 16) { //checks if lenth of one member is reached (as for datatype word its 16)
        sd_position = 0; //resets position that new member starts being written at the beginning
        sd_member++; //counts up member to acces trough array
      }
      }
    }
 myFile.close();    // close the file

grz mx

something really strange I found out now:

I am using the SD.h library on Arduino IDE r23.
I am using some interrupts and timers for my sketch.
The problem is, that the SD library crashes when the timer 1 overflow intrrupt is activated
-When i deactivate it it works very well (atmega 1284p).
Has anyone a idea??

My sketch now reads an .BIN file (i filled it up in an HEX editor - random values)
the file is 4096bytes big, and it is transfering at a speed of around 20kByte/sek.

  • That still seems a little slow to me - I need to investigate a bit further to test where the speed gets so lacked down...

EDIT: same problem with an external interrupt (INT0)
EDIT2: found out that disableing cli(); before my setup fexes the INT0 problem - the overflow problem is still there and I have no f**** clue why that is happening...