Author Topic: Transistors & Base resistor values  (Read 5638 times)

0 Members and 1 Guest are viewing this topic.

Offline ONETENTopic starter

  • Contributor
  • Posts: 17
Transistors & Base resistor values
« on: April 15, 2014, 07:28:50 am »
Hi Guys,

New to this forum, hope this is a good place to come for help with this sort of stuff. I am from Perth, Australia and have been into electronics for a little while, but in the last couple of months have been spending a fair bit of time on a new project.

I am a pretty involved EE hobbyist and and am designing a unit to interface with automotive electronics over a CANBUS. I am learning massive amounts as I go (I learn pretty fast :)) and really enjoying this challenge.

On the particular MCU I have chosen (PIC18F46K80) I have decided I want to have a series of warning LED’s, as well as the ability to drive a standard automotive relay (in the future anyhow)

LED’s I have are grouped in pairs, and draw around 25ma each at 2.2v. I am currently running each one with a 150R resistor.

Max current sourced/sunk by the PIC on some pins is 25mA, 8mA or 2mA, so by putting them into pairs (parallel) I am saving I/O pins but increasing current draw, meaning I cannot supply directly from the MCU anymore.

So I am going to use a basic NPN transistor as a switch, which is a first for me. Transistors are kind of like my final frontier with basic digital circuits, I find them more confusing than most other things... just me I guess.

The unit I have on hand is a BC549 and has the following characteristics:
Ic (max) 100mA (suitable for the LED’s)
Hfe min 420
VCEsat 200mV at IC = 100 mA; IB = 5 mA
VBEsat 900mV at IC = 100 mA; IB = 5 mA

What I am struggling to understand is how to equate the base resistor value. I have read probably 20 different web theories and still do not fully understand, and have come up with a few different values as a result.

Some things I wonder are:
- Is my RL (load resistance) figure the total impedance of my load circuit? Or just just my resistor in the case of the LED circuit? The example on the webpage below uses a relay which has an obvious RL due to the relay coil.
- The relationship between HFE and my need, from what I read the rule of thumb is 5 x Ic of the load you are trying to switch.
hFE(min)  >   5 ×       load current Ic  / max. IC current
In my case the Ic load is 50mA so I must have a HFE min of at least 125, well the BC549 is way over that figure, is that a good thing? or does it not even matter?


Both the LED and the IC (connected to base) operate off the same VDD of +5v, and the pin I want to control the transistor from has a Ic max of 2mA, but I do also have a pin with Ic max 8mA also.

Can anyone point me to some clear-cut theory or help me to understand this a little better?

One website I found most helpful was http://electronicsclub.info/transistorcircuits.htm
But I am obviously missing something here.

Thanks,
Hayden
« Last Edit: April 15, 2014, 07:44:34 am by ONETEN »
 

Online mariush

  • Super Contributor
  • ***
  • Posts: 5029
  • Country: ro
  • .
Re: Transistors & Base resistor values
« Reply #1 on: April 15, 2014, 07:39:06 am »
I've often found this video very good at explaining transistors :

 

Offline ONETENTopic starter

  • Contributor
  • Posts: 17
Re: Transistors & Base resistor values
« Reply #2 on: April 15, 2014, 08:39:11 am »
Thanks so much mate!!

Video was a great help, much easier to understand than what I was previously reading. I really should turn to youtube more often!!

So from what I learned:
Ic (Current to be drawn through transistor): 50mA
Hfe (beta) of transistor: 420

seeing as Ib = Ic / Hfe we need a base current draw of 0.11mA
Ic of 50mA is bare minimum to run LED's, so in good practice I will allow for a Ic of 100mA, which would give us an Ib of close to .25mA

So to calculate Rb (resistor base) via Ohms law:
Ib = Vb - (.7) / Rb
and
Rb = Vb - (.7) / Ib

which gives me (units in volts & amps & ohms):
Rb = 5 - (.7) / .00025 = 17200 ohms

The closest resistor I can buy would be a 18K ohm, which would give me slightly less than my Ic of 100mA, but still plenty to drive the 50mA LED's.

Does that all look ok?

One question I do have, is it safe to assume all NPN transistors have a voltage drop across base & emitter of .7v?

Cheers :)
« Last Edit: April 15, 2014, 08:42:39 am by ONETEN »
 

Offline bronson

  • Regular Contributor
  • *
  • Posts: 172
  • Country: us
Re: Transistors & Base resistor values
« Reply #3 on: April 15, 2014, 08:58:35 am »
Well, Vbe will vary with temperature and from transistor to transistor.  It's safe to assume it's around a diode drop, but not safe to assume it's right at 0.7V.

It sounds like you're trying to use the base resistor to control the amount of collector current running through the LEDs.  This can work but it will be pretty unstable.  You'll probably have brightness variations between LEDs and flickering.

It would be more reliable to use the transistor as a switch instead of in its linear region.  So, throw a smaller resistor on the base (1K should be fine), then use another resistor in series with the LEDs to restrict the current.

If you draw up a schematic, you would probably get less hand-wavy answers.  :)
 

Online mariush

  • Super Contributor
  • ***
  • Posts: 5029
  • Country: ro
  • .
Re: Transistors & Base resistor values
« Reply #4 on: April 15, 2014, 09:02:08 am »
The beta value will vary by lots of factors, it's always a good idea to be more conservative. Even though it says minimum beta 420, I'd pick a value of 350-400 or even lower.
If your datasheet is this one: http://www.nxp.com/documents/data_sheet/BC549_550.pdf then pay attention because it says for Vce = 5v, see figure 2... and you can see there that hFe (beta) drops down to about 300 when Ice goes to 100mA.

In theory, your math is correct with those assumptions. However, in practice it's not really a good idea to keep such small transistors in the linear regions. 
I would suggest picking such a base resistor that the transistor will allow at least 90mA (the transistor is rated for 100mA maximum) .. have a look in figure 2 in the datasheet above (or see if your datasheet has such a graph) and do math again for at least 90mA.

I would also not rely on the transistor limiting the current flowing through the led, use a current limit resistor in series with the led or limit the current through some other way.
 

Offline ONETENTopic starter

  • Contributor
  • Posts: 17
Re: Transistors & Base resistor values
« Reply #5 on: April 15, 2014, 09:41:00 am »
Thanks for the responses guys.

Sorry for the confusion, I am not trying to current limit with the base, just as a standard switch.
I have 150R resistors inline with each LED, as previously I was driving them direct from MCU pins by sinking them low to turn on.

In relation to my calculations I was more saying I dont want to calculate Rb off Ib that came from Ic that was only just going to meet the 50mA draw needed to drive both LED's, but rather calculate Ib off of an Ic closer to 100mA or so. That way, I am not drawing current too close to the limit of the Rb value, as the LED's are always only going to draw 50mA. Hope that makes a bit more sense.... It was explained in the video too :)

Here is a quick schematic of what I have built on the strip board:



Sadly it doesnt work... not sure what I have done wrong. The LED will flicker but thats about it.

Thanks for the hints about the Hfe value, I will sit down and do the maths again and go from there I think.
« Last Edit: April 15, 2014, 09:45:09 am by ONETEN »
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16618
  • Country: us
  • DavidH
Re: Transistors & Base resistor values
« Reply #6 on: April 15, 2014, 09:45:47 am »
Beta current limiting is usually only used to protect against fault conditions unless temperature compensation is used to make it more accurate like with a current mirror.  Forced beta switching assumes the minimum beta over all conditions and in the case of a saturated switch, the minimum can be a fraction of the real value for some operating leeway.  A 2N3904 for instance might have a minimum beta of 100 at Ic=10mA so I would used a forced beta of 50 and rely on the collector resistor to limit the current.

There are more sophisticated drive schemes which do not rely on such ambiguous operating conditions.  Common base could be used with the current limiting resistor in series with the emitter for instance but driving an LED does not need such finesse.

 
The following users thanked this post: petert

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16618
  • Country: us
  • DavidH
Re: Transistors & Base resistor values
« Reply #7 on: April 15, 2014, 09:48:20 am »
That schematic should definitely work whether the transistor is saturated or not so something else must be going on.
 

Offline ONETENTopic starter

  • Contributor
  • Posts: 17
Re: Transistors & Base resistor values
« Reply #8 on: April 15, 2014, 10:00:05 am »
Hmm ok, good to hear its not just me missing something then.

Its acting a bit erratically, started working breifly but LED's were dim.

I think I will take a trip to Jaycar and get some transistors that are more suitable, I only used these BC549's because I had them in the parts bin.

Thanks very much everyone for the input, I will let you know how it turns out.
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 7765
  • Country: de
  • A qualified hobbyist ;)
Re: Transistors & Base resistor values
« Reply #9 on: April 15, 2014, 11:31:49 am »
Its acting a bit erratically, started working breifly but LED's were dim.

Please try to lower the value of the base resistor (10k, then 4k7)

Quote
I think I will take a trip to Jaycar and get some transistors that are more suitable, I only used these BC549's because I had them in

A BC549 is more than sufficient to drive two LEDs. If you don't know yet, the BC549 could have a marking based on the hFE/beta. The markings are A, B or C. If you check the datasheet you'll see the hFE ranges for each marking.

BTW, you can run most standard LEDs with just 5mA today. The 20mA days are long gone ;-)
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
Re: Transistors & Base resistor values
« Reply #10 on: April 15, 2014, 11:57:04 am »
You didn't mention what "VDD" is.  Presumably, it is high enough to enable this circuit to work properly.
The value of the base resistor is extraordinarily high. We typically use "overkill" and drive the transistor into "saturation" for a switching circuit like this. I would expect something closer to 180 ohms vs 18K!
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 7765
  • Country: de
  • A qualified hobbyist ;)
Re: Transistors & Base resistor values
« Reply #11 on: April 15, 2014, 12:20:15 pm »
You didn't mention what "VDD" is.  Presumably, it is high enough to enable this circuit to work properly.
The value of the base resistor is extraordinarily high. We typically use "overkill" and drive the transistor into "saturation" for a switching circuit like this. I would expect something closer to 180 ohms vs 18K!

Standard 5V supply. I don't think a 180 Ohms base resistor is a good idea:  5V/180Ohms = 27.8mA. That's too much base current for that little fellow ;-) A base resistor >= 1k is ok. And because hFE should be >100 anyway, a 4k7 resistor is fine to drive the maximum load of 100mA. Any more base current is a waste of energy :-)
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16618
  • Country: us
  • DavidH
Re: Transistors & Base resistor values
« Reply #12 on: April 15, 2014, 04:04:55 pm »
I was thinking about it and the transistor is oscillating.  Lowering the base resistance to drive it into saturation will solve that.  I usually use 4.7k or lower.
 
The following users thanked this post: petert

Offline jlmoon

  • Supporter
  • ****
  • Posts: 609
  • Country: us
  • If you fail the first time, keep trying!
Re: Transistors & Base resistor values
« Reply #13 on: April 15, 2014, 09:13:32 pm »
.470 - 1000 ohms on base, 220 - 330 on collector for two conventional LEDs should do it!
If you want a really cool cpu peripheral switch.. look up VN10KM  N-Channel Enhancement mode MosFet.. they are perfect for switching (with no current draw from cpu) large amounts of current (200 ma easy) through Drain / Source connections
hope this helps
links all over the place..    http://datasheetcatalog.com/datasheets_pdf/V/N/1/0/VN10KM.shtml

JLM
Recharged Volt-Nut
 

Offline ONETENTopic starter

  • Contributor
  • Posts: 17
Re: Transistors & Base resistor values
« Reply #14 on: April 16, 2014, 05:00:10 am »
A BC549 is more than sufficient to drive two LEDs. If you don't know yet, the BC549 could have a marking based on the hFE/beta. The markings are A, B or C. If you check the datasheet you'll see the hFE ranges for each marking.

BTW, you can run most standard LEDs with just 5mA today. The 20mA days are long gone ;-)

Thanks for the tips! The LED's I am using are 12000mcd waterclear ultrabright and draw a touch over 24mA each :) They are for warning lights so wanted to make sure they were not missed!

You didn't mention what "VDD" is.  Presumably, it is high enough to enable this circuit to work properly.
The value of the base resistor is extraordinarily high. We typically use "overkill" and drive the transistor into "saturation" for a switching circuit like this. I would expect something closer to 180 ohms vs 18K!

Sorry Richard, VDD is +5v. I too think my base value is too high but calculating off a HFE of 420 this is what the maths says, but I too am thinking this might be the problem. I have a feeling by running too high a value resistor on the base I am actually restricting current through the collector - hence the erractic behavior.

I have tried with a 15K which also did not work.

I was thinking about it and the transistor is oscillating.  Lowering the base resistance to drive it into saturation will solve that.  I usually use 4.7k or lower.

Thanks David, I am pretty certain you are on the money. I will test with a lower resistor tonight and report back. I thought about it too and realized what I was seeing was almost like PWM at low duty cycle.

.470 - 1000 ohms on base, 220 - 330 on collector for two conventional LEDs should do it!
If you want a really cool cpu peripheral switch.. look up VN10KM  N-Channel Enhancement mode MosFet.. they are perfect for switching (with no current draw from cpu) large amounts of current (200 ma easy) through Drain / Source connections
hope this helps
links all over the place..    http://datasheetcatalog.com/datasheets_pdf/V/N/1/0/VN10KM.shtml

JLM

I am running the LED's off 150ohm at the present but I suppose no reason I can simplify and run a single 330 or similar, the circuits were connected individually prior to implementing transistors which is why I did not do that in the first place.

Great idea about the MOSFET, I know of a few devices used in automotive that use MOSFETs in a similar fashion. High current drive would make them perfect for the AUX ouput relay drive function too...

You've all been a great help, thanks for your expertise  :D

Cheers,
Hayden





 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf