Mosfet basics – get your power mosfet working!

Allow me to explain some useful circuits to get your power mosfet working. The mosfet basics I will be covering are:

  • Voltage level shifting
  • Voltage biasing
  • Current amplification
  • Power mosfet protection
  • Dedicated drivers


Voltage level shifting #1

Voltage level shifting is a technique you use when the voltage level of your controller does not match that of your power mosfet. For instance; when your microcontroller’s PWM port outputs at most 5V but your mosfet needs at least 10V at the gate to function properly.

One way to change your signal is by using a pull-up resistor with a NPN transistor.

voltage level shift NPN circuit switches mosfet on or off
voltage level shift NPN circuit for switching mosfet

When the IO signal is low, the NPN transistor is not sinking any current on its cathode allowing the pull-up resistor to send 10V to the gate of the mosfet and the mosfet switches on.

voltage level shift NPN circuit switches mosfet off
voltage level shift NPN circuit for switching mosfet

When the IO signal is high, the transistor starts to conduct, pulling all current down through the cathode. The gate of the mosfet get’s depleted and the mosfet switches off.

voltage level shift NPN circuit switches mosfet off
voltage level shift NPN circuit for switching mosfet

Please note that this circuit does invert the signal of the controller.

NOTE: Also, do not try to use an PNP transistor instead of an NPN to combat the inverting of the signal. The 5V on the IO pin will still be lower than 10V at the emitter and therefore pull the base of the transistor down keeping the transistor conducting in both cases. The mosfet will never turn on.

Voltage level shifting #2

Another way is by using a comparator and two resistors, or you can even use an opamp if speed is not an issue.

voltage shifting comparator circuit for switching mosfet
comparator circuit for driving a mosfet

At the negative input of the comparator two identical resistors are connected, one leads to your logic’s power source, the other to ground, creating a resistor network which feeds half your logic’s voltage to the comparator’s negative. At the positive input the IO signal is connected.

The comparator itself also needs a power source and ground, these are called rails and are the lower and upper boundaries of the output signal. The negative supply goes to ground and the positive to a voltage source high enough to drive the mosfet’s gate.

When the IO signal is low, it is also lower than the negative pin of the comparator and the output signal goes low.

voltage shifting comparator circuit switching mosfet off
comparator circuit for driving a mosfet

When the IO signal is high, it is higher than the negative pin, which is still half the logic’s voltage and the comparator’s output switches to the upper rail giving the voltage needed for the gate.

voltage shifting comparator circuit switching mosfet on
comparator circuit for driving a mosfet

Please note that a comparator usually is not capable of providing high currents so if fast switching is needed you need an additional circuit to boost the current.

Voltage biasing – Explained

A voltage bias means your low signal or ground for a particular piece of a circuit is not at 0V in regard to the controller. For example, if a mosfet is positioned at the high side of the circuit and after it comes a load with relatively high resistance, then the source of the mosfet won’t be at 0V but more like 20V if you switch 24V into it. This means the gate of the mosfet has to be at 20V + 10V = 30V to turn it on. And at 20V to turn it of again.

If the source voltage is stable, like a battery and the load is always present and has a high resistance then the following circuit will help you switch in this kind of situation.

NOTE: If there is a capacitor in parallel with the load, then that keeps the mosfets source voltage from rising quickly while still applying a gate voltage 30V higher. This will destroy the mosfet. This is why this circuit needs to meet a lot of conditions in order to work.

Voltage biasing #1

This circuit uses two optocouplers. The top one is used to connect the gate to the high voltage source to switch it on, and the bottom one connects the gate to the source of the mosfet to switch it off. You can generate this 24V+10V voltage in a number of different ways but most people use a charge pump for this. They are fairly simple to build.

NOTE2: In the way I have drawn this circuit the signal gets inverted. However, you can easily switch the top and bottom optocoupler to correct this. It would have made the schematic badly readable.

mosfet driving circuit using dual optocoupler
mosfet driving circuit using dual optocoupler

When the IO signal turns to high, a current flows through the bottom LED inside the optocoupler and switches the associated transistor on. This drains the gate to the source voltage level and switches the mosfet of.

dual optocoupler switching off high side mosfet
mosfet driving circuit using dual optocoupler

When the IO signal turns low, the opposite happens. Current flows from the 5V through the top LED into the controller and enabling the’s transistor. This feeds voltage into the gate of the mosfet. As the gate voltage rises to a couple of volts, the mosfet starts conducting a little. Some current can get to the source side allowing the source voltage to go up together with the gate voltage. If gate voltage rises to quickly, you might think of adding a resistor in series with the gate, which is good practice anyways.

voltage shifting comparator circuit switching mosfet off
comparator circuit for driving a mosfet

Voltage biasing #2

A better way to approach this problem is by using a transformer. The second winding of the transformer doesn’t care at which voltage level it is operating, it just delivers the voltage. The only downside of this is transformers are huge, heavy and expensive when compared to using a dedicated driver. The transformer in this example has four times more windings on the output side This give it a voltage gain of four and a quarter of the current.

transformer circuit for switching a floating mosfet
transformer circuit for driving floating mosfet

When the controller’s output pin goes high with 5V, current goes up through the transformer into the 2.5V supply, creating a magnetic field that is picked up at the second half. At the second half a voltage differential of 10V is created. Since it is tied at the source and gate, the gate gets the full 10V switching the mosfet on.

transformer driving mosfet gate high switching mosfet on
transformer circuit for driving floating mosfet

When the IO output goes low, it is sinking current from the 2.5V power source through the transformer creating a magnetic field in the other direction. At the output side of the transformer this results in a -10V differential with enough power to completely drain the gate of the mosfet, which turn of again.

transformer driving mosfet gate low switching mosfet off
transformer circuit for driving floating mosfet

Current amplification

Big power mosfets need a lot of current in a short time to switch on correctly while not staying in the transition phase to long. Most controllers are not able to deliver this directly. So you probably need a current amplification circuit. The circuit shown here is a push-pull configuration, also known as a totum-pole. This one uses a NPN and a PNP transistor but you can use small mosfets as well.

push pull transistor circuit for driving mosfet
push pull transistor circuit for driving mosfet

Now this one is easy, IO goes high to 5V, enabling the top NPN transistor which conducts the IO current multiplied by the transistors gain into the gate of the mosfet.

push pull circuit in push mode switching mosfet on
push pull transistor circuit for driving mosfet

And at the bottom side, when IO is low at 0V it pulls the base of the PNP transistor down, once again allowing the IO current multiplied by the gain of the transistor and draining the mosfet’s gate into ground through the transistor.

push pull circuit in pull mode switching mosfet off
push pull transistor circuit for driving mosfet

Mosfet protection #1

There are situations in which a mosfet needs protection against voltage spikes. Although these spikes only last for microseconds they can also shoot up to hundreds of volts in that short time, killing the mosfet. For example the circuit below is and inductor followed by a mosfet, this is a fairly common setup to do current chopping for a LED strip or electric motor.

When the mosfet is switched on current goes through the inductor at a steady pace while building up a magnetic field. When the mosfet closes the inductor still has its electric field and want’s to continue putting out current like it’s used to. Because the current on the mosfet side can’t go through the mosfet it builds up into a pile smashing into the mosfet, this pile is a pile of voltage, short-lived but very high.

a inductor with a mosfet in series
inductor mosfet circuit

To get rid of the spikes’ sharp edges you can use a resistor and a capacitor. The higher the spike the more current the resistor lets through in to the capacitor while dissipating some power as heat. The capacitor is there to make sure power is not leaked constantly but only the spikes. The second picture shows an almost identical setup but instead of being tied to ground it goes over the mosfet.

A resistor capactitor snubber over a mosfet
snubber circuit for mosfet protection
mosfet circuit with a resistor capacitor pair for protection against spikes
snubber circuit for mosfet protection

Mosfet protection #2

If you use current amplification or have a long path from the controller to the mosfet, then inductance can become a problem. Slamming lots of current into the gate at once can induce a voltage spike. You can fix this by using a resistor in front of the mosfet’s gate. The resistor can have a low value to allow multiple amps while still cleaning of the sharp edges.

A mosfet circuit with a gate resistor
mosfet gate resistor

Putting a resistor between gate and source of the mosfet creates an auto-off functionality. This is handy when you can not ensure a safe shutdown of the circuit. While the mosfet could still be switched on, you can encounter unpredictable situations. On the other hand, if you are switching a light for longer times for example, an auto off could be really unpractical. It’s a tool, use it when you need it.

A mosfet circuit with a resistor between gate en source
mosfet gate source resistor

Dedicated drivers

Like most people I struggled a lot with all the problems above.  I discovered there are lots of dedicated mosfet drivers which take care of all these different problems at once, they are pretty cheap also, and in DIP packages. The problem however is finding the correct driver and figuring out how to hook them up. The picture below is an example of a driver and how you should connect it to a circuit. This however was not very clear by reading the datasheet.

Image of IR2125 mosfet driver hooked up in a circuit
IR2125 mosfet driver circuit

There are a lot off hints in datasheets. Have a look at the block diagram explaining what is in the chip for example. You can often find something like a ‘pulse-gen’ or a ‘uv-detect’ which often indicates it handles voltage biasing. ‘Level shifting’ is often mentioned as well.

When you look at the pin description they do not only tell you what they are for, but also about the logic level it expects. If it says ‘Logic low: 0-0.6V’ you know an Arduino can handle the low. If this is followed by ‘ Logic high: 6-20V’ then you know this is not the chip for you. Find one that accepts 2-5V as high¬† for example.