Go Down

Topic: Advice on a 8x8 RGB matrix, TLC5940 (Read 5724 times) previous topic - next topic

vivo

Hi all.
I am currently in the analysis and design phase of my RGB matrix. What I want to do is to drive 64 (8 x 8 ) common anode LEDs with 256 shades of each colour.
I have already ordered an Arduino Uno, 5 x TCL5940 and 100 x RGB CA LEDs. I also modified an ATX power supply, so I have access to 3.3V, 5V and 12V capped at 10A each by a resettable fuse.

I already got the theory of multiplexing, but I would like your advice on the way the matrix is updated.
                                                   1  2  3    (cathodes connected vertically)
A  (anodes connected horizontally) |__|__|__|
B                                                 |__|__|__|
C                                                 |__|__|__|

Idea 1:
Turn on a row, then light LEDs on the row one after the other.
Pseudo code:
A <-- ON
A1 <-- ON
A1 <-- OFF
A2 <-- ON
A2 <-- OFF
A3 <-- ON
A3 <-- OFF
A <-- OFF
B <-- ON //and so on

Advantages:
--TCL5940 can drive them directly as the current will be 60mA MAX on the anode, and 20mA on each cathode (I probably need a transistor for the anode, but not sure which one)
Disadvantages:
--Dimmer LEDs
--More and slower code

Idea 2:
Turn on a row and control all LEDs on the row at the same time.
Pseudo code:
A <-- ON
A1, A2, A3 <-- ON
A1,A2,A3 <-- OFF
A <-- OFF
B <-- ON //and so on

Advantages:
--Slightly less and probably faster code
--Brighter LEDs
Disadvantages:
--Current: 480mA on the anode and 160mA on the cathodes, both over the specs of the TLC5940
--Need current sink device on the cathodes


Which idea do you think is better?
Also how do I use a transistor with the anode? NPN? PNP?
With the cathodes?
Could someone quickly explain on how to wire a transistor with the cathode and anode, so it can be switched from the TLC5940?

I am sorry for the silly questions, but I am just starting out with electronics and due to my VERY limited budget can't afford any smoking mistakes.
Thank you all.



Grumpy_Mike

Quote
Could someone quickly explain on how to wire a transistor with the cathode and anode, so it can be switched from the TLC5940?

A small 4 by 4 RGB matrix is featured in this project:=
http://www.thebox.myzen.co.uk/Hardware/Mini_Monome.html
It uses multiplexing to drive more LEDs
You can extend this to an 8 X 8 RGB driver by chaining two more TLC5940s

Quote
Also how do I use a transistor with the anode? NPN? PNP?

PNP or better yet p-channel FETs

For general multiplexing see:-
http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html

vivo

The ordered parts finally started to arrive. Still waiting for the TCL5940's though.

I have written some code, which allows me to drive a M x N matrix. It does NOT yet truly support matrices of arbitrary sizes as I am limited to a 2 x 2 matrix from the arduino pins due to the 40mA current limit per pin.

Quote

byte row[] = {2,3};//Pins used for the rows. NO PWM needed. MUST be byte type, sizeof is used in the code
byte col[] = {11,10};//Pins used for the columns. PWM would be needed for grayscale values. MUST be byte type, sizeof is used in the code
boolean row_active_high = true; //Whether the row is active (passing current) on HIGH(5V) or on LOW(0V)
boolean col_active_high = false; //Same as above, but for the columns

byte frame[(sizeof(row) * sizeof(col))]; //Allows future use of grayscale values through PWM, but too much flicker using Arduino PWM.

void setup() //TODO Add support for matrices of any size
{
  Serial.begin(115200);
  for (int i=0; i<sizeof(row); i++)
  {
   pinMode(row, OUTPUT);
  digitalWrite(row, LOW); // TODO add check for active state
  }
  for (int i=0; i<sizeof(col); i++)
  {
   pinMode(col, OUTPUT);
  digitalWrite(col, HIGH); // TODO add check for active state
  }
}

//Loop for an MxN matrix, 1 byte per LED
void loop()
{
  if (Serial.available() >= sizeof(frame))
  {
    Serial.println("Got frame...");
    processFrame();
    do
    {
      multiplexFrame();
    }while (Serial.available() < sizeof(frame));
  }
}

void multiplexFrame()
{
  int f = 0;
  for (int i=0; i<sizeof(row); i++)
  {
    digitalWrite(row, row_active_high); //row ACTIVE
    
    for (int j=0; j<sizeof(col); j++)//Turn on the required LEDs on the row
    {
     //TOO MUCH FLICKER analogWrite(col[j], col_active_high ? frame[f] : 255 - frame[f]);  //col[j] STATE = frame[f] VALUE
     digitalWrite(col[j], col_active_high ? bitRead(frame[f], 0) : !bitRead(frame[f], 0));
     f++;
    }
    //delay(5);
    for (int j=0; j<sizeof(col); j++)// Turn off all LEDs on the row
    {
     digitalWrite(col[j], !col_active_high); //col[j] INACTIVE
    }
    
    digitalWrite(row, !row_active_high); //row INACTIVE
    
  }
}

void processFrame()
{
 int f = 0;
 for (int i=0; i<sizeof(row); i++)
  {
   for (int j=0; j<sizeof(col); j++)
   {
    frame[f] = Serial.read();
    f++; 
   }
  } 
}

[/size]

Please note that the code ONLY works for the arduino pins, but will be updated once I receive the TCL5940s'.
I have also DISABLED PWM, because I was gettings too much flicker. Hopefully the TCLs' higher frequencies will fix that. Right now, each LED still gets its own byte, but only the least significant bit is used. If anyone has better luck with PWM, just uncomment the line in the 'multiplexFrame' method and comment the one below it.

Any feedback on the code is more than welcome.

I can in theory drive a 6x6 matrix with the arduino (no PWM), but I haven't ordered any PNP transistors and therefore limited by current limit per pin.
Can anyone recommend a PNP transistor for sourcing current (minimum 0.5A (25 leds in a row at 20mA each in an 8 x 25)) ? I am planning on using the TLCs to switch the rows and columns. I believe the TLCs will be able to sink the current, as only 1 LED will be on per column and the pins are rated up to 120mA.

Also how do I wire the PNP transistors for sourcing current? Emitter to 5V power supply, collector to LED anode, base with resistor to TCL pin? What value should the resistor have?


vivo

#3
Oct 24, 2011, 12:17 am Last Edit: Oct 24, 2011, 12:29 am by vivo Reason: 1
I have ordered 50 2n2907 PNP transistors. Could someone advice me on the value of the base resistor going to the TLC5940 pin? Each transistor will be used to power a row of 8 * 3 LEDs at ~20mA each.

Do you think I can control the rows (anodes) with a TCL5940, or should I buy some 74HC595 shift registers?

Can I use the PNP arrangement shown on the link below? 4k7 from 5V to base and 2k7 from base to pin.
http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html

Grumpy_Mike

Quote
Can I use the PNP arrangement shown on the link below?

I would use something better. That has only 0.6A maximum current and you are wanting to drive them at 3 * 8 * 20 = 480mA, it is a bit too close to the maximum for comfit. Also the gain is low at those sorts of currents only 30, that means you have to supply 16mA into the base which means a 260R base resistor  (4.3 / 16mA)

vivo

Can you suggest any other PNP transistors, which would be more suitable to the job?

Grumpy_Mike

You would be better off using a p-channel logic level FET like the TCP6108

vivo

I tried on eBay and on all of the Global and UK electronics shops from http://arduino.cc/en/Main/Buy , but a search on TCP6108 gave me nothing. Google was kind enough to suggest the TCP protocol and port 6108.


vivo

The link unfortunately points to SMD devices only, and  I was planning to use a stripboard as I am with a limited budget.
Is there a way I can wire up two or more PNP transistors together, so they share the current, or am I just day-dreaming?

Grumpy_Mike

Quote
The link unfortunately points to SMD devices only,

You can use these SMD devices on strip board. See the mini monome project for a photo of how:-

Grumpy_Mike

There is not a lot to choose between them but if pushed I would go for the 6401. But either would do.

vivo

I went ahead and ordered 10 pcs  of 6401. However I ordered them from eBay as it was much cheaper AND because there was a minimum order of £20 on Farnell.
Now I just need to wait for a couple of weeks for them to arrive, probably with the rest of my items.

Thank you, Mike, for helping out a complete n00b. I just got hooked up into electronics and I learn everything as I go along.
After a bit of thinking today, I decided to scrap the 8x8 RGB matrix idea and use the LEDs to make clever lighting for my fish tank. An 8x8 RGB matrix might be cool, but it is not very useful.  
This topic will not go to waste however...
I decided on making an 8 x 25 Blue LED matrix using the same principles from above, which will be connected to the computer and show various things like time, weather, messages, notifications etc. I will also try to make the design such that I could easily expand it in the future.

Go Up