Lowest Parts Count / Highest LED-Yield Matrix?

Hey there Arduino.cc! Longtime lurker, first time poster.

I've spent hours and hours on Google over the last two weeks trying to figure out how I can achieve the result I'm aiming for, but I have no concrete answers, and am, in fact, more confused than I was before.

I'm trying to wire up 132 (or more) individual 0604 (SMT) LEDs and be able to individually address all of them, with brightness control. I'm making myself a clock (60 minutes, 60 seconds, 12 hours*3 colours: AM/PM/room for extra functions). I need to be able to PWM all of them.

To clarify: I'll have 60 red LEDs for seconds, 60 blue LEDs for minutes, and 12 RGB LEDs for hours. I would love room to have extra LEDs in case I want to throw in more features or whatever. I would like to treat the RGB LEDs as separate LEDs for simplicity of logic.

I'm looking to make the final design as compact as possible and with the lowest part count possible. Consider it an exercise in extreme board design. My intent is to make a portable pocket clock no bigger than a pocket watch (though if I can fit it in a pocket watch case, I think that would be awesome).

I've come across TLC5940s, 74HC595s, ULN2803s, and 74HC259s in my research. I have 4x 5940s, 2x the rest at my disposal in DIP form for breadboarding, along with the requisite LEDs and resistors (and an Arduino Duemilanove 328p). I plan on purchasing the final components in the smallest QFN or TSOP available when I make the final product.

How can I control all my LEDs using the parts I have on hand? If I can't, what parts do I need to get? Please don't make me get a bunch of individual FETs. I want to have as few discrete components as possible, though if I can save board space, I will consider it; but only if the part comes in a mind-bogglingly tiny SMT package.

I understand the ULN2803s are used to source(?) current, and the 74HC595s I believe are also, and the TLC5940s are for sinking. To be honest, my knowledge and understanding of electronics is flaky at best, but my enthusiasm is not. This is how I learn; diving in head-first, and coming back to surface with a deeper understanding.

It would be great if I could just take two TLC5940s and make a 256x256 matrix, but I'm pretty sure I can't do that.

In any case, please excuse my repeating myself and poor grammar. I've stayed up too late for the 10th night in a row researching this thing, and I finally caved and asked for help like the hundreds of other people I've seen do it.

Thank you. :smiley:

Best Regards,

Dash

I understand the ULN2803s are used to source(?) current,

No it just sinks it.

My intent is to make a portable pocket clock no bigger than a pocket watch (

Have you thought how you are going to power this.

Have you considered the MAX6954 with 128 LEDs from one chip. You can PWM then but only in groups of 16 not individually.

t would be great if I could just take two TLC5940s and make a 256x256 matrix

You guessed it you can't.

I like the MAX chip idea, but it's expensive and big. Two 28-pin 5904 (32-pin in QFn) are big enough, but to have two 36-pin (40-pin QFN) seems like it might take up too much space. I dunno.

How I'm planning on powering this is with a coin-cell rechargeable from Sparkfun to provide the battery backup for the DS3231 RTC I'm using, and a tiny LiPo battery charged via USB and a MAX1555. I'm not solid on the voltage of the battery, or which one in particular I'll be using, but I will, for sure, be needing to step-up the voltage from the 3.x volts most of the tiny LiPos provide to the 5V I'll need for most of my circuit. Not sure how many mA I'll need. I need the power source to last all day, if possible (18 hours should be good, but more is always acceptable), and the display will have a user-definable auto-shutoff delay, so it will only be on when actively viewing the time (button-press or touch sensor or something).

On the watch face, for the most part, it is unlikely that more than 4 LEDs will be on at a time for the clock feature (it'd be neat to have the previous LED fade out as the new LED lights up for seconds/minutes/hours progression), but I intend to include a temperature feature (using the DS3231's built-in temp sensor) that may need two whole rows to appear to be on simultaneously (but I could live with just one LED again, it would just be nicer-looking to light up the whole blue row for 1-60 degrees Fahrenheit, and progress up through the red row for 61-120 degrees Fahrenheit), meaning that up to 120 LEDs may need to appear to be on at the same time.

So far, I'm thinking that a TLC5904 (or however many I would need) could drive the "rows" (the matrix's physical layout would be somewhat different than its logical layout), while a special darlington (or however many I would need) could source the columns, and then I could somehow drive the LEDs like that...but I really have no idea what I need to make this work.

I'll be using an Atmel AT90USB1286 in a Teensy++ 2.0 style, running Arduino code. I want that chip for the built-in USB and the extra I/O pins, among other things. I get the feeling my program code might end up being huge, so the extra Flash space couldn't hurt either. My original idea was to use a 328, but I don't think it has enough pins to do this if I wind up having to abandon my driver chip idea and go with a hand-picked matrix using discrete FETs and such.

I started out reading about and drawing plans for a simple transistor-and-resistor driven matrix, with each row and column being done by hand, each row taking one pin and each column taking one pin, which would almost use up all the I/O on the 1286, but stumbled on these driver chips, which could save me lots of pins. The fewer discrete components I have, and the smaller they are in the end, altogether, then the smaller my board can be. I'd like it to be circular, and no more than 1.5 inches in diameter...so very small.

One of my main sources of inspiration for attempting this ridiculous miniaturisation feat: http://www.eng.yale.edu/pep5/pocket_watch.html.

That's what I'm going for.

I emailed Paul Pounds, and he says he's using a transistor to provide switching for several rows of LEDs, but I am unable to work out from the board layout pictures just how the schematic would look, and therefore what parts I need to buy and how to lay it out on a breadboard for testing.

That method looks like it is physically smaller in the end, but might use up more I/O pins on the MCU.

I'll take whatever help I can get in the form of guidance and direction in what parts to choose and how to lay it out, if anybody will give me that level of help.

And yes, Grumpy_Mike, I saw your Mini_Monome. I would absolutely be willing to use that method of driving the LEDs, I would just like to avoid the discrete FETs, unless they would save space. And provided I could actually drive the 60+60+36=156 LEDs (the 132 in my last post was an erroneous number) with just one (or two) TLC5940s and a handful of P-type FETs. Would your design scale up that large? As-is, yours appears to handle 48, so by adding 2 more FETs, I could get up to 6 per pin (I read that someplace as a possible limitation per row) and another TLC, I could (in theory) drive up to 144 with 6 FETs and 2 5904s? And more TLCs for more? Or could I use more FETs?

I'll take any solution that isn't too expensive, can drive as many LEDs as possible, and takes up the least amount of physical space, balanced with taking up the lowest amount of MCU pins for control. PWM is a must (even if it's software, done completely by-hand), because I intend to be able to balance the brightness of the red, blue, and rgb LEDs so they appear to be approximately the same brightness, as well as using an ambient light sensor to change the overall brightness of the display to match the environment (darker display in a dark room, brighter display in sunlight), so it's comfortable to view in any light.

I saw this possibility: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230851345. How would I lay that out? Would I use 2x 74HC595s for the rows and 2x TLC5940s for the columns? The 595s source, and the 5940s sink, right? Would I have to use a darlington array with the 595s? I'm really not sure how this whole thing would work.

I'd be willing to entertain your suggestion of using the MAX chips, but unless I can stretch the LED count to 156 from 128, I don't think it would be of much use to me. Having two of those chips would take up quite a bit of space. Would I need any other components besides it? Resistors? FETs? If it's self-contained, it might be worth looking into, since my PWM doesn't need to control individual LEDs (it would just be nice for display animation purposes).

I like the MAX chip idea, but it's expensive and big.

It's only big in the DIL package, the surface mount one is much smaller. If you think about it to control a given number of LEDs you need a certain number of pins. the MAX chip is about the minimum number you can get away with because it charliplexes them.

The more you extend the multiplexing the shorter is the on time compared to the off time and so the LEDs are dimmer. I wouldn't go any further than the 4:1 used on the mini monome but 8:1 is common. By adding one more TLCs you double the number of LEDs but you also have to shift more data.

However, before you get too involved with the design please look at the current requirements. Look at how you will share it amongst 156 LEDs.
Lets say you go for 8:1 multiplexing with 20mA per LED then you have to supply (20 * 156)/ 8 = 390mA.
Just to power that for 10 hours you need a 3900mA hour battery. You can't get such a high capacity in a coil cell, you are looking at something like three AA size batteries.

To clarify, the coin cell would only be the backup battery for the DS3231. Its sole purpose is to provide backup power to keep the time set properly through a power outage.

If I go as low as 10mA for the LEDs (I honestly don't know if that will work; I don't have a datasheet available for the 0604 SMT LEDs I'm planning on using), I could use a 1950mAh battery to get 10 hours...but you're absolutely right. A whole day is not a realistic expectation for this. I'll have to do some hardcore searching for a good, tiny, high-output LiPo.

Darn.

However, considering the LEDs will only usually be "on" for 15 seconds at a time (by default), the majority of the power requirements will be skipped over. The MCU could be put into a low-power mode of some sort, where it just keeps enough power consumption to check things like button presses and stuff...and the DS3231 doesn't draw that much power, so it should be ok. I'll have to experiment with being really conservative of my power usage, but I bet I can draw that mAh usage out over a whole day if I'm really careful.

So how about this: http://blipbox.org/polynome.html suggested using a TLC5940 and a MCP23017.

I could use the 5904 to control the "row" switching, and the 23017 to handle the "columns," thus providing me with control capability for up to 256 LEDs. To be honest, current considerations and brightness aren't too important to me, so long as the system will run without burning out. If I need to use some FETs or a darlington or something to up the current, I'm fine with that. Whatever's necessary to make this work, provided it will fit on my board.

Would one 5904 and one 23017 actually work to control a matrix? I've seen so many suggestions (both right and wrong, sensible, and crazy) for arrangements that I don't even know what works and what won't.

The problem is that a MCP23017 is only an I2C and so it too slow to do the output multiplexing you required. I is supposed to be able to work at 400KHz but I couldn't get it to go that fast with my arduino.
The MCP23S17 is better as this has an SPI interface that works a lot faster. However, you still have the problem of current sourcing this chip can only supply about 20mA per pin and a total of 150mA spread over all 16 pins. So you still need FETs.

Ok, so would it be P-type or N-type, and would I put them in between the driver and the LEDs on the anode or cathode side?

Let me know if I have this right: since I'm using them to source power, I'd need to put them between the MCP and the LEDs, putting the cathodes towards the MCP and the anodes towards the TLC?

This led display was built using TLC5940 and mosfets. Transistors are ok but the mosfets allow you to turn the led off better otherwise you get bleed.

That looks awesome. Where can I get a schematic, or an explanation or something? I checked out the YouTube link, but it's just a webstore selling basic stamps.

Or at least, what type of FETs were used, P or N? I'm very confused about how to interface the LEDs and the 5940 in the first place (anodes, or cathodes, which goes where), and honestly confused about the difference between P and N FETs, and where they would go in the array. I'm guessing:

TLC --> LED (-) legs
led (+) legs --> FETs

Is that how it goes?

The MCU would handle the SPI to the TLC for activation of the rows, and then the pin-by-pin activation of the FETs for the columns?

Any solution that requires less than 25 total pins is acceptable to me, but I'm also concerned about board-space, since I've got one side full already (LEDs, MCU, other junk) on a double-sided circular 1.75-inch diameter board. And there has to be room for two batteries (a coin-cell and a LiPo), a rotary encoder (5x5mm), and a flat vibration motor on the back. Inside a case either the size of or actually a pocket watch.

Perhaps doing a 100% FET-driven array would be best, for both rows and columns, since the tiny parts are more flexible in their placement and can be put in blank space between things on the front of the board? Their total size might be larger, but perhaps their flexibility in placement will make it all worthwhile?

Let me make sure I understand you. Your mouting the leds to a 1.75inch disc?

From what I gather, your probably better off with a 74HC595 and BC547 solution. You wire the LED's in a matrix. Say you want 32x32, you would create 32 rows and 32 columns. You would connect the columns to 32 transistors. Then the rows to the 74HC595.

TLC5940 are used if you want "brightness" control. If your just needing to turn them off / on then you dont need a part like this.

Two features of the TLC5940 are necessary for me: QFN package size, and PWM dimming. I do need to control the brightness of the LEDs. I want to match the Red, Blue, and RGB LEDs in my matrix to have approximately the same brightness, and I also want to have the overall brightness fade in and out based on ambient light levels.

I'm just messing with the 259 and 595 so I can learn how this stuff works before moving up to the TLC5940s. I figure I'll have a use for them someday, just not necessarily in this design. I like to learn; it's what I do. :smiley:

The LEDs in question will be mounted in three concentric circles: 60 red outer, 60 blue middle, 12 RGB inner, but the logical arrangement of them in software will be whatever is easiest to set-up and wire, even if it makes coding patterns for them a slight headache; I'm more concerned about available board space.

I had a go at tying a PWM to the output enable pin on a 74HC595 to control brightness. I had a small accident before getting it to work and have not fixed the problem yet. It's supposed to work.