Powering Arduino Uno board from 5V pin and avoiding back-feeding USB - Page 1
Forum section: electronics / beginners

author: HwAoRrDk
author_rank: Super Contributor
timestamp: July 06, 2023, 02:00:34 pm
content: Here's the scenario: I want to make a 'shield' PCB for an Arduino Uno that supplies power to the Arduino board via the 5V header pin - not the VIN pin, or the barrel jack, nor USB. This is because the shield board will be driving a number of high-power loads with 5V, so I will be using an external high capacity 5V supply, and therefore it makes sense to take advantage of that as a single source of power to everything. But that will be the only supply at my disposal - nothing of higher voltage - so using VIN or the barrel jack won't be possible (they need >7V). And hacking something together with a USB cable isn't suitable for other reasons I won't go into.(And before anyone says that powering an Arduino board from the 5V pin is a bad idea, not recommended, danger!, danger!, you'll blow up the on-board linear regulator, etc. - most of that "general consensus" is bollocks. Feeding the 5V pin with a regulated 5V supply isliterally no differentthan powering from USB. The on-board '1117 regulator willnotblow up - if it was vulnerable to such usage, it would also do so when you powered the board via USB!)What I want to do is try and solve, or mitigate as best as possible, the problem of the situation where the external 5V is powering the board via the 5V pin, but the USB is also connected and powered. I am aware this situation is problematic, because of the possibility of any voltage difference back-feeding one or the other supply. And with the external PSU being rather low impedance, that could be very bad for the USB side...One might think from looking at the Arduino Uno R3 schematic (attached) that because there is a P-ch MOSFET (T1) that only switches the USB V-BUS to +5V when VIN is absent, that would prevent external +5V from back-feeding to the USB, but that is not so. That's because when external 5V is present, the MOSFET is always turned on! When there is no VIN and the '1117 regulator is back-fed 5V on it's output, it presents 4.4V on its input to VIN; this VIN voltage is divided by two and compared with an op-amp (U5A) to 3.3V; because it is lower (2.2V), the op-amp pulls its output connected to the gate of the MOSFET to ground, turning it on. I've verified this behaviour on both a genuine Arduino Uno R3 board (with NCP1117) and a clone Uno board (with AMS1117).What I'm thinking of doing is adding a low-value resistor (single-digit ohms) and a schottky diode in series with the external supply to the Arduino 5V pin. I believe this will have two effects: prevent the USB side back-feeding the external PSU; drop the externally-supplied voltage below that of any reasonably in-spec USB supply voltage, so that USB power will implicitly take priority. And if the USB voltage droops (e.g. crappy cable, un-powered hub, etc.) then the back-feed current should be minimal. I'vesimulated this(with a 4.7 ohm resistor) and I don't get any back-feed current to the USB until that side drops below approx. 4.5V.Will my solution be "good enough"? Is there a better way of doing this?

author: Ian.M
author_rank: Super Contributor
timestamp: July 06, 2023, 02:39:23 pm
content: No. To prevent backfeeding Vbus if the USB host goes into a power-saving mode (which can shut off Vbus), you have to keep Uno MOSFET T1 off *ALL* the time external 5V is present. You need to feed TP_COMP (U5A pin 3) via a Schottky diode and 1K resistor from your 5V external source to guarantee its above 3.3V and the MOSFET is off. Note that your external source must feed Uno +5V via another Schottky (or MOSFET 'ideal') diode so it cant be backfed, to permit the UNO to run from USB power.Alternatively if you want to avoid hacking the Arduino PCB, a small boost module could give the Arduino 7.5V on Vin from your ext. 5V without the need to tie the high power 5V bus to the Arduino 5V.N.B. the Arduino Nano has a simple diode from Vbus to +5V so is immune to this issue.

author: Peabody
author_rank: Super Contributor
timestamp: July 06, 2023, 02:49:01 pm
content: What if you replace the mosfet with a schottky diode? That's what the Nano does. That protects USB from back-feed, but doesn't protect the external supply. But with a diode in that line too, then both are protected, and if both are present, the one with the higher voltage will supply the Uno. I don't think you need the resistor.

author: HwAoRrDk
author_rank: Super Contributor
timestamp: July 06, 2023, 07:35:58 pm
content: I don't want to have to modify the Arduino board in anyway. Ideally this needs to be plug-and-play with any Arduino Uno board that happens to be on hand (it's not me that's going to be using it).I feel like they kind of goofed with the design of the Uno. Can't imagine why they didn't think to put a diode in series with the USB supply back then, but obviously realised it was a good idea on subsequent products. In fact, now I look at the design more, I realise that the VIN/USB switching is flawed because if VIN drops to anywhere between 6.2V and 6.6V, the '1117 will still be producing 5V (1.2V dropout), but the op-amp U5A will have turned the MOSFET on (because VIN/2 < 3.3V) and allow USB VBUS and regulated 5V simultaneously - with the peril of back-feeding either side that goes with it.Quote from: Ian.M on July 06, 2023, 02:39:23 pmAh, I hadn't thought about that. Yes, I suppose there's no guarantee the USB host/hub/etc will keep the VBUS powered all the time. I suppose that might happen if e.g. a laptop goes to sleep. Although, as far as I'm aware, most hosts and hubs these days use dedicated power ICs on each port's VBUS that feature reverse current prevention in addition to current limiting, so in reality probably not possible in most situations.Perhaps I need to forget about trying to use a single 5V supply and instead procure a dual output 5V+12V supply, then I can feed the Arduino board VIN with the 12V. A boost converter on-board the shield is probably making things a little too complicated (not to mention the 'yuck' factor of taking a lower voltage, boosting it, then lowering it with a linear regulator - that just seems wrong to me).

author: Peabody
author_rank: Super Contributor
timestamp: July 06, 2023, 10:10:21 pm
content: Well, how about specifying a Nano instead of an Uno? Same processor, but your power setup would work just fine.I agree with you that the Uno design was lacking.You may be pushing your luck with 12V at Vin, depending on how much current the Uno will be drawing. The regulator could get a bit hot, and it has no way to effectively dissipate the heat.Maybe a single 9V supply, applied to Vin, with another branch going to a 5V regulator for the other parts of your circuit.