# Limit power draw - transistor, mosfet, base resistor choice

I know the Arduino is rated for max per pin 40mA and 20mA recommended.
But i also have micros with just 5mA.

Everytime i need to switch a relay or something else i start from the beginning and my head spins around hFE.

It would be nice to make some kind of spreadsheet to look at, reduce everything to 5mA, what resistors/transistor/mosfet to use and how much can be switched.

Here the BC337 is popular but with just 5mA/10mA base current it's good for nothing?

I have some IRLU8726PBF but how do i calculate the resistors for the different voltages and how much i can switch?

MOSFET gates have very high impedance, and won't draw much current. The current limiting resistor is not as critical for them. It is the gate voltage that matters.

Make R2 = 100k.

Your circuit will only deliver half the supplied voltage to the gate, and 1.65v isn’t enough.

Allan.

The values of the resistors where just examples…

The load that can be driven is not depending on gate voltage/current with a MOSFET?

MrGlasspoole:
Everytime i need to switch a relay or something else i start from the beginning and my head spins around hFE.

Hfe is irrelevant for switching, so forget about it.

For switching (saturating a transistor), you need a base current that is between 1/10 and 1/20 of collector current. 1/20 is ok for small transistors (BC547 etc). Bigger ones can do with a bit more.

For small things (like relays) try 2N7000 mosfets.
No resistor between Arduino pin and gate needed. Maybe only a 10k bleed resistor from gate to ground.
ESD sensitive, so not noob-friendly.
You could thread a thin bare copper wire through the pins (shorting all) when soldering, and remove when done.
Leo..

No resistor between Arduino pin and gate needed.

A 220 Ohm (minimum) resistor is needed to limit the pin current into the gate capacitance to 20 mA.

jremington:

A 220 Ohm (minimum) resistor is needed to limit the pin current into the gate capacitance to 20 mA.

Not for this fet though.
Gate capacitance of this fet is probably less than the wiring and the breadboard.
Leo..

You can ignore hfe and just look at Vbe instead.
Figure most NPNs have a Vbe of 0.7V, about one diode drop.
Then (5V - 0.7)/25mA = 172 ohm, so a 180-200-220 ohm resister will provide plenty of drive current while still protecting the Arduino output.

Same for the input gate capacitance on a MOSFET, which looks like a short to Gnd when driving the input high, and a short to +5 when driving the input low.
Thus 5V/25mA = 200 ohm will provide plenty of drive current to switch the MOSFET quickly while still protecting the Arduino output.

You can go up to 35mA if you think you need a little more oomph.

If the NPN you are using needs 50mA to switch on into saturation, then a different setup is needed.

Wawa:
ESD sensitive, so not noob-friendly.

You can get ones that have clamping diodes connected between the gate and source, and are much more forgiving. They’re also quite a bit rarer and harder to find. I didn’t see it as an option to filter on at Mouser or Digikey, so I had to resort to a brute force search. I soldered 10 each of DMG3415 and DMG6968 onto breakout boards with no ESD protection and they all blinked an LED just fine afterward.

The downside of the protection diodes is much higher gate leakage current. I just checked all the datasheets I have stored locally. Without the diodes, the maximum gate leakage was between 10 - 100 nA. With the clamping diodes, the gate leakage was 10 uA.

The more i look at calculation examples the more confusing it gets.

I should ignore hFE but all the examples look at it…
The more i calculate the more different results i get…

But it looks like i can switch more with a BC337 then i thought.
One example i saw used “IC / IB” so i thought i have to use:

IC = 500 mA, IB = 50 mA

from the data sheet.

But for IC i have to use the current i want to switch?
So with another calculation i found i only need 0.32mA to switch 80mA?

Ib = required base current
Ib = IC / DC Current Gain
Ib = 0.08 / 250 = 0,00032

Lets say i want to limit the base current to 10mA:

R = (5.0v-0.7v) / 0.01 = 430R

So i take 470 and that gives me 9mA base current:

I = V/R
I = (5.0v-0.7v) / 470 = 0.009

So i could switch 2.25A (if the Transistor would support it) with just 9mA?

Ic = Ib x DC Current Gain
Ic = 0.009 x 250 = 2.25A ???

How do i calculate what the maximum is that i can switch with a BC337-40 for:

1. 3.3v / 10mA
2. 3.3v / 5mA
3. 5.0v / 10mA

I guess with knowing how much this 3 configurations can switch i then know if the BC337-40
is strong enough and i can use the circuit for everything without any calculation anymore up to 24v?

You have to understand that FETs and bipolar transistors are two very different things. It seems like you are trying to treat them the same. Advice about FETs and how to drive them is NOT applicable to transistors.

When you are switching with a transistor you want to saturate the transistor, that is you want to minimise the voltage across the collector / emitter, the so called saturation voltage. This is not calculated by considering the hFe of the transistor, that is for small analogue signals only.

You want to look at the data sheet at the Vsat voltage - these are quoted to be as small as possible. The more collector current the higher this saturation voltage will be. Alongside the quoted Vsat their will be a collector current and what base current was needed to achieve. It is this value that you want to design for your transistor.

So this calculator that is looking at hFE is wrong?:
http://www.petervis.com/Raspberry_PI/Driving_Relays_with_CMOS_and_TTL_Outputs/Driving_Relays_with_CMOS_and_TTL_Outputs_Calculator.html

This one is also looking at DC current gain (Beta) to calculate base current (example no1):

"Enter the supply voltage Vcc in volts for your circuit. If your relay coil needs five volts then your supply voltage needs to be the same amount obviously."

They obviously have forgotten that the transistor has a volt drop across CE.
Listed Hfe of the BC337 is at a CE voltage of 1volt, so if you work with Hfe you obviously need a 6volt supply for a 5volt relay. Or your relay only gets 4volt on a 5volt supply.
A non-saturated transistor also gets hotter. With 100mA collector current, a BC337 with 1volt across has a temp of 20C above ambient.
Leo..

Drive it hard enough ( Ib =10mA) and the Vce sat should be much less than 1v with 100mA Ice

Or use a 2N7000...

Allan

There is also the circuit on one of germany's biggest electronic website:
Relay Driver

It says you can drive 5 to 24v relays without changing anything.
It does not say how much current is drawn from the TTL.

Even if i would use 2N7000 and throw 50 BC337 in the bin the i don't have the calculation for that mosfet.

MrGlasspoole:
It says you can drive 5 to 24v relays without changing anything.

It does not say how much current is drawn from the TTL.

Sure, because base current results in collector current.
Collector current is limited by the load (voltage/resistance rating of relay).

BE is a diode, so 0.7volt drop there.
R1 will have 5-0.7=4.3volt across, so 4.3/2200= ~2mA through R1 (from the Arduino pin).
R2 will use 0.7/2200= ~0.3mA of that, so about 1.7mA will flow into the base.
Not enough to saturate, so the transistor will drop ~1volt across CE in most cases.

MrGlasspoole:
Even if i would use 2N7000 and throw 50 BC337 in the bin the i don't have the calculation for that mosfet.

Fets are voltage controlled. No current flows into the gate, so no calculations needed.
From the datasheet: With more than 4.5volt at the gate, souce/drain resistance is typical 1.8ohm.
That resistance is in series with the relay circuit.
For the 5volt/75mA relay example, that would be a loss of 0.075A*1.8ohm= 0.135volt.
Leo..

MrGlasspoole:
Everytime i need to switch a relay or something else i start from the beginning and my head spins around hFE.

Which is odd because hFE is not relevent to switching with a transistor, it is the small signal analog
gain in the active region. Switching a BJT uses the cutoff-region and the saturated region.

Most transistors saturate with Ib = 0.05 to 0.1 time Ic, whatever the hFE value. So a 100mA relay
would use 5 to 10mA on the base, so a 470 to 1k resistor would be reasonable.

For logic-level MOSFETs its simple, just use a 150 ohm gate resistor and 10k to ground pull-down to prevent
the gate turning on during power-down or during reset/start up.

Wawa:
BE is a diode, so 0.7volt drop there.
R1 will have 5-0.7=4.3volt across, so 4.3/2200= ~2mA through R1 (from the Arduino pin).
R2 will use 0.7/2200= ~0.3mA of that, so about 1.7mA will flow into the base.

So it would be save to always use this circuit if it only draws 2mA...

But what about how much it can switch? Lets say i want to switch some LEDs on and off and i have to switch 200 mA, 300 mA?

dc42 wrote here he uses the BC337 up to 500mA. But he drives them with much more current:

dc42 wrote here he uses the BC337 up to 500mA

Yes that transistor has a maximum current of 800mA.

He also says:-

For these transistors, Vce(sat) is quoted at Ic=500mA, Ib=50mA. However, 50mA is too high for an Arduino pin.

YOU have to decide if you want to calculate with Hfe, and accept the >=1volt drop across the transistor.

OR calculate 1:10 for lowest saturation voltage across the transistor.

Or somewhere in between.

If you calculate with Hfe, I doubt you can switch 500mA with a BC337.
Because the ~1volt drop would heat up the transistor to at least 100C above ambient.
Could be a quick trip to silicon heaven.
Leo..