Using a resistor and transistor

Hi everyone :slight_smile:

Before anyone is asking "Did you use Google, the search on this forum, etc.": Yes, I did!
For most of you my question is rather basic I might assume but I for me as a beginner it certainly isn't.

What I'm trying to accomplish is a quite simple setup. I want to have six different PWM-Outputs of my arduino where each of them should have 4-5 LED's connected to it.
Now the programming was quite an easy task and I did this circuit on my breadboard with some transistors and resistors in order to have it working.

Now everything's fine with that but I'm certainly not sure WHAT transistor to use specifically for this application because I want to have it printed on a PCB with SMD-components.
I just used a "normal" NPN on my breadboard I had laying around but to be honest now where things getting serious I really want to have the right transistor soldered onto the PCB. And that's where I'm stuck :frowning:

And the next question would be, which resistor I have to use between the arduino pin and the NPN?!
I found a similar setup somewhere here on the forums and the guy used a 1kOhm resistor to have it working but I'm absolutely not sure if that would work for me aswell...

I hope you guys can really help me out on this one! Sorry for the dumb question :frowning:

Some data for you:
It's an Arduino UNO and the LED's that I'm using are 5mm orange ones with 2,2V and 20mA.
The source certainly will be a 9V battery.

If there is any further information required I will definitely provide it.

Cheers and thank you very much!
Mario

The right transistor is the one which meets your needs! If the one you used on the breadboard did the job, you should be able to use it on the PCB without any problem (lighting up a few LED is not a very critical task).

However, check in its datasheet to confirm that its specifications are good for your application. You should look at data such as the maximum collector current, the VCE when the transistor is turned on, etc.

For the base resistor: it determines the current that will flow thru the base of the resistor. And we know that Ic = hfe*Ib. hfe is not a well known value and can differ a lot even between 2 transistors of the same batch. That's why you must take the lower value given by the datasheet when doing the math.
Then again, it will give you a minimal Ib. When you look at the graphs on the datasheet, you'll see that to turn the transistor "full on" (with a very low VCE), you'll have to put more current thru the base.
All these information should let you determine the correct Ib you need. Then you can calculate the value of the base resistor.

PS: Are the LED on each transistor wired together in series or in parallel?

Hi Sacha,

first of all, thanks a lot for your fast and helpful response! :slight_smile:

Exactly this data and the values is the thing that bothers me and is kinda troublesome since I do not understand how they work!
The maximum collector current is the number summed up all the mA of the Leds? So I would need a NPN with at least 100mA if using 5 Leds?

I found this one which I think is suitable for my circuit: http://www.reichelt.de/BC-847A-SMD/3/index.html?&ACTION=3&LA=446&ARTICLE=18561&artnr=BC+847A+SMD&SEARCH=npn+smd
(hope it'S alright to post links).
The Vce if I looked it up right is 45V at maximum whereas I'm using only 9V should be fine? I'm sorry for not understanding how this all sums up together :frowning:

The hfe is mentioned with 10µA and 2mA whereas the Vce is stated as 5V in the same table.
When I'm doing the math with 10µA and 5V I end up having a outcome of 500KOhm where using 2mA results in 2,5kOhm. Not sure if I did the math right.

The Leds are hooked up parallel on the board! :slight_smile:

My pleasure to help ^^

First, I suggest that you draw a schematic of your circuit and post it here.

The collector current is the current that's going thru the transistor's collector, so using your schematic you can determine what is this current. If your LEDs are in parallel, each LED will draw 20 mA so the total current will indeed be 100 mA... But once again, it depends on how you wired the all thing, so post a schematic and we'll look at it without any ambiguity.

When calculating such a circuit, you basically have to use Kirchhoff's laws to calculate currents and voltages. Since it's a switching circuit, you have to do it for 2 cases : when the LEDs are lit and when they are not.
When they are lit, you have to make sure:

  • The current is not too high
  • The VCE is low enough
  • The power dissipation in the transistor is not too high.
    The 2 last points shouldn't be a problem in your case.
    When they are off:
  • The transistor will handle all the battery voltage, you have to make sure that it can. As you said, the transistor is rated for a VCE max of 45V, so that's fine with your battery.

The hfe, as well as many parameters, vary with the functionning point, ie the current and voltages (as well as temperature). You read the hfe for a VCE of 5V but the VCE in YOUR circuit might not be 5V. Once again, post your schematic please and we'll look at it since it depends on the circuit you're using.

Thanks again, so much! I feel like slowly understandig more and more how it's going to work :slight_smile:

My bad, good sir. I will be upload the schematic as soon I come home. Should be around in 2-3 hours!

Cheers! :slight_smile:

I’ll be here waiting for it haha.

Sacha22:
For the base resistor: it determines the current that will flow thru the base of the resistor. And we know that Ic = hfe*Ib. hfe is not a well known value and can differ a lot even between 2 transistors of the same batch. That's why you must take the lower value given by the datasheet when doing the math.

No, hfe is not appropriate for a transistor in saturation at all. Typically for proper saturation
you would use 5 to 10% of Ic into the base to get decent low Vce and thus efficient
switch-on. So since the Arduino pin can tolerate upto about 30mA normally, a switching
BJT will only boost that to 300 to 600mA at most - a logic-level MOSFET is much more
flexible in practice.

If you know the current of your load, set the base current at about 5 to 10% if within
the capabilities of the Arduino pin. Ensure the voltage rating is high enough (v likely!)
and calculate the heat dissipation when on using the Vce(sat) graph on the datasheet.
Check that the surface mount package can handle that amount of heat dissipation.

You are using that transistor as a switch not an amplifier so the hfe isn't particularly relevent. You are operating the transistor in saturation, in other words the base current is higher than Ic/Ib. For that device operating at 100mA Ic the collector voltage is specified for Ib = 5 mA so that is what you should aim for.

100 mA is the maximum collector current for that transistor so, with five LED's it would be better to design for about 15 mA per LED.

Russell

Hi Mark,

You just beat me to it!

The power dissipation is OK with that device. Vce(sat) at 100 mA Ic and 5 mA Ib is 400 mV max so 40 mW power dissipation against 250 mW maximum.

Russell.

MarkT:
If you know the current of your load, set the base current at about 5 to 10% if within
the capabilities of the Arduino pin. Ensure the voltage rating is high enough (v likely!)
and calculate the heat dissipation when on using the Vce(sat) graph on the datasheet.
Check that the surface mount package can handle that amount of heat dissipation.

Then that's why I talked about full saturation and the need to put more current, looking at the transistor's datasheet.

Hi Mark and Russel:)

Thanks for joining in an letting me know what I need to take a look at.
So the transistor would be fine for this job?!

I did a quick and very poor schematic of the circuit. On the other hand I’ve uploaded the board’s layout I want to go with… it does continue on the right side a little more with more leds but that’s a thing wich doesnt matter I guess. The interesting part is stuffed on the left side anyway.

Once again I’m very sorry for the quick and dirty method! :frowning:

Every fourth led is hooked up with each other; or better said, shares the same PWM output of the arduino. There will be six or four (left to be decided) different PWM-pins whereas every 4-led-cluster gets hooked up to one. The final goal is to have every fourth led fade in a different/random pattern.

I hope you understand the schematic/board-layout.

Cheers and thanks a lot guys, you really helping me out! :slight_smile:

Mario

You have the emitter and collector reversed in your schematic.

Aw yeah I just saw it! Sorry, of course it’s vice versa! :slight_smile:

So for each LED, the current is set by the resistor. Let's say each LED draws 20 ma. With 4 LED per transistor, the collector current is 80 mA.

As MarkT said, for a full saturation, Ib should be about Ic/10, but in your case that's not critical... Anyway if it was, just keep that rule of thumb in mind and check your transistor's datasheet, it should have a curve showing VCE with respect to Ib when the transistor is used in saturation.
Once you've determined the appropriate Ib, you can calculate the base resistor.

Once again, things become more complicated when you have higher specifications (higher currents, low voltage, etc) and you might want to spend more time choosing your transistor. For your application, it's not critical as you just want a transistor that can handle the current.
The one you've posted the link earlier is rated for a 100 mA collector current. It's relatively close to your 80 mA but it should do fine!

Hi Sacha,

I guess 100mA is quite on the edge since I could possibly be that I need to hook around 2-3 more LED's on it so will go with a transistor which can handle 500mA; just to be sure if I'd extend the circuit.

Here's the one: http://www.reichelt.de/BC-817-16-SMD/3/index.html?&ACTION=3&LA=446&ARTICLE=18553&artnr=BC+817-16+SMD&SEARCH=transistor+smd+npn

Unfortunately this one doesnt have a curve in its datasheet but I will try to figure it out! :slight_smile:

Thanks a lot, really! Thanks to all of you!
Mario

Data sheet

That device looks fine.

Russell

Thanks a lot Russel… was going to search for it myself but you beat me to it! :smiley:
I think I got the base resistor…
I’m not quite sure though since I’m not aware which hfe value I have to use in order to get the resistor.
There are two lines in the datasheet on page 5 which say:

Symbol Parameter Conditions Min
hFE DC current gain IC = 100 mA; VCE = 1 V 100
hFE DC current gain IC = 500 mA; VCE = 1 V 40

So do I have to use the hfe value of 100 or 40? Not sure which condition is needed in order to do the math for the base resistor. I did the math with 40 and came up with following:

hfe = Ic / Ib
Ib = lc / hfe
Ib = 0,5A / 40
Ib = 0,0125A

R = U / I
R = 9V / 0,0125A
R = 720 Ohm

Cheers,
Mario

supermaRiio:
Hi Sacha,

I guess 100mA is quite on the edge since I could possibly be that I need to hook around 2-3 more LED's on it so will go with a transistor which can handle 500mA; just to be sure if I'd extend the circuit.

[...]

Good way of thinking :wink:

As has already been said, you don't use the hfe figure for switching. Work on Ib = Ic/10. Remember that the voltage across the base resistor will be = 5 - Vbe where Vbe will be about 0.7 V.

Russell.

Ah okay, I somehow didn't understand that! :slight_smile:
So if I wanted to have the R I would do the following:

R = Vin - Vbe / Ib
whereas Ib = Ic / 10

R = (5 - 0,7) / (0,5A / 10)

R = 4,3V / 0,05A

R = 86Ohm

That's kinda low, right? :S
Sorry for being such a newbie to this stuff. Electronics in school has been quite a while ago...

Cheers,
Mario