0
\$\begingroup\$
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

\$\endgroup\$
  • 1
    \$\begingroup\$ If you had all (say) column 3 glowing and nothing intentionally glowing in any other columns can you describe the residual erroneous glow in the other columns. For instance does all of column 2 have a dim glow? Ditto column 4? Is col 2 and col 4 same dim intensity to the eye. Is column 1 showing any glow? Is it the same as column 2 or 4. Ditto column 5 and rest of columns. Do you get the same effect when row 3 is exclusively lit? This time think about adjacent rows. \$\endgroup\$ – Andy aka Jun 13 '13 at 21:22
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ I intended to post a JPG of my schematics but i wasn't allowed to do that. I don't know how to post it here. Manually drawing it is a bit labourious as the schematic is quite extended. I will try new coding this evening. \$\endgroup\$ – S. Huitema Jun 14 '13 at 6:15
  • \$\begingroup\$ I added the schematics! \$\endgroup\$ – S. Huitema Jun 14 '13 at 17:32
  • \$\begingroup\$ A lot of the problems solved!! \$\endgroup\$ – S. Huitema Jun 14 '13 at 20:50
  • \$\begingroup\$ What i did:1) Add scottky diodes on the bd135 diodes (10) as described in the linked article. That solved the problem of the previous row that was glowing.2) Add some 0,1uF capacitors between 5V and ground around the 74hc595. The problem that remains is that some unpowered LEDS are flickering faintly during normal operaton. This problem is solved when the print with all components is slighty twisted. Also pressing on the 74HC595 seems to solve the flickering. All solderings seem ok. Does this mean the sockets for he IC's are faulty? Can I do anything about this? \$\endgroup\$ – S. Huitema Jun 14 '13 at 20:59
1
\$\begingroup\$

I have had the students do multiplexing in my class. They often experienced 'ghosting'. The cause was always not disabling the column before changing the row data. (row can column can of course be exchanged).

You say:

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

Are you very very sure about 4) switch of rows?

\$\endgroup\$
  • \$\begingroup\$ My codes works like:1) Set latchpins of rows and colums low, 2) Shift new data in the colums, shift row registers one position higher (next row), 3) Set latchpins of rows and colums high, 4) Delay, 5) Next row. So I think I do just that. \$\endgroup\$ – S. Huitema Jun 14 '13 at 6:17
  • \$\begingroup\$ Sounds OK. (see andy aka's question): is there any pattern in the ghosting? And we realy need your circuit diagram. How are the 595 shift clocks wired? Best is from last to first. \$\endgroup\$ – Wouter van Ooijen Jun 14 '13 at 7:41
  • \$\begingroup\$ Do you have suggestions how to upload the schematics? As said before, I'm not allowed to upload JPG files (yet). Is there another way of uploading files? \$\endgroup\$ – S. Huitema Jun 14 '13 at 8:39
  • \$\begingroup\$ @S.Huitema: Just upload your JPG to a public file server then edit your Q to contain a URL to that image. Some kind person will then edit the image into your Q for you. \$\endgroup\$ – RedGrittyBrick Jun 14 '13 at 9:07
  • \$\begingroup\$ I added the schematics. \$\endgroup\$ – S. Huitema Jun 14 '13 at 17:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.