Transistor and base resistor calculations

Hi community!

I have read a ton of resources to be able to choose an appropriate transistor and base resistor for my application. At more than one time, I have ended up just being more confused. This thread (LINK) ended up summarizing 3 different ways:

  1. using just the test values from datasheets, i.e. Vce(sat) usually shown at a few different test currents
  2. using the charts (find the collector current you need, scan across the chart to get the base current needed)
  3. using the Hfe(min) or Hfe(typ) values. Some people use the typical values, others prefer the minimum values.

Please, if you can read through my simple calculations, and verify that the setup will work.
Relay Datasheet LINK
Transistor (P2N2222A) Datasheet LINK

I will use a 12 VDC relay with the following coil ratings.

We need to switch a collector current of 30 mA. The worst scenario Hfe (gain) for the transistor is 30, but likely it will be closer to 30 mA at room temperature, which according to the table below gives a gain at closer to 200. But based on other threads I have read, I will stick with the lowest rating. So 30mA / 30Hfe = 1mA. If I multiply this by x5 as a safety factor, I find that I need 5mA in Ib to switch 30mA in Ic.

Base resistor calculations:
5mA and 5V = 1K ohm, hence I need a 1K ohm base resistor.

If I account for the VBEsat, which is between 06 – 1.2 VDC (let’s say 1), I have 5mA and 5-1 = 4V, which gives us a resistor value of 800ohm. I would probably go with the 1K anyway.

Again, if someone with the knowledge can verify my calculation (and logic thinking) I would be happy. Please also comment about power dissipation (Pd = 635mW). Will it work? Below is a schematic of my thoughts:

Best regards,
Aleksander Hansen

check one more link then

http://www.petervis.com/GCSE_Design_and_Technology_Electronic_Products/transistor_base_resistor_calculator/transistor_base_resistor_calculator.html

super clear to me

If I account for the VBEsat, which is between 06 - 1.2 VDC (let's say 1), I have 5mA and 5-1 = 4V, which gives us a resistor value of 800ohm. I would probably go with the 1K anyway.

This doesn't make sense.

If you "go with 1k anyway", you won't get your full 5 mA that you think you want.

Are you trying to limit the collector current to 30 mA ? Or are you trying to turn the transistor "on" as much as possible ?

I'm trying to "turn it on as much as possible". With a 1K resistor, I will have a base current of 4mA, which with a gain of 30x allows me to switch 120mA, well above the 30mA load. Also, the hEF is likely much lager than 30x if have understood it correctly.

If not, please correct me.

With a simple driver transistor as you have it, you simply want to turn on the transistor fully. The R value chosen is just selected to achieve this. Most general purpose transistors (such as you have selected) will be fully turned on with 10k or less. To be totally sure use a smaller R that does not give more current than the base can handle.

I have not calculated a base R for many decades, I just use a rule of thumb that 10k will work. I have had no problems yet.

My point is that for a driver Tr, it does not really matter about exact values.

Weedpharma

Your diagram and calculated values look good. You may want to consider adding a 10K "pull down" resistor connected from the Arduino output pin to GND. That way, when ever the pin is high impedance (disconnected or configured as an input as Arduino boots up) the pin will be pulled low.

weedpharma:
With a simple driver transistor as you have it, you simply want to turn on the transistor fully. The R value chosen is just selected to achieve this. Most general purpose transistors (such as you have selected) will be fully turned on with 10k or less. To be totally sure use a smaller R that does not give more current than the base can handle.

I have not calculated a base R for many decades, I just use a rule of thumb that 10k will work. I have had no problems yet.

My point is that for a driver Tr, it does not really matter about exact values.

Weedpharma

Nearly all older bipolar transistors need Ic/10 to Ic/20 to saturate - the DC gain
is only relevant for linear operation, when Vce is 2V or more. Saturation is all about
reducing heat in the transistor by reducing Vce.

Heat dissipation = 0.7 * Ib + Vce * Ic
To reduce this Vce is the important value, if you can get that down to 0.1V its
still the dominant term, the base current can be 10% of the collector current
and still not be "wasteful" as its helping to keep Vce down at a low value.

Modern super-beta devices saturate well at perhaps 2 or 3% of collector current.

Even with these using a 10k base resistor will only work well for loads of less than
25mA, and for older devices 10k base will handle 10mA load well.

In general give the base 20mA (which an Arduino pin can comfortably handle) to
switch loads of 200mA, maybe 30mA will handle upto 0.5A with a good transistor.
(and up to 1.5A with a superbeta device like ZTX851)

For higher load currents either a MOSFET or darlington will be required for efficient
switching (MOSFET prefered).

MarkT has said all that I was going to say.