Preferred circuit layout for running LEDs from transistors

I'm working on making an IR remote system. I've got some IR leds that I'll be running at the end of cables, with a central box containing the arduino/power/etc. (before looking at the circuits below - yes, I know that on a teensy you have to use pin 10 for the IR library - this was just neater to use this pin for the example)

Looking into this, it seems like all the circuits I see are laid out like this:


TransistorLayout1 by mostlytechnic, on Flickr

Power supply goes to the LED, then the LED is connected to the collector, and then the emitters connect together to ground.

Is there any reason it's not done like this:


TransistorLayout2 by mostlytechnic, on Flickr

Would the 2A power fry the transistors? (I'm using 2n2222s, so they're rated for 600ma - the resistors are letting 200ma thru the LEDs). This just seems more intuitive to me than the first layout.

I'm planning to have 7 LEDs and 7 transistors. That's based off the tv-b-gone design, using individual transistors to switch IR leds. The electronics box will contain the teensy, transistors, and an RJ45 jack. The LEDs will be on the other end of some cat5 cables and splitters. So 7 wires of the cat5 will be for the 7 LEDs, and the 8th will be a shared either gnd or 5v, depending on which circuit layout I use.

(oh, while I'm at it... any issues with using a single pin to switch 7 transistors like that? I know on the tv-b-gone they added a transistor to switch the transistors, but that isn't using the same microcontroller)

You need to use the 1st circuit, and each transistor MUST have a a series resistor in the base (1K - 4K7 should work), unless that teensy board already has it. The 2nd circuit will not work as you may think, as a "switch". You may have tried it and it may appear to work, but believe me, it's not the way to do it and you're probably stressing the transistor.

The current that goes through the transistor is the same that goes through the LED, and this current is basically set by the resistor in series. The transistor will chop off some 0.2V from Vcc and the LED will chop off some voltage too (depends mainly on LED color); dividing the resulting voltage by the resistor gives you the current that will flow. A small, normal LED will work well at 20mA, so you can reverse the calculation to get the resistor value.

UPDATE: I saw now that you're using both transistors of the same teensy pin. You need only 1, then parallel both LEDs and resistors, that is, Vcc -> R1 -> LED1 -> Transistor1 -> GND and Vcc -> R2 -> LED2 -> Transistor1 -> GND. Each resistor gets calculated as I described above, independent from each other. It's a PIA to explain these things without a drawing...
More, if you're using "normal brightness" LEDs (white and blue excluded), you can probably use only 1 resistor, having both LEDs in parallel series; just subtract both LED's voltage drop and the transistor's 0.2V from Vcc, to calculate the resistor.

I'm actually using IR LEDs, 1.2V, pushing them to 200ma (they're rated at 100ma continuous or 2A at a short enough pulse). My calculated series resistors on the LEDs are 18ohm if I remember right.

I have not built circuit 2 - that's just the way I'd do it if I didn't know otherwise. I'm more experienced in "bigger" electric stuff like household wiring, so circuit 2 is the way my mind intuitively wants to do it.

Since I'm going to be using 7 (not just the 2 shown), that's too much for the transistors I have. I could get a more powerful transistor that can handle switching 2+ amps and run the LEDs in parallel, or I could use multiple transistors in parallel. Since I've got em, I was going to use 7 small transistors so that there's no parallel LEDs - each LED has its own "power supply" if you will. That seems like a safer method since the LEDs will be spread out on cat5 cable, ranging from a couple feet to 20+ feet away.

But you're saying I also need a resistor between the teensy and the transistor base? Assuming I stick with the 7 transistors, can that be 1 resistor or do they each need their own? That resistor is to keep from frying the transistors with too much current to the base? (a quick googling doesn't indicate that the teensy has them, so I'll add it)

so circuit 2 is the way my mind intuitively wants to do it.

What you are missing is that in that circuit the emitter will be at a voltage 0.7V below the voltage on the base. So you don't apply the full voltage across the load (resistor and LED). In the other arrangement you get the maximum voltage out, it also allows you to connect the load to a higher voltage.

My calculated series resistors on the LEDs are 18ohm if I remember right.

As a rule of thumb if a resistor for an LED turns out to be lower than 33R (ohms) then you need some better way of limiting the current like a constant current supply. At these sort of loads you also need to consider the gain of the transistor and calculate the value of the base resistor.

can that be 1 resistor or do they each need their own?

I am having a hard time thinking how you can put one resistor in series with 7 outputs and 7 transistor bases. So you must not be understanding the concept of a series base resistor.

If you have LEDs in parallel they also need their own current limiting resistor in line before you parallel them up.

As a rule of thumb if a resistor for an LED turns out to be lower than 33R (ohms) then you need some better way of limiting the current like a constant current supply. At these sort of loads you also need to consider the gain of the transistor and calculate the value of the base resistor.

And this is why I come here for help :slight_smile: I'm running everything off a 5V 2A external power supply. So I calculated the resistor for the LEDs based on 5V supply, 1.2V LED, and desiring 200ma (so that 7 of them is drawing ~1.4A). That came out to be 18-19R, so I am planning to use 18Rs. Is there a better way to do it? How much effect does the transistor have?

I am having a hard time thinking how you can put one resistor in series with 7 outputs and 7 transistor bases. So you must not be understanding the concept of a series base resistor.

The transistors/LEDs are all running from the same signal, just spreading the IR signal over a wide physical area. So I was picturing pin -> resistor -> 7 transistor bases. Or should it be pin -> 7 resistors -> each resistor to a transistor?

I fixed a little mistake I had on the post, at the end I said "parallel" but meant "series".

Yes, 18 Ohm resistor would be the value for 200mA for a circuit 1 - like with that IR LED ((5V - 0.2V - 1.2V) / 0.2A = 18 Ohm). Since the LEDs are 100mA max continuous, this means you're not planning to run them 100%, but ON/OFF with duty cycle at or below 50%, correct? In that case you should be relatively OK with the 18 Ohm resistor (I suppose this is not a "serious product") unless you can feel the LEDs and/or the transistor warming up continuously, because the average current will be 100mA which would require a 36 Ohm resistor (not that simple, because dissipated power is proportional to current squared, but I think we can ignore that here).

You can use 1 transistor to light up to 3 LEDs, because 0.2V + 1.2V x 3 = 3.8V which is still below 5V with a good margin. Put them in series, and in series with the resistor (recalculate it, pick the closest commercial value above the value you calculated). This has several benefits compared to having 1 LED per transistor, both in number of parts and in power consumption (7 will now pull, not 1.4A from the power supply, but only 0.6A, in a 3 + 3 + 1 arrangement). Make sure they won't warm up continuously even in a hot environment, otherwise you'll have to go back to current control as already mentioned by Grumpy_M)

You cannot use bipolar transistors in parallel for this scenario (parallel = connecting emitters and collectors or emitters and bases).

Yes, these are sending an IR signal, so pretty low duty cycle. Probably <1%. And no, not a serious project. Just something to control some model train stuff in the basement. I've had issues with the IR remote working reliably to all the receiver locations, and I wanted to build my own control interface, so I'm doing this. This is just the output side.

Due to the way I'm setting them up physically, putting LEDs in series won't work. I'm basically running cat5 cable with splitters along, and then having modules that plug in at any of the points that have the LED and resistor in them. I figured I'd build 7 modules, each connecting to a different line of the cat5 wire, so that way it doesn't matter which are plugged in or in which location.

sending an IR signal, so pretty low duty cycle. Probably <1%

I am not sure why you think you will get a low duty cycle with data. IR has to be modulated normally at 38KHz but can be between 32 and 48KHz depending on the receiver. During the time of the pulses you will have a 50% duty cycle. You can't average it over a long period.

I would disagree about you being fine with an 18R resistor, at high currents the forward voltage drop of an LED can change dramatically with temperature and with age. If you don't want to go to constant current control then I would put two or three in series together and run them at a lower current.
I see what you are saying about the transistors, yes you need a separate base resistor for each one. You calculate the base resistor by taking the current you want to switch and dividing it by the minimum gain of the transistor from the data sheet. This gives you the base current you need. When feeding the base from an arduino output you will get 5V out (for the purposes of this calculation) and the base voltage will be 0.7V when the transistor is on. Therefore you calculate the resistor to have this current flowing down it with 5 - 0.7 = 4.3V across it. You might want to make the base current a bit larger to be on the safe side. No harm will come by having this up to 10 times larger than it needs to be.
If driving lots of transistors from the one output make sure the base currents they require does not exceed about 30mA, if it does use more than one output and split your transistors over these outputs.

I have 2 links that you may find useful. It is a LED wizard calculates the values of resistor needed to operate LED in series(s). Turns out, if you have them in series it actually draw less power than individual with resistor. I think pushing the LED to 200ma is a bit much, it will shorten is life. Most 100ma LED has a peak current at 150mA for pulsing.

http://led.linear1.org/led.wiz
http://ledcalc.com/

use both wizard to compare results.

kkman20xx: Yep, I've used both those sites to calculate. However, for the design I'm doing, series LEDs will be a problem. I really need parallel.

Grumpy_Mike:
I am not sure why you think you will get a low duty cycle with data. IR has to be modulated normally at 38KHz but can be between 32 and 48KHz depending on the receiver. During the time of the pulses you will have a 50% duty cycle. You can't average it over a long period.

you're right, I was averaging it over too long. This is a 38kHz system, so yeah, it'll be at 50% for a second or so, then off for a while. So it needs to be designed to handle a 50% duty load, which these LEDs should. I'm only planning to run them at 200ma.

I see what you are saying about the transistors, yes you need a separate base resistor for each one. You calculate the base resistor by taking the current you want to switch and dividing it by the minimum gain of the transistor from the data sheet. This gives you the base current you need. When feeding the base from an arduino output you will get 5V out (for the purposes of this calculation) and the base voltage will be 0.7V when the transistor is on. Therefore you calculate the resistor to have this current flowing down it with 5 - 0.7 = 4.3V across it. You might want to make the base current a bit larger to be on the safe side. No harm will come by having this up to 10 times larger than it needs to be.
If driving lots of transistors from the one output make sure the base currents they require does not exceed about 30mA, if it does use more than one output and split your transistors over these outputs.

Ok, lemme see if I'm getting this then. My transistors are just a bag of generic P2N2222. Googling, people seem to calculate using 25-100 as the gain. So that'd mean a base current of 2-8ma, for a 200ma output. Running 7 then would need 14-56ma, so it could be fine or not off a single output pin. Wikipedia says these should have at least 100 gain, so it'd likely work (my test setup used 4, with no base resistors, and it worked fine, but I only ran it a little while).
Assuming gain of 100 means base current of 2ma, so a resistor of 2150R or less (obviously, there isn't a 2150 exactly)

Ok... rethinking the design a bit...
If you were starting from scratch and wanted to run 7 LEDs in parallel at 150-200ma each, from 1 PWM output, how would you do it (cheap of course is always good...)

I would run them in series, preferable from 12V (maybe 9V - 10V...), which would allow to run the 7. One transistor handles it.
Or 3 + 3 + 1 from 5V; using 3 transistors at 8mA base current would still be "affordable" by a single AVR pin.

At the points where you don't want an LED, plug-in a 60 Ohm resistor (or 56 + 4.7), which will cause the ~1.2V voltage drop at 20mA, thus simulating that there's a LED in there.

timropp:
(...) (my test setup used 4, with no base resistors, and it worked fine, but I only ran it a little while).

That's pulling some (5V - 0.7V) / 25 Ohm ~ 172mA from the AVR pin, way outside its spec'd limits (AVR pin has an internal series resistance of around 25 Ohm). That chip just lost its specs guarantee from ATMEL.

At first I was sure that it HAD to be parallel to work for my layout, but thinking more, series might work... 12V will be easy to source for this, so I'd go with that. Put all 7 in series and just always use them all, or make some dummy resistor plugs like you suggest. Does make it a bit simpler to not need resistors at each LED, just one in the main box. Now, my calc suggests from 12V for 7x 1.2v LEDs at 200ma each, I'd need an 18R 1W resistor. That's still in the "too low of a resistor" category that got this all started :slight_smile: Is that a problem here or should that work ok? I'd probably make that out of a couple 1/2w, since I've got a 1/2w assortment on hand, but no 1w on hand.

I'll draw up a new schematic in a little while, but would it matter that there's 30 or more feet of cat5 between the series LEDs and multiple plug junctions along the way? I might hook it all up (with just jumpers where the LEDs will be) and make sure it's got continuity and that resistance is low enough to ignore.

Ok, did some more thinking about the series method. Here's what I came up with:


SeriesLEDs by mostlytechnic, on Flickr

Does that look ok? (I just noticed that I labeled the one resistor as 22R when it should be 18R for 200ma to the LEDs. It'll probably actually be a pair of 1/2w 10R 39R in parallel or a pair of 1/2w 10R in series.)

It'll probably actually be a pair of 1/2w 10R in parallel.

That will give you 5R you want to put them in series.

Oops... did my math wrong (calculated it as 1/Rt = 1/(R1 + R2) instead of 1/R1 + 1/R2)

any benefit to doing a pair of 10R in series vs a pair of 39R in parallel?

timropp:
any benefit to doing a pair of 10R in series vs a pair of 39R in parallel?

Not that I'm seeing. Dissipated power in each is roughly the same.

Do you have the cable already installed? It's just because, you see, you are using 7 wires for a series connection. This can be done with 2 wires, by running the 2 wires from the board to the farthest LED passing by all the other LEDs, and at each LED break one of the wires and insert in it the LED.

I don't know if you're going to have trouble with cable length, a grey area to me. The frequency is relatively small, but the signal rise/fall times can be fast. You'll have to try, maybe scope it, and then if problems arise, maybe slow down the signal transitions speed by inserting a small capacitor from the base to the emitter of the transistor.

Yeah, the cabling is pretty much set already. I'd originally planned to do parallel LEDs, so wired things in prep for that. This odd method of doing series here is just a way to not undo too much other stuff.