# MOSFET for 5V high-side switch

I have a 5V logic signal coming from a pin on my microcontroller. I would like to use this to turn on and off another circuit which also runs at 5V. i. e. the logic level is the same, but I need to switch more current than the microcontroller pin can source.

I started with this circuit by Jon Watte, for using a P-channel MOSFET as a high-side switch for 12V:

I tried using this same circuit, but running it at 5V instead of 12V. It worked, but when I started to draw more than a few mA of current, the voltage starts to sag towards 4V and even lower.

I thought the problem was that the IRF9530 has a drive voltage of 10V, so at 5V it isn't fully turning on.

So, I tried replacing the IRF9530 with a NDP6020P, which has a drive voltage of 4.5V. I thought that ought to fix the problem:

However, that did not fix the problem. The voltage doesn't sag quite as much quite as quickly as with the IRF9530, but it still gets lower than I would like. (The voltage drops to 4.3V at 150 mA.)

Why didn't this work the way I thought it should? What are the "engineering calculations" I need to perform to choose a MOSFET that will make this circuit behave properly as a switch?

Edit: Here is how I'm performing measurements:

I've connected the output to a SparkFun Variable Load. The variable load acts as an electronically-controlled variable resistor. It also measures the current going through the resistor (MES3), and measures the voltage across the terminals (MES2). I also have a separate voltmeter connected directly across the power supply (MES1).

The 5V supply, depicted as a battery in the schematic, is actually a 5V, 2A USB wall adapter.

As the load increases, the voltage measured at the output (MES2) decreases. However, the voltage measured at the power supply (MES1) also decreases. This would seem to suggest the power supply can't handle the current.

However, if I connect the variable load directly to the power supply, I can draw significantly more current without the voltage sagging by any significant amount.

So that would suggest there is not an issue with the power supply. This seems very weird.

Conclusion: I never did figure out what was wrong. But I rebuilt the same circuit on a new breadboard, and it seems to work as expected now. So obviously I messed something up before, but the design itself seems to work.

• Since you are experimenting, it would be a good idea to put a 12 volt 500mW zener diode from gate to source on the P-channel MOSFET. Put a 1K resistor in series with the gate to limit any instability at the gate.
– user105652
Commented Apr 17, 2018 at 23:14
• Thanks, I'll order a zener with those specs. Can you expand on why it would help the problem? Commented Apr 17, 2018 at 23:40
• They would not directly solve your problem. They are precautions used to protect the MOSFET's gates from over voltage or current shoot-through, especially when you are in an experimental phase.
– user105652
Commented Apr 17, 2018 at 23:45
• While it doesn't blame the supply, it does blame the intermediary circuit. If you replace the FET with a brute relay, what heppens? If you insert the circuit without the FETs, what happens? If you don't insert the circuit, but only the FETs, and directly (with a wire) control the BS170, what happens? Commented Apr 18, 2018 at 6:01
• But why would the intermediary circuit affect the voltage at MES1? Commented Apr 19, 2018 at 12:18

## 2 Answers

This arrangement of 2 fets is only needed because 12V is higher than 5V, and Q1 is needed to level shift.

You only need a PFet connected directly to your micro, when they run from the same (5V) supply.

simulate this circuit – Schematic created using CircuitLab

You could also use a pnp transistor (BC337). There is no issue with VGS, but there is base current used when turned on. That is what I would use for switching the LCD backlight led, for example.

• The BC337 is NPN... Do you mean BC327? Commented Feb 11, 2022 at 12:33

It should typically drop less than 10mV at 150mA with 5V drive, so you should troubleshoot this.

1. Are you sure of the part number (and that it is a genuine part)

2. Check that the gate-source voltage is as-expected

3. Check that the supply voltage is not drooping

• Aha! If I check the supply voltage while I'm testing my switch, the supply voltage is drooping almost as low as the output voltage of the switch. HOWEVER, if I just connect my variable load directly to my power supply, it does not droop. (I can draw up to 600 mA before it even drops below 5.0 volts.) So I am puzzled. Why would the supply droop when using the switch, when it doesn't seem to droop under the same load by itself? Commented Apr 18, 2018 at 0:07
• Your ammeter is dropping the voltage, would be my best guess. Commented Apr 18, 2018 at 0:34
• not sure I understand that. The current is being measured by the variable load in both cases. How does it "drop" the voltage, and why does it behave differently connected to the output of the switch than it does when connected directly across the power supply? Commented Apr 18, 2018 at 2:03
• Maybe it's oscillating due to the electronic load interacting with the power supply or switch. Bypass caps on the +5? Got an oscilloscope? If not, have you tried a 33 ohm 1W resistor instead of the load? Whatever the root cause is I don't think it is shown on your schematic. Commented Apr 18, 2018 at 4:28