Go Down

### Topic: Driving 6 IR LEDs using a transistor (Read 16577 times)previous topic - next topic

#### fungus

#30
##### 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.

#31
##### 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?

#### runaway_pancake

#32
##### 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?
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

#33
##### 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.

#### runaway_pancake

#34
##### 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?]
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

#35
##### 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.

#### dc42

#36
##### 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?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#### mjkzz

#37
##### 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.

#### mjkzz

#38
##### 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.

#### runaway_pancake

#39
##### 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.
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

#### Hippynerd

#40
##### 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.

#### runaway_pancake

#41
##### 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.
"Who is like unto the beast? who is able to make war with him?"
When all else fails, check your wiring!

#42
##### 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.

#43
##### 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)

#44
##### 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.

Go Up