Driving N channel mosfets using bipolar transistors

Thread Starter

ag-123

Joined Apr 28, 2017
276
hi,

i'm pretty much an electronics novice

i'm trying to drive some N channel mosfets from a 3.3v arm mcu (stm32), the actual mosfets are really basically the RepRap Ramps1.4 heater mosfets.
However, based on the specs, the turn on gate source voltages is at least 4.5 volts as seen in various data sheets. Hence, to model a possible interface i made a schematic with something equivalent IRFZ44N as the N channel power mosfet. I'm skipping the logic level power mosfets that can run at 3.3v as i observed that they are expensive on ebay / aliexpress etc.

The idea here is i drive input A from the gpio pin, and R1 (100 ohm, but in reality i think it may be just a few ohms as that is the heater hotend heating cartridge) is the load.

i used a PNP transistor (Q2 2n2904 - the part number in the image is incorrect) at the gate and another NPN transistor (Q1 2n2222) to drive the NPN transistor. i did a though experiment / analysis and figure that Q1 NPN should be off at the start (assuming that the input is floating or low), that should keep Q2 PNP off, which in turns keeps Q3 the n channel power mosfet off. i've initially started with just a single NPN transistor, but the level/logic inversion is a problem as it leaves the mosfet switched on right at the start.

if i raise A to 3v (i should probably have placed a series transistor), i figure that the 3 transistors will be switched on.

do this circuit make sense or do you have any comments about this?

i'm actually also thinking about the IR2109 half bridge driver in which the parts are rather inexpensive on aliexpress
https://www.infineon.com/dgdl/ir2109.pdf?fileId=5546d462533600a4015355c7e85b1679
however, i'm not too certain about the implications if i simply leave the high side unconnected. i.e. just use the low side to drive the mosfet.
would there be any advantage using a IR2109 rather than discrete bipolar transistors as such?

simplegatedrive.png

the actual part i'm interfacing is the heaters section in the 2nd image attached.
heaters.png
 

ElectricSpidey

Joined Dec 2, 2017
2,758
If your mcu can invert using software then you only need one PNP to drive the MOSFET, if not then you need the NPN as well.

But I would suggest you use something like the TC4420, and simplify the design, especially if the output is PWM. (even if it’s not)

Also if your GPIO output does not go rail to rail, you should use a pull up/down resistor at the output.

And if you do go with the BJTs use a 907 instead of the 904.

And do yourself a big favor, get your parts at Digi-Key or some other supplier…not Alibabbashabba.
 

crutschow

Joined Mar 14, 2008
34,285
You PNP is upside-down.
Remember that the normal current direction in a BJT is in the direction of the base-emitter arrow.
You also need a resistor at the input to the NPN.
upload_2019-3-7_9-48-52.png
would there be any advantage using a IR2109 rather than discrete bipolar transistors as such?
You need a driver only if you need to turn the MOSFET on and off rapidly.
A MOSFET has a lot of gate capacitance and needs a driver for that if you switch it at a high frequency, such as with a PWM signal.
If you just using the MOSFET to control the load as a DC switch, you don't need a driver.
If your mcu can invert using software then you only need one PNP to drive the MOSFET
No.
He needs to convert from a 3.3V signal to 12V and one PNP won't do that, since the PNP's base voltage needs to go up 12V to turn-off.
 

Thread Starter

ag-123

Joined Apr 28, 2017
276
thanks, for pointing out my goof on the pnp, i'd think for 3d printing hot end there'd likely be some pwm but i think 'rapidly' shouldn't matter too much, temperature don't change that much and pwm could probably be rather slow.

i'd think i'd give the bipolar transistors approach a try as the component counts is rather low, i could patch that up on a perfboard which in turn interface the Ramps board
 

BobTPH

Joined Jun 5, 2013
8,813
You can do it with a single NPN though. The only difference is the input is inverted, low for on and high for off.

Bob
 

MrChips

Joined Oct 2, 2009
30,714
Or you can get a proper logic level MOSFET. You're only buying one, right?
And don't bother to buy it from eBay etc.
 

crutschow

Joined Mar 14, 2008
34,285
You can do it with a single NPN though. The only difference is the input is inverted, low for on and high for off.
If you do that it might be a good idea to add a pull-up resistor (e.g. 10kΩ) from the transistor resistor input to plus 3.3V so that the output is off with no input, as shown below.
upload_2019-3-7_12-17-47.png
 

ElectricSpidey

Joined Dec 2, 2017
2,758
Right, I thought he meant the output from the NPN, not the MOSFET.

But still isn’t that pull up resistor connected to 12 volts?

And if it is, why can’t a pull up be used to turn off a PNP instead.
 

BobTPH

Joined Jun 5, 2013
8,813
And if it is, why can’t a pull up be used to turn off a PNP instead.
The problem is you cannot drive a PNP connected to 12V from a 5V output. The PNP is turned on by a voltage negative with respect to the 12V. The 5V output will be either -7V or -12V relative to the 12V source. Either of which will turn the PNP on.

Bob
 

Andrei Suditu

Joined Jul 27, 2016
52
If the mosfets switch some power (a couple of amps) it's better to use a IC driver that can charge and discharge the mosfet's gate fast.
If not then an optocoupler solution(some can drive about 50ma on the output)/bjt variants can work.
Just make sure to simulate the bias point of the bjt to make sure you get enough voltage at the output.Try with LTSpice and get an ideea.The voltage at your gate will be the CE voltage of the bjt.To get that you substract from the supply voltage the Ic*Rc voltage drop.When the transistor is off Ic -> 0 so Vgate~12V.The gate charge time can be tought as the charge time needed to charge a capacitor trough Rc.
Be carefull to not overload your transistor.The Ic VCE product when on must not exceed the transistor power disipation.Also keep in mind that the discharge is done by the transistor.I've seen totem pole bjt configs ,but they seem more complicated to implement correctly since you must avoid having both on at the same time.
Any way for high freq stuff at high power always use IC's.
 

Attachments

ElectricSpidey

Joined Dec 2, 2017
2,758
According to the data sheet that mcu has an open drain output mode that uses an nmos transistor and to get the output high a pull up resistor must be used.

So when the output is “high” (open) a resistor can pull the output to the 12 volt rail.

From the data sheet:

• Open-drain output mode: Open-drain output mode does not use the PMOS transistor and a pull-up resistor is required. When the output has to go high, the NMOS transistor must be turned off, pulling the line high only by the pull-up resistor. This pull-up resistor could be internal with a typical value of 40 kOhm and activated through GPIO port pull-up / pull-down register (GPIOx_PUPDR).

Note:It is important to note that it is not possible to activate pull-up and pull-down at the same time on the same I/O pin.

Programmed as output, an I/O port exhibits the following characteristics:

Open-drain output is often used to control devices which operate at a different voltage supply than the STM32. Open-drain mode is also used to drive one or several I2C devices when specific pull-up resistors are required. It is also possible to use an external pull-up or pull-down resistor instead of the internal resistor. In this case, the value must be adapted to be compliant with the GPIO output voltage and current characteristics.
 

crutschow

Joined Mar 14, 2008
34,285
According to the data sheet that mcu has an open drain output mode that uses an nmos transistor and to get the output high a pull up resistor must be used.

So when the output is “high” (open) a resistor can pull the output to the 12 volt rail.

From the data sheet:

• Open-drain output mode: Open-drain output mode does not use the PMOS transistor and a pull-up resistor is required. When the output has to go high, the NMOS transistor must be turned off, pulling the line high only by the pull-up resistor. This pull-up resistor could be internal with a typical value of 40 kOhm and activated through GPIO port pull-up / pull-down register (GPIOx_PUPDR).

Note:It is important to note that it is not possible to activate pull-up and pull-down at the same time on the same I/O pin.

Programmed as output, an I/O port exhibits the following characteristics:

Open-drain output is often used to control devices which operate at a different voltage supply than the STM32. Open-drain mode is also used to drive one or several I2C devices when specific pull-up resistors are required. It is also possible to use an external pull-up or pull-down resistor instead of the internal resistor. In this case, the value must be adapted to be compliant with the GPIO output voltage and current characteristics.
Are you certain the output can tolerate 12v?
 

ElectricSpidey

Joined Dec 2, 2017
2,758
Honestly, no I'm not…one of the reasons I suggested using a driver chip, to simplify things. I’m pretty sure the TC4420 will do the level shifting.
 
Top