Go Down

Topic: ShiftPWM support topic. Latest update: Schematics, high power LED's, LED strips (Read 166180 times) previous topic - next topic


Yes, the modified file should work with either.

Why you're getting problems, I do not know.  Is there a schematic for how you're hooking this stuff up?

Consider that a 16x8 matrix of RGB LEDs is 384 individual LEDs.  If you turns them all on (all white) at 10 mA average per element, that is 3.84 amps of current.  USB directly from a PC is limited to 0.5 amps, and only 0.1 amps if from an unpowered hub.

You will very likely need a separate power supply for the LEDs, capable of at least 4 amps for 10 mA per element, or 8 amps for 20 mA per element.  To conduct so much current, you'll need heavy wire, like #18 or larger (smaller numbers for thicker wire).  The rows appear to be 1:8 multiplexed.  If there are only 8 transistors for the 8 rows, then each transistor could possibly be powering 48 LEDs at once.  Because they're only on 1/8th of the time, you need 8X the current so it averages out.  For 10 mA avg, that's 80 mA per LED.  There's 16 per row, so each transistor needs to conduct the full 3.84 amps (or 7.68 amps if 20 mA avg current).  That's a huge amount of current, so you need a very good transistor.  It's do-able, but when you mux so many LEDs, the current requirements are really extreme.

If only the red ones are turning on, it's quite likely your 5 volt power is dropping to 3 volts or less under the load.  Even if your power supply can put out 10 amps or more, the interconnecting wires and transistors will lose a substantial amount of voltage if they're not able to conduct so much current.  I don't want to discourage you, but rather point out the intense current requirements so you can troubleshoot.


10k is way too big as base resistor. Your transistors are not fully open. Red needs the lowest voltage and that's why only red works.

for Ic = 500 mA, the DC current gain is only 20 according to the datasheet. For 150 mA its 100-300.
For your 320 mA, i expect it's about 40, which would mean you need a base current of 320/40=8mA at least.
To be safe I would aim at around 20 mA. This is already drawing a bit much current from the shift registers.

5V/20mA = 250 ohm. Try using 270 base ohm resistors.


OK. Thanks for the tips. I will try that Elco. Both libraries now work on the teensy, or at least teensy ++2.0


I ordered a couple of the Futurelec displays.


Then I started looking at specs to actually drive this beast.  First, the 74HC595 chip is only specified for 6 mA drive per pin.  I'm sure it can put out more, with more voltage loss, but the spec says at 4.5 volts power and 6 mA sourcing, the pin will typically be 4.31 and worst case 4.18 volts.  So even at 6 mA, 0.2 volts typical loss.

Even though the LEDs in the matrix are supposedly capable of handling 20 or maybe even 25 mA, to make this easier, I decided to shoot for a 7.5 mA average current (at least on paper).  So the 24 column drivers need to source 60 mA current (7.5 mA * 8 rows).  That's TEN TIMES the '595 spec.

So 24 column transistors would be needed.  Luckily, they only need to put out 60 mA, so a cheap transistor like a 2N3906 can work.  A datasheet says it has a gain of 60 at 50 mA, so a base current of 1 mA should be fine.  24 1K base resistors should do it.  The red LED will be approx 2 volts, so 8 resistors of 47 ohms will be needed for the red columns.  16 more resistors of approx 33 ohms will be needed on the green and blue columns.

The 8 rows are the tough part.  Each row transistor needs to be able to sink the current from all 24 columns.  That's 1.44 amps!  That's probably a job for a darlington transistor or beefy mosfets.  The trouble with mosfets is the huge gate charge.  A lot of them are 10 to 20 nC.  If the current charging the gate is limited to 6 mA (eg, a 820 resistor), it will take about 3 us to charge a 20 nC gate.  That doesn't sound like very long, but unless the library is designed to shift out an all-off pattern while one N-channel transistor is turning off and another is slowly turning on, there will be ghosting problems.  Perhaps a darlington pair could be built from 2 individual NPN transistors, where the big one has a relatively low value pull-down resistor on its base, so it shuts off quickly?

Still, the library should really have some design to shut off all the columns right before initiating the row change, and keep them off for a few microseconds (eg, about 50 instructions on Arduino) while the big row transistors turn off and on.  It looked at the code briefly, and it appears to instantly switch without any dead time.  Is that right?

Of course, each of those 8 row transistors need wiring to conduct 1.4 amps (each wire to and from each one needs to carry the full 1.4 amps), and a supply line to the 24 column transistors needs to supply 1.4 amps (each wire carries only 60 mA, but the feeder to them all carries 1.4 amps).  Wiring capable of handling these currents is difficult-at-best on a breadboard.  At least 2 wires of #22 solid should be in parallel for every path that handles 1.4 amps.

That's also for only 7.5 mA per element.  Multiply everything by 3 for max brightness!  Well, except make those 33 ohm resistors only 10 or 11 ohms, and the 47's about 15 ohms.

That's for only one single 8x8 display!  Multiply everything by 2 for a 16x8 display.

It is do-able.  Maybe this weekend I'll sketch up a PCB layout and send it off to Laen.....


Hi Paul,

You could take a look at the MIC5891, which a shift register with output latches. It can handle a lot more current.

I think you are making a mistake in how you calculate the currents.
Because the columns are multiplexed, only 24 LED's could be on at any time. Thats 24x20mA = 480mA.

In an 8x8 matrix, the LED's are off 7/8 of the time.

No delay in column switching is a deliberate choice to keep the library as fast as possible.


Dec 29, 2011, 01:31 am Last Edit: Dec 29, 2011, 01:40 am by Paul Stoffregen Reason: 1
The MIC5891 certainly looks like it can source a lot of current!  It costs more than a '595, but saves soldering 8 transistors and 8 base resistors.   :)

However, the "Typical Output Circuit" on page 2 worries me.  I see at least one PNP saturation voltage and 2 NPN base-emitter voltages between the positive power rail and the output.  I read the datasheet a couple times, looking for some sort of spec for the output voltage under a load current when running on 5 volts.  They do spec "Output Saturation Voltage" at 1.8 volts with 100 mA, with 50 volt power.  I'm pretty sure that means you actually get 48.2 volts.  I'm pretty sure that 1.8 volts is from those 3 transistors in the output stage, so it'd be similar on only 5 volt power.  For running with only 5 volt power, which I'm going to assume is actually 4.7 under heavy load (eg, real wires, connectors, etc), losing losing 1.8 in the chip will give only 2.9 volts out.  That's not enough for a blue LED, not to mention a current setting resistor, and that's if the sinking transistor doesn't eat up some of the voltage.  I think this would work great if 9 or 12 volt power was used (and higher value LED current setting resistors), but unless I've misunderstood, I suspect the MIC5891 won't be very satisfying on only 5 volts.

Regarding the current, you're right, only 0.48 amps is needed if you drive the LEDs with 20 mA during their on time.  But will you really be happy with the LEDs at only 1/8th of their intended brightness?  They're off 7/8th's of the time.  It's the same as PWM... if you reduce the duty cycle but want the same brightness, you must increase the current during the on time.

I figured 1/3rd of intended capacity would be a good compromise.  That's not nearly as dim as only 1/8th.  Also, if the software fails and a row remains selected indefinitely, the LEDs will "only" be stressed with 3X their intended current.  Not good, but they'll probably survive.  At 8X, they'd certainly burn.  Then again, 8X gives the full LED capacity!

Even 1/8th should still light up and be viewable in a dimly lit room or at night.  But as a design goal, isn't that a bit skimpy for so much trouble to wire up all these chips, resistors and transistors?  Or have I estimated things wrong?


Everything works great, except there is still ghosting and the rainbow functions are still messed up. Thanks for the help everyone!


Paul, I think you are right about everything you just said. If you want a smaller voltage drop, mosfet's are probably the way to go.

I don't know what's up with the rainbow function. I don't have an RGB matrix, so I cannot even test it. I might order one some day when I have some more money and time to spare. I would like to test a 16x16 setup some day.
Is pin 0 of register 0 red on your setup? You might have to rearrange the arguments to SetGroupOf3 if not.

The ghosting might be gone if you use fast mosfets, but I am just guessing because I cannot test it myself.

The transistors have a 30 ns fall time, so that would not be visible probably. It could also still be a software bug as well. Is the ghosting only on the row next to it?


The ghosting is on the whole column of the lit LED. I only barely saw it in a dark room. And no, my matrix pins go green blue red so I will change that


Ok modifying the setgroupof3 only made the flashing red and made the rainbow look cooler


Oh and I'm working on setting up ShiftPWM with 21 shift registers and 54 RGB LEDs. I will post a video once I'm done


Dec 29, 2011, 07:45 pm Last Edit: Dec 29, 2011, 07:49 pm by Paul Stoffregen Reason: 1
I drew a PCB layout for ShiftMatrixPWM.  I'll send it in to Laen's PCB group order, which makes 3 copies.  I'll build 1 board.  If it works, I'll send the other 2 boards to you guys (elcojacobs & ematson5897) for free!  The next group order goes in next week, so they'll probably arrive near the end of January.  I'll post info about the board design later today.

While working on this last night, I had a concern about the overall design.  There no enable/disable signal for the whole display.  What happens when the AVR chip resets?  The rows will stop advancing, and one row of LEDs will be left on at 100% duty cycle.  If the resistors are picked for good brightness, which means current much more than 20 mA per LED, the LEDs in that row will be indefinitely subjected to a high current which they can only handle for a short duration.  Or at least the duration of a new program download, which is slow on older Arduino boards.  Not good.

One easy solution would be to add a 7th signal to disable the display, but it would be nice to only need 6 pins.

Another approach could use the row latch signal.  The code seems to leave it high much of the time.  If that were changed so it is only driven high in a short pulse, so it stays low virtually all of the time, then the row latch could also act as a active-low display enable.  It could go to the output enable pins on '595 chips, or other disable circuitry if different chips are used.  With a single pullup resistor, when the AVR goes into reset or runs the bootloader for a new download, the AVR pin becomes and input and the resistor would bring that signal high to shut all the drivers off so the LEDs won't burn up.

Another nice possibility might be staggering the row latch pulse with the column latch pulse, to help with ghosting problems.  When the row latch pulse goes high, the new row data will latch to the outputs, but the output drivers will also disable until the pulse ends.  The column can then be latched while the drivers are disabled, and then the row latch pulse can end, causing the drivers to enable again after the new column is latched.  That should completely eliminate ghosting problems.

How would you feel about making this code change?  Is there any downside I haven't seen to making the row latch a short pulse and using the low state to enable the drivers?


Dec 29, 2011, 11:28 pm Last Edit: Dec 29, 2011, 11:36 pm by ematson5897 Reason: 1
OK. Thanks for the offer. And Elco, how many LEDs can be on at one time on the ShiftPWM library? And also, a function that would be nice to add to both libraries is the ability to set all of the RGB LEDs to the same color (for RGB LEDs and matrices of course)


Paul, the 595's have an output enable pin. It can put the outputs in a high impedance off state. Isn't it easier to use that?

Go Up