# Easiest way to read a large bank of LED's

I have a pretty straight forward question but every answer I come up with seems over complicated or just plain wrong. I'm designing a data logger/fault detection system to be used for a large piece of industrial equipment. The gist is that the only output for the current status of this machine is a large bank of LEDs (>64) either lit RED, GREEN or a BOTH (Common cathode or anode led lights) and we would like to make this output remotely accessible. I have no access to the control system of the machine so I cannot tap into the signal that controls which lights are on or off but I do have the ability to read the voltage drop across each LED with respect to either the cathode using a microcontroller. Imagine the circuit for the LED's is just a common cathode connection of all the LEDs and then >128 wires coming in connecting the anodes (no access to the current limiting resistor).

My question for you is how would you go about determining if each of the LED's has either RED, GREEN or BOTH lights lit so that it could be read by a microcontroller?

My current thought is to take a massive bank of analog multiplexers and then just multiplex the voltage of each LED (>128 different voltages to read) into an ADC and use a software threshold to determine if its on or not however this method seems way to complicated and expensive and I'm sure there is a better option. I know daisy-chaining a bunch of IO expanders together and connecting the voltages w.r.t. the cathode would work but the voltages seem too low for TTL (1.65V and 2.5V) and probably wouldn't work to produce a '1' when the LED is lit.

Could you suggest a circuit or IC or a combination of both to make this work? Thanks!

• This sounds like a nightmare. Can you access the different color anodes/cathodes? I'd probably go with comparators early instead of routing a bunch of analog signals. That or set up, one of those remote viewing devices, a camera. – Samuel Feb 3 '15 at 23:42
• Are all the LEDs wired common Cathode or Anode? This does make a difference in coming up with an effective but low-cost solution. And: how often do all of these LEDs need to be read? – Dwayne Reid Feb 3 '15 at 23:59
• @Samuel: Thanks for sympathizing! Access to each of the LED's pins is about all I have. – TrapLevel Feb 4 '15 at 2:11
• @DwayneReid: All of the LEDs are common cathode so luckily I can tie the GND to my circuit and just read all the positive voltages from the anodes. Preferably I'd like to know when one of the LED's turns a different color as quickly as possible since it could signal something really bad – TrapLevel Feb 4 '15 at 2:14
• Did you consider a web cam? – Aaron McMillin Nov 16 '15 at 16:56

If an IO expander seems OK to you, I don't see the problem. You can get them in various supply voltages, including 1.8 and 2.5 volts. So if you used 1.8 units for the red LEDs and 2.5 for the greens, I think you'd be in business. A TI TCA9534 would seem to do the trick, and you can get 64 bits on an I2C bus with them. So you'd actually need two sets of IO expanders, one for red and one for green. But it seems a lot better than the brute force approach.

• I like this idea a lot, thank you for the reply! I didn't know you could change the digital levels of IO expanders so easily but my one fear is that by lowering Vcc to compensate for the LEDs will require me to add a buffer for the I2C or SPI lines but thats only one more chip. – TrapLevel Feb 4 '15 at 2:19

This seems to be fairly easy but I suspect that it's going to be painful to install. There are is several different approaches that should work. One of those is to use the I/O expanders as mentioned by WhatRoughBeast. What I don't like about those is the logic level thresholds.

I'm going to suggest something a little bit different. I'm fond of the really old CMOS analog multiplexers like CD4051. These are dirt cheap and readily available from a number of manufacturers in both SOIC and DIP packages. Each of these will handle 8 inputs.

You mention that you want to monitor 128 LEDs. I'm suggesting that you use 7 of these 4051 mux chips. Each has several control lines and 3 power supply pins. Vee goes to ground, as does Ground. !Ena goes to ground as well (the "!" indicates active-LO). The 3 control lines A, B, C are all connected together on each of the chips and come from your micro.

I'm partial to the PIC family from Microchip. One interesting and very useful specification is that for a PIC16F PIC running from a 5V supply, the logic HI threshold for TTL inputs is about 1.3V . But be careful - some pins have ST (Schmitt Trigger) inputs - these have a logic HI input of about 80% of Vdd (about 4V). You do NOT want to use a ST input pin for monitoring the output of the mux.

Anyway, connect the "Z" pin of each mux to a PIC input pin having TTL threshold. Drive all of the A, B, C lines on the muxes from the PIC. Note that this allows you to read 7 input bits in one fell swoop.

This will give you a very fast read capability. Set address "000" on lines A,B,C and read all 7 muxes at once. Store this data, then set address "001" on the control lines and read again. And again. 8 reads later, you are done. Do with the data what you need to do.

Not only is this approach faster than using I2C, it requires much simpler code and the 4051 chips cost significantly less than I2C expander chips.

One final point: I don't know what is driving the LEDs from your original controller. If they are coming from symmetrical-drive logic chips, no problem. But if they are coming from an open-drain or open-source type driver, you may have problems with the voltage at each LED hovering just below the LED's threshold voltage. This will cause you all kinds of grief.

The cure is simple: just use medium-high pull-down resistors on the MUX inputs. I'm going to suggest that somewhere between 10k - 47k should be good. Also note that these can be physically quite small - simply use a 10-pin bussed SIP resistor network. One small package per MUX chip.

Although not specified, it sounds like you have a multiplexed led display. If that is the case, then it is only necessary to read the voltages on the peripheral lines to the LED x-y busses. There will be three states +V.-V. and almost no V. External light can make an LED act as a photocell, so an unactivated LED may show a few Mv due to external light. Use a microprocessor (your choice) to scan the wires with an analog multiplexer, like a CD4067B (16 x 1), at a rate faster than the LED multiplex rate. Two CD4067B would allow a 16 x 16 scan or 256 points. Three '67B's could do 32 x 16, four 32 x 32 . . . with only 9 (or 10) data lines from the microprocessor. If the microprocessor has a two (or more) muxed 12 bit analog to digital converter, it might be possible with only the mux chips and the microproc. The micro then does a binary lookup table for the patterns and outputs ascii data, 232, 485, or whatever via a optocouplers or wifi. An Atmel328 might be right. . .

• Thank you for the reply! The LED control signals are coming off a PCB and are routed to the LED's via 3x 20 wire ICD ribbon cables and another 60 wire ICD cable but I can't access the PCB (mainly from fear of messing up a $3000+ proprietary board) otherwise great idea. Also thank you for pointing out that LED's can act as a photocell, I would be been scratching my head for days trying to figure that out! – TrapLevel Feb 4 '15 at 2:07 I will point out that an idc flat cable allows pressing on another connector which can then attach to your PC card. After I first replied, I realized that a 5mp video camera with a Raspberry Pi could also do character recognition by focusing on the display, but I think that is a "cheating" answer. Software would be a material for a dissertation. • Yes, I thought about adding another IDC connector to the mix but worried that if by chance I accidentally cut one or more wires I'd have to get a technician out to fix it ($1000+) especially since there are so many that crossing two wires would cause the wrong LED to light. The camera idea was a great idea however my DSP programming skills aren't what they use to be and even if there was a library I'd worry about a lot of false positives or missed failures under certain circumstances (room lights on or off, someone accidentally taps the camera etc.) – TrapLevel Feb 5 '15 at 18:04