Driving an 8x8 LED matrix with mcu - Page 1
Forum section: electronics / projects

author: sentry7
author_rank: Regular Contributor
timestamp: March 04, 2017, 10:44:35 pm
content: Hey guys,I have this CC LED matrix, the CBB model [https://cdn-shop.adafruit.com/datasheets/1047datasheet.pdf] that I'm driving with a 3.3v mcu. A 4017 is doing the multiplexing. Currently, my setup is this,With the mcu directly driving the leds, I'm getting about 2.6mA per led. My target is to get about 5mA. I do have a 9v rail available and some more npns (and maybe more pnps on hand). What would be the best transistor topology to get this current gain?

author: orolo
author_rank: Frequent Contributor
timestamp: March 05, 2017, 11:10:25 am
content: It's not clear what voltage does your MCU works at (could be anything over 3.3V from the schematic). It is also unclear if your matrix is the ABB or CBB model, which are driven differently. Anyway, the matrix is designed to be driven by 8 logic inputs, and 8 logic outputs, 8 for rows and 8 for columns.For example, in the CCB model, if all rows are high, and all cols are low, no LED lights up, since they are all reverse biased. If you take one row low, and one column high, only the LED at the intersection of those row and column will be forward biased. This means that you should only light either one row or one column at the same time.Since your 4017 is sequentially high in only one output, I'd use it to drive the columns of the CCB matrix. The rows would be driven by the 8 pins of the MCU, active low (sinking). Ideally you would limit current with a resistor at each pin in the row, but if the eight LEDs in a column must be on, the 4017 should provide 5*8=40mA, and that's above the chip maximum of 20mA. So you need the 4017 to turn on a transistor switch to provide that current: any small signal transistor will do. Since the 4017 is active high, the transistor must be NPN (or N-channel) and saturated. You should not use the 9V rail, otherwise when your MCUs row pins go high (3.3-5V) they won't reverse bias the diodes at 9V. Work with your, hopefully, 5V logic rail, well decoupled.What I would try is to drive the base of a regular PNP with each pin of the 4017, using an adequate resistor, and then place a resistor in each MCU input to limit the current to 5mA. At 5V, 1K for the base and 500 ohm for diode limit look good. I have attached the circuit I'd try for a 5V MCU and the CBB configuration: only when column is high the transistor turns on, and only if the row is low the current flows, limited by the resistor.If your matrix is ABB, or you are working from a 3.3V rail, things should be rearranged.I think there are ICs specifics for tasks like this, like the MAX7221 and MAX7219.

author: BrianHG
author_rank: Super Contributor
timestamp: March 05, 2017, 12:48:48 pm
content: Which MCU are you using. And like mentioned above, remember, most MCU IOs have a larger sink current switched to GND compared to when they drive source to high output.

author: sentry7
author_rank: Regular Contributor
timestamp: March 05, 2017, 01:50:11 pm
content: And as usual, I forget to mention something vital...The mcu is 3.3v and the max current per io pin is 40mA [https://www.parallax.com/sites/default/files/downloads/P8X32A-Propeller-Datasheet-v1.4.0_0.pdf].For the led matrix, I have the CBB model.So I'm driving the columns high with the mcu and the 4017 is selecting the row by grounding them.

author: orolo
author_rank: Frequent Contributor
timestamp: March 05, 2017, 02:58:57 pm
content: Oh, just noticed. Your LEDs are blue, with forward drop from 3.2 to 4V. There is your problem, you can't drive them reliably from the 3.3V rail. You need to drive them from the 9V supply.A quick and dirty solution would be to regulate from 9 to 5 volts, feed the 4017 from the 5V supply, and use my above scheme. With the pins of the mcu high the diode plus resistor will only see 1.7 volts, probably not enough to conduct much, or even turn the transistor on. A diode in series with each sink could help, reducing the drop to 1.1V. Any clean solution I can think of requires more transistors.

author: sentry7
author_rank: Regular Contributor
timestamp: March 05, 2017, 05:29:30 pm
content: Actually, I worked out another solution (I think). I fed the 4017 from the 9v rail, then dropped the output current using a resistor divider into the npn. That way, I can still drive the leds with the 9v rail.Everything is working except now, when the mcu turns off all rows (with a HIGH level at all rows), all the leds in the selected column light up. This only happens when the level at all rows are HIGH. If even one row is at a LOW level, the leds light up correctly.

author: orolo
author_rank: Frequent Contributor
timestamp: March 05, 2017, 06:18:21 pm
content: Your solution looks right, as long as you are using an CD4017 and not a 74HC4017, which is only rated for 6V, I think. I have experienced funny effects like yours with logic circuits and lots of LEDs, due to current leakage. In one circuit I remember the wrong rows lighted up I think due to reverse leakage from other diodes. In your case, could it be that the transistor is leaking enough collector current to light the diodes? When one LED is grounded it will steer all the current, when none is the leakage could be distributed among the column. If that is the case, maybe going down to 5V could solve the problem.

author: sentry7
author_rank: Regular Contributor
timestamp: March 05, 2017, 09:13:53 pm
content: I solved the leakage current problem by putting a shunt resistor to ground on the emitter so as to divert the current when all the rows are HIGH level.Thanks for the insight.