Pages: [1]   Go Down
Author Topic: Common cathode 8 by 8 RGB Matrix w/ 74HC595 shift registers  (Read 2015 times)
0 Members and 1 Guest are viewing this topic.
Portland Oregon
Offline Offline
Newbie
*
Karma: 0
Posts: 32
Blink
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

I have been building an 8 by 8 Matrix of RGB LEDS using common cathode bulbs and 74HC595 shift registers.

I am posting my schematic below and asking is it going to be possible to individually address each led in this matrix as well as enable Pulse Width Modulation (PWM) ?  And if it is possible can anyone point me in the right direction?

As it stands now it is all soldered together and I can cycle through the rows that are each assigned to a pin on the 74HC595 but I can't figure out how to cycle through the columns or enable PWM.

I am using one shift register for each of the red, green, and blue anodes and then one shift register for the cathodes via 8 BC548 transistors.

I have been searching online for examples of RGB matrix using PWM but it is all common anode.  Any clues would be greatly appreciated.

Here is a preview image and below is a link to download the pdf of the whole matrix.



Here is a photo of the prototype so far.  If I can't use PWM with this design then I clearly left the breadboard stage to early.


Here is the code that lets me display solid colors and cycle through rows:
Code:

int latchPin = 8; // connect to pin 12 on the '595
int clockPin = 10; // connect to pin 11 on the '595
int dataPin = 9; // connect to pin 14 on the '595

byte data = 0;
int va[]={
1,2,4,8,16,32,64,128,255};

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

void loop() {
  rowMix();
  blinkAll_2Bytes(3,500);

}

void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
  int i=0;
  int pinState;
  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, OUTPUT);

  digitalWrite(myDataPin, 0);
  digitalWrite(myClockPin, 0);

  for (i=7; i>=0; i--)  {
    digitalWrite(myClockPin, 0);
    if ( myDataOut & (1<<i) ) {
      pinState= 1;
    }
    else {
      pinState= 0;
    }
    digitalWrite(myDataPin, pinState);
    digitalWrite(myClockPin, 1);
    digitalWrite(myDataPin, 0);
  }
  digitalWrite(myClockPin, 0);
}

void blinkAll_2Bytes(int n, int d) {

 
    //digitalWrite(latchPin, 0);
    //shiftOut(dataPin, clockPin, 255);
    //shiftOut(dataPin, clockPin, 255);
    //shiftOut(dataPin, clockPin, 255);
    //digitalWrite(latchPin, 1);
    //delay(500);
   
    digitalWrite(latchPin, 0);
    shiftOut(dataPin, clockPin, 255);
    shiftOut(dataPin, clockPin, 255);
    shiftOut(dataPin, clockPin, 0);
    shiftOut(dataPin, clockPin, 0);
    digitalWrite(latchPin, 1);
    delay(500);
   
    digitalWrite(latchPin, 0);
    shiftOut(dataPin, clockPin, 255);
    shiftOut(dataPin, clockPin, 0);
    shiftOut(dataPin, clockPin, 255);
    shiftOut(dataPin, clockPin, 0);
    digitalWrite(latchPin, 1);
    delay(500);
   
    digitalWrite(latchPin, 0);
    shiftOut(dataPin, clockPin, 255);
    shiftOut(dataPin, clockPin, 0);
    shiftOut(dataPin, clockPin, 0);
    shiftOut(dataPin, clockPin, 255);
    digitalWrite(latchPin, 1);
    delay(500);

}

void rowMix()
// warning! warning! blinkiness ahead!
  {
  for (int z=0; z<30; z++)
    {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, va[random(8)]); // cathodes
    shiftOut(dataPin, clockPin, MSBFIRST, va[random(8)]); // green
    shiftOut(dataPin, clockPin, MSBFIRST, va[random(8)]); // blue
    shiftOut(dataPin, clockPin, MSBFIRST, va[random(8)]); // red
    digitalWrite(latchPin, HIGH);
    delay(100);
    }
 
}




« Last Edit: April 15, 2011, 08:34:58 pm by freddyk » Logged

It would probably be safer to play with matches.

-------------------
http://www.unhingedfx.com
http://www.fredknack.com

Derby
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I can't immediately see a way that you'd control the columns. All the LEDs anodes in a row are connected together, as are their cathodes...
Logged

Portland Oregon
Offline Offline
Newbie
*
Karma: 0
Posts: 32
Blink
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Tomm

I was afraid of that.  I guess I am having problems wrapping my head around how this needs to be designed.  I thought there was some way to use a combination of the cathode 74HC595 w/ transistors and the RGB 74HC595 to access the columns.

So much to learn.  Great soldering practice though smiley
Logged

It would probably be safer to play with matches.

-------------------
http://www.unhingedfx.com
http://www.fredknack.com

"The old Europe"
Offline Offline
Edison Member
*
Karma: 1
Posts: 2005
Bootloaders suck!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sure your schematic is correct ?

Looks like common anode to me. The BC548 NPN transistors don't make sense the way they're wired up here (collector to GND, emitter to LED anodes).

I did pretty much what you want quite some time ago. The common anode vs. cathode thing can be accounted for in the PWM code by replacing "setbit" with "clearbit" and some other minor things, given that the hardware does what it should.

If you have a look at my demo code (via my blog, not the old forum posts), you will get the idea how to do PWM for your project. It's not efficient, but simple and it works well enough.

I also suggest to move away from the 595 shift registers and replace them with constant current led drivers + source driver chips (MBI5168 are cheap and work more or less the same way as the 595s + TLC59213 / UDN2981A). This will get you a lot more light and does away with 99% of the resistors.
Logged

• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

Portland Oregon
Offline Offline
Newbie
*
Karma: 0
Posts: 32
Blink
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks madworm

Common cathode is where all the LEDs share the ground right?

That is actually my very first schematic so I will have to double check to see if it is correct.   

I will take a look at your blog as well as those other chips.  I got my hands on a few TLC5940 so I will check to see if it is similar to what you have recommended.
Logged

It would probably be safer to play with matches.

-------------------
http://www.unhingedfx.com
http://www.fredknack.com

Derby
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think it's a fairly simple fix to make it so you can access individual LEDs. Rather than connecting the output of the transistors across LED rows, you want to connect them across columns.
Logged

Portland Oregon
Offline Offline
Newbie
*
Karma: 0
Posts: 32
Blink
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for that tip tomm!

I have been banging my head against this all day.  Your input has made me realize that I connected the cathodes along the rows in the same way I handled the anodes.  What I really needed to do was connect the cathodes along the columns.  This information should prove useful...

I will let you know how it goes.

Logged

It would probably be safer to play with matches.

-------------------
http://www.unhingedfx.com
http://www.fredknack.com

Portland Oregon
Offline Offline
Newbie
*
Karma: 0
Posts: 32
Blink
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks again tomm.  It worked.  HUGE hassle to rewire the soldered cathode wires but it was possible. 

I will update my schematic soon.
Logged

It would probably be safer to play with matches.

-------------------
http://www.unhingedfx.com
http://www.fredknack.com

Derby
Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Glad to hear smiley-grin
Logged

Portland Oregon
Offline Offline
Newbie
*
Karma: 0
Posts: 32
Blink
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is a preview image of the improved schematic:


Here is a link to a PDF of the schematic:
http://www.fredknack.com/Arduino/pdfs/IAStation-V2.pdf

I am still trying to figure out how to code it so I can really control the lights.  I am not even sure if I can use PWM with this setup. 

Code tips and pointers to improve this design would be appreciated.







Logged

It would probably be safer to play with matches.

-------------------
http://www.unhingedfx.com
http://www.fredknack.com

Pages: [1]   Go Up
Jump to: