Go Down

Topic: 8x8x8 multiplexed LED cube with an Arduino Mega 2560 (Read 41 times) previous topic - next topic

CrossRoads

Try this: use the TPIC6B595 OE to disable the outputs when switching.

Use direct port manipulation to make it go faster.
So that OE is bit 2 and SS/Latch is bit 3, both on port D:
Code: [Select]

PORTD = PORTD | B00000010; // bring OE/ high
// xfer data
    SPI.transfer (B00000000);
    SPI.transfer (B00000001); //leftmost, frontmost corner cathode column
    SPI.transfer (B00000001); //bottom anode plane
PORTD = PORTD & B11111011; // bring SS/latch low
PORTD = PORDT | B00000110;  //  bring OE/ an SS/latch high
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.

Un4Seen

So... basically your are suspecting that the latency is introduced by the Arduino itself! Interesting thought!
Does this require any rewiring in the physical circuit? Do I need to connect anything from the Arduino to the circuit?

Un4Seen

#207
Feb 23, 2013, 01:54 pm Last Edit: Feb 23, 2013, 01:57 pm by Un4Seen Reason: 1
I've read about the direct port manipulation and I think I understand what it's about and I have also come to the understanding that OE means output enable. I'm still struggling to understand the following:

1. Looking at the datasheet of the TPIC6B595, I can't find an OE pin on it. How can I set the OE on the shift register? My current understanding is that I should use two pins on the Arduino to control when and how data is transferred to the shift registers: SS and OE, instead of the currently used SS only. The SS should remain connected as it is now, but where on the shift registers is the OE pin?
2. The direct port manipulation section of the Arduino documentation states that PORTD is mapped to pins 0-7, but they only say that it is so on ATmega8, ATmega168 and ATeega328 chips. Mine is ATmega2560. Nobody seems to write anything about which pins PORTD maps to on the Mega2560... I think I would have to disconnect the SS from the current Arduino pin 53 and connect it to where bit 2 of PORTD is mapped. I should connect the OE to where PORTD's bit 3 maps... But which pins are the bits of PORTD mapped to on my Mega2560? :)
3. There are a few things I'm not sure I understand in the example code:
Code: [Select]

PORTD = PORTD | B00000010; // bring OE/ high
// xfer data
   SPI.transfer (B00000000);
   SPI.transfer (B00000001); //leftmost, frontmost corner cathode column
   SPI.transfer (B00000001); //bottom anode plane
PORTD = PORTD & B11111011; // bring SS/latch low
PORTD = PORDT | B00000110;  //  bring OE/ an SS/latch high


a) PORTD = PORTD | B00000010; //bring OE HIGH
   Didn't you mean to bring EO low here (in the beginning, before the SPI transfers)? Isn't the goal to disable the outputs during the next lines, which do the transfer?
b) PORTD = PORTD & B11111011;
   PORTD = PORTD | B00000110;
   There's nothing in between bringing the SS/latch LOW and bringing it back HIGH. Is that correct and is that so in order to keep the time between the point when the data transfer starts and the data transfer ends to a minimum?

Thank you!

Un4Seen

#208
Feb 23, 2013, 04:09 pm Last Edit: Feb 23, 2013, 04:45 pm by Un4Seen Reason: 1
I've found a good resource here: http://www.henningkarlsen.com/electronics/pm_arduino.php
If you open the PDF that corresponds to the Arduino Mega 2560 Rev3, you'll see the port labels there. For example PORTD 0-3 is mapped to digital pins 18-21. I hope that's right. I don't exactly know which revision of the Mega2560 I have, but hopefully the Rev3 mapping will apply to my device too.

The sad conclusion is that if people will try to use my code on other type of Arduinos (not Mega2560), they'll have to figure out where PORTD is mapped on their device.

So now what remains to be figured out is what is OE on the TPIC6B595 shift registers and how I can control it. Also, the questions a) and b) referring to CrossRoads' example code still puzzle me...

Un4Seen

#209
Feb 23, 2013, 11:41 pm Last Edit: Feb 23, 2013, 11:43 pm by Un4Seen Reason: 1
OK, I have figured it out! OE (output enable) is pin 9 (marked G) on the TPIC6B595. So I disconnected the OE pins of the shift registers from the GND (that's how it originally was) and connected them in chain and to the Arduino pin 49. I left SS on Arduino pin 53, as it was before. And I started using this code:
Code: [Select]

   PORTL |= B00000001; //Output enable (pin 49) disabled
   SPI.transfer (cathodeData1);
   SPI.transfer (cathodeData2);
   SPI.transfer (anodeData);
   PORTB &= B11111110; //Latch (pin 53) low - start transfering data    
   PORTB |= B00000001; //Latch (pin 53) high - done transfering data
   PORTL &= B11111110; //Output enable (pin 49) enabled


Unfortunately this doesn't change anything :( The ghosting remains. During multiplexing the ghosting is seen as the previous plane being lit up very lightly at the same time when the new layer is lit up at full brightness.

Go Up