Leds glowing when multiplexing 10×11 LED matrix

74hc595arduino

int colum01 = B00000000;
int colum01d2 = B00000000;
int colum02 = B00000000;
int colum02d2 = B11111111;
int colum03 = B00000000;
int colum03d2 = B00000000;
int colum04 = B00000000;
int colum04d2 = B00000000;
int colum05 = B00000000;
int colum05d2 = B11111111;
int colum06 = B00000000;
int colum06d2 = B00000000;
int colum07 = B00000000;
int colum07d2 = B00000000;
int colum08 = B00000000;
int colum08d2 = B11111111;
int colum09 = B00000000;
int colum09d2 = B00000000;
int colum10 = B00000000;
int colum10d2 = B00000000;

//Port D = (digital pins 0 to 7)
//Port B = (digital pin 8 to 13)

const int datarowPin = 2;       // Port D2 
const int latchrowPin = 3;      // Port D3 
const int clockrowPin = 4;      // Port D4  
const int datacolumPin = 5;     // Port D5
const int latchcolumPin = 6;    // Port D6
const int clockcolumPin = 7;    // Port D7 
const int datacornerPin = 8;    // Port B0
const int latchcornerPin = 9;   // Port B1 
const int clockcornerPin = 10;  // Port B2
int rijtijdms = 1000;

void setup () {
    pinMode(datarowPin, OUTPUT);
    pinMode(latchrowPin, OUTPUT);
    pinMode(clockrowPin, OUTPUT);
    pinMode(datacolumPin, OUTPUT);
    pinMode(latchcolumPin, OUTPUT);
    pinMode(clockcolumPin, OUTPUT);
    // Alle registers leeg

    PORTD &= ~(1<<3); // Set latchrowPin low
    PORTD &= ~(1<<6); // Set latchcolumPin low
    // Datapins low
    PORTD &= ~(1<<2); // Set dataPin high
    PORTD &= ~(1<<5); // Set dataPin low
    // Clear registers
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD ^= 1<<7; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~(1<<7); // Set CLK low 
}

void loop () {
    //rij 1
    PORTD &= ~(1<<3); // Set latchrowPin low
    PORTD &= ~(1<<6); // Set latchcolumPin low
    //PORTB &= ~(1<<1); // Set latchcornerPin low
    // Kolommen
    ShiftOutColum(colum01);
    ShiftOutColum(colum01d2);
    // Rijen
    PORTD &= ~(1<<4); // Set CLK low
    PORTD |= 1<<2; // Set dataPin high
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD |= (1<<6); // Set latchcolumPin high
    PORTD |= (1<<3); // Set latchrowPin high
    delayMicroseconds(rijtijdms);
    //rij 2
    PORTD &= ~(1<<3); // Set latchrowPin low
    PORTD &= ~(1<<6); // Set latchcolumPin low
    // Kolommen
    ShiftOutColum(colum02);
    ShiftOutColum(colum02d2);
    // Rijen
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~1<<2; // Set dataPin low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD |= (1<<3); // Set latchrowPin high
    PORTD |= (1<<6); // Set latchcolumPin high
    delayMicroseconds(rijtijdms);
    //rij 3
    PORTD &= ~(1<<3); // Set latchrowPin low
    PORTD &= ~(1<<6); // Set latchcolumPin low
    PORTB &= ~(1<<1); // Set latchcornerPin low
    // Kolommen
    ShiftOutColum(colum03);
    ShiftOutColum(colum03d2);
    // Rijen
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~1<<2; // Set dataPin low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD |= (1<<3); // Set latchrowPin high
    PORTD |= (1<<6); // Set latchcolumPin high
    delayMicroseconds(rijtijdms);
    //rij 4
    PORTD &= ~(1<<3); // Set latchrowPin low
    PORTD &= ~(1<<6); // Set latchcolumPin low
    // Kolommen
    ShiftOutColum(colum04);
    ShiftOutColum(colum04d2);
    // Rijen
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~1<<2; // Set dataPin low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD |= (1<<3); // Set latchrowPin high
    PORTD |= (1<<6); // Set latchcolumPin high
    delayMicroseconds(rijtijdms);
    //rij 5
    PORTD &= ~(1<<3); // Set latchrowPin low
    PORTD &= ~(1<<6); // Set latchcolumPin low
    // Kolommen
    ShiftOutColum(colum05);
    ShiftOutColum(colum05d2);
    // Rijen
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~1<<2; // Set dataPin low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD |= (1<<3); // Set latchrowPin high
    PORTD |= (1<<6); // Set latchcolumPin high
    delayMicroseconds(rijtijdms);
    //rij 6
    PORTD &= ~(1<<3); // Set latchrowPin low
    PORTD &= ~(1<<6); // Set latchcolumPin low
    // Kolommen
    ShiftOutColum(colum06);
    ShiftOutColum(colum06d2);
    // Rijen
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~1<<2; // Set dataPin low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD |= (1<<3); // Set latchrowPin high
    PORTD |= (1<<6); // Set latchcolumPin high
    delayMicroseconds(rijtijdms);
    //rij 7
    PORTD &= ~(1<<3); // Set latchrowPin low
    PORTD &= ~(1<<6); // Set latchcolumPin low
    // Kolommen
    ShiftOutColum(colum07);
    ShiftOutColum(colum07d2);
    // Rijen
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~1<<2; // Set dataPin low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD |= (1<<3); // Set latchrowPin high
    PORTD |= (1<<6); // Set latchcolumPin high
    delayMicroseconds(rijtijdms);
    //rij 8
    PORTD &= ~(1<<3); // Set latchrowPin low
    PORTD &= ~(1<<6); // Set latchcolumPin low
    // Kolommen
    ShiftOutColum(colum08);
    ShiftOutColum(colum08d2);
    // Rijen
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~1<<2; // Set dataPin low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD |= (1<<3); // Set latchrowPin high
    PORTD |= (1<<6); // Set latchcolumPin high
    delayMicroseconds(rijtijdms);
    //rij 9
    PORTD &= ~(1<<3); // Set latchrowPin low
    PORTD &= ~(1<<6); // Set latchcolumPin low
    // Kolommen
    ShiftOutColum(colum09);
    ShiftOutColum(colum09d2);
    // Rijen
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~1<<2; // Set dataPin low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD |= (1<<3); // Set latchrowPin high
    PORTD |= (1<<6); // Set latchcolumPin high
    delayMicroseconds(rijtijdms);
    //rij 10
    PORTD &= ~(1<<3); // Set latchrowPin low
    PORTD &= ~(1<<6); // Set latchcolumPin low
    // Kolommen
    ShiftOutColum(colum10);
    ShiftOutColum(colum10d2);
    // Rijen
    PORTD &= ~(1<<4); // Set CLK low
    PORTD &= ~1<<2; // Set dataPin low
    PORTD ^= 1<<4; // Toggle CLK port high
    PORTD &= ~(1<<4); // Set CLK low
    PORTD |= (1<<3); // Set latchrowPin high
    PORTD |= (1<<6); // Set latchcolumPin high
    delayMicroseconds(rijtijdms);
    PORTD &= ~(1<<3); // Set latchrowPin low
    PORTD &= ~(1<<6); // Set latchcolumPin low
    }

void ShiftOutColum(int data){
PORTD &= ~(1<<7); // Set CLK low

 for(int i = 0; i < 8; i++) {// step from bit 0 to 7
   if ((data >> i) & 0x1 == 1) {//// Check the content of this data bit
      PORTD |= 1<<5; //Set bit high
   }
   else {
      PORTD &= ~(1<<5); //Set bit low    
   }
   PORTD ^= 1<<7; // Toggle CLK port high
   PORTD ^= 1<<7; // Toggle CLK port low 
 }
}

void ShiftOutRow(int data){
PORTD &= ~(1<<4); // Set CLK low

 for(int i = 0; i < 8; i++) {// step from bit 0 to 15
   if ((data >> i) & 0x1 == 1) {//// Check the content of this data bit
      PORTD |= 1<<2; //Set bit high
   }
   else {
      PORTD &= ~(1<<2); //Set bit low    
   }
   PORTD ^= 1<<4; // Toggle CLK port high
   PORTD ^= 1<<4; // Toggle CLK port low    
 }
}

The project:
It s supposed to be be a clock that displays the actual time words. This type of clock is available on the internet. Many may know it.

The setup:
The system consists of an 11 colum by 10 row system of 5050 LEDS. So each LED has 3 emitting diodes in it.
Each row is switched on/off by an BD135 transistor. Each colum is switched of by an BC547 transistor. All transistors (21 in total) are switched by 4 74HC595 IC's.
In each colum there is a potentiometer to adjust brightness of the LEDS. The power source is a small power.
The shiftregisters are filled by an arduino UNO.
Please find the attached schematic

The program:

  1. The pogram first fills the colums with data (for the first row).
  2. Then switches on the first row.
  3. Delay of 1 ms.
  4. Switch of rows and colums
  5. Fill colums with data (for second row).
  6. Switch on second row
  7. Delay, and so on

For test puroses I made a program that is supposed to show only the first 8 LEDS (colums) of the 2nd, 5th and 8th row (program above).

The problem:
The first 8 colums of the 2nd, 5th and 8th row are indeed lighting up bright. However the first 8 LEDS of the 1st, 3rd and 7th row are also lighting up faintly (glowing). The same happens to the last 3 LEDS (colums) of the 2nd, 5th and 8th row, but a littlebit brighter. This is an unwanted effect as it will destroy the eventual performance of the clock. Only the LEDS that I want to light up should light up.

I read this Learning Multiplexing with LEDs, transistor switching speeds thread, but I do seem to have the opposite. The row before the one that is actually lit is glowing. Any help is highly appreciated.

My schematic:
schematic

Best Answer

The normal cause of this is that you don't turn off the matrix completely when switching between rows/cols. Even though you switch quickly, the LEDs are on just long enough to cause some bleed-over or ghosting. Do this:

  1. Turn the matrix completely off.
  2. Configure for the next row.
  3. Turn the matrix on.
  4. Wait.
  5. Go to step 1 and do it again for the next row.

Now, how you turn it off is dependent on your circuit (which you didn't post). But it appears that you have a single transistor for each row. So step 1 would be to turn all rows off, and step 3 would be to turn only the current row on.