TLC5940 multiplexing problem

Hi

I'm trying to create an LED matrix by using TLC5940's and 74HC595's.
What I'm doing is, I connect the anode of the LEDs to an output of the 595, and the cathodes to the outputs of the TLC5940.
(No fet or transistor is needed for now, since I only connect 1 led per output of the 595, at 20mA)
I loop through the colums (595 outputs), while using the TLC5940 for PWM. This works, but I see some kind of glitch happening.
In the video you can see what happens. Every time the first led is activated (most left one), it flickers a little, while it should be completely out. This is probably because the 595 gets updated before the 5940, but changing the updating point doesn't help solving it.
I even placed the Tlc.update() between the downtime of the latch of the 595, but even that doesn't seem to work.

What should I do to solve this problem?

edit

here's the code (forgot that)

#include "Tlc5940.h"

#define LATCH 5    // GREEN  = WHITE
#define DATA  6    // BLUE   = ORANGE
#define CLOCK 7    // YELLOW = YELLOW

int dataArray[] = {0, 4000, 1500, 500, 10, 500, 1500, 4000};  // pwm values

void setup()
{
  Tlc.init();
  Tlc.clear();
  
  pinMode(LATCH, OUTPUT);
  pinMode(DATA, OUTPUT);
  pinMode(CLOCK, OUTPUT);
}

void loop()
{
  for(int i=0; i<8; i++)
  {
    //shift data to TLC5940
    for(int n=0; n<16; n++)
      Tlc.set(n, dataArray[i]); //dataArray[i]
    Tlc.update();
    
    //shift data to 74HC595
    digitalWrite(LATCH, LOW);
    shiftOut(DATA, CLOCK, LSBFIRST, 1<<i);
    digitalWrite(LATCH, HIGH);
    
    //delay
    delay(400);
  }
}

Your YouTube video is Private so we cannot see it 8)

Pedro147:
Your YouTube video is Private so we cannot see it 8)

Should be solved now, thanks for telling me

Hi Steen.

Latch isn't the same thing as Output Enable. If the 595 has an output enable and you have a spare digital output on the arduino, you coukd use that to blank all leds until you have updated both the 595 & 5940. Otherwise you must shift 8 zero bits into the 595 and latch them before updating the 5940.

Paul

PaulRB:
Hi Steen.

Latch isn't the same thing as Output Enable. If the 595 has an output enable and you have a spare digital output on the arduino, you coukd use that to blank all leds until you have updated both the 595 & 5940. Otherwise you must shift 8 zero bits into the 595 and latch them before updating the 5940.

Paul

Thanks for that hint. I tried it out (code below), but somehow that flickering is still there.
I double checked if I really had the /EO input, which is correct. And it's also only connected to the arduino output, not to gnd via another wire. There's nothing wrong with the 595 either, since I checked with two other IC's too.

To triple check if I was doing anything wrong, I placed a delay between the pulling high of /EO and the updating of the TLC, which would shut down the LED for 400ms if working correctly. It does that, so everything's correctly wired for sure.

#include "Tlc5940.h"

#define LATCH 5    // GREEN  = WHITE
#define DATA  6    // BLUE   = ORANGE
#define CLOCK 7    // YELLOW = YELLOW

int dataArray[] = {0, 4000, 1500, 500, 10, 500, 1500, 4000};

void setup()
{
  Tlc.init();
  Tlc.clear();
  
  pinMode(LATCH, OUTPUT);
  pinMode(DATA, OUTPUT);
  pinMode(CLOCK, OUTPUT);
  pinMode(2, OUTPUT);
}

void loop()
{
  for(int i=0; i<8; i++)
  {    
    //shift data to TLC5940
    for(int n=0; n<16; n++)
      Tlc.set(n, dataArray[i]);

    //disable outputs of 595  
    digitalWrite(2, HIGH);
    
    delay(400); //This is the delay I was talking about
    
    Tlc.update();
    
    //shift data to 74HC595
    digitalWrite(LATCH, LOW);
    shiftOut(DATA, CLOCK, LSBFIRST, 1<<i);
    digitalWrite(LATCH, HIGH);
    
    //enable outputs of 595
    digitalWrite(2, LOW);
    
    //delay
    delay(400);
    //delay(1);
  }
}

Suggest changing things to gain clues to the problem. For example move the zero pwm value to a different 5940 output. Does the glitch follow?

PaulRB:
Suggest changing things to gain clues to the problem. For example move the zero pwm value to a different 5940 output. Does the glitch follow?

It somehow does, yet not completely.
I see the same thing happening on all other pins, yet not as bright and frequent as the first pin, it's still there though.
They all have this strange flickering, which seems random (with random I mean sometimes it does, sometimes not, but if it happens, it does so on the moment the 74HC595 pin of that column gets activated).
It almost seems like there's some voltage or current remainder of the previous led, since when I give the last led (the one right before the first one that has the worst glitch) a pwm value of 0, the glitch is way less present than with a value of e.g. 4000.
I tried placing resistors in parallel with each row for faster discharge, but that increases the glitch even more.

Ok, so what if you connect the led anodes directly to 5V and cathodes to the 5940, bypassing the 595?

What if you connect the anodes to the 595 and the cathodes direct to ground, bypassing the 5940?

Looking at your video again, the led anodes appear to be connected to the power rail (5V). Its not very clear what is connected to what. What is the 595 connected to?

Do you have decoupling caps (0.1uf) close to the power pins of both the 595 and 5940?

PaulRB:
Ok, so what if you connect the led anodes directly to 5V and cathodes to the 5940, bypassing the 595?

What if you connect the anodes to the 595 and the cathodes direct to ground, bypassing the 5940?

Both times it functions correctly, although with the 595 bypassed I only worked with one led, since I only made one row for now.

PaulRB:
Looking at your video again, the led anodes appear to be connected to the power rail (5V). Its not very clear what is connected to what. What is the 595 connected to?

I should have explained this better. They are connected to the common, but that's only because all the leds are placed in parallel to one input of the 5940. I scan each led, while all their cathodes to one common point that I connect to the input of the 5940, get it? I changed this a little though. In the video you'll see that all three legs of the leds are connected together. I changed this so only on led (the green one) of all the rgb leds are connected to the common, the other ones are left floating.

PaulRB:
Do you have decoupling caps (0.1uf) close to the power pins of both the 595 and 5940?

I had, but since that didn't change anything I removed them again. I can place them though if it would somehow still make a difference

I see, you were using the "power rail" on the breadboard as a common rail for the cathodes.

Always best to have those decoupling caps even if they don't seem to make a difference.

Do you have another 5940 to swap in?

Do you have some pnp transistors you could use to boost the current sourced by the 595 outputs? Wire them as emitter followers, i.e. base to 595 o/p with no series resistor, collector to +5V and emitter to the led anodes. BC337 would be a suggestion.

I'm running out of ideas to try now. Seems to be it might be something to do with the constant current sources in the 5940 but I don't know what. Its not like you are trying something no-one else has ever done. This configuration is probably used in RGB led cubes or to drive RGB led matrices.

Good luck!