Problem with chaining more than 2 TLC5916 ICs

I wired 3 mini breadboards with a TLC5916 and 8 LEDs.

My goal is to chain the three together and make an led chaser. Each of the boards works fine, connected to my UNO, and I am able to make the 8 LEDs light sequentially, chasing back and forth.

When I connect a 2nd on into the chain, and send 2 bytes each cycle, I have 16 lights chasing back and forth, exactly how I want.

However, when I connect a third set to the chain, and send 3 bytes per cycle, the lights chase across the first 16 LEDs, then instead of the pattern continuing to the last set, the 2nd set repeats, and the third set stays dark.

I am attaching pictures of the board, as I have it setup, as well as the code that is driving it, below...

I also attached a crude diagram of how each board is wired.

If anyone sees what I am doing wrong, I would greatly appreciate your help. I am a software guy, I haven't worked with electronics hardware in years, and find that I am rustier than I thought I was :slight_smile:

This is the test code I threw together to try to get this working like I want.

int latchPin = 5;
int clockPin = 4;
int dataPin = 3;
int DelaySpeed = 50;

byte LEDs1 = 0;
byte LEDs2 = 0;
byte LEDs3 = 0;

void ToggleLED(int num);

void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {

  for (int i = 0; i < 24; i++) {
    ToggleLED(i);
    delay(DelaySpeed);
    ToggleLED(i);
  }

  for (int i = 23; i >= 0; i--) {
    ToggleLED(i);
    delay(DelaySpeed);
    ToggleLED(i);
  }
}

  void ToggleLED(int num) {
    if (num >= 0 && num < 8) {
      LEDs1 ^= 1UL << num;
    } else if (num >= 8 && num < 16)  {
      LEDs2 ^= 1UL << (num - 8);
    } else if (num >= 16 && num < 24)  {
      LEDs2 ^= 1UL << (num - 16);
    }

    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, LEDs3);
    shiftOut(dataPin, clockPin, MSBFIRST, LEDs2);
    shiftOut(dataPin, clockPin, MSBFIRST, LEDs1);
    digitalWrite(latchPin, HIGH);
    digitalWrite(latchPin, LOW);

  }

If anyone wants to see a video of how it is acting, I can throw one up on youtube. Just let me know if you think it would help.

Thanks,
-Larry

Show us a good schematic of your complete circuit.
Show us a good image of your ‘complete actual’ wiring.

Decoupling capacitor should be ceramic 100nF.

void ToggleLED(int num)
Try
void ToggleLED(unsigned long num)

    } else if (num >= 16 && num < 24)  {
      LEDs2 ^= 1UL << (num - 16);
      ^^^^^

“LEDs2” ? Try “LEDs3”… :stuck_out_tongue:

larryd:
Show us a good schematic of your complete circuit.
Show us a good image of your ‘complete actual’ wiring.

Decoupling capacitor should be ceramic 100nF.

void ToggleLED(int num)
Try
void ToggleLED(unsigned long num)

Thanks for pointing out my incorrect data type, and the use of the wrong capacitor. I will correct both of these.

Also, note post #2 @ Erik_Baas comment re: LEDs2 vs LEDs3

Erik_Baas:

    } else if (num >= 16 && num < 24)  {

LEDs2 ^= 1UL << (num - 16);
      ^^^^^



"LEDs2" ? Try "LEDs3"... :P

I stared at this code for over an hour before posting, and I completely missed this cut and paste error :frowning: Now I feel like an idiot.
Thank you, this was exactly the problem, and the circuit is working as expected now.

Again, thank you.