Programming for a custom LED matrix / display

for a chase animation, why would you even consider storing individual frames of an animation? that type of animation is clearly best implemented with a simple for loop...

then again, if you use some smart mapping, you can store all the data for one frame of your display with only 5 of bytes of memory, since you've got a maximum of 39 individual LEDs to control. that makes the frame data REALLY hard to read or edit by hand, though.

OK, I've decided to define all ones and zeros explicitly in arrays. Maybe I'll revisit it in the future, but I don't have time for a better solution right now.

I wanted to be sure of my schematic, though, before proceeding. Here is how I was planning to connect my LEDs to the 4051s:

The plan was to send a PWM pulse into the 4051 and select the appropriate output using the selector pins. The PWM should switch on the transistor, supplying +5V to a row of LEDs. Finally, I would pull one of the anodes to LOW using the Arduino, turning on one LED. Repeating this same structure for each of the rows I have (max of 8).

Should I add anything to this schematic, maybe some resistors? Or will this work as I intend it to?

I think you'd have better luck using a PNP transistor, this might work.
You need to get ~2V at the anode of the LEDs (or more, depending on what you're using).

How much current can a 4051 source? The BJT wants to amplifly that, by a 100 or so, so if you want 8) ( 8 ? ) LEDs, you will need 160mA thru the transistor.

I have a bag of 2n3906s, I could use. But why? I thought the 2n2222 would connect the LEDs to 5V?

The 5V at the collector of the 2n2222 is an external power supply, which can supply up to 1A. I was thinking all of the current drawn by the LEDs would be drawn from that external power supply, not the 4051. Is that wrong?

"I was thinking all of the current drawn by the LEDs would be drawn from that external power supply, not the 4051. Is that wrong?"

No, that is correct. I was more concerned about the 4051 being able to source enough current into the transistor to turn it on enough for the current flow needed to turn on the LEDs.

Having a logic level MOSFET here could be better, its easier to turn on with a low-current capable voltage source like a 4051.

Oh, I see. Could you recommend a logic level MOSFET to use here? Looking at the 2n2222's datasheet, it seems to indicate that the base can switch ON with only 0.3V @ 15mA, so a logic level "high" should more than suffice (I have used 2n2222's experimentally to control motors and LEDs using PWM signals generated by PICs, so I think they would be OK here).

The only things I am unsure about right now are whether or not I should add resistors to both the base of the 2n2222 and the collector of the 2n2222 - I don't quite understand why, but I've always heard it was 'good practice'.

Furthermore, the way I was planning on ensuring that an LED is off when its supposed to be off was by setting its 'column' line to HIGH, so that there is no path to ground. My concern is in the case when both a row and a column are at digital HIGH: will the LED blow up? Is there another way I can ensure that my LEDs do not get 'stuck' on?

Exactly my concern - turns with 0.3V, but needs 15mA thru its internal base/emitter junction.

The reason you add resistors is to limit current flow.
With no resistor on the base, the base pretty much looks like a diode connected to the emitter. Here you have a resistor from the emitter to the LEDs to eventually low, so I'm not sure how that will play out.

Do you a surface mount recommendation or a thru hole recommendation?
Digikey has good filtering.
search for p-channel mosfet.
then single fets (or maybe arrays, depending on your planned build configuration)
then in-stock
then logic level
then thru-hole or surface mount
that should narrow the list.
cick on sort by price, then start going to find a part with low Rds (down in the mOhm range), and a price/package you can work with.

IMHO

The actual base current will be less than one milliamp as the gain of the transistor is over 50 and the collector current supplies most of the 50 mA for the LEDs, but I would prefer to have the LEDs and their resistors in the collector circuit (common anode connected ) and save the half a volt base bias. ( minus the saturation voltage to be pedantic )

I don't know what colour LEDs you are using, but it sounds like there are different ones for the range of current you mention.

Some LEDs have 3 volts forward drop, which if added to the base/emitter drop of say .6 volt, only leaves you with 1.4 volts to drop across each resistor ( 56 ohm at 25mA ) which is fine, but its better to have more voltage to play with ( as with the common emitter configuration ) to match the differences of forward voltage and brightness in the pair of LEDs .

A 1k8 resistor from the chip to the base of the 2N2222, ground the emitter, and each LED in series with its own resistor ( again to separate V forward differences in the LEDs )

Incidentally, you wont perceive too much difference in overall display brightness by running the LEDs 10% less than their max current.
The reliability will depend on the heat of each LED, which can vary with local conditions, sunshine for instance, and how well ventilated the LEDs are.

I mainly use red wide angle LEDs with a recommended current of 20mA, but I run them at 18mA.
Apart from during initial testing after soldering, where some have failed, in the last 10,000 LEDs used I have not had one failure reported ( I might be sorry I said that :slight_smile: )

It is a far different story with orange ones from my supplier, I don't use orange anymore !

Boffin, how'd you make out getting your thumb dial swithes read? Success in the end? I was just not following what you were trying to do there.

@ Crossoads I was up till 3am soldering in the 19 shift registers, it seems to be working ok with the 2 Artduinos hooked up, but I want to see it in real action.

There is somethng funny with the Shiftout function, but I will sort that out later today.

I will post some pics a bit later, the wiring in the remote is quite something !

@ Crossroads. I got the BCD switch scanner going, and have posted a photo on the original thread at

Boffin,
Saw the pics, looking good.
What software did you use for the PCB? That's pretty good size, folks have been asking recommendations for larger boards like that.

Post some pics of the remote also.

I have been using Sprint Layout for pcbs for a while now, it was only about $40 I recall, I didn't like auto-route on most packages I tried, so routed manually anyway, so this has been OK.
Its very basic in that when you move a component the trace doesnt move with it, but I have since downloaded http://www.designspark.com/pcb which looks interesting, and has some nice reviews .
I havn't had a chance to even try it yet with so many projects on the go, but I like the price - its FREE.

If anyone has tried it I would like to hear how it works, as I hate wasting time learning a new program that will not work for me.

I hope to finish the remote this morning, and will put some pics up.

I hope to also finish a 4 digit version of this today, it uses the same scanning idea, but doesn't use the 4017s, just 4 pins of the micro to select the bcd switches in turn..

Kicad also looks interesting, if anyones tried it?

Lot of folks were praising kicad, haven't tried it myself.

I just tried designspark under Ubuntu 10.04.2 Wine 1.2. It crashed after about 5 min when I was attempting to move a window splitter bar. I have a dual screen display so perhaps my setup is not well tested...

Thats nice to know Andrew, I have downloaded the Kincad, and will check that when I catch up

I wrote last week

"Apart from during initial testing after soldering, where some have failed, in the last 10,000 LEDs used I have not had one failure reported ( I might be sorry I said that :slight_smile: ) "

Stupid, stupid, stupid ]:slight_smile:

I had to fix a problem on Saturday on a LED sign on the roof of a hotel, and guess what, there was one string of LEDs unlit !
One LED was open circuit, and of course I didn't have a spare, so I just shorted it out, so the other 4 in the chain are going to be pushing the limit ( like the old Christmas tree lights once they start popping :~ )

Nobody has noticed yet, each segment has 20 LEDs so its not too obvious.

Ooh, that sucks!
One of my scoring machines is like that. Has 20 LEDs in strings. 1 LED in 1 string does not work, one LED dropping a little too much voltage I guess. Just left alone as they're not close to 20mA anyway (was way too bright!).