problem with led cube with 3-8 decoder 74HC238

Hi all,

i am really new into electronics so i decided to try constructing a led cube as my first project following a tutorial on instructurables (http://www.instructables.com/id/LED-Cube-with-Arduino-and-custom-PCB/). despite i got it to work i have a few problems with the decoders and led matriz response (i figure it as a comunnication problem).

this cube uses 1 decoder to control (tuning on and of) other 4 decoders in charge of driving the 24 columns. all this decoders share a data line for adressing the leds while de layers are driven separatedly through NPN 2222 transistor connected to the UNO.

my problems starts here. if i choose to light a single led or a random single led everithing works, but if i choose to light up for example column 7 (managed by decoder 1) and column 18 (managed by decoder 3) columns 3 and column 22 will also be turned on (i guess this is a problem with the data line swithcing time and the decoders time to actually retrieve and send the data. as C7 ---> y6 pin ---> A1 Low A2 High A3 high and C22 ---> y6 pin ---> A1 Low A2 High A3 from the other decoder that i call to turn C18).

i dont know if i cn control in any way the reading time from the decoders, so i hope someone can help me on this. (by the way next time i will use shift registers)

void displayNum(int num){
  //constrain the argument to be between 0 and 24 inclusive.
  num = constrain(num, 0, 24);
  
  /*
   * AND: selects the bit, the bit at weight will be 1 if the pin is to be high
   * >>: shifts the selected bit to the end of the word, making the value a 0 or 1
   * first result is lsb
   * digitalWrite: write the approptiate result (HIGH or LOW) to the appropriate decoder pin
   */
  for(int weight=1, pin=0; pin < DECODER_BITS; weight*=2, pin++)
    digitalWrite(decoderPins[pin] ,(num & weight) >> pin);
  
  //delay, this is the absoloute minimum time the light will be displayed. 
  //ensures adiquate delay for decoders as well. 
  delayMicroseconds(MICRO);
}

/**
 * z < 0: no layers enabled
 * 0 < z < LEDS_PER_ROW : only the layer at z will be enabled
 * z >= LEDS_PER_ROW: all layers enabled
 */
 
void cathode(int z){
  for(int i = 0; i < LEDS_PER_ROW; i++){
    if(i == z || z >= LEDS_PER_ROW){
      digitalWrite(cathodePins[i], HIGH);
    }else{
       digitalWrite(cathodePins[i], LOW);
    }
  }
}
void displaySquareSmall(int z)
{
  cathode(z);
  displayNum(7);
  displayNum(18);

}
/**
 * Stores pin numbers of pins to decoders in array, for iteration
 */
unsigned int decoderPins[] = {p0, p1, p2, p3, p4};
unsigned int cathodePins[] = {Z0, Z1, Z2, Z3, Z4};
#define DECODER_BITS 5
#define LEDS_PER_ROW 5
#define ARDUINO_JUMPERS 5

Hard to say what's the problem, without a circuit diagram. I don't want to register in the linked site, only to download the pdf.

As a general solution, can you turn all decoders off until the next address is completely sent to the output pins? E.g. disable the level 1 decoder while the address bits are changed. Which chip is used for that decoder?

thanks for you repply. i made myself the eagle cad file with the schematic and board. you can get an idea from this image or from my eagle cad shared files (board & schematic)

in my setch, the main decoder is supposed to only call one decoder at a time, but the data line for decoder pins A1, A2 and A3 which selects the output pin seems not to be switching at the same time that my decoders do (this is my guess as the columns that are turn on by mistake are not as bright as the correct ones). i need my decoders selection to sync with my data line change.

i hope now its more clear and that you may be able to help. were i suppose i need a work around is in the displayNum function from my code. Kind regards

As I said, make the E3 of U5 low (disable), then change all address and transistor base pins. Finally set E3 high again (enable), after calling displayNum() and cathode(). Or turn all transistors off before changing the address bits...

For testing purposes I'd use a loop that turns on all LED successively, for e.g. 1 second each, so that you can find eventual shorts or other failures in your circuit. You may find out that you reversed the polarity of the ghosting LED, or damaged decoder outputs.

Another test would reduce the delay to the final scan time (MICRO), so that all LED appear to be on at the same time, for testing the achievable brightness.

When only one LED can be on at a time, you can remove all resistors and replace them by one in each transistor collector line. You even may remove the transistors, when the 20mA from an Arduino output pin are sufficient.

I don't know how you finally want to make your cube display patterns, when a LED is on only for 1/50 (2%) of a scan of 50 LED. The 74HC238 data sheet says that the nominal output current is only 4mA, resulting in 80µA for each LED when all are turned on sequentially. Which values do you use for the LED resistors, and for the transistor base resistors?