21x16 Led Array Resistor Values Help

Thread Starter

Eric Kubischta

Joined Nov 22, 2014
21
Hello all. I am working on a design but am having trouble with the math calculations for selecting resistors.

My goal is to get the best refresh rate with little flickering and as bright of LED's as I can get.

The Project
21x16 LED BAR Array (21 rows, 16 columns) acting as VU Meters and driven by 5 74hc595 chips via an Arduino Mega.

Hardware Test
I have successfully tested my setup with 2 of the 16 columns operating. (and simulating the other 14 by writing out zeros to the shift registers)

Voltage
+5v from the Arduino

LED Bar Specs
Vf : 2.0V
Forward Current: 20mA
Max Forward Current: 100mA

The Columns (common cathodes)
Each column is looped through and turned on via 2 of the 74hc595 shift registers. Only one column on at a time.
Each column currently has a 2N3904 transistor and a 1.5K resistor at its base.
The software is looping through each column with a built in delay (D) of 510 Microseconds. I worked out this number by trying different values
My oscilliscope (if I am reading it correctly) is correctly showing roughly 0.5 Milliseconds for each column

The Rows (anodes)
Each row may have anywhere from 0 to 21 LED's lit
The leds "grow" from the bottom so they are all lit in succession creating a bargraph
The rows are turned on via 3 74hc595 shift registers
Each row has a 33Ohm resistor between the 74hc595 and the anode of the LED

My Questions:
1. How do I determine the best value for the row anode resistor ("Ra")?. I started with 220ohm but it was too dim, so I tried 33ohm. Much better but still a bit dim

2. How do I determine the best value for the common cathode resistor ("Rb") that is at the base of the transistor? - 1.5K was a guess based on some other similar designs.

3. What problems will I run into when connecting all 16 LED Bars that I may run into?

4. Is there an optimal value for my "delay" between each column lighting up?

Finally: If something goes wrong in my code, and a fault occurs and a column gets stuck "ON", how do I prevent the leds from burning out?

Schematics
I made up a few different versions - I hope these are helpful!!!

Closeup of 1 LED Bar and the resistors



Block Diagram



Full Crazy Big Schematic




Some Measurements I have taken
- 0.7mA : Between one anode resistor and it's LED - This seems small
- 0.11V: Between one anode resistor and it's LED - This seems small
- 0.4V: Between one cathode resistor and the 74HC595 pin

When ALL 21 leds are lit in a single column:
- 8.6mA - At the collector of the transistor to the common cathode
- 0.17V - At the collectorof the transistor to the common cathode

When only 1 led is lit in a single column
- 2.2mA - At the collector
- 0.36V - At the collector


Finally - My software setup
I am reading values from a digital audio workstation program on my computer (It's called "Reaper" - does what Pro Tools does). I am sending track VU data via USB Serial to the Arduino.
The arduino reads the values sent to it from the computer, and then writes them out to the shift registers via PWM

Psudocode:

void loop()
{

readTheUSBSerialData();
putSomeDataIntoArrays();

for(i=1;i<=16;i++)
{
writeShiftRegistersForColumn(i);
delayMicroseconds(510);
}

emptyAllShiftRegistersForColumnInCaseOfFreakout();
delayMicroseconds(510);


}


Thanks!
I hope I provided enough information and I appreciate any insights at all!

This is a personal project to add some digital VU meters to my home recording studio.
 

Art

Joined Sep 10, 2007
806
Why did you not go for 74HC164 non-latching shift registers?
They would be much faster if you only move LEDs up from the bottom, you wouldn’t have to latch them every time one LED changes.

EDIT... whoops.. I get you , they are being used at row & column drivers.
 

AnalogKid

Joined Aug 1, 2013
10,987
The 74hc595 datasheet fro NXP does not list the max continuous output current. It does spec the output voltage at around 7 mA, and for an HC part that sounds about right. That's not much, especially in a system with 16:1 multiplexing. With a 5 V system and 2 V LED Vf, a 33 ohm resistor is setting the current limit at 91 mA. That's a good value, but your driver chip cannot deliver it. Its absolute max current must be limited to 35 mA (datasheet). Bottom line, you need 21 row drivers. And, the column driver 2N3904 probably is undersized.

ak
 

takao21203

Joined Apr 28, 2012
3,702
You'd see leaving out or having 33R makes no difference at all.

These hc chips have equivalent impedance of approx 150R. The leds also wouldn't not bring down the outputs to zero like a short as long as their forward voltage is maintained.

The average current for LEDS is depending on how many multiplex phases.

Also generic small leds have approx 20 ohms internal impedance.

So there's a simple answer, no resistors are needed. You shouldn't have more than 4 or 5 phases or your leds are dim. Especially led bars don't use the best led chips except some recent kinds.

Led bars aren't designed for multiplex displays even if it is possible to show patterns on them. So if you have too many refresh phases you won't be able to see it properly in daylight.
 

Thread Starter

Eric Kubischta

Joined Nov 22, 2014
21
Ok thank you. Seems that there are a few approaches.

takao21203: I had sort of thought the same thing but was a bit scared to try it for fear of burning out the LED's. But, I guess as long as the code-loop doesn't get "stuck" on one of the columns - then everything would be OK - yes?

AnalogKid - If I changed it out to use transistors as drivers. I would go 5v into the emitter? - Then the collector to the LED? (or to a resistor and then to the LED?) - This would then, if I understand correctly, increase the amps going into each LED. Would I use the same 1.5K resistor on the base?

Pro's and con's between each approach?


Also - In order to ensure the LED's are not damaged in the event of a software fault. Is it worth implementing some sort of a hardware watchdog circuit such as the one described at this link?: (I would need to see if it is possible to make the watchdog timeout very fast..e.g. 500 milliseconds)

http://www.chrisramsay.co.uk/posts/2015/04/giving-an-arduino-a-heartbeat/
 

takao21203

Joined Apr 28, 2012
3,702
Leds wouldnt burn out.

If you use transistors you don't have the internal impedance anymore.

And consider digital mosfets for the cathode rails. Leds will be brighter.

There's a driver ic called tm1638. But it's not as well known as the serial input register latch.
 

AnalogKid

Joined Aug 1, 2013
10,987
These hc chips have equivalent impedance of approx 150R.

So there's a simple answer, no resistors are needed.
I disagree. The 595 is not designed for continuous operation into an overcurrent load. The effective internal impedance is not a true current limiting resistor, and is not designed for this application. By datasheet and calculation, the current limiting resistors should be 430 ohms minimum. This will make the LEDs dismally dim, indicating the need for row drivers.

ak
 

AnalogKid

Joined Aug 1, 2013
10,987
AnalogKid - If I changed it out to use transistors as drivers. I would go 5v into the emitter? - Then the collector to the LED? (or to a resistor and then to the LED?) - This would then, if I understand correctly, increase the amps going into each LED. Would I use the same 1.5K resistor on the base?
Yes, PNP row drivers connected the way you describe. Keep the base resistor. A 2N3906, 2N2907, 2N4403 will work fine since each driver is driving only 1 LED at a time.

With a true saturated switch at each end of the series string, the current limiting resistor is much easier to calculate. Watch the transistor power dissipation and the LED peak repetitive current. Both are called out on datasheets.

ak
 

takao21203

Joined Apr 28, 2012
3,702
I disagree. The 595 is not designed for continuous operation into an overcurrent load. The effective internal impedance is not a true current limiting resistor, and is not designed for this application. By datasheet and calculation, the current limiting resistors should be 430 ohms minimum. This will make the LEDs dismally dim, indicating the need for row drivers.

ak
1. The fact if it is an actually max. Current or actually delivered current isnt clear. Statements are vague.

2. The actually delivered power product is only half or less. Since the led forward voltage. It even increases with current. Chips remain cold as well, and total circuit current hints equivalent of some 5ma continuous led current equivalent.

Less with lower voltage.

You are not scaring me burning out a PIC driving a 7seg directly with a button cell.
It's not happening. Not even remote.

Besides I do have the tm1638 by now.

What's the use making 12 connections when you could connect 5 pins directly on the pcb adapter? Only need 7, roughly half the time

When you need to design a product use the ic if it makes you feel better.

You agree an led doesn't have zero ohms right?

So if it has 20 ohms that's a large resistance.

The best designs would saturate the inductor just above regular current. And so, leds have small chance burning out.

I had large toroid with banks of power leds. Some with voltage switchers some with nothing.

If all leds connect, voltage would go down a lot on the secondary side.

Think of old large crt televisions heating up a lot with power resistors inside.

You get the tuner on 1x1cm these days.
 
Last edited:

takao21203

Joined Apr 28, 2012
3,702
So, hahaha, I found instead of many resistors I could use a single choke.

I also use them to attenuate noise I get away with only a few 100uf electrolytic and small tantalum on each pic driving almost 100 leds at 18 mhz.

The supply itself fluctuates but signal lines are dampened or I get data corruption.

You don't want to solder resistors for 1000 leds then see a dim board then I do 16 bright levels for each led in c language with a 16f59.

Just saying.

I made a board with 74hc595 and resistors each. It was disappointing. 2006 maybe. Just not useful at all because it's so dim.
 

AnalogKid

Joined Aug 1, 2013
10,987
Seems like there is more than one way to skin a cat!
Maybe, but they are not all equal and most do not deserve discussion as if they are interchangeable, especially when a thread is opened with specific and general requirements and a schematic. Relying on undocumented operational parameters or operating a part outside its datasheet boundaries are not stable design practices.

ak
 

OBW0549

Joined Mar 2, 2015
3,566
Seems like there is more than one way to skin a cat!
Don't bet on it, especially if you need to get repeatable results in anything more than a one-off hobby-quality circuit.

For anything else, running LEDs without a series resistor is a stupid newbie frat move, and I'd fire any engineer who tried to design a commercial product that way. Yes, in theory you can drive an LED without ballast if you give it exactly the right voltage; but the V/I curves of LEDs vary not only from manufacturer to manufacturer, but from production lot to production lot within a single manufacturer and part number. One set of LEDs might give you exactly the brightness you need; but the next lot might be very dim and the lot after that might be extremely bright or even have a very short operating life-- or even burn out immediately.

As a general rule, don't EVER rely on semiconductor device characteristics alone to establish current levels.
 

Thread Starter

Eric Kubischta

Joined Nov 22, 2014
21
Ok - I think I am sort of starting to understand.

As a test - I took out the resistors, and then operated just one of the columns, and turned on just one of the LED's. My software turned it on and off at a rate of 0.5 Milliseconds (500 microseconds). So. 0.5ms ON..0.5ms OFF - repeat.

I measured the current between one of the output pins and the lit LED and got a value of 25ma

I then measured the current at the Vcc pin - same result: 25ma.

Does this mean that I am pulling 25ma through the chip? - Or, is the chip limiting the current down to 25ma somehow?

Now 25mA is too high for my LED's which want 20mA. So in the condition where only 1 single LED is lit across all 16 columns, I would end up with this value...I think. (which could happen if all 16 meters hit my "clip" level which turns on the CLIP led and then hit the end of the song with no volume)

Thanks - I am learning alot.

Eric
 

AnalogKid

Joined Aug 1, 2013
10,987
Does this mean that I am pulling 25ma through the chip? - Or, is the chip limiting the current down to 25ma somehow?
Yes and yes. When one of the output transistors in the chip turns on, it is not a perfect switch with zero ohms resistance like a light switch. The chip has enough internal impedance to limit the current available at its outputs, but that should not be counted on as the only current limiting impedance when designing an LED driver circuit unless the chip is specifically designed as an LED driver. A better way is to use a part designed to be a switch, followed by a part designed to be a resistor. More parts, more cost, more complexity - but way better performance, way better reliability, and - more brightness.

ak
 

John P

Joined Oct 14, 2008
2,025
You need to think about how this display will function.

With 16 columns, each LED can only be on 1/16 of the time. Set up a a single LED, or a few, and try driving them at that duty cycle with a transistor and a resistor and experiment until you see the brightness you want, then note what the instantaneous current is. Your column transistors must carry this much current times 21, so when you know what it is, you can select a transistor and the circuit that drives it. (The max current spec for the LEDs is 100mA--will this give you enough light, with a 1/16 duty cycle? It only averages out to 6.25mA.) You can already see that if you go anywhere close to the maximum instantaneous current of 100mA, your transistors will need to be much larger than 2N3904's. You need a power supply that can drive all this stuff, too.

The row transistors have an easier life, because they only have to drive one LED at a time. But an HC series chip won't do it.

I'd consider a protection circuit in case the processor freezes. Something that detects cycling of a strobe line, maybe?
 

takao21203

Joined Apr 28, 2012
3,702
Don't bet on it, especially if you need to get repeatable results in anything more than a one-off hobby-quality circuit.

For anything else, running LEDs without a series resistor is a stupid newbie frat move, and I'd fire any engineer who tried to design a commercial product that way. Yes, in theory you can drive an LED without ballast if you give it exactly the right voltage; but the V/I curves of LEDs vary not only from manufacturer to manufacturer, but from production lot to production lot within a single manufacturer and part number. One set of LEDs might give you exactly the brightness you need; but the next lot might be very dim and the lot after that might be extremely bright or even have a very short operating life-- or even burn out immediately.

As a general rule, don't EVER rely on semiconductor device characteristics alone to establish current levels.
Sounds like if you never actually tried.

No the currents and brightness don't vary all that much. I doubt what you describe would happen at all.

If you haven't observed it please refrain from guesswork.
 

Thread Starter

Eric Kubischta

Joined Nov 22, 2014
21
You need to think about how this display will function.

With 16 columns, each LED can only be on 1/16 of the time. Set up a a single LED, or a few, and try driving them at that duty cycle with a transistor and a resistor and experiment until you see the brightness you want, then note what the instantaneous current is. Your column transistors must carry this much current times 21, so when you know what it is, you can select a transistor and the circuit that drives it. (The max current spec for the LEDs is 100mA--will this give you enough light, with a 1/16 duty cycle? It only averages out to 6.25mA.) You can already see that if you go anywhere close to the maximum instantaneous current of 100mA, your transistors will need to be much larger than 2N3904's. You need a power supply that can drive all this stuff, too.

The row transistors have an easier life, because they only have to drive one LED at a time. But an HC series chip won't do it.

I'd consider a protection circuit in case the processor freezes. Something that detects cycling of a strobe line, maybe?

Thanks John. I have PNP for the columns, would I need NPN for the row drivers?

Also - For circuit protection, is there an IC or circuit that can be set to go "OFF" after some interval?

Say:

If( NoPulseReceivedIn500MS) then
switchOFF
else
stayON

I could then send pulses to the IC from the arduino during my loop, and if something freezes, no pulses, IC goes off and cuts power to the LEDS's

Just thinking outloud on some sort of protection mechanism.

Eric
 
Top