getting my Uno 8x8x8 led cube to run on a mega

J-M-L:
the OP code drives a refresh rate of over 1000 FPS

Really? It's that for pwm dimming?

PaulRB:
Really? It's that for pwm dimming?

that's what they claim in the article.. I've not tested... They agree it's probably overkill but you get flicker free cube and still plenty of CPU cycles available apparently...

This gives us a refresh rate of 1309 FPS (10472.7/8). At this refresh rate, the LED cube is 100% flicker free. Some might say that 1300 FPS is overkill, but the interrupt routine is quite efficient. At this high refresh rate, it only uses about 21% of the CPU time. We can measure this by attaching an oscilloscope to the output enable line (OE). This is pulled high at the start of each interrupt and low at the end, so it gives a pretty good indication of the time spent inside the interrupt routine.

J-M-L:
With a bit of luck it should not be rocket science and just moving a few wires around and recompiling a slightly modified sketch...

PORTD on your UNO are digital pins 0 to 7 and the doc seems to hint they are all used --> So I assume that in your current set-up you have wires going from pin 0 to 7 to form the Data bus. PORTD on your mega are digital pins 43 to 50 --> so if you don't change the code you need to move the wires from pins 0-7 to 43-50

Oke first little problem .... on the Uno PORTD pin 0 - 7 no problem, but on the mega PORTD 43 - 50 are the ones on the processor not the pinouts on the board. Those would be 21, 20, 19, 18, ?, ?, ?, 38 .
I can`t seem to find the pinout numbers for PORTD4, 5, or 6 ....??
What am I not seeing ....??

Ronald

Roonie:
Oke first little problem .... on the Uno PORTD pin 0 - 7 no problem, but on the mega PORTD 43 - 50 are the ones on the processor not the pinouts on the board. Those would be 21, 20, 19, 18, ?, ?, ?, 38 .
I can`t seem to find the pinout numbers for PORTD4, 5, or 6 ....??
What am I not seeing ....??

Ooops - I read the wrong column in the pinout documentation


indeed this is an issue since some pins are not mapped... so need to change port. portA seems a possibility as being fully mapped

So on the UNO, PORTD maps to Arduino digital pins 0 to 7

DDRD - The Port D Data Direction Register - read/write
PORTD - The Port D Data Register - read/write
PIND - The Port D Input Pins Register - read only

You would need to change every occurence of DDRD --> DDRA, PORTD --> PORTA, PIND --> PINA and plug the wires in the new pins as per the table (D22 to D29)

OK great .....

I thought that would be the case.... I`ll give it a try.

Thankx again for all the help .....

Ronald

Hi,

Correct me if I`m wrong but in the code ;

if (current_layer < 6)
  {
    PORTC = (0x01 << current_layer);
  } else if (current_layer == 6)
  {
    digitalWrite(12, HIGH);
  } else
  {
    digitalWrite(13, HIGH);
  }

  current_layer++;

  if (current_layer == 8)
    current_layer = 0;

It digitally writes pin 12 and 13 for layers 7 and 8 because layers 0 to 6 are on PORTC and on the Uno there are only 6 pins on PORTC. But on the mega there are 8 ! So wouldn`t it be beter and nicer to do layers 7 and 8 the same way;

  if (current_layer < 8)
  {
    PORTC = (0x01 << current_layer);
  } else if (current_layer == 8)
 
   current_layer++;

  if (current_layer == 8)
    current_layer = 0;

Also I think, change al PORTC to PORTF then we would just need to rewire the in 12 and 13 to A6 and A7 ...??

sorry for al the questions .... but I`m trying to understand how it all works.

thankx,

Ronald

YES ....

It`s working perfectly, after some debuging and tweaking my 8x8x8 led cube is running a Mega :o

Thanks guys for the help .......

Now let`s see if I can get the IR to work :confused: