# Drive P channel MOSFET with Arduino, unable to get desired behaviour (LOW pin, MOSFET ON)

After hours of building a circuit on a perfboard, I discovered that Vgs is not easy with P-MOSFETs. After searching I figured out that I need to use either a N-MOSFET or a BJT (NPN) to bring the source voltage to the gate in order to turn the MOSFET OFF.

It is very important to me that when the Arduino pin is LOW, the MOSFET stays ON. This is to provide current to the Arduino itself if the system behind has no power left (not relevant to the circuit here).

Because of this limitation, circuits like this:

will turn off the MOSFET when arduino input is LOW. (To my understanding) I have tried to provide the voltage to the gate using an N-MOSFET on the HIGH side, see this screenshot (apologies for not using a proper circuit software):

Despite having the N-MOSFET shown as in saturation, only 3.32V gets on it's source, not enough to trigger fully the P-MOSFET's gate.

My short knowledge of electronics has been beaten, as I cannot wrap my head around this. It would be logical to me that the N-MOSFET would apply the full drain voltage on it's source, given that the gate voltage is high.

While primary interested in a solution for this circuit here, tired of spending time on this, an explanation on to why my knowledge is flawed would be welcome.

Thanks for your time, I'll update the post if I am missing something

• You wrote: "...I have tried to provide the voltage to the gate using an N-MOSFET on the HIGH side...". My answer try appoaches exactly the difficulties in order to saturate N-channel in high side MOSFETs. – Dirceu Rodrigues Jr Aug 23 '18 at 0:59

Ok, so assuming the requirements are:

• Arduino GPIO Low (0V): PMOS Switch ON (Load voltage = 12 V)
• Ardunio GPIO High (5V): PMOS Switch OFF (Load voltage = 0)

This circuit would work:

simulate this circuit – Schematic created using CircuitLab

• Thanks for the reply, I'm trying to understand the differences between the circuit showed by Spehro and yours, is there a reason for the differences on the collector of Q1? You seem to have a voltage divider there, where Spehro has it on the base of Q2. – Cubox Aug 23 '18 at 0:46
• The location of my R5 (1k) vs his R2 (20k) makes no difference for its purpose; it is simply setting the base current for Q2 in both cases. In Sphero's the current will be ≈ (12-0.7)/20k = 0.6 mA. In my case it'll be ≈ (12-0.7)/1k = 11.1 mA. Honestly; the value I chose was arbitrary, but one advantage would be reduced unique part counts. Spehro's advantage is lower overall power consumption. Depends what you are optimizing for! – Jim Aug 23 '18 at 0:52
• +1 They're pretty much equivalent. The main tradeoff is R4 (both circuits) that determines how fast the MOSFET turns on (too slow is hard on the MOSFET). We both picked the same number. If you want to make it switch faster, it can be reduced to (say) 1K (you could switch R5 and R4 values in Jim's circuit) 1/4-W or better. – Spehro Pefhany Aug 23 '18 at 1:56
• Thanks for the valuable info. Since this circuit is not going to switch often (maximum once every minute), I'm not too worried about being hard on the MOSFET. – Cubox Aug 23 '18 at 2:08
• As I did not find a way to send a private message to you guys, I wanted to ask about CircuitLab you seem to use. I had a few minutes to try before my trial expired, and liked it. Despite the quite high price for a membership, do you recommand it for an hobbyist? I am currently using falstad.com/circuit/circuitjs.html (I will delete this comment once answered, as it is not related to the question) – Cubox Aug 23 '18 at 2:33

Try something like this (P-channel MOSFET capable of >12V Vgs)

simulate this circuit – Schematic created using CircuitLab

Q1 shifts the level to the +12, Q2 inverts the signal so the MOSFET is ON with input LOW.

• Ha. Beat me by a few mins. Well done as always Spehro – Jim Aug 23 '18 at 0:32
• Thanks! I will try this once my will to try again has been restored, and report back. – Cubox Aug 23 '18 at 0:40
• The problem here is that the switch is on any time the input is not actively driven high. The asker seems to want an Arduino to control its own power, and this circuit won't permit that. While if you add a pullup resistor to keep Q1 on when the MCU is powered down, the pulling resistor may end up re-powering the MCU through the I/O protection diode. – Chris Stratton Aug 23 '18 at 3:54
• @ChrisStratton is correct. This will do what you asked for, but it is not what you need if you expect the MCU to be able to turn its own power off. – Spehro Pefhany Aug 23 '18 at 3:59
• I think the OP's requirements are not totally clear. Chris may be right. Or maybe not. To the OP, if you drive Q1 low, M1 will be ON. If you drive Q1 high, then M1 will turn off, cutting power to the arduino. But once power is cut to the arduino, the input to Q1 will be low again, and M1 will turn on again. Is this what you want? – mkeith Aug 23 '18 at 5:23

This configuration is not suitable for drive N-channel in high side position. Use a P-channel mosfet or provide a $Vg$ higher than $Vd + Vgs_{TH}$ (ex. using bootstrap techniques). Some examples (below), showing how to drive high side switches according you require - pin low -> load on.

• "This is to provide current to the Arduino itself if the system behind has no power left (not relevant to the circuit here)." Actually, if that is your goal, it is extremely critically relevant, as an MCU that is going to control its own power must use a non-inverting switch made of two semiconductors. If you try to use a normal single FET inverting switch, you'll end up turning yourself back on through the I/O protection diodes and keeper resistor. – Chris Stratton Aug 23 '18 at 0:46
• @Chris Startton: I confess that I did not understand anything of what you wrote. – Dirceu Rodrigues Jr Aug 23 '18 at 1:08
• @ChrisStratton The 12V are not going directly into the Arduino. The arduino has a separate DC-DC buck converting 25V into the 5V, from another separate source. The 12V here is backup power if the 25V is missing. But I'm curious on how you can turn the Arduino back on from the output pin, could that happen with Spehro or Jim's examples? – Cubox Aug 23 '18 at 2:14
• @Cubox - it doesn't matter that it is not going directly. Your desire to control a high-side switch such that it is on when an I/O pin is low is basically incompatible with self power control, for any MCU that has protection diodes clamping the I/Os to the power rails. – Chris Stratton Aug 23 '18 at 3:56