I have I device with USB. When connected to USB it is powered from the USB port (an LDO to adjust from 5V to 3.3V), and when not connected to USB it is powered from a CR2032 battery. Below is the schematic with a P-MOSFET to switch between battery and USB power. The output from the LDO is 3.6 V, since it will drop slightly over D1.


simulate this circuit – Schematic created using CircuitLab

The problem I'm having is that on USB disconnect, there is a rapid drop in voltage. See the oscilloscope image below. When connected to USB the voltage is 3.28 V, and on USB disconnect the voltage rapidly drops to 2.1 V, before stabilizing at 2.5 V for approx. 60 ms before rising to battery voltage of 3.08 V. The duration at 2.5 V can be anything from 1 ms to, as in this case about 60-70 ms.

Voltage drop on USB disconnect

On a previous version of the device, the exact same components and schematic layout is used, just a different PCB/board layout. Below is an oscilloscope image for that version. The same behavior is observed, but the "in-between voltage" is 2.75 V instead of 2.5. The duration at 2.75 V can be anything from 1 ms to 60-70 ms in this case as well.

Voltage drop on USB disconnect for other version of device

But how come the difference (2.5 V vs. 2.75 V) with the exact same components, just different board layout? And how do I go about fixing this problem? There are components in the device that does not survive (loses settings) when forced to run on 2.5 V for as long as 60 ms, and maybe the rapid drop to 2.1 V is a problem as well.

How do I fix this?

UPDATE: The circuit load (across C1) is a low-power microcontroller, and some LEDs and buttons.

What I refer to as "USB disconnect", i.e. removing the USB power source and switching to battery power is accomplished through removing the device from the computer USB port. I.e., the LDO input disappears, and hence the LDO output 3.6 V.

ADDED: Voltage drop on R1 (10K) when USB is disconnected: enter image description here

Voltage drop on R1 (1K) when USB is disconnected: enter image description here

  • \$\begingroup\$ I think the connection of Source and Drain of your Q1 is wrong. They should be reversed. \$\endgroup\$ – Curd Jan 5 '16 at 9:12
  • 1
    \$\begingroup\$ @Curd they are correct as I see it. When USB power is removed, the P channel fet turns on. \$\endgroup\$ – Andy aka Jan 5 '16 at 11:08
  • \$\begingroup\$ What do you have connected as a load across C1 (2.2uF)? How did you remove the presence of the USB supply? Did you remove the output from the LDO regulator or remove the input to the regulator? Were you consistent on both occasions? \$\endgroup\$ – Andy aka Jan 5 '16 at 11:14
  • \$\begingroup\$ @Andy aka: I think the Source of the P-channel MOSFET should connected to the positive terminal of the battery, not to the load. Otherwise the substrate diode may become conducting. \$\endgroup\$ – Curd Jan 5 '16 at 11:18
  • \$\begingroup\$ @Curd the substrate diode will only conduct (intentionally) when the USB derived power is removed. Then, when the gate is discharged to 0V the MOSFET will switch on bypassing the diode - that is the intention of the circuit. \$\endgroup\$ – Andy aka Jan 5 '16 at 11:23

This answer was made before the OP corrected the MOSFET type!!

It's a poor choice of MOSFET the IRF9530 - it can have a gate-source threshold voltage as high as -4V and for a lot of circuits this is going to produce a vast spread of results. In fact the spread would be so large that a few percent of units will not manage to turn the MOSFET on at all. This could easily account for the differences seen between two PCBs.

As for the time taken to properly recover. the 10k resistor has to charge up the gate capacitance and this might be in the order of 1nF. This is a CR time of 10us so it doesn't look likely that this will contribute more than maybe a millisecond maximum. But there are other things to consider too: -

  • What do you have connected as a load across C1 (2.2uF)?
  • How did you remove the presence of the USB supply?
  • Did you remove the output from the LDO regulator or remove the input to the regulator?
  • Were you consistent on both occasions?

Bottom line is the MOSFET choice is poor.

  • \$\begingroup\$ I'm sorry, the MOSFET in the schematic is just the default in CircuitLab. The actual MOSFET used is FDN342P (Fairchild semi). \$\endgroup\$ – sakitten Jan 5 '16 at 11:38
  • \$\begingroup\$ @sakitten: That important bit of info belongs in the question. I've edited it into your schematic. \$\endgroup\$ – JRE Jan 5 '16 at 11:45

Fix is easiest: Just use identical diodes. The 3.6V source will win over the battery because the voltage drop should be identical.


simulate this circuit – Schematic created using CircuitLab

If you want to keep the fancy design (like if you're also reading the PMOS gate input to determine if you're running off your battery or not). Try this solution.


simulate this circuit

We can always add more transistors to the design to get rid of L->H and H->L transition differences.

As for why certain physical orientations produce different results, without pictures I couldn't say for sure. Most likely has to do with the mosfet discharging at different rates due to either parasitic resistance or parasitic capacitance.

  • \$\begingroup\$ What (dis)advantages does the identical diodes solution have when compared to my original solution? It is not I who has made the original design, why would one choose a "complicated" mosfet solution if the same can be accomplished just using two diodes? \$\endgroup\$ – sakitten Jan 5 '16 at 10:20
  • 1
    \$\begingroup\$ Note that you are dropping 0.6 Volts across the diode. If you drop 0.6V from the 3Volt battery, you are already below the 2.5Volts needed for your other devices. Even using a diode with a lower forward voltage will still lower the voltage supplied to your circuit. This will reduce the amount of time that your circuit can run on battery. The FET solution greatly reduces the voltage drop (nearly zero.) This lets you get more use out of your battery compared to using a low forward voltage diode. \$\endgroup\$ – JRE Jan 5 '16 at 11:41
  • \$\begingroup\$ @JRE Yes, of course! That is a very big disadvantage in my case. Thank you for making that clear. \$\endgroup\$ – sakitten Jan 5 '16 at 12:43
  • \$\begingroup\$ Regarding the second solution, how exactly would this reduce the voltage drop? I understand the principle of the circiut, but not how it is supposed to affect the observed behavior. Will it remove the fast transient (rapid drop to 2.1 V) or somehow change the "in-between voltage" (2.5 V for up to 60 ms). Also, this is a very cost sensitive device, so adding a BJT and other components could be problematic unless it is the only choice. \$\endgroup\$ – sakitten Jan 5 '16 at 12:56
  • \$\begingroup\$ I think the idea is to speed up the discharge of the gate capacitance. Using the transistor to pull the gate ground would cause the FET to switch faster than letting the 10K resistor in the original diagram pull the gate down. Not so sure this suggested circuit will work right, though. Looks wrong to me somehow. \$\endgroup\$ – JRE Jan 5 '16 at 13:05

If it were me, I'd try changing R1 to 1K.
That should make the switchover faster. The 1K will draw 3.6 mA where the 10K drew 0.36mA, but since you have the USB bus to draw on it shouldn't be a problem. R1 has no effect on current draw when running on battery.

  • \$\begingroup\$ I tried this. Unfortunately it does not seem to have any significant impact on anything. The rapid drop to 2.1 V is still present, and the duration at 2.5 V is not decreased. Could it help to widen the PCB traces? Not all traces, but the ones related to power \$\endgroup\$ – sakitten Jan 5 '16 at 14:51
  • \$\begingroup\$ Then the next interesting question would be "what does the signal on R1 look like when the USB power goes away?" Well, that and all the questions that Andy Aka asked. \$\endgroup\$ – JRE Jan 5 '16 at 14:56
  • \$\begingroup\$ I tried updating the question with oscilloscope captures of the gate voltage on USB disconnect, but apparently you need at least 10 reputation to post more than 2 links. For the 10k resistor, the drop from 3.6 V to 0 V takes about 2.5 ms. For the 1k resistor the time is reduced to about 1 ms. However, I updated with answers to Andy Aka's questions. \$\endgroup\$ – sakitten Jan 5 '16 at 15:50
  • \$\begingroup\$ Just put the link in a comment as text and I'll insert them in the question. \$\endgroup\$ – JRE Jan 5 '16 at 16:05
  • \$\begingroup\$ The voltage drop on Q1 gate on USB disconnect with R1 10k: i.stack.imgur.com/kbhfI.jpg When, as suggested, changing R1 to 1k the result is the following: i.stack.imgur.com/f6AEY.jpg \$\endgroup\$ – sakitten Jan 5 '16 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.