[SOLVED] Calculating a transistors currents

Hi, I'm using a 2n2222 transistor to power a 24v bosch relay, I have measured the internal resistance of the relays coil and it give 340 ohms, looking for a lot of tutorials and courses I already have some doubts about how transistors works so I'm stuck in this step, I want to calculate the Ic an Ib currents.
I don't want the answers I want the maths so I can calculate it for myself for others relays and stuff.
Thank you in advance and sorry for my bad english.

First you must add a freewheel diode or you'll just trash stuff. Highly inductive
loads will generate high voltages if you don't add something to prevent this. Normally
a freewheel diode or snubber network across the coil.

24V at 340 ohms is 70mA relay current, so even a 1N4148 will do as a free-wheel diode.
Set the base current at 7mA (1/10th collector current) so 560 ohms would be fine for
base resistor.

Yes, thanks, I already have a freewheel diode I forgot to mention that, my fault.
Is the base current 1/100 of Ic? 0.7 mA? So the base resistor will be 7Kohms? I have not read about a 1/10, sorry if I'm wrong.

1/10th or 1/20th is usual for switching - the transistor is meant to saturate, not
be in the linear region.

Ohhhh ok, thanks, my entire life is a lie.

Look at Vce(sat) on page 3, middle of the page. It is specified for IB = IC/10.

PN2222A Datasheet

The linear beta varies with time, temperature, and which batch you got. So for a saturated switch, the 2N2222, 2N3904, 2N3906, and other older transistors specify 1/10th the collector current as base drive current.

Newer transistors may specify only 1/20th, but 1/10th is safe.

Keep in mind that 1. The BE junction drops out 0.7V, and 2. The Arduino output is less than 5V when it is loaded at all. So I'd probably use 4V @ 7mA to calculate, or 4V/7mA = 571 ohms, therefore MarkT is on the nose with 560 ohms as the closest but not higher standard value. 510 or 470 ohms would work just fine, too.

The DC gain only really holds when the collector is a volt or more above the base (for an
NPN), since the electric field in the reverse-biased BC junction then accelerates the
injected carriers in the base out to the collector before they can recombine. In saturation
you want the collector voltage close to the emitter voltage (ie the BC junction is forward
biased), there is no field to accelerate the injected carriers out of the base, they have
to diffuse out, and this takes longer, so much more recombination happens, meaning a
higher base current is needed to compensate for the recombination. I think that's how
the explanation goes. The diffusion is mainly driven by the much higher carrier concentration
in the heavily doped emitter, which is usually 2 or 3 orders of magnitude more highly
doped than base or collector.

First read MarkT´s comment about the freewheel diode.

However, I would use a 2,2 K ohms restistor at the basis of the transistor.

The 2N2222 has a guarantied minimum amplifying factor of 50 (hFE gain according to datasheet when the collector current is between 1ma and 100mA).

This is only significant if your 5V source is a battery. You will have a multiple times longer runtime.

A 2N2222 can have a hFE gain of up to 200. So if you are interested in battery live you can experiment with 4.7 and even 10K resistors.

If your 5V source is NOT a battery, just forget all my words.

However, do remember my first sentence. No it were actually MarkT´s words.

arduionaleman

Multiple times longer runtime? Your Ib would be lower but your Ic (which is the greatest part of the total current drawn) would stay the same.
So your battery life gain would be only a few percents... Or I missed something in what you said.

arduinoaleman:
First read MarkT´s comment about the freewheel diode.

However, I would use a 2,2 K ohms restistor at the basis of the transistor.

No, you want Ic/Ib to be about 10 to 20, so 560 to 1k ohms would be the best choice.
(I make the relay load to be 70mA, so 7mA base current or so.)

If you don't drive the device fully into saturation then you waste more heat in the Vce
drop than you save by using less base current.

if a transistor has a current gain of at least 50 you will need just 1.4 mA at the basis for a 70mA output current. a 2N2222 usually has a gain of more than 50 - that is the bare minimum.

so if you have got a voltmeter i recommend to start with MarkT´s resistor value. measure the voltage drop between collector and emitter.

then make the resistor value higher and higher step by step. as long as the voltage drop does not increase, the transistor is in full saturation.

the 2N2222 datasheet just gives you the minimum gain. if you were using a BC547/548 the A, B, or C would tell you exactly about the voltage gain.

A = 100 - 200
B = 200 - 400
C = 400 -800

however, it is better to use a 2N2222 in your case, as a bc457/458 allows for a maximum current of 100 mA while your 2N2222 will allow up to 800 mA when in full saturation. it was just meant as an example how much gain you can expect.

and transistors are like other things in life. you never know exactly what will happen without trying and measuring.

in your case the 2N2222 seems to be a good choice.

my main message was even printed in red. i was NOT talking about the 24 voltage source.

I believe I covered it, including the datasheet:
http://forum.arduino.cc/index.php?topic=327332.msg2259886#msg2259886

hi polymorph

i had a look at the datasheet for the 2N2222 (using the link you presented):

MINIMUM current gain is:

50 at 1mA Ic (collector-emitter current)
75 at 10 mA
100 at 150 mA

your recommendation is to calculate with a gain of just 10.

i always use the minmum of datasheets for my calculations because you never know.

however, a fifth, is very pessimistic.

Let me repeat myself again. Current gain is only relevant to the linear region,
where the BC junction is significantly reverse biased, it is not relevant to saturation
where the BC junction is forward biased but carrying current in the reverse direction.

When the collector voltage of an NPN is lower than the base voltage, the BC junction
is forward biased, there is no significant electric field present to cause the current to
flow across it (in fact the field is the wrong way round), the current happens due to
the higher density of carriers in the base than the collector (which in turn is due to
the emitter injecting those carriers into the base).

The base current to collector current ratio is very different in this saturation regime,
and is not directly related to the DC gain at all, although both are primarily set by
doping level ratios.

Modern switching transistors like the ZTX851 are highly optimized for saturation, and
perform better than the ancient 2222 BTW, which is a general purpose device.

When choosing a switching device the correct part of the datasheet to look at is the
bit describing Vce(sat) as a function of collector current and base/collector current
ratio.

I assume the reason no one has asked "where is the load ?" is because this is just a transistor tutorial session ? (The circuit is obviously not an amplifier because there is no signal input so the collector resistor can't be the load because then what would be the point of the circuit ?)

Page 3. Did you look?

Well there is no Page 3 and Reply#3 doesn't address that question but I did find this in the OP's first post :

I don't want the answers I want the maths so I can calculate it for myself for others relays and stuff.

I think this thread is overkill for calculating resistors for a transistor to power a relay.
It's not that complicated.

Page 3 of the datasheet that I linked to in this reply:

http://forum.arduino.cc/index.php?topic=327332.msg2259886#msg2259886

If the OP can't divide by 10, well...

Here is the datasheet again.

https://www.fairchildsemi.com/datasheets/PN/PN2222A.pdf

2N2222SaturationIV.gif

2N3904SaturationIV.gif

Whatever happened to :

Hi, I have a bosch relay

with a coil resistance of 340 ohms

and a coil current of 70 mA @ 24V

My P.S. is a 24V dc switching supply.

My uC is an Arduino UNO.

I have a 2n2222 transistor.

How do I calculate Rbase and Rcollector ?
Where do I find the information I need about the transistor to do this ?

(if this had been the first post , would we be on Reply#19 now ? )