Required Current From GPIO To Activate Gate Of Transistor?

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
Hey guys,
This is the circuit I typically use when controlling a relay using a GPIO on a microcontroller:
gpio_transistor1.jpg

I just noticed that a microcontroller that I am wanting to use has 2 output modes... a normal mode that can source 0.5mA, and a high drive mode that can source 5mA.

Are either of these 2 modes adequate to activate the transistor? The relay I am using has a coil current draw of 40mA @ 12VDC by the way.

How do you make this calculation to know how much current draw would be needed to activate the transistor? Thanks and any help/advice is greatly appreciated!
 

dl324

Joined Mar 30, 2015
16,846
How do you know I need a logic level mosfet instead?
A logic level N channel MOSFET can be driven by your GPIO in low current mode.
How do you know 0.5mA will be enough to drive the transistor?
We don't. The relay coil requires 40mA. Conservative design would require 4mA of base current.

You didn't specify the voltage involved, but it could work in the high drive mode.

R11 needs to be smaller.
 

danadak

Joined Mar 10, 2018
4,057
For a bipolar transistor to saturate the transistor rule of thumb
is Ib = Ic/10, thats otherwise known as forced beta.

So 5 mA would work fine, as long as its driving V at 5 mA
is > Vbe of transistor, typically .7V for silicon transistor.

So calc the series R from output to base as [Voh (@ .5mA) - Vbe] / 5 mA.
Also put a R from base to ground to make sure when output is in HiZ the
transistor does not turn on from leakage. Simply calc it as ~ << Vbe/Ileakage.

Be sure to clamp relay coil with back emf diode (note R from base to ground
not shown as discussed above) -



Regards, Dana.
 

shteii01

Joined Feb 19, 2010
4,644
How do you know I need a logic level mosfet instead?
I did not know about them either until I became regular on these forums.

In school they teach us about BJT transistors, those need voltage to turn on b-e junction and they need protection from too much current into base. This makes them "complicated".

Logic level mosfet just needs "logic level" voltage applied to it. If you have Uno, the logic is: 5V is On or Digital 1, 0V is Off or Digital 0. So you pick logic level mosfet that has logic 5V. You turn a digital pin on Uno On, 5V at the pin, and that will turn the mosfet On. DONE! No need to deal with current. Just pic a mosfet that fits your micro.
(And you save on parts since you don't need the resistor.)
 

danadak

Joined Mar 10, 2018
4,057
You need a R from gate to ground on an N chan MOSFET to absorb leakage
when output in tri state (like UP startup, depending on part) so the MOSFET
says off until UP can take control of it.



This circuit does not show a series R from UP out to MOSFET gate.
Consider doing this due to high current involved in charging gate cap
when gate charge is 0. If you have a UP driving a lot of these on pins
you could exceed the internal UP rail current, hence dropping internal
rail V and then compromising noise margin of the internal logic.


Regards, Dana.
 
Last edited:

shteii01

Joined Feb 19, 2010
4,644
You need a R from gate to ground on an N chan MOSFET to absorb leakage
when output in tri state (like UP startup, depending on part) so the MOSFET
says off until UP can take control of it.



Regards, Dana.
Maybe. Some boards have those resistors already.
 
Top