Electrical – How to convert a 3.3V signal to 5V for a Mosfet gate

gpiomosfetvoltage

Based on the question 4-5-v-on-gate-of-mosfet-while-switch-open I ask this more generic question.

Main project: I want to create a 16×8 (or so) multiplexed LED circuit
Sub project: Creating a 2×2 LED matrix, typically this form:

GPIO->resistor->Mosfet->LED->Mosfet->GND

The mosfets are used to use for the LED external (5V) power.
The resistor is for current limiting the LED.

I made this on a breadboard, using all 5 V (also from GPIO) and it works. The mosfets are 2N7000's).

However, when I tried to use for GPIO 3.3V, and using logic level shifters to convert from 3.3V to 5V I ran into problems (Gate always on, independent on GPIO).

So my main problem is to achieve this:

GPIO (3.3V) -> resistor -> Mosfet Gate (5V)

How should I convert this?
The only solution I can think of is a level shifter. Or a voltage/resistor dividor, but that only works to lower the voltage, not to increase it.

Best Answer

You can indeed use a passive voltage divider to increase the voltage drive to a FET gate driven from a 3.3V GPIO pin. You just need to be careful, and understand the rules.

If you are using the 2n7000 then you expect the VGS(th) range:

enter image description here

Devices could have a VGS(th) across this whole range, but you know that the devices you have won't turn on to any usable extent with 3.3V drive. So the devices you have are probably very close to the 3V VGS(th).
In this case if you hold the gate below 3V they won't turn on, but you need to drive the device beyond 3.3V to get it to pass your desired LED current.

In the schematic below I have a restricted range for VGS, but can ensure it's below 2V (which should be well and truly off for your application) and drives to 3.9V (which should turn it on).

If you look at the typical VGS/ID curve, you can see that 3.9V drive should work fine for ID up to about 100mA with relatively low on voltage drop.

enter image description here

schematic

simulate this circuit – Schematic created using CircuitLab

In the schematic above, if NODE1 was open circuit, the voltage across R3 would be 3.3V. So when the MCU GPIO pin drive a high out, there is no (or very little) current flow from or into the pin.
When Node1 is driven low is shorts out R3 and sinks current from R2.

If you can accept the limitations (a lower range of VGS drive, and limited current sink) then this circuit may work for you. Just remember that if you get a batch of 2N700 with a much lower VGS(th) you'd have to alter the R ratios or even be able to drive them directly (just leave R1 out).

Since in most MCU power supplies the 5V supply is used to generate the 3.3V supply (via a regulator) the GPIO pin is protected from seeing a voltage higher than 3.3V.

Since you already have the level shifter boards from your first question, you could easily repurpose those and use the lower VGS(th) FET (the BSS138) to drive your load. There would be multiple ways your could use those boards:

  1. Use each FET providing that the LED current you have can be sunk by the MCU GPIO pin (probably limited to under 20mA depending on your MCU).

  2. If your current requirements are higher then you could drive the LV pin from the MCU and ground the LV1, LV2, LV3, LV4 pins. Now all the current flows directly to ground and the outputs can be joined together to provide up to 1A or so without problems.