Why do people use NPN transistors in order to build a LED cube?

Hi!

I was wondering one thing: There are many people out there who has built an LED cube with the help of NPN transistors in order to control each layer. Why do people use NPN transistors in order to control each layer? Isn't it possible to just use a cable to directly connect it to one of the outputs of the Arduino?

Cannot seem to find an answer on the internet, so I am trying to post my question here.

I've never built one, but I'm gonna go ahead and say that they use an NPN transistor to enable the use of an external power supply to power the LED cube, as to not draw too much current from the arduino and burn it up. That way, the arduino just sends the high/low signal, and doesn't have to try and supply the power.

Anon_person:
Hi!

I was wondering one thing: There are many people out there who has built an LED cube with the help of NPN transistors in order to control each layer.
Why do people use NPN transistors in order to control each layer? Isn’t it possible to just use a cable to directly connect it to one of the outputs of the Arduino?

Cannot seem to find an answer on the internet, so I am trying to post my question here.

Arduino pins can only handle a maximum of 40 milliamps.

(and even 40 milliamps isn’t recommended for constant use).

Anon_person: Hi!

I was wondering one thing: There are many people out there who has built an LED cube with the help of NPN transistors in order to control each layer. Why do people use NPN transistors in order to control each layer? Isn't it possible to just use a cable to directly connect it to one of the outputs of the Arduino?

Cannot seem to find an answer on the internet, so I am trying to post my question here.

The answer is in how a cube is wired to operate. There are usually individual drivers (either direct avr output pins or shift registers output pins) driving the vertical columns of a cube. And as such depending on how many leds the given pattern wants to turn on for a given cube 'level' (or "layer" if you please) the total amount of current demand for that level can vary from 0 ma to 20ma X the number of leds for that level, so for a 5x5x5 cube there can be as many as 25 leds that must be powered, or 500ma, so the 'level driver' current requirement is way too much for directly connecting to a digital avr output pin, therefore a switching transistor rated for well above the worst case "level" current requirement is needed.

Does that make sense?

Lefty

Thanks for all the answers, yes Lefty it makes very sense. But if I do not want to turn on all the leds at the same time and use multiplexing on the programming, is it possible to skip the transistors for a 5x5x5 cube? BecaUse it seems like the leds are very dim when we have our own LED cube 5x5x5 on, especially when we use multiplexing and we do use transistors

Anon_person: Thanks for all the answers, yes Lefty it makes very sense. But if I do not want to turn on all the leds at the same time and use multiplexing on the programming, is it possible to skip the transistors for a 5x5x5 cube?

Anon_person: Yes but it will be very dim.

Anon_person: BecaUse it seems like the leds are very dim when we have our own LED cube 5x5x5 on, especially when we use multiplexing and we do use transistors

Circuit diagram? Multiplexing scheme...?

You can buy common anode and common cathode RGB LED’s.

But, as pointed out, it’s how you go about powering them, do you Source or Sink… take a look at the attached image.

PNP_NPN_switching-outputs-195x147.jpeg

What are you using as current source for the anodes in your cube, and where are your current limit resistor located?

Well you can power a 5x5x5 LED cube from the arduino itself by using shift registers and 5 npn transistors for switching to gnd. I run my cube @ ~13mA per led. So if I light up 1 layer it only draw 325mA + some current for the chips/uno itself of the 450mA(or 500mA, however I'm not sure) available. Though its working you can't light up more than 1 layer at the time, because of this you have to multiplex the cube... In my thread there are some pics of my cube as you can see I only use 5 npn transistors:http://arduino.cc/forum/index.php/topic,144057.0.html. You have to use those transistors because the arduino can only sink up to 40mA per pin, with 5 transistors you only need a limited amount of current from the arduino pins to the base of the transistor to switch it to gnd.

I have a question regarding LED driving, every time I think I understand things I realise I don’t. I know this is getting a bit OT, please forgive that but there seesm to be some knowledgable people here, and this does seem to be very close to topic,switching LEDs with NPN transistors.

Basic task : I want to drive some common cathode RGB LEDs with an Arduino. I’ve got a bunch of IRF520s on hand, also small transistors like 2N2222, BC557.

Does this circuit even make sense? Is it the best way to do what I want to do? (I’ll settle for ‘works’ as a definition of ‘best’)

Can’t inline images ?

I was planning on running the LEDs in ‘parallel’ ie connecting all their red pins together and so on, then using one FET for each colour channel. I’ve tried that woth the 220ohm resistors and the current flow is OK, a bit low but the LEDs are bright enough. I know I dont need the FETs, they’re 10A units and some little transistors would do fine. Also, PNP transistors would be fine, I just happen to have the IRF530s.

Any help much appreciated.

fet-lowside-2.jpg

another restor to the unconnected led in series with the source of the fet, same as the connected existing one

Yep. I put the second LED in there to indicate "more LEDs go here...", that is, the same colours all tied together. Probably wasn't that clear of me in the diagram. If the circuit's OK apart from that I'm happy.

What is the complete IRF520 or IRF530 part number being used? http://www.digikey.com/scripts/dksearch/dksus.dll?vendor=0&keywords=IRF520 http://www.digikey.com/product-search/en?lang=en&site=us&KeyWords=IRF530

Some are Logic Level, and will switch from 0-5V just fine. Some are Standard Level, and will not switch full on unless 10V or more is available. Some are N-channel and are really intended as current sinks (use between cathode and Gnd) Some are P-channel and are really intended as current sources (use between 5 or 12V and anodes)

The markings on them are:

IRF 530N I?R 226E 15 5E

? is a marking I can't decipher, looks a bit like a triangle. They're in a TO220 package.

From the IRF530 datasheet, almost all are logic level gated, so they'll switch properly with the Arduinos 5V? That'd be good news.

I'd read that FETs are better chosen to suit the load given them - not the few hundred milliamps this will use where, but also the FETs have a much lower on resistance, so surely I'm better off doing things the way I'm doing them?

Also, I left a wire out of that diagram, I was just going to connect all the anodes for a particular colour together, then to the resistor and FET, is that OK? At this stage there's only 4 LEDs ie 4 LEDs on each of the RGB channels.

Okay, that's an N-channel MOSFET. Better suited as a switch between cathode & Gnd, but if you have common cathode RGBs and its a 5V only system then using between 5V and a resistor to each anode might be okay. If you use 1 resistor and parallel up the Anodes you may get uneven brightnesses, or burn them out if the LEDs have different current flows between them.

I'm happy to hear that. I'd seen the uneven brightness before - I'd set up the LEDs on a breadboard and ran the resistor and power leads to them. They get about 13mA, nothings being stressed out it seems.

I've read, now, that common cathode LEDs are a pain to use, and now I see, hard to drive even with discrete components, won't work with a 5940, or a uln20003, or anything that could be described as being 'neat'.

I've seen another curcuit that used a PNP transistor connected to the anodes of each colour and had the cathodes direct to ground. Is that a better way of doing it? I only have some low power 557 PNP devices atm.

if this FET circuit can be 'got going' I think it'd be more useful. especially if I can then drive 20 or 30 LEDs.

Thanks for your time and help with this.

"Is that a better way of doing it?" No, it's just another way.

You cannot connect the LED's to the IRF530 as described on the schematics above - fet-lowside-2.jpg (high-side switch). The IRF530 is not a "logic" level transistor, even they write its Vgs "threshold" is ~4V for 1A Ids (see the datasheet). When you connect the diodes into the IRF530's source, the voltage drop on the diodes and resistors will increase the required IRF530's Vgs threshold. Thus you must have the Vgs1 = Vgs + I*Res+Vfdiodes, which will be more than 5V definitely. Use low-side switch (diodes in the IRF530's drain).

I've been reading a lot about this - I'm not expecting people here to just teach a lazy student - but I just can't figure it out. There's mention of instability because of the gate voltage on my original circuit and the fact that the diode + resistor will drop a lot of voltage. I'd assumed that the output of the Arduino would be 5V, or close to it, and at any rate about as high as you could get on a 5V circuit.

But there's no way I can see a common cathode LED being placed on the other side of the FET (yeah, I know I stuffed up the high side /low side terminology earlier). If all their cathodes are tied together, then all the LEDs diodes will be affected at once . So, I'm back to using a PNP transistor?

I'd assumed that the output of the Arduino would be 5V, or close to it, and at any rate about as high as you could get on a 5V circuit.

With your schematics (diodes in IRF530's source) you need much higher gate voltage to switch the transistor ON. The voltage you would need to switch the IRF530 ON is VgsON = Vgs + I*R + Vfdiode. That voltage is MUCH higher voltage than your arduino's output pin can offer. Therefore, it is a bad idea to do so..

When you connect the diodes in the drain of the IRF530 you need "Vgs only" to switch the transistor ON.

Be aware there is no warranty the IRF530 transistor will be switched fully ON with 5V, however.

Why do people use NPN transistors in order to build a LED cube?

I do not know, I never delt with LED cubes, but the usage of an NPN/PNP/NFET/PFET transistors depends on the design, not on what people say. You may use basically any of them, but you have to design the stuff properly.. ;)