Continue to Site

### Welcome to our site!

#### EdStraker

##### New Member
Trying to calculate the value of R2 and I get 2 different results depending on the method.
For the sake of argument assume LED's are 2v / 20mA.
When calculating Parallel resistor total load, you divide the value by the number of. In this case would be 39.
Or is the total load 390 or 3.9k?
Total Current would be 200 mA.

Thanks in advance for the assistance.

Last edited:

##### Well-Known Member
Your circuit as drawn when Q1 turns on shorts the 9V supply to ground ! Is
that what you want ?

Or do you want all the leds to turn on when the transistor turns on ? In which
case the transistor collector connects to all the led cathodes, hence when it
turns on all LED cathodes shorted to ground and they all turn on.

Then you want the Ib = Iload /10, to insure transistor is saturated.

So then Ib = (5V - Vbe)/ R2, or R2 = (5V - Vbe)/ Ib. Note look at micro datasheet
to estimate the 5V coming out of micro, what its Vout will be, and use that in

Each LED current = Iled = (9 - Vled - Vsat) /R1 so total load current = 10 X Iled,
then solve for R1. Vsat comes from transistor datasheet.

Regards, Dana.

#### ronsimpson

##### Well-Known Member
Each type of transistor is different. What transistor are you using.
Many digital IO pins on micros do not pull up well. Your "5v uC" might only be 4 volts or 3 volts.

Collector current is 200mA. You probably need 20 to 15mA of base current. Voltage across R2 is 5V-0.65V. You know how to do the math.

Last edited:

#### EdStraker

##### New Member
Wow, how stupid, yes the cathodes go to collector. I will repost the correct diagram

#### EdStraker

##### New Member
Note look at micro datasheet
to estimate the 5V coming out of micro, what its Vout will be, and use that in
I wasn't trying for technical accuracy. It was how I was attempting to calculate.

#### EdStraker

##### New Member
Each type of transistor is different. What transistor are you using.
Many digital IO pins on micros do not pull up well. Your "5v uC" might only be 4 volts or 3 volts.
Either a 2N2222 or 2N3904, I have both on hand. The uC puts out aprox. 4.3v @ 20mA in my circuit at the pin. I was just inquiring if my math was flawed. I'm not sure if the total load was right. In my case is 39Ω correct? Or am I in error?

#### rjenkinsgb

##### Well-Known Member
When calculating Parallel resistor total load, you divide the value by the number of. In this case would be 39.
Or is the total load 390 or 3.9k?
Total Current would be 200 mA.

OK, so the voltage across the resistors is 7V.
7 / 390 = ~18mA

x 10 = 180mA

You could consider it as equivalent to a 39 Ohm resistor in series with a 2V 200mA LED.
However the resistors are not technically in parallel; the current (= transistor current) is the most important value.

#### Kerim

##### Member
By the way, the output pin internal resistance of ATmega8, for example, is around 40 Ohm (excluding the Reset pin if used as an output pin).

##### Well-Known Member
What uC are you using ? Check the spec for the total allowed current, all GPIO either in a port
or total of all chip GPIO to insure you are in spec.

Thge Atmega328 has a limit Imax in suoppoly rail -

So you would worst case its operating Idd, min LED V and its series min R, to find out of
you are OK.

Regards, Dana.

Last edited:

#### rjenkinsgb

##### Well-Known Member
Trying to calculate the value of R2 and I get 2 different results depending on the method.
Oops.. I did not notice that, with the mention of parallel resistors!

The load current is around 180 - 200mA as above.

Anything from around 20mA up base current should be fine with any small general purpose transistor.

I'd probably use 180 Ohms for the base drive; that should give about 20mA on a typical MCU output, that has reasonable current drive.

(That's allowing 0.6V for base-emitter, and a similar drop from +5V for the MCU pin output, under load; 3.8V / 0.02A gives 190 Ohms, so 180 as a standard value).

#### ronsimpson

##### Well-Known Member
Either a 2N2222 or 2N3904
I looked up the 2N2904's data sheet.
"Collector Current Max 200mA"

These two curves tell us much about the transistor.
Top curve shows the gain is best at 7mA and drops off with more current. Gain is 1/10 as much at 200mA.
Curve two shows 100mA, VCE=0.35 Base needs 7 to 10mA.

I think you need a 500mA transistor not a 200mA transistor.

#### Kerim

##### Member
Since a few years ago, I started using BC337.

#### Nigel Goodwin

##### Super Moderator
Since a few years ago, I started using BC337.
I'm a big user of BC337's as well - I would also use BC327's (PNP) but they were out of stock, so I had to buy BC557's instead.

#### Tony Stewart

##### Well-Known Member
I am here to tell you your entire design is all wrong or to be kind sub-optimal. It works, but you can do better.

First you want to choose a voltage that matches the net LED voltage with perhaps 10% for the current limiting or more for battery tolerances which are typically 10% for most of their capacity range so that would be 20% more at most.

It seems you have 5V and 9V to choose from, so if these are all 2V LEDs ( which also have a tolerance which once was 50% and today is more like 5% from reputable hi-brightness sources for most of the parts at "rated" current ( not absolute max current)

The current gain on transistors also has a huge manufacturing tolerance and also a large variability with current, but you don't have to achieve perfect Vce(sat) or the rated saturation at Ic/Ib=10 because if you choose Ic/Ib=20 it just means Vce is slightly larger than 0.1V or whatever it is which is only 1% of your 9V range so no sweat there. You might even get good results with Ic/Ib= 50 and still be under 0.5V for these current levels because the "rated transistor Vce(sat)/Ic"is resistance and is around 1 to 2 ohms for the PN2222A and 3 to 5 ohms for other common switches. Take the 2N2904 for example at Ic=30 mA Ic/Ib=50 means Ib= 2% or 0.6mA intersects at 0.3 V drop on the switch (Vce) which at 30 mA is only 9 mW, so that's a cool 0.3V/30mA = 10 ohm switch. So at 20 mA, it's even cooler ,but for TEN (10) LEDs in parallel from 9V, you have a problem with efficiency and waste heat.

The LED also has a bulk resistance that lowers with a rising current near the rated value which is due to the size of the chip (and thus power limit) and the thermal insulation of the epoxy. For instance, the 2V 20 mA LEDs are in the ballpark of 8~10 Ohms and the 3V 20 mA White LEDS are around 12~16 Ohms rated near 65 mW. This variation in bulk resistance is the only reason for the tolerances in LED Vf .

Fortunately, this is easily corrected by using making better choices of matching supply voltage to LED voltages.

e.g. (1) Using 5V only 2S ( two in series) with Ic/Ib=30 leaves about 800 mV for the current limiting resistor /20mA = 40 ohms ( or nearest 1% value) then have 5 circuits in parallel or 5P to have an array of 2S5P with a total load current of now 5P * 20 mA = 100 mA and a base current of 3.3% *Ic or Ic/Ib=30 is not only 3.3 mA which is trivial using 4.3V drop = 1.3k.

(2) using 9V makes 4S2P possible for 8 LEDs leaving 0.8V drop across the resistor at 20 mA = 40 ohms or nearest.

or if you really need 10 LEDs using 9V choose 4S2P + 2S with different R for the 2S

There are of course many other solutions some with active current limiters vs. the passive resistor which is the theme to this answer. How to recognize the bulk linear resistance in EVERY part.
Especially in non-linear devices like transistors as switches and LEDs which follow exponential diode law and choose an optimal array for better efficiency. Think of Vce(sat) as the condition where Vbc goes from being a reverse-biased diode to a forward-conducting diode across Vce which when not saturated is a high-impedance current sink. So that Vce is the difference voltage of the bulk resistances of Vbc and Vbe which by design are different-sized diode junctions created to amplify base current, but as the Vbc junction conducts more in the forward region the linear current gain gets shunted to nearly 10% of its maximum hFE gain by this property. But if you can tolerate a slightly higher resistance than the rated Vce(sat)/Ic @ Ic/Ib = x then you can easily scale x but you can never be saturated as a switch AND use all the worst-case linear current gain specified. so it is a trade-off.

Using Nigel's fave BC337, we see options for binned ranges which span from 100 to 600 and suffix letters at slight added cost and Vce(sat)/Ic = 700 mV (max) / 500 mA = 1.2 Ohms which is good and rises to 8 ohms using 2% base current @ Ic= 10 mA

Last edited:

#### Kerim

##### Member
I'm a big user of BC337's as well - I would also use BC327's (PNP) but they were out of stock, so I had to buy BC557's instead.
I noticed lately that I had also a lot of BC327, but I forgot why I bought them, many years ago
Before these two types, I used to buy BC546 and BC556. I still use them sometimes if the max switching current is below 50mA and the voltage on their collector is higher than 50V (Vces breakdown of BC337 and BC327).

#### Kerim

##### Member
If I have 9V and 10 red LEDs, I add 2 LEDs to let then be 12 LEDs.
I connect every four of them in series with a limiting resistor Rs (and get 3 branches).
I usually choose the LED current to be not more than 15mA (for the 20mA type).
To calculate the value of Rs, I usually know the typical voltage (@15mA) of the LEDs I am working on. Also, I have to know the possible upper and lower limit of the 9V supply. In case the lower limit could be close to 8V, I connect just 3 LEDs in series (and get four branches).

#### EdStraker

##### New Member
There seems to be some confusion here. I said 3904 not 2904. No Battery power, 9v wall adapter supply.
The MCU is a PICaxe 14M2. max. current:
Sourced through chip : 80mA
Sunk through chip : 85mA
Sourced or sunk per pin : 25mA

For the sake of simplicity I have changed over to 12 LED's as per Kerim's suggestion. Easier to Calculate that way.
So if I understand this right (not taking into account LED internal resistance because it's unknown at this point), and using common value resistors, would the following now be correct?

Last edited:

#### ronsimpson

##### Well-Known Member
Power loss in resistors is down.
Current in transistor is 1/2.

##### Well-Known Member
Possibly minor problem but when you parallel LEDs as you did in #17 post
unless they are binned with close Vf their brightness can vary substantially from
one LED to another, so just be aware of that.

Regards, Dana.

Last edited:

#### Kerim

##### Member
For the sake of simplicity I have changed over to 12 LED's as per Kerim's suggestion.

View attachment 140861

Those LEDs are connected in parallel not in series, a very big difference!
I am afraid this makes things worse.
Connecting two LEDs in parallel is much like connecting two diodes or Zener diodes in parallel. The slight difference in their V-I characteristic lets their currents be different noticeably, as Dana pointed it out (post #19).

In case they are in series (assuming 2V LED):
(I believe you did a misdraw, like we do mistypes sometimes, by drawing them in parallel instead of in series because as we will see below your calculations are right):

Rs = (9 - 4*2) / 56 ~= 18mA
Ic= 18*3 = 54mA
Ib= (5-0.7) / 0.82 ~= 5mA
Ic/Ib = 54 / 5 ~= 10 which is more than enough to saturate Vce close to zero volt.

Kerim

Replies
6
Views
5K
Replies
5
Views
604
Replies
9
Views
2K
Replies
2
Views
8K
Replies
5
Views
1K