LED Matrix Questions

Sep 16, 2008 4 Replies

Hiya folks. I got into electronics mostly as a result of messing with digital components, so unfortunately I still find myself confused when it comes to various analog aspects of circuitry. So I was hoping someone could help me learn how this works a little better.



Basically, I thought about messing around with an LED matrix. Preferably small to start out with, like a 4x4. I was going to use a



74LS374 latch to control it, since a.) that's what I already have laying here, and b.) it's what I was going to use in a different project soon (one where I'd actually be addressing and writing to the latch in a microprocessor environment), and thought being able to operate LEDs with it would be a good test for that when the time comes (making sure my address decoding worked properly, etc). Anyway, I know that the LS series can't source much current. About 2.6ma for this part if I'm reading the datasheet right. But it can sink 24ma apparently.

The red LEDs I have apparently want 2v at 30ma to power them. A



100ohm resistor would get it down to 30ma if I did my math right (5v vcc minus 2v forward voltage of LED, divided by 0.030 amps). But now I'm confused on how many milliamps are going through such a circuit, even if it's just a simple vcc->resistor->led->gnd setup with nothing else in the mix. Is it just 30ma total? Or does the LED also have a resistance that one would combine with the resistor's value to calculate the amps of the whole circuit?

In the full LED matrix circuit, I'd be using NPN transistors from pins of the latch to control the voltage going to the rows of LEDs. But just to clarify, I'd have to be careful of what resistor I used on the pin coming from the chip to the base of the transistor, right? I'm assuming that current from the output pin of the IC would mingle with the current going across the collector and emitter from my power source, which could possibly result in too much current going through the LED and/or into the IC pin sinking the other end of the matrix.



I hate that my knowledge of analog electronics leaves me so baffled sometimes over seemingly simple concepts, but hopefully I'll be able to cram all of such knowledge into my head eventually!


First off, you probably need only 20mA on the LEDS - 30mA is the *max* on most LEDS, not the ideal. 20mA is probably plenty bright enough for you anyway. Read your specs again and be sure.

In a matrix, you normally activate one row/column at a time, and any LEDs in that row/column. Since the '374 can sink 24mA, use four of those to connect, say, each column to GND. For the rows, use a PNP or P-MOSFET transistor for each row, capable of passing 20*4 = 80mA, and drive the row that way. For the base resistor, you need to do some math, at least for PNP transistors...

The voltage across the resistor is Vcc - Vol - Vbe. Let's assume Vol is 0.3v and Vbe is 0.7v, leaving 4v across the resistor.

The Ice current is 80mA.

The base current Ibe is Ice / hFE. For example, if hFE is 100, Ibe =

0.080 / 100 = 800uA

The base resistor is then Vbe / Ibe, or 4 / 0.0008 = 5000 ohms maximum. I'd go with half that, or 2.2k or so, or even as low as 1k since the '374 can sink plenty of current.

For the LEDs themselves, you want resistors on the "drive each" edge (one per column, in this case), not the "drive row/column" edge. I.e. they go away from the transistors, or the columns in this case. That way, each resistor is only responsible for one LED at a time. Size the resistors for Vcc - Vol - Vce - Vled, which is probably about

5 - 0.3 - 0.1 - 2.0 or 2.6v. For 20mA, 2.6/0.02 = 130 ohms.

Note: size resistors based on the *largest* voltage you can calculate from the specs (i.e. smallest drop across each other device), not the average.

Also, size the *wattage* of the transistors big enough to handle Ice * Vce.

If you use a P-MOSFET the math is a little easier. No "base" resistor is needed, The "Vce" equivalent for math purposes is zero, just choose one with a big enough Ids for your current needs. The only catch is that the turn-on voltage is a bit higher than bipolar, so bipolar is better if Vcc is small enough. Wattage is less of a problem as Vds is so much smaller, check the specs.

The next thing to consider is that, if you're cycling through the rows fast enough, each LED is only on for 1/Nth of the time (or not on at all, of course). You can usually get away with higher currents in the LEDs and transistors since they're not on all the time.

Size the resistor wattages for the full load, though.

Here's an 8x8 raster module I made with two LEDs in each cell (red and green), with 16 resistors and the row lines on the back side:

formatting link
(or .html)

LED's are current driven devices, and the voltage drop changes with the current through it. See here:

formatting link

You don't "power a LED from 2V", you power a LED with X amount of current.

Depending on the LED, 30mA is most likely the absolute maximum current rating. Normally you would not go that high. Most ordinary LED's will work on anywhere from a few mA to say 20mA, with brightness that is fairly linear with current. With your particular LED you may find that it is plenty bright enough at say

5mA.

That is correct for a 5V supply.

The LED does not have any extra resistance, it's just the voltage drop for a given current. In the case you have given, assuming a 2V drop with a 5V supply, and

100ohms, the current will be 30mA.

Dave.

Yeah the "DC forward current" rating was in a box with max specs, it seems. So "forward voltage" is 2v but at 20mA, not 30, according to this. 3v max. But if I understand how LEDs work, the voltage isn't what's most important, it's the amps that affect brightness.

Why PNP transistors instead of NPN? Couldn't that lead to some potential problems at the start of the system? I mean, if the latch pins are all '0' by default, then wouldn't the PNP transistor would be active at startup and allow the current to pass into the LEDs by default?. As in, every row and column would be activated at once until the 4 output latch pins were set to '1'? If all four LEDs were active in a column at once, wouldn't the IC pin then be sinking too much current (the whole 80mA), possibly killing that pin or the whole IC?

What was the Vol, exactly?

Thanks for the response!

Yup, but if you don't have a current *regulator*, you end up using the voltage as well as current specs to figure out the load resistor.

So, if you know the LED drops about 2v at 20mA, you figure out what resistor passes 20mA at whatever voltage is left:

  1. Select operating current
  2. Look up voltage drop at that current
  3. Calculate voltage drop across resistor
  4. Choose resistor value according to voltage drop and desired current.

Because the '374 can sink 24mA but only source 2mA.

So, you can use the '374 to drive the GND side of the LEDs directly, but you need a transistor to drive the Vcc side.

Normally in an MCU-driven system, one of the first things you do is initialize all your I/O ports. Also, normally you'd tie nOE high to disable the outputs until the MCU overrides it. Besides, you shouldn't rely on ANY specific "safe" power-on state. Use the nOE pins to keep the outputs off until you latch in safe values.

Now that I think of it, though, the LS version has a Voh low enough that it might (will?) trigger the PNP transistors even when high. I'm used to using CMOS parts, where the output is symmetrical so it doesn't matter which way the transistors go. Try it and see.

Of course, you could use an NPN transistor to drive the PNP transistor. Or an open collector inverter/buffer.

With today's MCUs, the outputs tend to be CMOS so Voh is as close to VDD as Vol is to GND, and they default to High-Z on reset, so they're safe and more flexible.

V = voltage for logic LOW output OL

V = voltage for logic HIGH output OH

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required