# Understanding the components of a LED matrix

I'm looking into making an 8x8 LED matrix. My eyes are almost burning from the amount of googling I've been doing. The most common parts that pop up all the time are the 74HC595 and the ULN2803A. The biggest hurdle is dealing with the current drain. Taking a look at this tutorial for the 74HC595 (http://arduino.cc/en/Tutorial/ShiftOut), I've realized that powering all 8 LEDs with only 220 ohm resistors would be far over the limit of the chip, which appears to be a maximum of ±70mA (http://www.sparkfun.com/datasheets/IC/SN74HC595.pdf). In a row-scanning matrix, the ULN2803A can sink 8 LEDs worth of current on a single pin, but it can handle 500mA, so that's fine (http://www.sparkfun.com/datasheets/IC/uln2803a.pdf). However, if each LED in the row is on, the 74HC595 still has to source 8 LEDs, 1 per pin. Why don't I see any examples or tutorials using a bunch of PNP transistors (differences to MOSFETS?) between the shift register and the LEDs to handle the current? Apologies for the noob questions. I'm trying to determine if I need to order a bunch of transistors to make my matrix. Thanks for any help!

What chip(s) you need depend on what you want.
Are you talking about a 8x8 RGB, bi-colour or single colour matrix?
Do you need to dim individual LED’s within the matrix or whole matrix dimming with simple LED on/off?

Why don’t I see any examples or tutorials using a bunch of PNP transistors (differences to MOSFETS?) between the shift register and the LEDs to handle the current?

Two reasons:-

1. Depending on how you scan the matrix you might have a ULN2803A sinking 8 LEDs but only one pin sourcing the current for one LED at at time. As described here:-
Arduino Workshop

2. There are a lot of moron tutorials out there. Some don’t even use resistors to limit the current in the mistaken belief that because it is multiplexing there is no need to. This is wrong. See:- LEDs

That is quite a helpful tutorial! However I still don't understand how you'd only ever source or sink 1 led as a worst case. Wouldn't the worst case be that each chip could be handling 8 LEDs, just one is per pin, and the other is a single pin? Take the last line in the row-scan example: each LED in the row is lit. That's 8x20mA sourced on a single pin (the walking bit), and 20mA sinking on each column. If those were connected straight to the arduino, wouldn't that be a dangerous 160mA? I feel like I'm misunderstanding some fundamental step here :~

This will be a single color matrix with no dimming for clarification.

M4573R: This will be a single color matrix with no dimming for clarification.

Then have a look at this article http://playground.arduino.cc//Main/MAX72XXHardware You cannot get much simpler than using a MAX7219 as it takes care of all the row/column scanning for you and only needs a single resistor to set current limiting. They are cheap to buy on ebay and so simple to use I made this http://arduino.cc/forum/index.php/topic,118338.0.html as my first arduino project.

That’s 8x20mA sourced on a single pin (the walking bit), and 20mA sinking on each column.

No it is the walking bit that needs the help in sourcing or sinking the current. So 20mA sinking is fine but 8X20mA sourcing needs extra help.
Normally on an arduino you can choose if you want to supplement the sourcing or sinking capacity. Then the way it is scanned is chosen so that the low capacity current pin only carry the current for one LED.

If those were connected straight to the arduino,

Yes so don’t.

Technically, you can make a single color 8x8 matrix without any ics. You use 16 arduino pins, 8 resistors, and 64 LEDs. I've made a 64 LED cube (4x4x4) with 64 LEDs, 4 resistors (16 resistors works better), wire, solder, and an arduino.

You can also do this with charliplexing, You could even do this with RGB LEDs if you use charlieplexing. Check out asher glicks charliecube. http://aglick.com/charliecube.html Im working on doing some documentation for this, he shows you what you need to accomplish, but not so much about how to get there, and its a bit tricky. Technically, this design should be doing damage to something Im unclear on weather its the LEDs or microcontriller at risk, but I've been running them over a month, without failure, and no appreciable differences in brightness or color, or speed.

If you really want to use shift registers, then you should check out ShiftPWM: http://www.elcojacobs.com/using-shiftpwm-to-control-rgb-leds-with-arduino/

I made a few examples that ran straight off the arduinos 5v pin, plugged into a 5v USB phone charger (about 500mA), I only ran them for a couple days, and technically its probably too much current for the arduino, so it may be doing some kind of damage.

Have you considered constant current drivers? They make chips just for controlling many LEDs, it makes things a lot easier, less stuff to deal with, less stuff to screw up, and tidier too.

If you want more examples of people using multiplexing with transistors, also check out cubes, and LED strips. Here Ladyada is using Mosfets and Darlingtons to power strips. http://learn.adafruit.com/rgb-led-strips/usage

Im still trying to figure out sinking and sourcing to my 2 other cube setups (one with shift registers, one with constant current driver), but I've been busy with other things. The charliecube was a lot of work soldering, but I had it working within a week, my other cubes are still not finished, and I started them over a month ago.

Grumpy_Mike: No it is the walking bit that needs the help in sourcing or sinking the current. So 20mA sinking is fine but 8X20mA sourcing needs extra help.

What I'm trying to get at is that I can't source OR sink with a 74HC595 since 8x20mA on one pin is too much, and 20mA on 8 pins is also too much. I'm completely new to this, so if I am not understanding some fundamental rules of current flow, I apologize.

Hippynerd: Technically, this design should be doing damage to something Im unclear on weather its the LEDs or microcontriller at risk, but I've been running them over a month, without failure, and no appreciable differences in brightness or color, or speed.

That is a bit settling, but it's what I'm trying to avoid, hehe.

20mA on 8 pins is also too much.

It isn't too much unless you are building for NASA.

In that case, you can add a swich (npn/pnp, depending on your design) on the 595's output.

dhenry:

20mA on 8 pins is also too much.

It isn't too much unless you are building for NASA.

In that case, you can add a swich (npn/pnp, depending on your design) on the 595's output.

The 595 is listed as 70mA max current across the chip, how long should I expect it to last?

At 20ma/pin, it will outlast all of us, by a few multiples.

dhenry: At 20ma/pin, it will outlast all of us, by a few multiples.

To be clear, we're talking 20mA per pin on all 8 pins at once, double the chips rated current. If that's true, I could use the 595's and a 2083 to even extend this to a 4x4x4 or 8x8x8!

If that's true,

You can easily try it.

dhenry:

If that's true,

You can easily try it.

I can try a lot of things! But I'd like to save my wallet from burning through chips and my mind by saving hours of debugging related to things like this.

Since you are talking about an 8x8 multiplex, thats a total of 16 control lines, you can do that with just resistors and LEDs, multiplexing is good enough.

If you want to reduce your control lines you can do that by serializing the data, but with this size you are not saving a lot, unless you serialize both at the same time (16 pins to 3 pins, vs 16 pins to 6 pins). It seems like you should be able to use 2 shift registers (one for source, one for sink).

Since you will only have 1 row on at a time, you have a 12% Duty cycle, so they may not be as bright as if you just have them on. If you want them as bright as each one can be, then you could serialize all the anodes or cathodes to 64 pins through 8 shift registers and 64 resistors. You can then have 100% duty cycle.

If you wanted do 100% duty cycle, but didnt want to do the resistors, you could use constant current drivers, heck, you may even be able to find a single chip to solve that.

The ShiftPWM demo runs 3 shift registers to 24 resistors to 8 RGB LEDs (thats 3 diodes per LED). Its sinking or sourcing up to 480mA through 3 70mA devices. So, in theory, it could source or sink 480 through something rated for 210 or about 225% of its rating. I personally have only run it for a few days, but I had no problems, It theoretically could be doing damage, but I dont know how long it takes to fail, days, weeks, years, its hard to say.

The charliecubes I have running over a month are pretty crazy, thats 192 LEDs running on an arduino, with no other parts. Its just crazy, thats almost 4 amps if the leds were fully driven at 20mA each (64 RGB LEDs = 192 LEDs @ 20mA each= 3840. This all runs from a single arduino, on a 500mA usb power supply, so there is no way its using 3840mA.

What have you tried?

But I'd like to...

The other option is to wonder.

You can use PNP transistorst to drive the anodes like this.
Or, skip the PNP, and use high brightness LEDs (6000-8000mCD) with 8-10mA from the 74HC595.
Or, skip both and drive the Anodes with 20mA direct from the Arduino, and spread the current over a couple of ports to not overstress any one port:

“3. Although each I/O port can source more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state
conditions (non-transient), the following must be observed:
ATmega48A/PA/88A/PA/168A/PA/328/P:
1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150mA.
2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150mA.
If IIOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current
greater than the listed test condition.”

Thanks Crossroads! That's looking exactly like what I'm after!