Author Topic: Transistor Calculations  (Read 6295 times)

0 Members and 1 Guest are viewing this topic.

Offline ShaunLeeClarke

  • Contributor
  • Posts: 14
  • Country: au
  • Hi from Melbourne!
    • ELV Technology
Transistor Calculations
« on: July 01, 2012, 10:03:39 AM »
Hello everyone.

I've recently started playing around with the Arduino platform which has been a great experience.

One of the things I have learned about is using transistors to switch larger loads from the digital outputs on the Arduino.

My question is, how does one determine the value of the resistors which drive the transistors base?

So far, everything I've seen uses a standard 1K resistor between the Arduino output pin and the transistors base, but I have also seen very lengthy (and confusing) articles which explain how to calculate the correct resistor value. For example: http://www.ermicro.com/blog/?p=423

My question is, what is the correct practice when using a transistor in this application?
Full time IT/AV tech from Melbourne VIC Australia. Newbie to electronics here to learn and maybe meet some friends :).

Offline IanB

  • Super Contributor
  • ***
  • Posts: 5256
  • Country: us
Re: Transistor Calculations
« Reply #1 on: July 01, 2012, 10:13:19 AM »
It depends on the gain of the transistor (hfe on the data sheet).

For instance if you apply 5 V to a 1 k base resistor you will get a base current of about 5 mA. If the gain were 100 you would obtain a collector current of about 500 mA. For smaller transistors this is about as much as they could handle without overheating. For more current than that you would want a second power transistor after the first with greater capacity. (Look up Darlington transistor to see how that works.) The reason you might not use a single power transistor alone is that the gain of power transistors is typically lower than for small switching transistors and the Arduino might not be able to provide enough base current by itself to fully turn on a high power transistor.
I'm not an EE--what am I doing here?

Offline Psi

  • Super Contributor
  • ***
  • Posts: 4776
  • Country: nz
Re: Transistor Calculations
« Reply #2 on: July 01, 2012, 10:19:39 AM »
A transistor has a gain, (check datasheet of transistor for actual value) but lets say its 100
This means the current through the collector to emitter needs to be 100x the current through the base to emitter ground to turn the transistor fully on.

So if you want your transistor to switch 1A you will need 1A/100 = 0.01A or 10mA to flow into the base.
However, its not quite that easy because we want more current available to the base to account for errors in things, like temperature and gain error etc.. We want to be absolutely sure the transistor will turn fully on because otherwise it will burn off heat unnecessarily.

So if you aim for say 2-5 times the current really needed that will insure it works in all conditions.
For this example 5x 10mA = 50mA.
If you're driving the base from 5V then you need 5V/0.05A = 100R resistor.
An arduino/micro cannot supply 50mA on its I/O pins so you either need a transistor with more gain or a 2nd transistor to boost the power for switching the primary transistor. (or you could use a fet instead, which work differently)

As a rule of thump,
 little to92 transistors are often around 100-300 gain
 to220 around 50-150
 to-3 maybe 10-40
But there are exceptions, so you need to check the datasheet for the transistor you're using.
Such as a Darlington transistor as IanB mentioned, which have very high gain.
« Last Edit: July 01, 2012, 10:30:26 AM by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 4569
  • Country: us
    • SiliconValleyGarage
Re: Transistor Calculations
« Reply #3 on: July 01, 2012, 11:09:37 AM »
A lot of people have given the long-winded answer.
People earlier in the post have given you a formula but these are not really correct. the transistor is non-linear and you really need to look in the curves. you can't really ride it that hard as the equasions give you.
The fact of the matter is that manifacturers will tell you the base current necessary for the transistor to be saturated.
If a transistor is saturated the connection between collector and emitter is a s good as it will get. keeping increasing the base current does nothing apart from warming up the transistor.

you can find this parameter in the datasheets. it is typically given under Vcesat. the saturation voltage for the collector emitter. they will note the conditions.

for a BC847 : http://www.nxp.com/documents/data_sheet/BC847_BC547_SER.pdf
Code: [Select]
Page 6
VCEsat collector-emitter saturation voltage
IC = 10 mA; IB = 0.5 mA - 90 200 mV
IC = 100 mA; IB = 5 mA - 200 400 mV  <- this is what you need

the last line is what you want.
if you want this particular transistor , which's max collector current is 100mA to be full on you need a base current of 5mA.

now , to calculate the resistor : take the output high voltage of the processor. typically 5 volts... substract the forward voltage of the BE junction at saturation, which you find on that same page 6 the line below :

Code: [Select]
VBEsat base-emitter saturation voltage
IC = 10 mA; IB = 0.5 mA - 700 - mV
IC = 100 mA; IB = 5 mA - 900 - mV   <- this is the one

in this case 0.9 volt.

so we have 5 volts ( cpu out ) - 0.9 volts ( Vbesat ) = 4.1 volts.
and we need 5 mA. so 4.1 volts / 5 mA gives you roughly 820 ohm. !K will work equally fine , but the transisotr will not be full-on as good as it could be in this case.
Professional Electron Wrangler

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1137
  • Country: ca
Re: Transistor Calculations
« Reply #4 on: July 01, 2012, 05:19:26 PM »
Those numbers on the datasheet are the manufacturer test conditions.  The methods given above for finding the needed base current using the Hfe are still sound.

One thing that free_electron said, that people should heed, is look at the curves. 

Quote
...the transistor is non-linear and you really need to look in the curves

This is the most important thing to take away from this thread. You can't just use the Hfe value from their characteristic  tables.  I've seen too many websites do that.  For example, the BC847 linked has Hfe of between 90 and 170 for just 2uA of collector current, and between 180-520 typical for 2mA collector current. I've seen people use these numbers for any current, and it doesn't work that way, "the transistor is non-linear"

So, for 100mA collector current, when you look at the curves, you see at room temperature the Hfe is just 80.

Then 100mA collector current with Hfe=80 is 100/80 = 1.25mA base current. minimum. But manufacturing processes cause slight differences, and you should never use this minimum current. so, the rule of thumb was devised: multiply the base current you get using the Hfe by 2x up to 5x , as Psi said. In this case choose 4.  4 x 1.25mA = 5mA. And 5mA is exactly the test current used in the manufacturers tables on page 6.  So in their test, they used the rule of thumb too. And yes, it will guarantee saturation at 100mA collector current.

free_electron also mentions Vbe(sat) This is important, especially at lower voltages like 3.3, 2.7, 1.8 I/O devices.  Lots of websites online ignore Vbe(sat).  At higher voltages you can probably ignore it because you've already factored in enough extra current by bumping the base current by 2-5 times more than calculated.

But at these  lower voltages you'd be best not to ignore Vbe(sat), because now it's a larger percentage of the available base voltages. In this case, at 100mA collector current, and 5mA base currnet, the Vbe(sat) is 900mV.  If you are using a 1.8V device, it's more than 50% of your voltage budget, so you can't ignore it anymore.

(do they make a transistor with a Schottky B-E junction?  I've never used one, but it would be useful as voltages get lower. Maybe we go back to germanium now)


Offline ShaunLeeClarke

  • Contributor
  • Posts: 14
  • Country: au
  • Hi from Melbourne!
    • ELV Technology
Re: Transistor Calculations
« Reply #5 on: July 01, 2012, 06:00:53 PM »
Thanks for your reply everyone.

The particular transistor I am looking at using is the 2N2222 as it seems quite popular with Arduino projects. I'm looking at the datasheet here: http://www.jaycar.com.au/products_uploaded/KSP2222A.pdf.

Here is an extract from the datasheet.



Is my reading correct in that applying a 15mA base current will allow 150mA through the transistor while applying 50mA to the base will allow the full 500mA to flow through the transistor?
Full time IT/AV tech from Melbourne VIC Australia. Newbie to electronics here to learn and maybe meet some friends :).

Online notsob

  • Frequent Contributor
  • **
  • Posts: 595
  • Country: au
Re: Transistor Calculations
« Reply #6 on: July 01, 2012, 06:14:23 PM »
IF you wish to learn more about transistors, Georgios Lazaridis has a series on transistor theory and another on basic transistor circuits on his site, PCBHeaven.com

http://www.pcbheaven.com/wikipages/Transistor_theory/

http://www.pcbheaven.com/wikipages/Transistor_Circuits/

Offline digsys

  • Supporter
  • ****
  • Posts: 979
  • Country: au
    • DIGSYS
Re: Transistor Calculations
« Reply #7 on: July 01, 2012, 08:08:46 PM »
Quote
Is my reading correct in that applying a 15mA base current will allow 150mA through the transistor while applying 50mA
to the base will allow the full 500mA to flow through the transistor?
This stuff is confusing, and the posts are probably not helping :-) .. not that there's anything technically wrong.
How I would approach it is this (from those specs) -
1/ Lets ignore voltage drops for now - from the hFe table : If I want Ic = 150mA, I need Ibase 150mA/100x = 1.5mA
That's for a BAD transistor. For a GOOD transistor I only need 150mA/300x = 0.5mA
- Notice though, that IF I want more or less Ic, the hFe (gain) varies quite a bit, so IF I wanted MORE Ic, I'd use the
WORSE value hFe @ 500mA as example. Generally you use the TYP figure, and check 1-2 from the batch you bought.
In actual fact, this is a pretty cr@ppy transistor at low Ic, you can find much better.
Even it's Vce sat is lousy.
If you're selecting a transistor PURELY as a SWITCH device, these are the only 2 specs you really care about (oh and VCE breakdown),
otherwise it becomes more complex (NOT harder really). You need to juggle some of the other specs as well.
Hello <tap> <tap> .. is this thing on?

Offline ShaunLeeClarke

  • Contributor
  • Posts: 14
  • Country: au
  • Hi from Melbourne!
    • ELV Technology
Re: Transistor Calculations
« Reply #8 on: July 01, 2012, 10:17:25 PM »
It seems there are two ways of working out the right base current. One would be to fully saturate the transformer, and the other would be to saturate it enough for the load I'm trying to switch.

What is the downside of fully saturating the transformer instead of calculating the base current? I'm guessing it wouldn't be as efficient?

Looking at the datasheet, I'm lost as to which figures I should be using to calculate both the Vce(sat) (as per my previous post) and the hFE.

For example, the hFE has 5 different values. How do I determine which one to pick?

They all have a Vce of 10V and varying Ic values.

The load I am trying to control is a 12 volt relay which has a 16.7mA rating @ 12V.
Full time IT/AV tech from Melbourne VIC Australia. Newbie to electronics here to learn and maybe meet some friends :).

Offline T4P

  • Super Contributor
  • ***
  • Posts: 3706
  • Country: sg
    • T4P
Re: Transistor Calculations
« Reply #9 on: July 01, 2012, 10:32:02 PM »
It means that if the gain is set at 10 and the Ic is at 500mA, Ib at 50mA
the collector-emitter junction will saturate at 1V
Which means that at 500mA and 50mA base current the most you can get pass 1V before it "locks up" and can't pass more then 500mA even at 51mA

Base-emitter junction is also similar...
You can push 2V through the base before it once again "locks up"
at 500mA and Ib at 50mA
http://the4thpin.comeze.com <-- Rants and Reviews! sorry my english  :palm:

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1137
  • Country: ca
Re: Transistor Calculations
« Reply #10 on: July 01, 2012, 10:38:02 PM »
Is my reading correct in that applying a 15mA base current will allow 150mA through the transistor while applying 50mA to the base will allow the full 500mA to flow through the transistor?
Yes.

It seems there are two ways of working out the right base current. One would be to fully saturate the transformer, and the other would be to saturate it enough for the load I'm trying to switch.

What is the downside of fully saturating the transformer instead of calculating the base current? I'm guessing it wouldn't be as efficient?

The excess current goes out through the emitter (assuming an NPN).  The emitter internal resistance can be about .23 ohms if I remember correctly (it's way more complicated to actually calculate it, because it a dynamic value). Here's a simplified way to look at it.

If your calculations say you need 10mA, and you give it 3x as much, 30mA, but the silicon only really needs 15mA, then you will waste 15mA and send it out the emitter.  15mA excess across the emitter internal resistance adds aprox 3.75mv to the B-E junction drop. P=I^2*R, so the excess 15mA out the emitter wastes 51.75uW of power and contributes to device heating.

Quote
Looking at the datasheet, I'm lost as to which figures I should be using to calculate both the Vce(sat) (as per my previous post) and the hFE.

For example, the hFE has 5 different values. How do I determine which one to pick?
Always pick the worst one(the minimum). You never know what your actual transistor will be.   
Sometimes they bin them into A, B, C class, and each class has a min/typical/max. 
So if you have a BC847A then use the A class, and its min Hfe.

Quote
They all have a Vce of 10V and varying Ic values.
Those are just listed so you know the manufacturers test conditions.
Quote
The load I am trying to control is a 12 volt relay which has a 16.7mA rating @ 12V.

so you need to switch 16.7mA.  Divide this by the lowest Hfe, which is 35. Some people use the typical Hfe, but I don't like to. 
so 16.7mA / 35 = 0.477 mA.  Multiply x5 for safety, and you have 2.4mA base current is needed to fully switch on 16.7mA collector current.

the x5 factor guarantees that no matter which 2n2222 you use, which manufacturer, which country it was made in, how they differ from one another, no matter what, it will always work as you designed it.
« Last Edit: July 01, 2012, 10:43:16 PM by codeboy2k »

Online SeanB

  • Super Contributor
  • ***
  • Posts: 8165
  • Country: za
Re: Transistor Calculations
« Reply #11 on: July 01, 2012, 10:44:21 PM »
You need to look at the current the load draws. In your case 16mA, so probably best to base it on 20mA as that will be easier to read off the graph ( you will have a tolerance in any case due to different relays, temperature and of course the transistor will vary with time and temperature as well). So with an average transistor gain of 100 ( most of the 2N2222 will hopefully be more than this at 20mA, but you might get the one that was a close to limit device) the required base current will be in the order of 200 uA to turn it close to fully on. Taking the figure of thumb of 5times then you want to drive it with 1mA of base current. At 5V this means a resistor of around 5K, and if you take voltage drops into consideration ( both the Vbe of the transistor and the unstated high voltage of the micro which can be as low as 3.8V at a supply of 5V) a resistor value of 3K3 will do.

You can thus use almost any value lower than this, so any resistor from around 1k to 3K3 will work in this case, to drive a 20mA load. Tradeoffs are that higher current loads need more drive current, thus with the 33K resistor if you have a 40ma load there is a good likelihood that the transistor will not be saturated at all, but will still be driving the load with enough current to turn it on, though the transistor will likely be a little warmer than if it was saturated. The reason that most use 1K is that you are free to use any load up to the 800mA rating of the 2N2222, without worrying that it will be out of saturation.

Edited as i dropped a decimal point in the initial estimation.
« Last Edit: July 01, 2012, 10:54:24 PM by SeanB »

Offline digsys

  • Supporter
  • ****
  • Posts: 979
  • Country: au
    • DIGSYS
Re: Transistor Calculations
« Reply #12 on: July 01, 2012, 10:53:30 PM »
Quote
It seems there are two ways of working out the right base current. One would be to fully saturate the transformer (transistor),
and the other would be to saturate it enough for the load I'm trying to switch.
Don't worry, it DOES get easier with practice. Also, learning by "text message" is very slow and inefficient. If you want to pursue this
field, you should try to find a human interaction method. Maybe a tutor from a local college etc
Back to your question-
It doesn't matter a whole lot how much over % you drive the transistor. It can be 200% - 1000%. We were just showing you the theory
of "how it works", so you could always design it yourself in future.
The limitation here is the MAX current the CPU / IC pin can deliver. You don't want to run it at MAX if you can avoid it. So, assume the
CPU pin can deliver 10mA max (the specs will be available), then I'd say I'll chose a resistor for 5mA max. Looking at your table,
worst case hFe is app 50, so with that transistor I have 50x5mA=250mA drive capability. You only need ~20mA, so it's HEAPS.
You can 1/2 the resistor current (X2 the value) and you'd still have plenty to spare.
Quote
What is the downside of fully saturating the transformer instead of calculating the base current? I'm guessing it wouldn't be as efficient?
Yes, but we're talking SAY 5V (CPU voltage?) x 2-3mA wasted =~ 15mW. If that's too high, then drop the base drive current further or
pick a better transistor, higher hFe.
Quote
For example, the hFE has 5 different values. How do I determine which one to pick?
You pick the closest Ic to what you want to switch. If you will switch a RANGE of Ic s, then pick the WORST case hFe
Quote
They all have a Vce of 10V and varying Ic values. The load I am trying to control is a 12 volt relay which has a 16.7mA rating @ 12V.
The 10V is just an example, the only time you need to look at the Vce max is if you're going to switch a high voltage.
Hello <tap> <tap> .. is this thing on?

Offline MikeK

  • Frequent Contributor
  • **
  • Posts: 577
  • Country: us
Re: Transistor Calculations
« Reply #13 on: July 02, 2012, 01:03:33 AM »
All really good information here.  I would just add two things.  If you need to restrict load current, then use a load resistor.  Trying to match the base current to the load current is futile.  That's what saturation is about...you push it beyond the exact value.  Also, make sure you have a protection diode at the relay!

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 4569
  • Country: us
    • SiliconValleyGarage
Re: Transistor Calculations
« Reply #14 on: July 02, 2012, 06:51:10 AM »
people... you are making it waaaay to difficult. allt hose calculations are not required
Ideally you would look this up in the curves. but sadly manufacturers in many cases no longer publish those ....

For a transistor in saturation mode usage only one things matters:
- the base current required to get the trasnsitor in full conduction (saturation). Like i said earlier that is stated in the datasheet under the testconditions. They typically list two conditions, one at the maximum collector current , one at half or 1/4 of the maximum current.

For an 2n2222 the max current is 600mA , but you wont get that without artificial cooling.

So , for a collector current of 500mA you need a base current of 50mA. The beta (sometimes calle hFE) for a 2n2222 is very low , especially at higher currents it collapses to snot..
If you know that your load is more in the order of 100mA you can take the other scenario : they give the base current for a maximum of 150mA as well.

There is some transistor physics at work that is not easily castable in equations. A transistor in saturation has extreme nonlinear gain behavior if you modulate the collector current.
If you keep a b-e current of 15 mA and you drive up the collector-current the gain will collapse and VCE will rise very quickly. This has to do with the balance of the doping between the BE and CB junction and the physical construction. the recombination area in saturation is so full of electrons that they start rejecting each other... so VCE shoots up. You need to 'pull' harder on the base to keep em from assembling in the emitter. the collector potential in saturation is actually lower than the base potential ! ( Vbe is 0.7 volt while Vce can go as low as 0.2 volts.. ). in Saturation hFE does no longer apply.... the equasion is invalid. some manufacturers will actually specify a hfe1 and hfe2. hfe2 is when you are driving the transisotr pretty hard... hfe1 may be 150 .. 200 while hefe2 can go a s low as 10 for the same transistor.

If you really want to find out the optimum : use  a curvetracer and measure it. but that too is overkill. simply go by the manufacturer standard. they have done the test.

it is possible that with a 15mA base current and a 500mA collector current the VCE reaches maybe 5 volts... resulting in a fried transistor because you are trying to burn off 2.5 watts in that case with an Rtja of maybe 150 to 200 for a to-92 body ... that thing hits 500 degrees internally !

As collector current goes up you will need to pump in more base current. it's as simple as that.

So in short : look at what current your load draws , look under VCEsat in which category you fall and pick the appropriate base current given. done.
no need to complicate.
for low-voltage designs keep in mind that the vbe goes up as Ibe increases so you may need to tweak your series resistor.
and for large collector current you will need large base currents... make sure your chip can drive that .... a 2n2222 is an old piece of junk with crappy performance...



Professional Electron Wrangler


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf