TLC5940 + 74HC595 Multiplexing Bleed Effect [SOLVED]

I am doing simple multiplexing of 2x4 regular leds. 74HC595 source current (4 coloumns) , TLC 5940 sinks current (2 rows).
It works but there is a slight bleed effect, the schematics of TLC5940 are similar to Tutorial – Arduino and the TLC5940 PWM LED Driver IC | tronixstuff.com

and 74HC595 schematic has been changed to pins to 5,6,7 from arduino's tutorial.

Here is a test code I had written everything seems good, but there is slight bleed effect, and I want to rectify it as I am planning to control of 80 leds and I dont want this bleed effect to bigger problem later on.
Here is the video of my effect, can somebody correct me if I am doing anything wrong. Slowing the delay further or speeding hasnt changed much atall.

PS: No decoupling capactiors being used anywhere.

Here is the code:

#include "Tlc5940.h"

int latchPin = 6;
int clockPin = 5;
int dataPin = 7;

void setup()
{
 Tlc.init(0);
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(dataPin, OUTPUT);
}

void loop() 
{

// These values are for next cycle not current cycle
  Tlc.set(1, 4000); 
  Tlc.set(2, 0);
  digitalWrite(10, HIGH);
  digitalWrite(latchPin, LOW);
  int data = 4;
  shiftOut(dataPin , clockPin, MSBFIRST, data);
  digitalWrite(latchPin, HIGH);
  Tlc.update();
  digitalWrite(10, LOW);
  delayMicroseconds(1024);

  Tlc.set(1, 0);
  Tlc.set(2, 4000);
  digitalWrite(10, HIGH);
  digitalWrite(latchPin, LOW);
  data = 16;
  shiftOut(dataPin, clockPin, MSBFIRST, data);
  digitalWrite(latchPin, HIGH);
  Tlc.update();
  digitalWrite(10, LOW);
  delayMicroseconds(1024);
}

Any advice would be really helpful. Thanks

Hi, try shifting out zero to the '595 before you perform Tlc.update(), then shift out the required column/row bit afterwards.

What is pin 10 doing?

EDIT: ah, pin 10 is the BLANK signal to the tlc. Ignore my suggestion above then. You could give pin 10 a name in your code though!

Also get those caps in. Some experts on this forum won't lift a finger to help you until you have done that, they do not want to waste their time. 0.1uF near the power pins of each chip and a 100uF across the power rails anywhere in the circuit shoul be ok for now, but may need larger/more such caps when you add more leds.

Paul

I SOLVED it, the idea was to make sync 74HC595 and TLC5940 as close as possible.
(1) I connected a pull down resistor on every pin of 74HC595 to make sure pins are set to 0v as soon as you switch rows.
(2) Took pin 6, the xlatch pin of 74HC595 and connected straight to TLC5940. This ensures synchronization. The uncommented lines were when latchpin was connected to arduino directly. Once I connect the latch pin of 595 to 5940's latchpin, at the end of the latch pules 595 reads input value and 5940 for its value.

//digitalWrite(latchPin, LOW);
int data = 18;
shiftOut(dataPin, clockPin, MSBFIRST, data);
//digitalWrite(latchPin, HIGH);

(3) Write data to TLC5940 registers, but also wait till all the data has been transferred.

while(Tlc.update);

(4) Since they are sync so close, the delay between switching rows was set to delayMicroseconds(500);
Previously was using delay(1).
Took me lot of time to wrap my head around and spending time in the wrong way learning abt TLC5940. Got it working with just 74HC595 but wanted to do with TLC5940, was a bit more stubborn.

evolutionsdisaster
Could you give more detail about your solution

"Once I connect the latch pin of 595 to 5940's latchpin, at the end of the latch pules 595 reads input value and 5940 for its value"?

If the latch pin of the 595 is PHYSICALLY connect to the 5940's latch pin, how do the 2 chips separate the data since both are coming in on the same SIN? I see only 1 latch pin and one data line in your code. It's not clear to me how the 2 small code fragments fixed the bleed. We are they located in your program.

This bleed effect seems to be an on-going problem for many posters. If you can clarify the wiring and post your working code, I would appreciate it.

Sorry should have posted the entire code here,
And I do not know its the right solution, but according to my brain it was right. And the explanation is in next post.

#include "Tlc5940.h"

//int latchPin = 6;
int clockPin = 5;
int dataPin = 7;

void setup()
{
 Tlc.init(0);
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(dataPin, OUTPUT);
}

int row_value1;
int row_value2;
int row_value3;

int col_value1;
int col_value2;
int col_value3;
/*
r1 ======>  l0  ......... l1  ......... l2  .......... l3
r2 ======>  l4  ......... l5  ......... l6  .......... l7
r3 ======>  l8  ......... l9  ......... l10 .......... l11
r4 ======>  l12 ......... l13 ......... l14 .......... l15

want to turn on led10; row = index/width = 10/4  ;;;; 10%4 = 3  
*/

int data;
void SetRowValue(int r1, int r2,int r3,int r4)
{
  Tlc.set(1, r1);
  Tlc.set(2, r2);
  Tlc.set(3, r3);
  Tlc.set(4, r4);
}
void SetColValue(int data)
{
  //data = 30;
  digitalWrite(10, HIGH);
  shiftOut(dataPin, clockPin, MSBFIRST, data);
  
}
void loop() 
{
  SetRowValue(4000, 0, 0, 0);
  SetColValue(2);
  while(Tlc.update());
  digitalWrite(10, LOW);
  delayMicroseconds(500);
  SetRowValue(0, 4000, 0, 0);
  SetColValue(4);
  while(Tlc.update());
  digitalWrite(10, LOW);
  delayMicroseconds(500);
  SetRowValue(0, 0, 4000, 0);
  SetColValue(8);
  while(Tlc.update());
  digitalWrite(10, LOW);
  delayMicroseconds(500);
  SetRowValue(0, 0, 0, 4000);
  SetColValue(16);
  while(Tlc.update());
  digitalWrite(10, LOW);
  delayMicroseconds(500); 
}

Yes I physically connected the latch pins. Pin 12(XLAT) of 595 is connected to 5940's Latch Pin (12) which then is connected to the arduino Pin9. (under the hood tlc library initiates a pwm on this pin)

How the data is transferred ??
(1) I first set row values using simple shit function, it stays inside 74HC595's buffers until latch pin goes low.
(2) I set the values of the row ie to TLC5940, but did not push it to TLC5940 yet.
(3) The tlc.update() function updates the data registers of TLC5940.

This all is happening within one latch pulse, at the end of latch pulse is when they start writing to the pins.
(4) At the end I clear the buffer.

So the shift of the data is happening at different time instances on both the chip, but staying on them until the Latch Pin goes down and writing. When you use 595, you manually pull up and down its latch pin, but this is not helping in getting sync with 5940 whose latch pulse is connected to PWM pin of Arduino. Since row and coloumn data are being written on different chip, you have to ensure that they are in sync as close as possible.
If you are using only 595 for both rows and coloumns you wouldnt have worried about it as you connect the latch pin's of both of them and transfer data byte by byte and then when latch pin goes down data is transferred from the buffer's to the pin.

Let me know if its making any sense, my English grammatically sucks.