Electronic – arduino – Power selection circuit for USB or DC Jack – both at 5V

arduinopowerpower supplysparkfunvoltage

I am designing a new board, where I need to detect if the DC input jack for powering the board has been plugged and then disconnect the USB power supply. I also need to detect it with the uC in order to enable some functions when I have a power supply.
The problem is that both of them are 5V inputs.

DC power supply:

DC power supply

USB power supply and power selector:

USB power supply and power selector

I have a couple of conditions in this circuit:

  • DC Power not connected / USB connected / USB Host function OFF: In this scenario, the comparator outputs a low voltage which makes Q3 to be ON (p-channel) and this helps me have a clean 5V through this circuit.
  • DC Power connected / USB connected / USB Host function OFF: In this case, I want to disconnect the power from the DC jack from the USB, so current does not go into the USB connector. It shouldn't, since both of them are 5V, but stay with me. So, the comparator outputs a high voltage and turns Q3 off, disconnecting VUSB and 5V, and taking current only from the DC jack.
  • DC Power connected / USB connected / USB Host function ON: Now I want the device to be able to give power to the USB port, so I turn Q2 on with the USB_HOST_EN signal and power can flow from 5V to VUSB through Q2.

This circuit is a remix form the SparkFun SAMD21 breakout board and the typical power selector circuit that a lot or Arduino Boards use.

The problem I see is that when the USB is connected, the 5V from the USB can be found also at VJACK, so the comparator will always have its output at a HIGH state.

Q1 is a reverse polarity protection transistor. I thought of just putting a diode and that would solve all these problems, but I would not have 5V after the diode, but a 0.7V or more drop.

Also, since both the DC jack and the USB will have 5V, I thought the whole power selection circuit could not be there at all, and just join both 5V outputs, after Q2. But then the body diode from Q2 would also drop 0.7V when Q2 is off (Non host operation) and I would have less voltage than required.

Can anyone help with ideas on how to solve this?

Thanks a lot!

Best Answer

One simple path that has escaped your considerations is that most DC power barrel jacks have an additional contact, precisely for the purpose of easy selection of power sources. See this contact in your schematics, red circled:

enter image description here

There are many uses of this extra contact, and I am sure the use of it will highly simplify your problem.

Related Topic