Pages: [1]   Go Down
Author Topic: Multiplexing RGB LEDs  (Read 1722 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27386
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Method to Multiplex 10 RGB LEDs with 5 PNP transistors and a 74HC595.
Limit current into 74HC595 to 70mA MAX.


* Mux RGB LEDs.jpg (64.86 KB, 960x720 - viewed 98 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 224
Posts: 13921
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,
do you have some code too?
does this work with PWM too?

(yes I know one mad men can ask more than 10 wise can answer;)

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27386
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure, put PWM on the OE pin instead of grounding it.

Code:
#include <SPI.h>
byte pinArray[] = {2,3,4,5,6,}; // Arduino pins
byte dataArray[5]; // data to turn RGBs on/off, 1 byte per row, bit 6-7 not used in this example
byte rowEnable;
byte ssPin = 10;
byte x;

unsigned long currentmillis;
unsigned long priormillis;
unsigned long duration = 5; // 5 mS udpates, 25mS total refresh time (40 Hz)

void setup(){
// setup output pins, HIGH to turn off PNPs
for (x=0; x<5; x=x+1){
pinMode (pinArray[x], OUTPUT);
digitalWrite (pinArray[x], HIGH);
}
pinMode (ssPin, OUTPUT);
digitalWrite (ssPin,  HIGH);
SPI.begin();
}
void loop(){
// My method to multiplex a display
// Loop thru the row, but update when a time has elapsed
// Is a for-next loop, but with time check mixed in, so traditional for-next format is broken up
// see if time to change the display
currentmillis = millis();
if ( (currentmillis - priormillis)>=duration){
// set up for next time check
priormillis = priormillis + duration;
// turn off prior row
digitalWrite(pinArray[rowEnable], HIGH);
// set up for the next row - this is where the for-next is broken up
rowEnable = rowEnable +1;
// reset when reach the end
if (rowEnable ==5){
rowEnable = 0;}
// write cathode data
digitalWrite(ssPin, LOW);
SPI.transfer(dataArray[rowEnable]);
digitalWrite(ssPin, HIGH);
// Enable Anode
digitalWrite(pinArray[rowEnable], LOW);
} // end dataArray writing

// code to perform dataArray goes here

} // end void loop
Compiled & passes. Up to user to develop code towards the end to define what is displayed.
« Last Edit: February 02, 2013, 02:43:23 pm by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks nice, but the specific parts (like a bill of materials) would make it easier. It looks like things are limited to 60mA, would about any npn transitor would work?

LED specifications will vary, so its hard to build the BOM when you dont know the LEDs forward voltage or current specifications.

It looks to me that you are planning on running the LEDs at about 10ma, to keep the shift register down to 60mA. That does require that only one transistor is turned on, and should something cause more than one transistor being on(program crash,...), could cause a situation where more than 70mA could happen.

This would also be a handy circuit for controlling 30 LEDs.

P.S. Im still working on a 64 RGB LED cube with 20 NPN transistors Im using tiny 2n2222s to sink upto 240mA.

This might be a curious way to make a 10x10x10 RGB LED cube or 10x10 matrix.
Logged


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27386
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

LED size - 3mm, 5mm, 10mm, SMD, thruhole, infinite choices of brightness. Same for Vf. 
Transistor must be PNP, not NPN.
Shift register can be 74HC595, or TPIC6B595 for more current sinking capacity.
Resistors sized to suit the other components.

That's why no BOM is provided.
Expand it higher or wider as needed.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27386
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

More LEDs connected


* RGB_led_shift_registers1.jpg (97.21 KB, 960x720 - viewed 59 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks like you have 100 RGB LEDs going on there, and a short BOM to boot. Nice work.

If im not mistaken, that looks like:
100 RGB LEDs
310 resitors
10 PNPs
4 shift registers.
----------
424 parts.  Thats pretty good when you consider that you are lighting up 300 LEDs.

Im not sure, but it looks like making a 10x10x10 cube is just another 10 more transistors.
Logged


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27386
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No, only 40 resistors - 10 on PNP bases, and 30 on the shift register outputs (which I didn't show - will have to fix that - this was modified from a WS2803 example which didn't need individual resistors)

10x10x10 cube - yes, 1 more transistor to enable each row,
and of course something to drive them all.
This card has 96 open-drain outputs.  I'm thinking 81 cathode sinks, and 9 pnp gate sinks for a 9x9x9 cube.

I used 2 cards, with 2nd card having only shift registers daisy chained off the first, to drive a non-multiplexed 20 column display

Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That card looks pretty nice, one day I should try doing things the easy way.

So... lets see if I can get the BOM approximation:

10x10 RGB Matrix:

100 RGB LEDs (too many options to list, but may effect other parts values)
40 resitors (10 x ??? for transistors, 30 for cathodes (values vary depending on many factors))
10 PNPs transistors (Part suggestion? 3906 is too small?)
4 Shift registers (could be 74hc595, TPIC6B595, ...)
4 decoupling caps (Probably .1uf ceramic cap)
-------
158 parts to control 100 RGB LEDs.

10x10x10
1,000 RGB LEDs
50 resistors (20x ??? for transistors, 30 for cathodes)
20 PNPs (unsure, two sets of 10 or maybe one set of 20, depending on other factors)
4 shift registers
4 decoupling caps
--------
178 parts to control 1,000 RGB LEDs.

Can that be right?

Lets say we wanted to go crazy, and use mosfets instead of BPJs Would that make any significant differences in design? energy consumption?
If my 4x4x4 transistor cube works out well, I was thinking of doing the same thing with some tiny mosfets.

Logged


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27386
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think you have the BOM correct.
I personally would use TPIC6B595 (as shown on my card) so that the design is not limited by the 74HC595's 70mA total current sink capability,
and some kind of P-channel logic level MOSFET with low Rds, then additional TPIC6B595 could be used to pull the gates low to turn them on, and simple resistors to pull the gates high to turn them off. My board populated with 7 TPIC6B595 would be sufficient to drive the 30 cathodes in the rows, the 10 row enable transistors, and the 10 layer enable transistors.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 27386
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Updated to show missing current limit Rs and expansion with Layer transistor to support multipexing of a 10x10x10 RGB cube.


* RGB_led_shift_registers2.jpg (117.81 KB, 960x720 - viewed 54 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: