Pmos switching circuit help - Page 1
Forum section: electronics / beginners

author: vireswires
author_rank: Contributor
timestamp: April 01, 2024, 07:11:52 pm
content: I’m currently working on a project that I wanted to power from battery when usb power is not connected. It was suggested to me to use a pmos mosfet. The usb power is working but I can’t get it to run on the battery. I’ve tried using leads to directly connect the +5v (of the battery) on the other end of the pmos, effectively bypassing the switch, and it works that way.So I’m wondering if I’ve possibly set this up incorrectly. Photo of the area in question, and the schematic (area in question, as well as full schematic) attached. I've gone over things checking circuit continuity and reflowing solder just to be sure there wasn't a problem in that area. If anyone could offer any help I'd really appreciate it!

author: Benta
author_rank: Super Contributor
timestamp: April 01, 2024, 08:13:48 pm
content: Why the PMOS?The two Schottkys should do the job alone (provided battery voltage is lower than 5 V).

author: vireswires
author_rank: Contributor
timestamp: April 01, 2024, 08:33:07 pm
content: I read that a 5v usb power can fluctuate down to 4.75v. My battery source runs around 4.8v and I don’t want the battery used unless the usb is unplugged. Of course I’m open to other options for a future redesign, but mostly I’m wondering why the current design isn’t working and how I might troubleshoot or fix it…

author: Benta
author_rank: Super Contributor
timestamp: April 01, 2024, 10:07:16 pm
content: Well, in that case use the PMOS.Vut it has to be a logic-level type, otherwise it won't turn on properly.

author: vireswires
author_rank: Contributor
timestamp: April 02, 2024, 12:49:00 am
content: Thanks. It’s an si2301 - I believe this is a logic level pmos. Any other suggestions on why this may not be working, or how to troubleshoot, are more than appreciated

author: Peabody
author_rank: Super Contributor
timestamp: April 02, 2024, 03:52:40 am
content: I can't tell where the battery is in your schematics. The positive terminal should be connected to the mosfet drain, without going through a diode. So D9 is not needed. Then the source pin supplies power to the rest of the circuit from either USB or the battery.I also can't tell from the photo what's connected to what, but the pin numbers on your schematic look wrong. Per the datasheet, pin 1 is the gate, pin 2 is the source, and pin 3 is the drain.

author: vireswires
author_rank: Contributor
timestamp: April 02, 2024, 07:56:01 am
content: Thanks for that. The battery is coming from above in the schematic, connected to pin 1 - the diode is there as a fail safe to prevent any current from back feeding into the battery but perhaps it’s unnecessary.I’m a little confused at the advice bc I thought with a p-mos, you want to connect +5v to the source, and the drain then supplies the current to the circuit once the mosfet is switched on (in this case when gate is pulled low by having 0v coming from the usb).I think you are right that I may have mixed something up… I think I may have reversed my gate and source. Would it be advisable to try unmounting and flipping the mosfet over? The pins will hover above the pads but it’s such a small component that I think a little extra solder could bridge the gaps

author: inse
author_rank: Super Contributor
timestamp: April 02, 2024, 08:56:58 am
content: The PMOS is reversed, drain and source need to be swapped - look at the intrinsic diode.Your battery voltage must not be much higher than the USB supply as you would not be able to keep the PMOS in off state.

author: vireswires
author_rank: Contributor
timestamp: April 02, 2024, 10:08:13 am
content: Okay I am realizing I think the pin order/numbers in my schematic symbol are in conflict with those in the actual pcb layout symbol. In the schematic its dgs, but on the actual component it’s gsd. Sorry for the headache everyone - makes sense why I was confused by the replies now

author: pcprogrammer
author_rank: Super Contributor
timestamp: April 02, 2024, 12:39:06 pm
content: Quote from: inse on April 02, 2024, 08:56:58 amThat is my thought too. The way it is setup with the P-MOSFET in the schematic looks like reverse polarity protection. For it to be a switch based on the presence of the USB voltage drain and source indeed need to be swapped.As soon as the voltage on the gate becomes low enough below the battery voltage the P-MOSFET will start to conduct. The minimum gate source threshold for the si2301 is specified at 0.45V so not a lot of wiggle room. Also the max Vgs = +/-8V. Your battery voltage should stay below that for sure.

author: Peabody
author_rank: Super Contributor
timestamp: April 02, 2024, 01:52:50 pm
content: The orientation of the mosfet in your schematics is correct. It looks backwards, but it's not. The mosfet will conduct equally well in either direction, but is oriented in this case so the body diode prevents USB current from passing to the battery when the mosfet is off. So that's why D9 is redundant. When USB is present, the battery is still shut off because its voltage is lower than USB voltage, so even though the body diode is oriented to pass current, it won't because it is reverse biased.Here's an app note that confirms this is the right orientation. You don't have a charger, but the relevant part is the "load sharing" circuit.http://ww1.microchip.com/downloads/en/AppNotes/01149c.pdfNote that this circuit works only if battery voltage at full charge is lower than USB voltage. So what kind of battery gives you 4.8V?Edit: Just to clarify - the whole reason for using the mosfet at all is to avoid the voltage drop in the battery line across D9. When the mosfet turns on, the body diode is bypassed, so there's virtually no drop across the mosfet. If you turn the mosfet around so the battery is on the source and load is on the drain, then you do need D9. But then - you don't need the mosfet. A 2-diode OR circuit will just have the one with the higher voltage supplying the load. So the battery should be on the drain, and the load on the source, and no D9.

author: pcprogrammer
author_rank: Super Contributor
timestamp: April 02, 2024, 02:19:05 pm
content: Quote from: Peabody on April 02, 2024, 01:52:50 pmI beg to differ on this. With the mosfet set in the given direction the battery voltage will be used when the USB voltage is lower due to the body diode of the mosfet conducting. The only difference is that when the USB voltage is so low that the mosfet starts to conduct the voltage drop across the mosfet will start to drop also. It does not fully disconnect the battery.Quote from: Peabody on April 02, 2024, 01:52:50 pmSure with the mosfet connected with drain and source swapped, the body diode can feed charge into the battery when the USB voltage is higher then the battery voltage, but this is prevented with D9.Quote from: Peabody on April 02, 2024, 01:52:50 pmIn the app note the mosfet is acting as areverse polarity protectionand not as a switch.

author: Peabody
author_rank: Super Contributor
timestamp: April 02, 2024, 05:22:25 pm
content: Well I guess we disagree. The assumption is that USB is going to be about 5V when present at all, and will always be higher than the battery voltage. If that's true, then the load sharing circuit will work, with no diode voltage drop in the battery line.

author: vireswires
author_rank: Contributor
timestamp: April 02, 2024, 05:52:43 pm
content: Thanks everyone - I’m learning a lot and realizing I have a lot more to learn from this conversation. It’s interesting to me that the mosfet can conduct in either direction, source to drain, or drain to source. Everything I’ve read says that a pmos works source to drain.Hopefully to clarify some things:The battery voltage is 4.8v (from four rechargeable aa batteries)I read that usb 5v can theoretically fluctuate down to 4.75 and didn’t want the battery switching on if this happens intermittently so, that’s the reason I decided to go with mosfet solution rather than just 2 diodes.The extra diode may be redundant, but I wanted to be sure that there was no chance of back feeding usb power into the battery.The point of the mosfet in this design is just to act as a switch, I wasn’t concerned about voltage drop.I’m going to try flipping the mosfet today bc like I mentioned I think the schematic symbol pins are in conflict with the actual component pin layout. Again, this is probably the source of confusion and I apologize for that!

author: pcprogrammer
author_rank: Super Contributor
timestamp: April 02, 2024, 06:49:38 pm
content: Quote from: vireswires on April 02, 2024, 05:52:43 pmA fully charged rechargeable battery will have a higher voltage than 1.2V and can level of at 1.35 to 1.4V and hold that even under some load. This would mean that your battery pack can be at 5.6V and feed your circuit despite the diodes and the mosfet, when USB is connected to your device.Maybe an ic likethisis better for making what you want to happen.

author: Peabody
author_rank: Super Contributor
timestamp: April 02, 2024, 08:57:42 pm
content: Yes, the higher battery voltage complicates things. I'd suggest you figure out what the voltages would be on the three mosfet pins when USB voltage is as low as you expect it to be, and battery voltage is at its fully-charged state. You'd need the voltage drop across the schottky diodes and the threshold voltage of the mosfet. The question is whether the mosfet would turn on even with USB present (i.e. - does Vgs exceed the threshold voltage).

author: Zero999
author_rank: Super Contributor
timestamp: April 03, 2024, 07:39:15 am
content: I might have misunderstood, but it appears as thought the original poster requires an ideal diode circuit, rather than simple reverse polarity protection. A MOSFET will behave like a diode when off and turn on when its gate-source threshold is exceeded and will connect the voltages between the source and drain together with a low resistance, allowing current to pass in both directions.An ideal circuit requires a couple of well-matched BJTs, as well as a MOSFET.https://electronics.stackexchange.com/questions/223935/understanding-an-ideal-diode-made-from-a-p-channel-mosfet-and-pnp-transistorsIdeal diode discrete.asc

author: Peabody
author_rank: Super Contributor
timestamp: April 03, 2024, 02:23:08 pm
content: The OP's battery is four 1.2V rechargeables in series. He calls it 4.8V, but that's just the nominal voltage. If you Google for the maximum fully-charged voltage of a NIMH four-pack, you'll see a wide range of answers, from 5.6V to over 6V.So he wants to always switch to USB power when it's present, but that may be switching to the *lower* voltage source if the batteries are fully charged, and diodes, even ideal ones, don't want to do that. Even with a diode in the battery line, the mosfet gate (which is at USB voltage) may be enough below the source voltage (the batteries in his preferred mosfet orientation) to turn on the mosfet when it shouldn't be on.One solution might be to pick a mosfet with a higher threshold voltage - something like 1.5V or 2V. With that, it might be possible to eliminate the battery line diode and replace it with a second mosfet, back to back with the first one, but with the opposite orientation, so you would have opposing body diodes which are bypassed when the mosfets are on. But then you'd have twice the RDSon.Or maybe @pcprogrammer's TI chip is the better way to go. It's designed to deal with this situation.Edit: The IRLML9301TRPbF has a 1.3 - 2.4V threshold voltage. A dual P-channel would be the IRF9362PbF.

author: vireswires
author_rank: Contributor
timestamp: April 04, 2024, 08:14:25 am
content: Thanks to everyone contributing here. From a learning perspective, every single comment has been super helpful.I did consider the power mux at one point, but decided I didn’t want to make space for another ic in the design. The mosfet solution, if it could work, seemed simpler.I should have mentioned this but it’s another device hosting the 4 batteries and the power coming from here is a consistent 4.8v - so luckily the mosfet will do what I want here.I did measure the batteries alone (outside of the device) and sure enough they register 5.5v. So I am glad for the discussion of this as I will now be aware of this in the future.I’m curious about the ideal solution with two BJTs - I will need some time to wrap my head around it

author: vireswires
author_rank: Contributor
timestamp: April 04, 2024, 08:27:06 am
content: Also @peabody was right that the PIN numbers in the schematic are wrong. On the actual pcb, after flipping the mosfet (I had to bend the pins the other way), I now have battery connected to source, usb connected to gate, and drain is supplying the circuit with battery power when usb is unplugged.To make sure it’s working as intended, I did a continuity test between source and drain, and indeed there is continuity only when usb is unplugged.

author: Peabody
author_rank: Super Contributor
timestamp: April 04, 2024, 04:36:35 pm
content: Ok, but for those reading this in the future, I would just say again that if you reversed the mosfet so the drain is connected to the battery, you can do away with D9 and the 0.3v drop across it. In that orientation the body diode already opposes any flow from USB into the battery, and battery current will not flow into the load unless USB voltage after its schottly falls below 4.1V (4.8V - 0.7V), or even lower as the battery discharges, unless of course the mosfet switches on. @vireswires, you may not care about the voltage drop in the battery line, but most will, particularly driving a 3.3V circuit from a LIPO cell. In effect, it significantly reduces battery life because the circuit stops operating properly earlier in the discharge curve.Below is the schematic of a "UPS" 18650 circuit which includes a charger and a boost converter. It's currently available on Aliexpress and Ebay. Notice the orientation of Q1.

author: vireswires
author_rank: Contributor
timestamp: April 06, 2024, 06:01:00 pm
content: Okay I think I see how that makes sense. Sorry if this is a stupid question but if the battery voltage is on the drain instead of the source, how does the mosfet turn on when usb is unplugged? Doesn’t it need to see negative gate-source voltage in order to turn on?

author: pcprogrammer
author_rank: Super Contributor
timestamp: April 06, 2024, 06:40:04 pm
content: Quote from: vireswires on April 06, 2024, 06:01:00 pmThe body diode conducts in that case making the source positive and with the gate grounded via the pull down resistor it will turn on. As long as there is a large enough voltage across the load the P-MOSFET will stay on.

author: Peabody
author_rank: Super Contributor
timestamp: April 06, 2024, 10:27:19 pm
content: I suspect that most of the time the capacitance in the load circuit (bypass caps, etc.) is enough that the voltage at the load does not drop as fast as USB and gate voltage drops when USB is disconnected, so the mosfet turns on before the output voltage gets low enough for current to flow through the body diode. But once the mosfet turns on even a little bit, it will snap on the rest of the way and bypass the body diode.But it's a test of any such circuit that you should be able to pull the plug on USB and the battery should take over without your processor resetting. That has always worked for me with this circuit, but you will want to test yours to make sure it works that way.