# Arduino Forum

## Using Arduino => LEDs and Multiplexing => Topic started by: adrian_h on Mar 27, 2013, 12:16 am

Title: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 12:16 am
I'm trying to drive 6 IR LEDs off of a UNO using a P2N2222A.  I'd like to push about 100-200mA through them.

In order to reduce the current draw, I was thinking that I should put them in parallel banks, however, I'm not sure how to calculate the resistor value to get the current I want.  Could someone help me out with the calculation?  Is what I am attempting to do a good idea?

Here is the schematic of what I am attempting:

Code: [Select]
`                     RB                +--./\/'-- pin 12                 |               B|       D00  D01   R0           +--C/ \E---+-|>|--|>|--'\/\,--+           |          | D10  D11   R1    |E=5v      _|_         +-|>|--|>|--'\/\,--+I=100mA   _-_         | D20  D21   R2    |  -200mA   -          +-|>|--|>|--'\/\,--+           |                             |           +-----------------------------+ RB = 330 ohms Transistor = P2N2222A`
All diodes are approx 0.63V at about 15mA.  I've driven them to go to about 1.5V each at about 150mA for a short period.  I figure that this wouldn't be too bad if I pulse them and allow them to dissipate heat.  I don't have datasheets on these.

BTW, what is the Vin for?  Is it just raw power without a current limit?  At least not limited to the board, but the power supply that supplies the board?

Thanks for the help.

Title: Re: Driving 6 IR LEDs using a transistor
Post by: runaway_pancake on Mar 27, 2013, 12:28 am

BTW, what is the Vin for?  Is it just raw power without a current limit?  At least not limited to the board, but the power supply that supplies the board?

Yes, "Vin" is the input voltage as delivered from your external supply / battery.

The LEDs should be between +V and the collector, not in the emitter (which ought to go straight to Gnd.)

(Vin - V_LEDs) / ? = Amps
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 12:50 am

Yes, "Vin" is the input voltage as delivered from your external supply / battery.

Ok, thanks.

The LEDs should be between +V and the collector, not in the emitter (which ought to go straight to Gnd.)

Oh, ok, didn't realize that would make a difference.  Still reading up on all of this stuff. :)

(Vin - V_LEDs) / ? = Amps

Yeah, that I know, but when I start drawing more current, the values I am getting from my multimeter don't seem to be correct.

Also, seems that the transistor will also take a voltage drop too and all these voltages are dependent on current draw (or is it the other way around?).

Oops, forgot to put in what I calculated.

Code: [Select]
` VR0 = 5 - 1.25 = 3.75V IR0 = 100mA / 3 = 33.33mA RR0 = 112`

So, this appears to be what I want (I am starting at a lower current for now, but may go higher later), but as I said, testing shows that these voltages on the LEDs and transistors are changing causing the current to change too.  Not sure how to compensate.

Title: Re: Driving 6 IR LEDs using a transistor
Post by: fungus on Mar 27, 2013, 12:54 am
a) The transistor emitter should be connected to ground (or it won't work).

b) Putting unknown amounts of current through a LED isn't a good idea. Where did you buy them? Somebody must know their power rating.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 12:57 am
Oh, one other thing, can I just plug in an external battery to the DC in plug even if I'm running off of USB?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 01:00 am

a) The transistor emitter should be connected to ground (or it won't work).

Well, it did seem to 'work'. :)  (the LEDs turned on)

b) Putting unknown amounts of current through a LED isn't a good idea. Where did you buy them? Somebody must know their power rating.

Bought them from a surplus store (Active Surplus).  I think I asked them before and they didn't know.  I'll ask again.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: runaway_pancake on Mar 27, 2013, 01:05 am
Let's go with 80 mA, IREDs can do with much more current than LEDs.
[Bold, daring, and unafraid - that's us, already]

Let's say you have a 9V Vin, 6 LEDs IREDs w/ nominal 1V each, that's 9V - 6V = 3V
3V / 80 mA = 37?
Two 100? in parallel are 50?, 3V / 50? = 60mA
3 100? in parallel are 33?, 3V / 33? = 90mA

Just for peace of mind, disconnect the battery (external) before connecting USB and vice versa.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 03:55 am

Let's go with 80 mA, IREDs can do with much more current than LEDs.
[Bold, daring, and unafraid - that's us, already]

Let's say you have a 9V Vin, 6 LEDs IREDs w/ nominal 1V each, that's 9V - 6V = 3V
3V / 80 mA = 37?
Two 100? in parallel are 50?, 3V / 50? = 60mA
3 100? in parallel are 33?, 3V / 33? = 90mA

So basically trial and error?

Just for peace of mind, disconnect the battery (external) before connecting USB and vice versa.

So, you're saying not to use the.battery when plugged into the USB? Will power leak into the battery?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 10:08 am
Ok, I rewired my board but didn't see any change:

Code: [Select]
`                        D00  D01   R0           +-(A)------+-|>|--|>|--'\/\,--+           |          | D10  D11   R1    |E=5v      _|_         +-|>|--|>|--'\/\,--+I=100mA   _-_         | D20  D21   R2    |  -200mA   -          +-|>|--|>|--'\/\,--+           |                             |           +--E\ /C----------------------+                |B                |    RB                +---'\/,-- pin 12 RB = 330 ohms Transistor = P2N2222A`

Here are my calculations:
Code: [Select]
`E = 4.5V - 2.5V = 2.0V (each IR LED is about 1.25V)I = 100mAR = 2.0V/0.1A = 201/R = 3/RR020 = RR0/3RR0 = 20*3    = 60`
So I happen to have 330 Ohm resistors on hand so, I could put 5 in parallel to get 66 Ohms or 6 in parallel to get 55 Ohms.  I used 5 in parallel.
Going backwards through the equations I just used, I can calculate current (I).
Code: [Select]
`RR0 = 66R = 66/3  = 22I = E/R  = 2.0V / 22  = 90.9mA`Ok, so those are my calculations.  Here is what I actually measured:
Code: [Select]
`V=4.46VI=48.9mAVD0 = VD00 + VD01 = 2.55VVD1 = 2.55VVD2 = 2.54VR0 = 66.0R1 = 66.0R2 = 65.5`
To measure current and voltage, I moved base wire from pin 12 to +5V.
Current was measured at (A) in diagram, diode voltages were measured along lit diodes and resistances were measured while circuit was broken.

Could someone tell me what I'm missing in my calculations?  This is driving me nuts. :(

Thanks
Title: Re: Driving 6 IR LEDs using a transistor
Post by: mjkzz on Mar 27, 2013, 10:23 am
What is Rb? Your transistor might not be fully on . . .
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 04:52 pm
Sorry. I put the value of RB in my first diagram.  It's 330.  I added it to the current diagram.

I looked up a spec sheet on the P2N2222A, and if I'm reading it right, it has the capability to carry 500mA.

Vce Saturation (Max) @ Ib, Ic:   1V @ 50mA, 500mA

Is that right?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: fungus on Mar 27, 2013, 05:56 pm
What's the voltage measured between the base&emitter of the transistor?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 06:30 pm
822mV when on, 0V when off
Title: Re: Driving 6 IR LEDs using a transistor
Post by: dc42 on Mar 27, 2013, 07:48 pm
What I think you are missing is the saturation voltage - Vce(sat) - of the PN2222A. The PN2222A (like the 2N2222A) is a rather poor transistor for medium-current switching because of its high Vce(sat). This is the voltage drop between collector and emitter when the transistor is turned on. More modern transistors such as BC327 or (even better) ZTX851 have lower Vce(sat).

You need to subtract the Vce(sat) from the supply voltage (along with the IR diode voltage drop) when calculating the current through the series resistor.

Also bear in mind that Vce(sat) is usually measured with the base current being 10% of the collector current, and with a 330 ohm base resistor, you are not driving it that hard.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: fungus on Mar 27, 2013, 07:52 pm

822mV when on, 0V when off

So...you didn't connect the emitter to ground like I said?

Transistors work on the difference between base and emitter, not the difference between base and ground.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 08:02 pm
It's connected just as it shows in the diagram.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: fungus on Mar 27, 2013, 08:04 pm

It's connected just as it shows in the diagram.

The transistor needs to go between the LEDs and ground.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: dc42 on Mar 27, 2013, 08:05 pm
822mV is within the expected range under these conditions. What matters more is the voltage between collector and emitter when the LEDs are on.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: fungus on Mar 27, 2013, 08:08 pm

822mV is within the expected range under these conditions.

According to my datasheet Vbe(sat) is 2V (or more). 822mV isn't enough to turn the transistor fully on.

Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 08:17 pm

It's connected just as it shows in the diagram.

The transistor needs to go between the LEDs and ground.

Sorry, isn't that what the diagram shows?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 08:25 pm

What I think you are missing is the saturation voltage - Vce(sat) - of the PN2222A. The PN2222A (like the 2N2222A) is a rather poor transistor for medium-current switching because of its high Vce(sat). This is the voltage drop between collector and emitter when the transistor is turned on. More modern transistors such as BC327 or (even better) ZTX851 have lower Vce(sat).

You need to subtract the Vce(sat) from the supply voltage (along with the IR diode voltage drop) when calculating the current through the series resistor.

Also bear in mind that Vce(sat) is usually measured with the base current being 10% of the collector current, and with a 330 ohm base resistor, you are not driving it that hard.

822mV is within the expected range under these conditions. What matters more is the voltage between collector and emitter when the LEDs are on.

Sorry, I'm not that familiar with transistors.  I'm starting to read the book The Art of Electronics 2nd Ed, but am not there yet.  I'm not in school, this is just a hobby.

So the Vce(sat) is 1V, correct?  So I need to push the current on the base to be 10mA to drive 100mA thru the collector/emitter?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: fungus on Mar 27, 2013, 08:26 pm

It's connected just as it shows in the diagram.

Oh, you changed it, sorry.

What current do you get if you short circuit the transistor's collector/emitter?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: dc42 on Mar 27, 2013, 08:34 pm

822mV is within the expected range under these conditions.

According to my datasheet Vbe(sat) is 2V (or more). 822mV isn't enough to turn the transistor fully on.

According to Fig. 3 of http://www.fairchildsemi.com/ds/PN/PN2222A.pdf (http://www.fairchildsemi.com/ds/PN/PN2222A.pdf), Vbe(sat) at 270ma (the current I believe he is aiming for) would typically be just over 0.9V, if he were supplying 27mA base current and drawing 270mA collector current. The maximum would be higher. But his base resistor and collector resistors are too high for those currents, so 822mV is reasonable. I agree with you that he isn't turning the transistor on hard enough, he needs a lower-value base resistor.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 08:40 pm

What current do you get if you short circuit the transistor's collector/emitter?

34mV
Title: Re: Driving 6 IR LEDs using a transistor
Post by: fungus on Mar 27, 2013, 08:50 pm

What current do you get if you short circuit the transistor's collector/emitter?

34mV

That's not current. I mean amps, measured where the (A) is in your circuit.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 08:53 pm

What current do you get if you short circuit the transistor's collector/emitter?

34mV

That's not current. I mean amps, measured where the (A) is in your circuit.

Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 08:56 pm
I'm going to the store to get more resistors.  Suggestions as to what values I should buy?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 27, 2013, 10:54 pm

What current do you get if you short circuit the transistor's collector/emitter?

34mV

That's not current. I mean amps, measured where the (A) is in your circuit.

Oh, you mean remove the transistor and measure the current.  It goes to 50mA.

I don't understand, shouldn't it be around 90mA?  I thought USB2 was supposed to give out 100mA.  Nobody is challenging my math, so I'm assuming that that is correct.  What is it that I'm missing?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: mjkzz on Mar 28, 2013, 02:19 am
I think dc42 is right, the part you are missing is the Vce, according to you, Vce(sat) is 1V, you need to substract that from your math. In fact if you do, your 48ma measure is very close to calculation.

Had you used a MOSFET for a this type of load (100ma), you probably will not run into this. Right MOSFET has turn on resistance in milli-ohms range and it is voltage driven, not current. This is why I always advocate using MOSFET instead of "normal" usual transistor.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: runaway_pancake on Mar 28, 2013, 02:55 am
Are you sure you have the transistor leads right, looking at the flat/face with leads pointing down it's E-B-C.
330?: orange-orange-brown?
And I thought you were going to run this off Vin.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: fungus on Mar 28, 2013, 09:35 am

I don't understand, shouldn't it be around 90mA?  I thought USB2 was supposed to give out 100mA.  Nobody is challenging my math, so I'm assuming that that is correct.  What is it that I'm missing?

USB is also supposed to give out 5V but you say it's only 4.5V. Something is very wrong there.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 28, 2013, 06:01 pm

I don't understand, shouldn't it be around 90mA?  I thought USB2 was supposed to give out 100mA.  Nobody is challenging my math, so I'm assuming that that is correct.  What is it that I'm missing?

USB is also supposed to give out 5V but you say it's only 4.5V. Something is very wrong there.

Hmmmm, did some voltage tests.  From the Arduino Uno I'm getting under no load (all wires were disconnected):

Vin = 4.39V
5V  = 4.90V
3.3V= 3.28V

But the different USB sources that I'm using are giving about 5.0V (4.98 and 5.06).  I'm thinking that I may have damaged the power regulator by pulling too much current from a few of the digital out pins, except that shouldn't the Vin pin be closer to 5V then the 5V pin in that case?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: runaway_pancake on Mar 29, 2013, 01:39 am

...except that shouldn't the Vin pin be closer to 5V then the 5V pin in that case?

No, if you're using USB as a voltage source then "Vin" is of no use to you.
Don't you have a 9V battery that you could use here?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 29, 2013, 04:15 am

...except that shouldn't the Vin pin be closer to 5V then the 5V pin in that case?

No, if you're using USB as a voltage source then "Vin" is of no use to you.
Don't you have a 9V battery that you could use here?

So I can plug in a battery into the connector while plugged into the USB?  I asked that question, but the response sounded like I use either one or the other.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: runaway_pancake on Mar 29, 2013, 04:22 am
From my point of view - Right (mostly).
Disconnect Vin and plug into USB when you want to upload to the Arduino.
Once that's done, disconnect the USB and then plug in the Vin to see how it works.
Not a lot of work.
[Reasonable?]
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 29, 2013, 05:44 am

From my point of view - Right (mostly).
Disconnect Vin and plug into USB when you want to upload to the Arduino.
Once that's done, disconnect the USB and then plug in the Vin to see how it works.
Not a lot of work.
[Reasonable?]

Hmmm, but then I can't see the serial stream. :(  Also at the moment I don't have the power connector or the battery box.

I've changed RB to 59 to push the Vbe to 0.9V (this was done by trial an error as I wasn't sure how to break the circuit apart to determine this resistor) and replaced the R0, R1 and R2 with 27s.  Now the current is at 60mA through the LED section of the circuit.  I was expecting 97.7mA.

*sigh*  I thought I had it when mjkzz suggested subtracting 1V for the transistor as the calculations actually worked out that time to what I had gotten.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: dc42 on Mar 29, 2013, 09:14 am
59 ohms is too low for Rb, you'll overload the Arduino output pin. Don't go below 100 ohms.

Can you post a photo of your setup?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: mjkzz on Mar 29, 2013, 10:41 am

From my point of view - Right (mostly).
Disconnect Vin and plug into USB when you want to upload to the Arduino.
Once that's done, disconnect the USB and then plug in the Vin to see how it works.
Not a lot of work.
[Reasonable?]

Hmmm, but then I can't see the serial stream. :(  Also at the moment I don't have the power connector or the battery box.

I've changed RB to 59 to push the Vbe to 0.9V (this was done by trial an error as I wasn't sure how to break the circuit apart to determine this resistor) and replaced the R0, R1 and R2 with 27s.  Now the current is at 60mA through the LED section of the circuit.  I was expecting 97.7mA.

*sigh*  I thought I had it when mjkzz suggested subtracting 1V for the transistor as the calculations actually worked out that time to what I had gotten.

Vce(sat) is not a fixed number, nor is it a linear relation between Vce, Ib and Ic, if I remember it, as Ic increases, Vce(sat) actually increase in some operating region, hence your lower measurement of 60mA.

The best way for you to experiment is to use SPICE simulation. Or you can measure Vce at different settings. When you plug in your Vce reading from your expriment and matches theoretcial calculation, it means that relationship between Ib, Ic and Vce is not linear (as confirmation). Please take a look at your datasheet, there must be some kind of chart regarding saturation, Ib, Ic, Vce, etc

Again, if you used MOSFET type of device, you will not have this kind of problem.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: mjkzz on Mar 29, 2013, 10:54 am
For example, a popular N-Channel MOSFET BS170 can handle up to 0.2A easily when 5V is applied at the gate with Rds  less than 1.5 ohm. For your application, 1.5ohm * 0.1A = 0.15V voltage drop. There is basically no current for the gate, perfect for digital pins.

 It also has TO-92 package, so easy for breadboarding.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: runaway_pancake on Mar 29, 2013, 04:16 pm
Oh, phooey.

Here it is -
I have just set up this "very" circuit using a PN2222.  (It's the same.)
In place of the LEDs etc I am simply using 50?.
For the base resistor I have 470?.
It's doing the 100mA (nom.) nicely:
4.8V across the collector resistor (4.8V / 50? = 96mA) and there is a whopping 200mV V_ce.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: Hippynerd on Mar 29, 2013, 05:09 pm
I just dealt with this sort of thing a couple months ago. I was trying to get an idea of how much current a cube was using, and when I measured stuff, I found that I had 4 different voltages from 4 different power sources, and all were under 5v.

I used 2n2222 in my transistor cube a couple months ago, and wasnt able to get much help, so I did a bunch of testing. The transistor cube needs between 0 and 240ma, and even the sot23 2n2222s are rated over 350ma, so thats what I used.

It turned out that I needed between 150 and 300 ohms to sink the full 240ma (actually, it was near 240). I ended up using 270 base resistors, because it allowed enough current for LEDs, and It kept the load on the arduino under 20ma (I think it was like 5ma with 270ohm).

I tried calculating things out, but I couldnt figure out what the gain should be, so I made many calculations, then I tried stuff, but a little experimenting, and measuring solved my problem quickly.

I also experimented with some tiny mosfets (a p, and an n), and they were a lot better, I think they drew a fraction of an ma. The mosfets are more expensive, but they seemed like a much better part in my basic testing.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: runaway_pancake on Mar 29, 2013, 07:31 pm

I used 2n2222 in my transistor cube a couple months ago, and wasnt able to get much help,...

I tried calculating things out, but I couldnt figure out what the gain should be, so I made many calculations, then I tried stuff, but a little experimenting, and measuring solved my problem quickly.

If you're truly of a mind to accept help and commited to learning then I can set you right quickly.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 29, 2013, 07:55 pm

59 ohms is too low for Rb, you'll overload the Arduino output pin. Don't go below 100 ohms.

Can you post a photo of your setup?

Sure I can, not sure what you'd get from them  though.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 29, 2013, 07:58 pm

Again, if you used MOSFET type of device, you will not have this kind of problem.

What specs would I be looking at?  And why would I be picking for those specs?  (The last q is just so that I can be able to pick such things out for myself for later projects)
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 29, 2013, 08:08 pm

Oh, phooey.

Here it is -
I have just set up this "very" circuit using a PN2222.  (It's the same.)
In place of the LEDs etc I am simply using 50?.
For the base resistor I have 470?.
It's doing the 100mA (nom.) nicely:
4.8V across the collector resistor (4.8V / 50? = 96mA) and there is a whopping 200mV V_ce.

Um, why are you saying phooey?  I'm not sure what you are trying to tell me here.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 29, 2013, 08:42 pm
I wonder, instead of doing this stuff using a transistor or MOSFET, I see that from this page:  http://playground.arduino.cc/Main/ArduinoPinCurrentLimitations, I could go up to a max of 40mA per pin for transient current draw so long as I do not exceed a total of 150mA on the banks shown.

Given that could I not wire this up like this?

Code: [Select]
` pin 10 ----|>|--|>|--'\/\,-----+                                | pin 11 ----|>|--|>|--'\/\,-----+                                | pin 12 ----|>|--|>|--'\/\,-----+                                |                               _|_                                _                                .E=5VI=40mAR=(5/.04)/3=41`

Then the pins for that bank would only be pulling at most 120mA.

Title: Re: Driving 6 IR LEDs using a transistor
Post by: Hippynerd on Mar 29, 2013, 08:49 pm

I used 2n2222 in my transistor cube a couple months ago, and wasnt able to get much help,...

I tried calculating things out, but I couldnt figure out what the gain should be, so I made many calculations, then I tried stuff, but a little experimenting, and measuring solved my problem quickly.

If you're truly of a mind to accept help and commited to learning then I can set you right quickly.

http://arduino.cc/forum/index.php/topic,129431.msg1101355.html#msg1101355

I'd rather not pollute this thread with my stuff.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: dc42 on Mar 29, 2013, 10:19 pm

59 ohms is too low for Rb, you'll overload the Arduino output pin. Don't go below 100 ohms.

Can you post a photo of your setup?

Sure I can, not sure what you'd get from them  though.

What I get from them is that your wiring is not  as you described it. Here are some problems I can see:

- You have a red wire connected between +5V of the Arduino to the bus strip marked "+" on the breadboard. But you have nothing else connected to that bus strip.

- You have a green wire connected between Vin of the Arduino and the LEDs. If you are powering the whole system via USB, you should not be taking power from Vin, you should be taking the power to the LEDs from the +5V pin instead.

- You have the PN2222A transistor wired back-to-front. If you look at the datasheet http://www.fairchildsemi.com/ds/PN/PN2222A.pdf (http://www.fairchildsemi.com/ds/PN/PN2222A.pdf) you will see that you have the emitter connected to the LED series resistors via an orange wire, and the collector connected to ground via a green wire.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: runaway_pancake on Mar 29, 2013, 11:23 pm

Um, why are you saying phooey?  I'm not sure what you are trying to tell me here.

Given the example that I cited I'm "saying phooey" to all this "Vce" junk (1V, 2V? Oh, my Aunt Fanny!) as well as the "magic mosfets" advocacy.

Way back at Reply #29 I asked you about the orientation of your transistor and you just keep looking for some easy way out.

David will take care of you.
As for me, I'm not going to plough the sea.

Title: Re: Driving 6 IR LEDs using a transistor
Post by: mjkzz on Mar 30, 2013, 03:38 am

Um, why are you saying phooey?  I'm not sure what you are trying to tell me here.

Given the example that I cited I'm "saying phooey" to all this "Vce" junk (1V, 2V? Oh, my Aunt Fanny!) as well as the "magic mosfets" advocacy.

Way back at Reply #29 I asked you about the orientation of your transistor and you just keep looking for some easy way out.

David will take care of you.
As for me, I'm not going to plough the sea.

Or so it was user error . . . I don't have 2N2222 so I could not build one :-)

For a while, I have doubted all the people who suggested 2N2222 to drive LEDs, phew :-). Nice work and thanks for actually doing it, thumbs up!!!

Well, MOSFET has its advantages -- it draws little current to turn it on and no Ib, Vce mess.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: mjkzz on Mar 30, 2013, 04:04 am

Oh, phooey.

Here it is -
I have just set up this "very" circuit using a PN2222.  (It's the same.)
In place of the LEDs etc I am simply using 50?.
For the base resistor I have 470?.
It's doing the 100mA (nom.) nicely:
4.8V across the collector resistor (4.8V / 50? = 96mA) and there is a whopping 200mV V_ce.

OK, so you did not actually use two LEDs which drops voltage by 2.5V. With two LEDs, the total voltage on the resistor and transistor is Vce+Vr = 4.5 - 2.5 = 2.0V (according to OP's claim)

I just downloaded datasheet for PN2222A and your 200mV Vce at 100ma Ic seems reasonable. The 1.0V Vce claimed by OP is too high and according to chart, it could only happen at 500mA. At 150mA, Vcesat should be around 0.3V according to datasheet.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 30, 2013, 07:32 am

59 ohms is too low for Rb, you'll overload the Arduino output pin. Don't go below 100 ohms.

Can you post a photo of your setup?

Sure I can, not sure what you'd get from them  though.

What I get from them is that your wiring is not  as you described it. Here are some problems I can see:

- You have a red wire connected between +5V of the Arduino to the bus strip marked "+" on the breadboard. But you have nothing else connected to that bus strip.

Oops, also had a blue wire on the -ve power bus, but these aren't important.  I removed some other circuits to make the main circuit clearer.

- You have a green wire connected between Vin of the Arduino and the LEDs. If you are powering the whole system via USB, you should not be taking power from Vin, you should be taking the power to the LEDs from the +5V pin instead.

Yes, this was also stated on this thread.  However, I'm still at a loss as to how I can plug in an external power supply while still maintaining communication with my PC through the serial interface.

- You have the PN2222A transistor wired back-to-front. If you look at the datasheet http://www.fairchildsemi.com/ds/PN/PN2222A.pdf (http://www.fairchildsemi.com/ds/PN/PN2222A.pdf) you will see that you have the emitter connected to the LED series resistors via an orange wire, and the collector connected to ground via a green wire.

That's super useful, I had assumed that it was collector, base, emitter and not the other way around.  Strange that it still functioned though.  Would doing that have damaged the transistor?  It seems to work in either direction.  Still only getting 60mA but probably won't get higher without going to an external power source.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 30, 2013, 07:36 am

Um, why are you saying phooey?  I'm not sure what you are trying to tell me here.

Given the example that I cited I'm "saying phooey" to all this "Vce" junk (1V, 2V? Oh, my Aunt Fanny!) as well as the "magic mosfets" advocacy.

Way back at Reply #29 I asked you about the orientation of your transistor and you just keep looking for some easy way out.

David will take care of you.
As for me, I'm not going to plough the sea.

lol, sorry, I missed that.  There's a lot of info here. :)  Though, changing the orientation doesn't seem to have changed anything, I have updated my circuit wiring accordingly.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 30, 2013, 07:42 am

For a while, I have doubted all the people who suggested 2N2222 to drive LEDs, phew :-). Nice work and thanks for actually doing it, thumbs up!!!

Why would you think that that particular transistor could not drive an LED?  Isn't it just another switch after all?

Well, MOSFET has its advantages -- it draws little current to turn it on and no Ib, Vce mess.

Yup, just trying to make this as inexpensive as possible.  But it doesn't preclude that I won't go that route.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Mar 30, 2013, 07:45 am

I just downloaded datasheet for PN2222A and your 200mV Vce at 100ma Ic seems reasonable. The 1.0V Vce claimed by OP is too high and according to chart, it could only happen at 500mA. At 150mA, Vcesat should be around 0.3V according to datasheet.

Sorry, I feign ignorance :).  I just got the info from here:  http://www.digikey.com/product-detail/en/PN2222ATFR/PN2222AD26ZCT-ND/459004

Looking at the datasheet (which I mostly do not understand) I don't see the info that states 0.3V at 150mA.

I really appreciate all the help you guys and gals are giving me BTW.  This is a very difficult but gratifying process (at least on my end), but not without its frustrations.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: runaway_pancake on Mar 30, 2013, 01:34 pm

OK, so you did not actually use two LEDs which drops voltage by 2.5V. With two LEDs, the total voltage on the resistor and transistor is Vce+Vr = 4.5 - 2.5 = 2.0V (according to OP's claim)

The object was:

• to verify 100 mA of collector current

• to note/observe V_ce

Done.

Quote

Well, MOSFET has its advantages -- it draws little current to turn it on and no Ib, Vce mess.

There is no "mess", it's the simplest thing in the world, there's no doctoral thesis here.
Quote
Yup, just trying to make this as inexpensive as possible.  But it doesn't preclude that I won't go that route.

There's no magic bullet there either - you will still have to get the wiring right.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: adrian_h on Apr 02, 2013, 08:37 pm
Well, thanks for all your help everyone.  Looks like it's just a matter of trial an error then.  Calculations are just too complex unless I try to use that SPICE simulator mjkzz talked about, which would be another project in itself.

One thing I've noticed though is that when I turn on the LEDs, it seems to do a number on the ADC unit.  I'll post that in another thread though.

Thanks again.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: mjkzz on Apr 03, 2013, 12:40 am

OK, so you did not actually use two LEDs which drops voltage by 2.5V. With two LEDs, the total voltage on the resistor and transistor is Vce+Vr = 4.5 - 2.5 = 2.0V (according to OP's claim)

The object was:

• to verify 100 mA of collector current

• to note/observe V_ce

Done.

Quote

Well, MOSFET has its advantages -- it draws little current to turn it on and no Ib, Vce mess.

There is no "mess", it's the simplest thing in the world, there's no doctoral thesis here.
Quote
Yup, just trying to make this as inexpensive as possible.  But it doesn't preclude that I won't go that route.

There's no magic bullet there either - you will still have to get the wiring right.

Yes, your objective is correct, however you are using a resistive load to simulate a non-resistive, non-linear load, LEDs, you get lucky to get same result.

I call it a mess when using a current based switch in digital circuit -- looking at your "simulation" cicrcuit, your base current is rather large for a digital pin.

Of course, calling it a mess is subjective :-)

Title: Re: Driving 6 IR LEDs using a transistor
Post by: mjkzz on Apr 03, 2013, 12:45 am

I just downloaded datasheet for PN2222A and your 200mV Vce at 100ma Ic seems reasonable. The 1.0V Vce claimed by OP is too high and according to chart, it could only happen at 500mA. At 150mA, Vcesat should be around 0.3V according to datasheet.

Sorry, I feign ignorance :).  I just got the info from here:  http://www.digikey.com/product-detail/en/PN2222ATFR/PN2222AD26ZCT-ND/459004

Looking at the datasheet (which I mostly do not understand) I don't see the info that states 0.3V at 150mA.

I really appreciate all the help you guys and gals are giving me BTW.  This is a very difficult but gratifying process (at least on my end), but not without its frustrations.

Title: Re: Driving 6 IR LEDs using a transistor
Post by: runaway_pancake on Apr 03, 2013, 02:17 am

Yes, your objective is correct, however you are using a resistive load to simulate a non-resistive, non-linear load, LEDs, you get lucky to get same result.

I call it a mess when using a current based switch in digital circuit -- looking at your "simulation" cicrcuit, your base current is rather large for a digital pin.

What luck?  Current is current, the LEDs make for zero difference.
And the base current, approx 5mA, is well under-spec for a "digital pin" anyway that's sliced.
It's not unsound and it works.
Maybe it's "over-driven"; but that makes it "beta-proof" - no harm, no foul. Look what I have to work with here.  smiley-tired_grin

Looks like it's just a matter of trial an error then.
Calculations are just too complex unless I try to use that SPICE simulator mjkzz talked about, which would be another project in itself.

It's not "trial and error".
Just do what I've told you - and get the wires right.
I don't know how better I can make the point other than to have you send me the parts and do it for you.

> > > > This person managed to get with the programme --
http://arduino.cc/forum/index.php/topic,156059.msg1178571.html#msg1178571
Title: Re: Driving 6 IR LEDs using a transistor
Post by: mjkzz on Apr 03, 2013, 02:51 am

Yes, your objective is correct, however you are using a resistive load to simulate a non-resistive, non-linear load, LEDs, you get lucky to get same result.

I call it a mess when using a current based switch in digital circuit -- looking at your "simulation" cicrcuit, your base current is rather large for a digital pin.

What luck?  Current is current, the LEDs make for zero difference.
And the base current, approx 5mA, is well under-spec for a "digital pin" anyway that's sliced.
It's not unsound and it works.
Maybe it's "over-driven"; but that makes it "beta-proof" - no harm, no foul. Look what I have to work with here.  smiley-tired_grin

Looks like it's just a matter of trial an error then.
Calculations are just too complex unless I try to use that SPICE simulator mjkzz talked about, which would be another project in itself.

It's not "trial and error".
Just do what I've told you - and get the wires right.
I don't know how better I can make the point other than to have you send me the parts and do it for you.

> > > > This person managed to get with the programme --
http://arduino.cc/forum/index.php/topic,156059.msg1178571.html#msg1178571

Well, the luck is that a non-linear device in this case behaved (or did it?) like your replacement resistor in that particular circuit, you might not be lucky to get the same result . . .

One example is, if the supply voltage is 3.3V and OP uses 3 three LEDs in series, your simulating circuit would still work, but OP's circuit won't if each LED has 1.25 forward voltage because there is not enough voltage to turn the LEDs on. Do you see what I am getting at? Of course, you could probably argue that you would use a different simulation circuit.

My point is, in general, it is not a good idea to use a linear device to simulate a non-linear device.
Title: Re: Driving 6 IR LEDs using a transistor
Post by: runaway_pancake on Apr 03, 2013, 03:12 am
It was and is valid within the "parameters" set forth, namely the 5V (USB)thing.

> > > If somebody then decides to up and use 3V, or 30V, or the house wiring, what has that to do with me?
Title: Re: Driving 6 IR LEDs using a transistor
Post by: mjkzz on Apr 03, 2013, 03:53 am

It was and is valid within the "parameters" set forth, namely the 5V (USB)thing.

> > > If somebody then decides to up and use 3V, or 30V, or the house wiring, what has that to do with me?

I knew you are going to say this. :-) Cheers.