Understanding the Uno's USB Isolation Circuit

Can someone explain to me how this circuit is working? I dont get what its doing. I see that its turning on and off the USB Vin based on some input, but other than that I dont understand how it is operating or what the application for such a circuit is? (Its part of the Uno circuitry btw)

1 Like

It's purpose is to isolate The USB +5vdc from the on-board +5vdc voltage regulator for the case when there is both an external DC power source connected to the board and also plugged into a PC USB port at the same time. It's called the 'auto-voltage selector' circuit. It's never a good engineering practice to have two voltage regulators 'hardwired' together so this circuit is designed to prevent that from happening. The T1 mosfet is the active switch element and the op-amp is wired as a simple comparator to drive the mosfet on or off. The presence of a Vin voltage above a minimum valid value cause the current path from the USB power to be cut off.

Lefty

1 Like

So if I have a 32u4 connected to USB and a voltage regulator at the same time, that would be a no-no, correct? I'd have to implement this circuit to separate the USB voltage from the circuit voltage to prevent frying my 32u4? Cant I just use a diode on the USB voltage line, or is that still not enough?

UNTEngineer:
So if I have a 32u4 connected to USB and a voltage regulator at the same time, that would be a no-no, correct? I'd have to implement this circuit to separate the USB voltage from the circuit voltage to prevent frying my 32u4? Cant I just use a diode on the USB voltage line, or is that still not enough?

Well it's not an automatic 'it will fry my board and put my eye out' sort of thing. Lots of people power their arduino boards with an external regulated +5vdc power supply via the 5V and ground shield pins and that does effectively wire the USB +5vdc and the external +5vdc together if you plug in USB at the same time, and most have reported no problems. However the two regulators can fight each other and current flow in the wrong directions if the two voltages are too far apart. The USB voltage standard is something like 4.75 to 5.25 and who knows what the actual voltage of a specific regulated +5vdc supply might be as it too has a voltage tolerance value. Simple diode isolating is certainly a simple and effective means to isolate the two voltage sources, with only the slight disadvantage of a slight voltage drop that might or might not be an issue using the analogRead() function and assuming the reference is 5.0 when it might by 4.4vdc due to the diode drops.

Lefty

what the application for such a circuit is?

It detects the presence of Vin and switches power supplies: U1A is a comparator. It takes Vin, divides it by 2 and compares it to 3.3v. If Vin / 2 is greater than 3.3v (aka Vin > 6.6v), U1A outputs 1 and turns off T1, which isolates USBVcc from U2. So U2 is powered by +5v (which hopefully is powered by Vin at this point).

If Vin / 2 is less than 3.3v (aka Vin < 6.6v), U1A outputs 0 and turns on T1, which switches in USBVcc.

So 6.6v is the cut off point for Vin to power the device.

They could have done a better job around U1A.

1 Like

So 6.6v is the cut off point for Vin to power the device.

Not really a cut off point, as the board will still be powered by whatever the on-board +5vdc regulator is putting out even if Vin is below the 'input regulation drop-out' spec of the regulator. So Vin is never cut in or cut out, just USB is cut in or cut out if Vin is below or above 6.6vdc respectively. The FET circuit switching action is SPST not SPDT.

Lefty

1 Like

dhenry:
It detects the presence of Vin and switches power supplies: U1A is a comparator. It takes Vin, divides it by 2 and compares it to 3.3v. If Vin / 2 is greater than 3.3v (aka Vin > 6.6v), U1A outputs 1 and turns off T1, which isolates USBVcc from U2. So U2 is powered by +5v (which hopefully is powered by Vin at this point).

If Vin / 2 is less than 3.3v (aka Vin < 6.6v), U1A outputs 0 and turns on T1, which switches in USBVcc.

So 6.6v is the cut off point for Vin to power the device.

They could have done a better job around U1A.

But what if my Vin is a regulated +5V? And why are they comparing the Vin with 3.3V?

UNTEngineer:

dhenry:
It detects the presence of Vin and switches power supplies: U1A is a comparator. It takes Vin, divides it by 2 and compares it to 3.3v. If Vin / 2 is greater than 3.3v (aka Vin > 6.6v), U1A outputs 1 and turns off T1, which isolates USBVcc from U2. So U2 is powered by +5v (which hopefully is powered by Vin at this point).

If Vin / 2 is less than 3.3v (aka Vin < 6.6v), U1A outputs 0 and turns on T1, which switches in USBVcc.

So 6.6v is the cut off point for Vin to power the device.

They could have done a better job around U1A.

But what if my Vin is a regulated +5V? And why are they comparing the Vin with 3.3V?

Vin is an 'official' shield pin name for the 7-12vdc input for external DC power that which then only feeds the on-board +5vdc voltage regulator and the resistor divider feeding the comparator opamp. Vin is the same as the voltage coming from the external DC power connector except for a series polarity protection diode added between the connector and the Vin pin. A regulated +5vdc should not be wired to the Vin pin because that would be too low a voltage to feed to the on-board +5vdc output voltage regulator. If you have an external regulated +5vdc power supply you would wire it to the board via the shield 5V pin and ground pins (but you then have the non-isloation situation with USB power we already talked about). The 3.3vdc is used as a reference switching voltage for the comparator just because it's available and allows them to use equal size resistors for the voltage divider.

Lefty

But what if my Vin is a regulated +5V?

That has been answered.

And why are they comparing the Vin with 3.3V?

You have to ask the Arduino people for sure. The voltage regulator they used isn't an ldo and its drop out voltage ranges from 0.7v (low/no load) - 2v (rated load), so I guess that they thought a 1.6v headroom is adequate.

retrolefty:
Vin is an 'official' shield pin name for the 7-12vdc input for external DC power that which then only feeds the on-board +5vdc voltage regulator and the resistor divider feeding the comparator opamp. Vin is the same as the voltage coming from the external DC power connector except for a series polarity protection diode added between the connector and the Vin pin.

Aha! $) Ok, Vin is the unregulated power supply, so I should place the mosfet between the Raw DC in and the regulator. I know the unregulated voltage before my 5V reg is about 22V. Im thinking that is too high for the mosfet they use. I'll just use a beefier mosfet than the one they use, such as an FDN360P.

Is there any advantage to using a comparator, or can I just go with a set of mosfets to determine using the USB VCC vs the 5V?

Also as a side question, should I use reverse diodes on the D+/D- USB signal lines?

bump!

UNTEngineer:
so should use an unregulated voltage input

It has nothing to do with regulated vs unregulated. Its about voltage drop.
Voltage regulators have a voltage drop.
If you want 5 Volts you need around 7 Volts.
So if you feed Vin with just 5 Volts you have a drop at the Arduinos voltage regulator.
An you should use a regulated supply that your power is stable.

MrGlasspoole:
It has nothing to do with regulated vs unregulated. Its about voltage drop.
Voltage regulators have a voltage drop.

I know that. :roll_eyes:

I was trying to understand what Vin was, and where to place the mosfets. This still doesnt answer my two other questions:

UNTEngineer:
Is there any advantage to using a comparator, or can I just go with a set of mosfets to determine using the USB VCC vs the 5V? Also as a side question, should I use reverse diodes on the D+/D- USB signal lines?

UNTEngineer:

MrGlasspoole:
It has nothing to do with regulated vs unregulated. Its about voltage drop.
Voltage regulators have a voltage drop.

I know that. :roll_eyes:

I was trying to understand what Vin was, and where to place the mosfets. This still doesnt answer my two other questions:

UNTEngineer:
Is there any advantage to using a comparator, or can I just go with a set of mosfets to determine using the USB VCC vs the 5V? Also as a side question, should I use reverse diodes on the D+/D- USB signal lines?

Well perhaps if you back up a little and try to explain what your are trying solve or achive rather then various methods one might use. Frankly I've always felt the arduino auto-voltage selector circuit was quite a waste of board space and not as fool proof or flexible as it should be. I very much liked the method the very first model arduino boards used, which was a simple 3 pin male header where you placed a jumper chip on one side or the other to choose USB or on-board regulator to power the board. The Seeeduino 328p boards also have a nice manual small slide switch to choose the power source. The space taken up and the cost of the extra components could have been better spent on a small RTC chip or some other useful and common function.

Lefty

retrolefty:
Well perhaps if you back up a little and try to explain what your are trying solve or achieve rather then various methods one might use.

I have a device that will have a constant power supply on the pcb board (it is an AC-to-DC power supply), and will provide the option to debug/service the device in the field without turning off or removing the power supply ( it will be hardwired in). I just need to make sure its OK, or rather make sure I include a method to plug in the usb on the fly without damaging my computer or the board itself. Not sure if I need a surge protector circuit just in case plugging in the USB creates some kind of back surge into the USB for that split second before the switch (I think Im rambling here :sweat_smile:).

Frankly I've always felt the arduino auto-voltage selector circuit was quite a waste of board space and not as fool proof or flexible as it should be.

How flexible should it be?

I very much liked the method the very first model arduino boards used, which was a simple 3 pin male header where you placed a jumper chip on one side or the other to choose USB or on-board regulator to power the board. The Seeeduino 328p boards also have a nice manual small slide switch to choose the power source. The space taken up and the cost of the extra components could have been better spent on a small RTC chip or some other useful and common function.

Board space isnt exactly a problem with me, as the parts are extremely small, and I am quite creative with running traces. In fact, I would rather tiny SMD parts as opposed to a large, bulky 3-pin header that takes up a lot of space. Besides, I already have an RTC on board, so that isnt an issue. :wink:

In the meantime, I am using the approach that the Arduino Micro uses (shown below), which got rid of the comparator all together, and just uses two p-channel mosfets to switch between usb and vin power sources. It seems like a much more efficient way of determining which source to use, without the use of the comparator chip. I also am using a tiny part (sot23-6 footprint) which caught my attention, which uses two reverse diodes to protect the digital lines on the usb port (not sure how necessary this is).

The Arduino Micro method does look like a better simpler method to use.

Good luck;

Lefty

retrolefty:
The Arduino Micro method does look like a better simpler method to use.

Good luck;

Thanks. :slight_smile: