2

I want to power a circuit I have from a dedicated power supply. But at the same time, I have a USB port that can also supply power but only when I decide to upload new firmware to a atmega32u2. Here is my circuit.

removed old pic

J2 is where my main voltage comes in and can be anywhere from +3.3V to +5V. Q1 acts as an ideal diode. Q2 is my load switch. R22 will pull the gate to ground. J4 is the USB port my circuit uses to connect to a PC. D1 isolates the USB voltage from the circuit's operating voltage. C3 is the bypass cap for my circuit. R21 and C1 mimic a tantulum cap. R15 and R16 are my current limiting series resistors for the USB data lines.

The idea here is to disable the use of J2's voltage whenever J4 receives voltage from the USB port. In other words, when +VUSB is present, it will go through D1 and supply about +4.7V which is good enough for communicating back to the PC and enough for my circuit to operate to receive code. +VUSB will have Q2's gate to +5V causing Vgs to be positive or zero volts, turning it off, and thus having +V only sourced from J4, despite J2 still supplying voltage.

Or at least I think so! I am basically asking for a design check to see if my understanding is correct. I am aware of power mux ICs but they are too expensive and I want to use "common parts" for this. In case this is needed, Q1,Q2 = DMP3056LDM-7 and D1 = SD1206S100S1R0. Current draw of the circuit is no more than 10mA.

EDIT 11/1/20: User Ste Kulov informed me of a cheaper kind of power mux. I like the solution. Here is the new circuit. It uses the TPS2104DBVT. Q1 is still DMP3056LDM. Note that when one of the voltage inputs are disconnected, the potential is floating. I first had a pulldown resistor but the datasheet informs to not ground the INx pin if not used. I took that as no pulldown resistor as well.

enter image description here

joe
  • 163
  • 12
  • Beware those transistors are not going to switch on very well if at all at 3.3v and below, they are not designed for switching at that low gate voltages. It is fairly difficult in general impo to find good fets that will down at those voltages. – Vinzent Oct 27 '20 at 23:55
  • 2
    Q1's gate also connect to Q2's Gate. Because, if by some means both USB & DC are connected and DC <= USB-diode drop, Q2 will conduct back from USB to DC. Q1 will be default ON so, trouble. There are few posts already in this topic. https://electronics.stackexchange.com/questions/96059/switch-between-battery-and-usb-power-no-microcontroller-circuit, https://electronics.stackexchange.com/questions/271475/switching-between-two-power-sources. You need to select P-MOSFET and post the circuit again, – user19579 Oct 28 '20 at 07:59
  • @Vinzent Really? Perhaps I have misread the datasheet then I see on page 3 that at -Vgs = 3V, -Id = ~4A. This is Figure 1. That lead me to believe that these would be okay to use. – joe Oct 29 '20 at 00:20
  • @user19579 Ah I see the trouble you pointed out. Since Q1 is one and even though Q2 is off, the body diode allows it to conduct anyway. Ugh I wish there were diodes with ultra low forward drops! Maybe those power mux ICs are worth the money. – joe Oct 29 '20 at 00:25
  • If you want to go for IC - LT4415 etc, powerpath controller – user19579 Oct 29 '20 at 04:46
  • @joe Does J2 have a significant risk of being connected backwards? Is that the purpose of Q1? – Ste Kulov Oct 29 '20 at 05:34
  • 1
    @SteKulov Yes there is significant risk. – joe Oct 29 '20 at 20:46
  • @user19579 Love the IC, and I have found similar, but I hate the price. I would pay ~$3 for an IC solution. – joe Oct 29 '20 at 20:51
  • 1
    @joe Have you taken a look at the TPS2104/TPS2105 from TI? Or their other power MUXes? https://www.ti.com/power-management/power-switches/power-muxes/products.html – Ste Kulov Oct 30 '20 at 02:38
  • @SteKulov huh I have not. I found other power muxes but they were bigger and more expensive. I think this might be the winning answer but let me design it in first. – joe Oct 31 '20 at 01:02
  • As user19579 says, you should short the gates of Q1 and Q2. Not only will this prevent a potential backdrive of the J2 supply by the USB supply, but even for a non-backdrive case it will reduce the leakage current into J2 from the shared bulk node between Q1 and Q2. – FrontRanger Nov 01 '20 at 06:44
  • @SteKulov I have posted a new circuit in the question. If you could just give your two cents on it in an official answer, and let me know if you agree with its setup, the bounty is yours. I will also mark your answer as the accepted one. – joe Nov 01 '20 at 17:06
  • @joe Ehhh...I'm not a rep whore, so I don't really care about that. But I still want to help. Few more questions. Is J1 a battery input? What is the expected current draw in VMAIN mode and also in VUSB mode? What is the minimum voltage required at V+ for reliable operation? – Ste Kulov Nov 02 '20 at 02:02
  • @SteKulov Hahaha I hear ya. I only made a bounty to get more attention. I didn't care about losing rep points either, does not matter much to me. J2 (there is no J1) is not designed to be a battery input and meant to be hardwired to a DC supply. Though I am not sure if I ever want it to be a battery in the future. Vmain draw is about 10mA. Vusb will be the same current draw. Minimum operation is +3.3V though the design can still work at +2.7V, which means the current draw will decrease slightly. Are you asking because of voltage drop when transitioning input sources? – joe Nov 02 '20 at 12:36
  • 1
    @joe Haha, cool. Oh yea, J2, my bad. Reason I asked for battery is the quiescent current is lower on IN2, so it's better suited for battery. Yes, I wanted to make sure the voltage drops weren't going to cause issues. You need a pulldown on !EN since it is pulled up on the TPS2104, so as it is in your schematic right now it will be stuck in IN2 forever. I think you are misinterpreting the ground thing. I will try creating an answer within the day so we can document everything in these comments for future users. – Ste Kulov Nov 02 '20 at 21:19
  • @SteKulov much appreciated! – joe Nov 02 '20 at 22:00

1 Answers1

1

Most of this was resolved in the comments (whoops!), but I thought it's worthwhile to summarize everything.

First, is that the original solution with Q1 and Q2 won't work properly. Let's say that J2 has 3.3V attached and is connected in the correct polarity while the USB power is also present. +VUSB connects through D1 to +V. Even though Q2's gate is pulled high, it will conduct through Q2's body diode. Now, since Q1's source is a healthy voltage it is fully on due to its gate being tied low. Re-explained better in the MSPaint masterpiece below, you have a conducting path between VUSB and J2. There is also a similar conducting path when J2 is connected in the reverse polarity.

enter image description here


Therefore, a power MUX IC was recommended and I threw out the idea of TI's TPS2104/TPS2105 series. Your modified post includes a schematic using this solution. However, I suggest a few changes based on additional info you provided.

The TPS2104 has an active low EN, where "active" means IN1 is switched on instead of the default IN2. This \$\overline{\text{EN}}\$ pin has an internal pullup according to the datasheet. Therefore, your schematic will always have IN2 enabled since it is controlled by the +VUSB signal. This signal is either +5-ish volts when USB is connected or high-Z if USB is disconnected. In either case, the \$\overline{\text{EN}}\$ pin sees a logic high.

This power MUX series uses an N-channel MOSFET for IN1 and a P-channel MOSFET for IN2. The N-channel has the benefit of lower \$R_{DS(on)}\$, while the P-channel has the benefit of lower quiescent current since its drive circuitry is simpler. Since J2 has the possibility of being a battery in the future and your operating current (10mA) is low enough that \$R_{DS(on)}\$ on either input doesn't really matter, I suggest connecting the J2 input to IN2 instead.

Due to everything laid out above, I think you should be using the TPS2105 instead which has an active high EN pin. Also, please add the 0.22µF capacitor on the other INx pin too. See professionally MSPaint-ed schematic below for reference:

enter image description here

Ste Kulov
  • 3,771
  • 10
  • 22
  • Thank you for documenting! When I am finished with my circuit and have tested, I can update here to let everyone how it worked out in practice. – joe Nov 05 '20 at 13:59
  • 1
    So I built the circuit just as I showed in my latest. Seemed to work fine for what I needed it to do. Thanks all! – joe Dec 15 '20 at 19:11
  • @joe Nice! Thanks for reporting back! – Ste Kulov Dec 15 '20 at 20:33