# Is the BSS138 capable of level shifting this voltage difference?

The goal is to control the IRF4905 with the ESP32. From my understanding (which is limited) the IRF4905 will have the lowest RDS(on) with a -15 V VGS. To achieve this voltage difference I have a linear voltage regulator dropping my ~33 V (the power source is a 8s Li-ion, so the voltage range is 28.8 V - 33.6 V) to 15 V. Assuming the voltage regulator connects directly to the gate of the IRF4905 it would have a voltage difference between source and gate of 13.8 V - 18.6 V effectively turning on.

My question is, can I use the BSS138 as shown in the schematic below? From my understanding the BSS138 can have a drain-source voltage of 50 V and a gate source voltage of +/-20 V. I should be within spec on both of these but I don't have any experience with MOSFETs.

Note: I'm using the IRF4905 p-channel instead of a n-channel as I only want voltage at the motor connector when the MOSFET is on (to prevent a shock if someone touches the connector and ground in a n-channel configuration) so I believe that means I need to use a P-channel and switch before the load.

I believe there should be a 10k resistor pulling to ground from pin 1 of the BSS138 to prevent floating the gate.

• can I use the BSS138 as shown in the schematic below? Yes you can but unless your ESP32 will output between 15 V and about 18 V, this circuit will not work. Look at other "level shifter" circuits and note how an NMOS is used but how its Source is connected to GND. For example, look here: eevblog.com/forum/beginners/drive-p-mosfet-from-mcu The first circuit there uses an NPN but you can just replace that with your BSS138 and that should work just as well. Nov 15, 2021 at 16:47
• I agree with @Bimpelrekkie - but also you have your PFET backwards and putting 33V on the gate to source of the PFET will exceed the gate to source rating and damage it. Nov 15, 2021 at 16:54
• I don't have any experience with MOSFETs. We all started at zero! What I did is look at many circuits using MOSFETs and try to figure out how and why those work. Nov 15, 2021 at 16:57
• @Bimpelreikkie - Thanks for pointing out the obvious flaw in the design! And no, sadly my ESP32 isn't on steroids. The issue here is that I cannot pull the gate of the IRF4905 to ground like in the schematic you linked as Kevin White pointed out, the gate to source is limited to +/-20v. Nov 15, 2021 at 17:08
• An additional problem is the voltage regutator can't sink current : R101/Q102 will pull the output up, possibly to 33V, unless there is an adequate load (typically few mA, see U101 datasheet) from 15V to GND. Nov 15, 2021 at 17:10

It won't work because the output swing of 0/3.3V of the ESP32 is inadequate.

If you want to make a high-side switch you can do something like this:

simulate this circuit – Schematic created using CircuitLab

However, the switching is relatively slow with this kind of simple gate driver and it would be unwise to feed the driver with a PWM. It's probably okay with on/off control, but more analysis would be required to be sure it won't kill M2.

For high frequency switching it would be better to use a proper gate driver and a low-side switch (use an N-channel MOSFET).

D1 is necessary, otherwise the large below-ground inductive spike when the motor turns off will avalanche and probably destroy M2.

Since I have a model of the IRF4905, I did a simulation of a 8.3A average 50% PWM control of a 2$$\\Omega\$$ 500uH motor. Yours will likely be different, of course. I used 5kHz for the PWM frequency.

Average motor current: 8.27A RMS motor current: 8.33A (my fake motor has enough inductance to smooth the current fairly well)

Average dissipation of the IRF4905 1.91W, peak is a couple hundred W briefly while switching.

Increasing the PWM frequency to 25kHz increases typical dissipation in the transistor to 7.6W.

The problem will become more obvious if you go to less optimal duty cycles than 50%, I would not use this above a few kHz. If your motor is low inductance then the MOSFET may fail because the RMS current is too high, especially during startup.

Frankly, I would suggest getting a MOSFET driver chip unless you are prepared to run through a stack of IRF4905s.

• Thanks! I am planning on controlling the motor/driver using PWM. Why would it would be unwise to feed the driver with a PWM (sorry if I'm missing the obvious here). Thanks for adding D1 as somehow that got omitted in my schematic Nov 15, 2021 at 17:26
• Because the simple voltage divider I show (a few K impedance) and your 22K resistor (if the circuit worked) are going to be so slow transferring charge in and out of the gate of the output transistor that it will get very hot and possibly fail. The max gate charge according to the datasheet is 180nC. Nov 15, 2021 at 17:32
• ESP32 GPIO pin can source up to 40mA & sink up to 28 mA. Providing it's running from 3.3V, and the GPIO are working as open-drain (only sourcing current) R3 and R4 can be much lower, up to 100 & 560 ohms in respective. That should provide better switching times which might be enough for a low frequency PWM. Nov 15, 2021 at 17:40
• @NStorm The problem is not R3, it can be reduced to zero. It's the parallel combination or R1||R2 and the relatively large gate charge of the output transistor. That's where you want a gate driver that can source/sink hundreds of mA. Nov 15, 2021 at 17:42
• Microchip has some inexpensive and good gate driver chips. You can use your 15V regulator and an N-channel MOSFET. DC motors can be pretty hard on MOSFETs, especially when starting up, so best to be conservative on the ratings. Nov 15, 2021 at 19:19