# How to power 24 7-segment displays with Arduino?

I'm working on an Arduino project where I need to power 24 7-segment displays (model Kingbright SC56-11YWA).

I decided to control them using 8 bit shift registers (model 74LS164N). This is working fine for one prototype. But already I notice that the segments are brighter when there are only two lit up as opposed to all 7.

Will an Arduino (Mega) be able to handle this when I connect all 24? Or is it OK if I use an external 5 V power source (converted from AC) for all the shift registers?

There's a 220 ohm (around that number) resistor connected at the 7 segment GND. I suppose decreasing that number or eventually omitting the resistor, would also do something, but maybe not enough for 24 of them.

I hope my question is clear.

-

## 5 Answers

You should be able to drive this very easily with nothing but the Arduino mega and 8 resistors, so you don't necessarily need 24(!) shift registers. You won't be driving all of them at once, you'll be driving one of them at a time. But it will be the simplest to build and take no extra chips. In all you'll probably need 32 of your pins, but the mega has no shortage of pins.

Remember that each of the IO pins are tristate. Putting them into input mode puts them into high impedance mode, which is like putting a very high value resistor on that pin, essentially removing its effect from the circuit. By wiring each of the common cathode pins to IO pins and setting all of them to input, you can then set single pins to output low (connecting it to ground) and drive single digits at a time. Then all you need is a timer and cycle through each of the digits.

The only thing to consider here is how much current you're sourcing and sinking through the MCU. But for only 8 LEDs at a time, I think it should be OK, depending on how much current they like and what else you're powering with the MCU. I tend to go for designs with less external components, so this is the solution that appeals to me.

Also, the others are right in saying that a single current limiting resistor on the cathode is not sufficient. Your brightness problem is either related to this, or the amount of current your shift registers can source.

-
Wait a minute, how do I address the individual pins of the 7 segment displays in your scenario, if only the common cathode pins are connected? Where do I connect that second single pin? Also, this will be for a piece of furniture which already has an electrical circuit, so drawing from an external power source isn't a problem. So I'm also wondering, what if I just do it like my original plan, power them all with shift registers and no multiplexing, but making sure the external current I give to the shift registers has enough ampere? Given that I can draw it from AC, I can provide 3.4A – Dyte May 10 '12 at 8:10
Oh, okay, I get it, the 7 extra pins are connected to all of the 7 segments and changing the state of the cathode pin selects which one you're powering. This powers 7 leds any given time, why would I need a peak for that, @stevenh? – Dyte May 10 '12 at 8:37
He might be right about the peak current, but I've done similar things before with no trouble, though not on this scale. But now that I think of it, the segments will be lit at 1/24th duty cycle, so they might be pretty dim. If possible, 2 or more multiplexing groups can be used. – UziMonkey May 10 '12 at 16:42
Typical peak current via Vcc or GND on an AVR is ~200mA. That's going to be divided - at best - across all lit segments, which isn't going to cut it for driving this many displays. – Nick Johnson May 22 '12 at 12:31
If you multiplex 24 columns then you have a 4% duty cycle. You won't see much on the displays I'm afraid. – Federico Russo Jul 21 '12 at 14:55

I agree with @stevenvh, see the DayCounter Kit - it's basically your project modularized using 74HC595 latched shift registers. We also provide cables to chain boards together and extension cables for the 7 segment displays. I even wrote an Arduino library for it that handles arbitrary chaining depth. See schematic here.

Edit

As promised, here is the unedited response I got from Texas Instruments to the question of "How much current can each pin sink in the context of driving LEDs, and is there a limit for the overall current that the outputs could sink?"

The SN74HC595 can sink or source a maximum of 20mA from each output. The limiting factors are two fold:

1. The maximum current through the entire chip can only be +/- 70mA. This means that all of the outputs cannot sink or source 20mA at one time as this would put the chip over the maximum level for total current from Vcc to GND.

2. The second limiting factor is the output voltage under load. This is specified in the Voh and Vol specs on page 6 of the data sheet. You can see that as you increase the current past the last current spec (depends on Vin) the Voh begins to droop and Vol begins to rise. In a logic application this would be unacceptable due to logic voltage specs. If you are driving LED's it doesn't matter in terms of logic levels, but you do need to make sure if you are driving LED's that there is enough forward voltage to drive the LED's.

So you can have individual outputs sink or source 20mA max , but the total for all of the outputs cannot exceed +/- 70mA. As long as you meet this spec you can drive LED's as long as the current draw per output does not decrease to less the forward voltage of the LED.

-
I know the 74HC595 is often used for this, but it's unfit. See my answer. – stevenvh May 9 '12 at 14:31
@stevenh, thanks for the revision and my apologies. What aspect of your answer makes them unfit? The DayCounter boards just route power through the board. One 74HC595 per 8-segments is not taxing from a power standpoint. The Daycounter also provides a 470Ohm current limiting resistor per segment. – vicatcu May 9 '12 at 14:34
@stevenvh - If you use PWM and only illuminate one segment at a time, it will work fine. A naive controller which allows all segments to be lit simultaneously will overload it. – Kevin Vermeer May 9 '12 at 14:36
@vicatcu - Which control mechanism do you use in your libraries? – Kevin Vermeer May 9 '12 at 14:36
@vitatcu - That clearly confirms what we already knew from the datasheet. Thanks for the notification. – stevenvh May 21 '12 at 14:07
show 6 more comments

As already mentioned by UziMonkey and most others, a single resistance at the cathode is 'dimming' the segments as more segments are to be lit up. The current thru' the resister ought to be more when more segments are lit, and this increases the voltage drop on the resister, which is why they are getting dimmer. You need to use 8 separate resistors on the anodes, so the above wont happen.

About Driving multiple LED segments. Use a 5 to 32 TTL Demultiplexer(aka demux, example : 74LS154) so you will get to control upto 32 7-segment LED modules. The 5-inputs to this demultiplexer shall come from the arduino. Connect all the 24(or 32) outputs of demux to the cathodes of 7-segment LED modules. Now, The Arduino will drive the 7 segments thru 7-lines, and the demux outputs will select which display is to be 'ON'. Several factors like voltage to be applied to the LED segments depends on the scan frequency of the Demux.

-

First, you shouldn't place the resistor on the ground side, but one at each output of the LS164. To get 20mA the value should be 150$\Omega$.

Next, the LS164 is a bad choice. You want a latched shift register, where you can freely shift data without disturbing the outputs. The TPIC6C595 is compatible with the often (ab)used 74HC595, but the latter can't supply 20mA to all outputs at the same time. (The supply current for one 74HC595 should never be greater than 70mA!) The TPIC6C595 outputs are open drain to ground however, so you'll need common anode displays.
(You would also need common anode displays for a low-power Schottky shift register like the 74LS164. LS-TTL can hardly deliver any current, and even can't sink enough to drive the LEDs!)

Dimmer LEDs when there are more connected often points to a too short duty cycle when multiplexing, but I think this is supposed to be static. Check the power supply to see if it can deliver the required current. Count on 20mA per LED, that's a total of 3.4A! That's a lot, and may be the cause of your problem. Note that multiplexing will add complexity, but will do nothing to save power; you'll need exactly the same.

-
 Thanks for the explanation. The power supply is one I'll have to provide myself with AC as source. So I suppose I can provide 3.4A. I don't quite understand the "latched" part, but I will look up what exactly that implies. – Dyte May 9 '12 at 14:53 @Dyte - the latch means that the outputs don't change while you're shifting the data through. Only when all bits are shifted to their right position you give a pulse to the latch input, and the data from the shift registers is copied to the output registers. – stevenvh May 9 '12 at 14:57 I see.. but the "shifting through" phase, isn't that a matter of milliseconds? The values of the displays won't be updated all the time, just now and then (when pressing a button). So I don't think this is an issue for me? Or am I missing something... – Dyte May 9 '12 at 15:04 +1 for pointing out the limitations of LS-TTL and 74HC164. – Federico Russo May 9 '12 at 15:05 +1 "(ab)used 74HC595" People often count on the fact that not all the LEDs will be ON at a given time.. which is bad design. At least add transistor to drive the LEDs, if you must use 74HC595 – m.Alin May 9 '12 at 17:11
show 2 more comments

## The Common Cathode resistor is limiting the current

You need a series resistor at the anode of each LED segment, not a single resistor at the common cathode. Here is a schematic representation of a single seven-segment display:

With your current circuit, you've connected a single resistor to the common cathode. That will cause the current to be dependent on the number of segments which are lit at a given time.

Each LED will drop approximately the same forward voltage. For the standard red indicator LEDs in most 7 segment displays, that's about 2 V. Assuming that you are using a 5 V driver, that leaves 3V to be dropped over the resistor. Ohm's law says that the current through that resistor is given by:

$I = \cfrac{V}{R}$

or about 13.6 mA. This 13.6 mA will be constant regardless of how many LEDs are lit. If you light all 7, the current in each will be 13.6 / 7 ~= 2 mA. The current in an LED is proportional to the luminosity; 2 mA is barely visible. To fix this, you need to connect a resistor to each anode of the LEDs. This will allow for 13.6 mA in each resistor which does not need to be shared. The current through the common cathode can then be 13.6 * 7, so you'll get full brightness.

## An alternative mechanism

That is a lot of resistors, however. If you're using through-hole resistors, it could increase the size of your circuit considerably. You can save board space, soldering time, and component purchasing cost by writing some slightly more complicated software.

An alternative control mechanism would be to only illuminate one segment at any given time. By blinking (or not blinking) each segment at 200 Hz or faster, your eyes will see the average. Because the LEDs will only be illuminated for 1/7th of the time that they would be with individual illumination, the average luminosity will be less and you'll want to increase the current. Over 20 mA or so, these LEDs won't increase in brightness appreciably so just use a 150 ohm resistor.

-
Multiplexing will decrease luminosity. At 1:7 (14% duty cycle) you'll need to pulse the LED with 7 times the nominal current. – stevenvh May 9 '12 at 14:39
@Dyte, to answer your question directly, yes if you only turn on one segment at any given time, one resistor should suffice, but be aware that your maximum brightness will be about 1/7 of what you could otherwise achieve without time division multiplexing. – vicatcu May 9 '12 at 14:55
@Dyte - If you want to multiplex you'll absolutely need the latches, or your display will flicker all the time while you're shifting data (which will be continuously when multiplexing). – stevenvh May 9 '12 at 15:03
@Dyte - LS-TTL is absolutely out! Don't look at them anymore! It can only source 0.4mA, and sink 8mA. That's even too little for a static display, let alone for multiplexing, where you have to pulse the LED with several times 20mA. (I'll have to check the function of the '259.) – stevenvh May 9 '12 at 15:14
Multiplexing is used to reduce the number of I/Os. An 8*8 display will need only 8+8 I/Os. When driving through a chain of shift registers it's useless. You can use the TPIC8C595s to drive the common cathodes successively, and use a 74HC595 to drive the anodes, but only if you add a transistor to the 595's output to pump up the current to the required peak values. – stevenvh May 10 '12 at 9:42
show 10 more comments