Iron in the Fire II

In my previous post, I write about an LED matrix for a marquee. The display itself is a two-board solution, the second board or ‘daughterboard’ piggy-backs on some pin headers from the display board. This second PCB provides the control interface and logic for handling these 64 leds, and passing along control data to any upstream displays.

led matrix display schematic diagram

The controller uses a 595 shift register to provide the ON/OFF control for each of the eight columns. To provide maximum current to these columns, I have used the ULN2803 current-sink driver. The 2803 is basiclly a darlington array which uses a small current to sink up to 500mA, on each channel… and it has 8 channels. So if I really blast my piranha LEDs with their bleeding edge maximum current of 80mA and the data called for all eight columns to be active at once, the entire column would need a total sink of 640mA! I believe the 595 alone can only sink 200mA. The daughterboard has no circuitry on it for controlling the rows of the matrix – they are just wired in parallel to the daisy chain connectors, which will connect it to a current source on the ‘master control’ or interface board. I plan to use some P-Channel mosfets to handle sourcing potentionally several amps of current. For example, if I connect sixteen of these modules together, and want to turn an entire row on at once, that is 128 LEDs, each drawing 80mA, for a grand total of 10.24A. Wow, that is a lot of power, my goodness, good thing I have a bunch of old AT style switching power supplies laying around, with 15-20A on their 5v rails.

The 595 shift register is just a set of switches, which are set through a synchronous serial interface – a big long string of 1’s and 0’s is clocked out of whatever ends up controlling this marquee (most likely a PIC microcontroller). Each register takes eight bits, thats why I went with eight columns. So if I build a sign with sixteen of these modules, I’ll be pushing 128 bits out a serial port. The entire register will need to be updated for every row, so an entire refresh will take 128 * 8 bits or 1024 bits. At 20mHz, my pic can clock a bit out every two microseconds, so refreshing the entire marquee would take roughly 2.1 milliseconds. A frame rate of 30FPS should be entirely possible, since 1/30th of a second is approximately 33 mS, that leaves a LOT of extra time for the pic to take a nap with… and if I go crazy and build some huge mother of an array, I can beef the pic up to 48mHz, hammering those bits out more than twice as fast.

The display modules are ‘modular’. Daisy-chain connectors provide pass-through of the row current, and data-control signals from the microcontroller. The D-IN port connects the ‘upstream’ registers serial output (QH*) to the current registers serial input (SER), the D-OUT port connects this registers serial output to the next registers input. The rest of the signals are straight parallel. Only changes in the software of the microcontroller would be required to add or subtract display modules from the finished array.

The pcb design and layout is ‘diy compatible’ I’ve used all through-hole components, and jumpers instead of via’s. If I send these out to be fabbed, I’ll probably change the signal routing around, switching the jumpers to vias, perhaps I’ll go with smt ICs, depends on how the layout works out… I might keep the through-hole because I like being able to run signals between the pins and under the ICs, which is hard to do when they’re tiny! The notations “dont move” are just to remind myself (or anyone else) that you can’t move the ARx (anode row) and CGx (column group) connectors, because they’re specificly positioned to mate with the display board.

composite pcb layout image
composite image of controller layout and top+bottom layers.

same disclaimer as my earlier post, these designs and images are not public domain… please read the disclaimer in my earlier post.

A New Iron for the Fire

I didn’t get a chance to make any PCBs this weekend, actually had more fun drawing them. I’m kinda stuck on my LED sensors project, since I haven’t come up with a good way to handle the current demands of an array yet, the catch is being able to reverse bias the rows/columns/whatever. so, I’ve been looking at building an led marquee instead. I’ve learned a lot about multiplexing and scanned LED matrices and arrays, and think it would be a good diversion.

There are a lot of pre-fab matrices out there, but the bright ones are expensive (for good reason I suppose), and what’s the fun in buying something pre-fab anyway. I’m thinking about using white piranha, but maybe green (red and blue have been done to death). The pulsed current specs on the white piranha I’m looking at show a max of ~80mA, with ~60mA being the close to the 200mW rating and 30mA being the continous wave rating (100mW). I have yet to do the math yet to make sure I stay within the pulsed current duration of 1mS max, but it shouldn’t be a problem.

I designed the PCB to be a huge heatsink, with almost all the copper left intact on both sides. This matrix is wired as cathode column, anonde row. Each column is driven by a darlington on the daughterboard (more on this in my next post). Each row of the completed array will be driven by some beefy P-Channel MOSFETs. To facilitate the mounting of the daughterboard, which piggy-backs on the display board, I used some standard .100″ spaced pin headers, seen as CG1-4 and AR1-8 (column ground and anode row.)

The top, bottom and layout art are linked below to full-scale TIFF images, for making your own PCB. I also have a for a multi-layer image in the Paintshop Pro format, which has the top and bottom layers on a 100x150mm 300dpi layout, for making transparencies to use with small double sided pcb’s I have.

Here is a not-to-scale composite image of the layout and top+bottom sides for what I call the ‘display board’:
printed circuit board layout leds

This is the schematic diagram of the LED array, showing the 64 indiv. LEDs and the connectors… linked to a larger version:
led matrix schematic diagram

Here are TIFF format files of the various artwork layers at 300DPI:
Display Board PCB, Bottom Layer
Display Board PCB, Top Layer
Display Board Parts Layout
Control Board PCB, Bottom Layer
Control Board PCB, Top Layer
Control Board Parts Layout

** Note: Paintshop Pro Image Format!
Double Sided PCB Layout, one display, one control, plus some stuff for another project.

Please note, these designs, layouts, pictures, etc are not being released into the public domain. I reserve all rights as the creator and copyright holder. I do however permit the hobbiest to use these designs in their own not-for-profit projects as they see fit. I also permit redistribution of the design and images by hobbiests for the purposes of education and other not-for-profit uses. Please mention me and/or give a link back here if you post these on another website.

EAGLE Libraries

Turns out, I didn’t get to make any PCBs over my four day weekend. I did spend a lot of time drawing things.

I have some parts libraries to share with everyone, I tried asking on a very popular electronics forum for the LED displays, but no one wanted to share, so I had to re-invent the wheel. Trusty caliper in hand, I measured the packages, and transfered those measurements to my cad program. The package for the 2 inch led matrix is dead on, I’m not 100% certain on the 0.7 inch matrix, I didn’t test it as much… the pins are fine, but the footprint might be a little off. By the way, these parts libraries are for Cadsoft Eagle.

LED Matrix Displays

High Flux ‘Piranha’ LEDs

Note; about the piranha package – the through hole layout is OK, the smd layout is brand new and probably needs a little refinement, but lines up good.

I might be close…

Wow, a long time with no posts – sorry about that!

I have been busy the past week, I wanted to take Thursday and Friday off, so I had to cram a weeks worth of work into the first three days.

I’ve also been racking my brain, trying to figure out how I can integrate a matrix wired LED array into my sensor project. I think I’ve come up with a solution, partly hardware, partly software. Originally I had wanted to have all the LEDs on, and turn them off to do a measurement. This created a lot of problems, mostly due to the current demands. Well, I think I can achieve the same goals, without having all the LEDs lit simultaneously, which will reduce the current demands and should simply the circuit a little.

led matrix sensor array 74hc595

There is the PCB layout for my latest design… I think I’ll make one to test out, and if it doesn’t work for my sensor array, I can use it as a mini marquee. Sixteen vertical columns, anode connected, each driven by a 74HC595 serial shift register. Seven horizontal rows, cathode connected, each driven directly by the PIC’s analog input / digital output pins. To keep current demands low, I will only illuminate one column at a time. I think that still exceeds the design recommendations of the 595, but heck, its all I can think of at the moment.

LED Array Schematics

My current ‘test’ setup with a 3×3 led matrix

prototype driver for the cathode rows … will never see the breadboard however, since it won’t pass-through an input signal to the PIC.

prototype driver for the anode columns… I’ll breadboard this out soon as I get some p-chan fets in.

More than a few days…

More than a few days have passed since my last posting. What have I been working on? Well, the same stuff.

I’d been getting my a** kicked by a logic gate thingy for two days, and turns out, all I had was two wires transposed – ahh well. Here is a re-post of a thread I started on

As part of my continuing effort to develop LED sensor technology, I’ve been trying to tackle the problem of expansion… My original brute-force method was an army of PIC microcontrollers, discretely controlling individual LEDs. While this method worked and was rather simple from a hardware stand-point, there were several drawbacks. The most ADC ports I was able to use was ten… there are microcontrollers with more than this, however they have certain drawbacks that make them unsuitable for my application. Knowing the limit of 10 leds per slave, to build an array of a useful size, say 3×10, would require three slave microcontrollers. Although not enormously expensive, each mcu costs at minimum $3, which adds up quickly.

The method I am currently exploring involves linear logic chips, specificly the 74HCT595N 8 bit serial load latching shift register. Here is the idea, and I’ll throw up a schematic shortly. The cost of a 595 for hobby purposes is roughly 75 cents. Even a modest quanity of 20-25 shifts that price down below 50 cents a piece. Far better than the cost of individual microcontrollers.

The 595 is used to source current, driving the anode axis of the array (columns). I fill the register with 1’s, which sets each output as a current source. While filling with 1’s, I clear the bit for the column which contains the LED I want to sample. The 595 holds this state indeffinately, until it is changed by the microcontroller. The microcontroller, which is directly interfacing the cathode axis of the array (rows), then samples each LED in that column by applying a reverse bias charge and then switching to a high-z input for the A2D reading for each row. This is done one bit at a time (each bit equals a row), so neighboring rows are left “on” at are lit, allowing a good amount of light to be reflected into the led currently being read.

This new arrangement allows a single microcontroller to handle a matrix of ‘unlimited’ columns by ten rows (each row needs to be connected directly to the microcontrollers unique tri-state IO port). A 160 pixel array of 16 columns by 10 rows needs only one microcontroller and two shift registers. Of course, the actual size of the array will be determined by how fast the PIC can scan through the columns, since one column is always ‘dark’ to allow for the reverse bias and read operations. Currently my microcontroller can scan my 3×3 array at a rate of 27kHz, which gives me a WIDE margin, since anything over 70 hz is practically impreceivable.

There are some flaws I need to sort out, mainly power related. The 595 can source 35mA and sink 75mA. 35mA is fine for a 3×3 array, but it won’t cut it for anything much larger. I need to find a way to increase the current handling abilities of each port, without a huge component count or complexity. If I build an array with 10 rows, each column needs to source 200 mA of current. But it also needs to retain the ability to sink a small amount of current. I figure I can solve this with a pair of transistors, one small npn for sinking, one larger pnp for sourcing.

Secondly, my microcontroller can source 25mA of current which is more than enough to reverse bias an led quickly, but it can only sink 35mA of current. So, when sinking a row that may be 16 or more columns long (at 20mA per led), some serious power handling capacity comes into play here. A simple TO92 mosfet can sink an amp of current without breaking a sweat, but I also need the ability to source current and the ability to go “high-z” to allow the microcontrollers internal circuitry to do the A2D sampling.

I think I am close to lickin this issue. More to come.

More LEDs, Less SLAVEs

Well, I’m having a some code-writers-block on applying data from the array to anything usefull… so I’m looking at ways to get more data from fewer and cheaper microcontrollers.

The cornerstone of led sensing is tristate logic. The PIC microcontroller can set each of its pins to high, low or neither (high-z). This is what allows me to forward bias, reverse bias and then sample the led. However, doing all of this requires a large number of pins on the PIC. Two pins are required for each LED. That’s why I did all this work on networking pics on a shared bus… but the cost of pics is pretty extreme, so I’m wondering about alternate ways of accomplishing the same.

Enter low-cost analog and logic interface ICs. There is a device called the 74HC573 octal tristate latching buffer. Basicly its a chip with 8 outputs, which can be high, low or high-z — same as the PIC. I really don’t care about the number of outputs, I plan to use a pair of them in an all or nothing configuration… tie all the data input lines together with a single PIC pin. I also probably won’t need the latching ability, but the 573 was cheaper than the 244 which is an octal driver without latching. So, the pic can control 16 led anodes with 1 pin – thats some awesome savings right there! 🙂 Next comes the cathode side, which is what the PIC reads with the ADC. For driving the cathodes, I plan to use the same configuration as the anodes, with the exception that I’ll also use the output enable line on the 573, to put the outputs into high-z just before sampling. All this leaves is the actual sampling. I’ll do this with a 16 to 1 analog multiplexer. The mux has a pretty high RDS(ON), something like 180 Ω … which is actually pretty close to the 150 Ω I’m using now. I figure I can put my resistor on the cathode side, after the mux connection, so when the cathode side driver is in high-z mode, my current limiting resistor disappears. In order to keep the array bright and eliminate any humans from seeing flickering, I’ll flash the entire row before sampling each LED. This should also give me the best conversion resolution on my leds, since the sampling time needs to be so high, I wouldn’t be able to read them all before their values changed.

By my calculations, scribbling in notepad, I figure I’ll need nine lines from the pic to control 32 LED lines (anodes and cathodes for 16 leds). Which is great, since I can use the lower-priced 18pin PICs… and it also sets the default row size to 16, up from the current 10. Of course, there’s no reason I’d need to do the full 16, but its good to have options! For the cost of one more pin from the pic (still easily within the 18 pin range), I could add another 16:1 mux, and lay 32 leds on a single pic! With the pic able to source and sink at least 25mA; it should be able to drive a ton of 74HC573s, which according to the datasheet need 1μA of input current per data line. Muhahahah! I’m not sure how many LEDs each PIC can handle and still have enough time to get a few complete collections inbetween servicing i2c interrupt requests with a 400 or 1000 khz bus clock.

Pictures of Sensors III

led sensor array microcontroller pic16f767 18f252

Here are two breadboards. The uppermost board has the master pic, the clock source and the serial IO hardware, the lower breadboard holds one completed slave and a bunch of leds.

Here is a closeup of the slave pic buried under spaghetti wiring…

buried slave microcontroller

LED Sensors III

After stuggling in the mud for the past week or so with compiler issues, I’ve finally broken free!

I have a newly configured breadboard, with enough room for four slave ICs, each handling ten LEDs. I haven’t found a decent way to create more than a double row of leds, given the way a breadboard is laid out electrically. I fear I’ll be making some PCBs for this endeavour shortly.

I’ve come up with a neat bit of code to set the address on my slaves, using a single pin. With one pin, I can actually set up to 127 different addresses, however I’ve got it capped at 16 for now. A buddy of mine suggested the idea of using diodes as or gates, for reading a bit shifted across the 8-bit port on the pic. So with between 0 and 4 diodes as a mutliple input single output OR gate, I can read any binary number between 0 and 15 (0000 to 1111) with a single pin, which happens to be the only one left!

I’ve also found the hundreds of cheap’o LEDs I ordered from a popular auction site aren’t well suited to this application. I believe this is because of their tight lense angle of 20°. The leds I was using prior to this had an angle of 45° and I’m now using heavy-duty piranha leds with an angle of 70°. I’m going to look into getting more of the 45 deg leds, I think that angle offers the best combination of a focused upward beam but still allowing enough off-axis light back in.

I think now that I have the sensors returning data the way I want, I need to work on applications to interpret that data and do something useful with it.

As soon as I remember to recharge my camera battery, I’ll have some more pictures.

New Page: LEDs as Sensors

I’ve created a new page under Tech and Projects, LEDs as Sensors. Since I’m getting to have several posts in my blog regarding that subject, I felt it best to have them all consolidated somewhere.

I’ve also included links to other information and inspiration on the subject.

Here’s the new page:
LEDs as Sensors