PCB Power supply via USB and Battery - Page 1
Forum section: electronics / projects

author: FeuerFrosch
author_rank: Newbie
timestamp: September 12, 2022, 11:49:44 am
content: I am getting started with pcb design and I am building a PCB to drive a small stepper motor. I want it to run via USB and have the possibility to use batteries (probably 4x AA Batteries in series) as well. I want the battery input to be reverse polarity protected and in case both power sources are active at the same time I want it to use the USB power, if that is easily achievable (otherwise using the source with the highest voltage is ok as well), and obviously I don't want any current to flow back into the batteries at any point.If I understand it correctly, if I would simply put a diode on both inputs I would have reverse polarity protection and no power could flow back into the battery, and the higher voltage source would be used (mainly) if both are connected at the same time. That would have the negative side effect of losing some not insignificant power due to the voltage drop through the diode.I know that you can use a P-Channel mosfet for reverse polarity protection for a single voltage source. Is there an easy way of using mosfets to achieve what I want? Since I want my pcb produced by jlcpcb and they have "Basic" parts which get assembled "for free", it would be great to use the "AO3401A" (P-channel) and "AO3400A" (N-channel) mosfets.

author: Peabody
author_rank: Super Contributor
timestamp: September 12, 2022, 02:52:20 pm
content: I'd like to know a bit more about what you will do with the power at the load end. Will it be regulated?If you would consider using three AA batteries instead of four, I believe the circuit shown below would work. If USB is not connected, the pulldown gate resistor turns on the mosfet, and there is very little voltage drop. If USB is present, the gate will be at 5V, so the mosfet is off. The mosfet's body diode will not conduct because its voltage drop is greater than the schottky diode in the USB line, and because USB voltage is higher than battery voltage to begin with. I haven't thought about reverse polarity protection on this circuit, but it looks like it might be provided. The orientation of the mosfet is "backwards", as would be the case with reverse polarity protection. But you would have to test this.However, I think you may find that this does not work if the battery voltage is materially higher than USB voltage. At some point current will flow through the body diode even if the mosfet is off. They make single-chip solutions giving you the option of connecting the the lower voltage source to the output. Take a look at the TPS2110A. I'm sure JLCPCB will have several versions of this kind of chip.

author: FeuerFrosch
author_rank: Newbie
timestamp: September 12, 2022, 11:58:55 pm
content: Thanks for your reply. I will check your circuit tomorrow and also look into those single chip solutions. I just got home and have to go to bed now (2am)...On the board there will be an stm32 and a tmc2225 stepper driver.There will be a 3.3v LDO for the stm32 and a boost converter for the stepper motor voltage (not sure about the voltage yet. Something between 5V and 24V)The pull down resistor between the input voltage and GND will not work. There will be a PIR sensor attached to the board and the stm32 will be in a low power mode until the sensor detects motion. Then it will enable the step up converter and run the motor for a certain amount of time. A pulldown resistor would consume way to much power. Maybe I will plug the usb cable into a power bank (I will have to check if modern power banks support low power output. My old one powers off after a while), so the "standby" consumption should be in the low uA range for both inputs.When using only 3 instead of 4 Batteries the voltage would drop below 3.3v before the batteries are fully discharged. In the datasheed of the LDO I am planning to use, I can not find any info about what happens if the voltage gets too low. I would like to use that one because it is a "JLCPCB Basic part":https://datasheet.lcsc.com/lcsc/1811062113_Holtek-Semicon-HT7533-1_C14289.pdf

author: Peabody
author_rank: Super Contributor
timestamp: September 13, 2022, 01:08:19 am
content: The pulldown resistor only draws current from the USB supply when it is connected. I assumed the USB source came from mains, so any current drawn through the resistor wouldn't be important. But if the USB supply is also battery powered, then I think your conclusion is correct that the resistor would waste current.If only the AA battery supply is connected via the mosfet, then the gate pulldown resistor would draw no current at all.Your LDO has a maximun dropout voltage of 100mV, so the three AAs could go from nominally 4.5V, but actually about 4.65V, down to 3.4V before you would lose regulation. However, while most datasheets don't discuss it, regulators of this type usually follow the input voltage on down after the dropout voltage is no longer satisfied. You lose regulation, but since the source is a battery, the supply would probably continue to be pretty stable. Another option if your STM32 and PIR sensor would still work would be to use the 3.0V version of the LDO, or even the 2.7V version.If you use four AAs, then I think you will need something like that TI chip. I don't know of a simple circuit that lets you automatically select the lower-voltage source when it is connected.I think you will find that all modern power banks still shut down when current falls too low, which makes them unsuitable for any circuit that periodically goes into low power mode.

author: FeuerFrosch
author_rank: Newbie
timestamp: September 13, 2022, 04:25:47 pm
content: I can not really find anything that does what I want, especially not something that is offered by jlcpcb. I think I am just going to either go with 2 Schottky diodes (one for each input), or with a single mosfet and a mechanical switch to choose the input.Would this diode be appropriate for such a job? The max. input current would be about 1A, probably way less though:https://datasheet.lcsc.com/lcsc/2204121115_MDD-Microdiode-Electronics--SS34_C8678.pdf

author: Peabody
author_rank: Super Contributor
timestamp: September 13, 2022, 10:27:32 pm
content: You might look a little further in power distribution switches. It looks like they have the TPS2113, which has a nominal 6V maximum, which is very borderline for four AAs, but otherwise might work. But it's very expensive.https://www.lcsc.com/search?q=TPS2113APWRIf you use two diodes, then when both supplies are present, the higher AA supply will be selected until it falls below 5V. That may not be ideal. But I think that diode would work.If you use a manual switch, then you don't need diodes or mosfets. Just switch from one supply to the other.