I'm planning to build a custom Arduino Mega PCB, so I downloaded the schematics and design files. For the schematic, I have a fairly good understanding of the connections, components, and their purpose.

However, I'm a bit unsure about the IC7B op-amp, RN5C/RN5D 10K voltage divider, and T1 FET and how they work together in the grand scheme of things. A picture of that part of the schematic is attached below. I also attached the power jack portion of the schematic below as well.

I'm assuming the op-amp will either send a voltage or not depending on the VIN line. That output is connected to gate of the FET that will either close or open the USB VCC line. So either the barrel jack or the USB will power the 5V Vcc line but NEVER both. Is that correct? I see the +3V3 line is the output of the voltage regulator but also the input of the op-amp so that's feedback op-amp right? I'm still not sure what the two 10K resistor voltage divider before the CMP input on the op-amp is for.

If you can confirm my guess and/or explain their role and importance, that'd be great.

enter image description here enter image description here


1 Answer 1


The +3.3V on the op-amp inverting input is obviously a voltage reference. The voltage on the non-inverting input would have to be just above 3.3V to pull the op-amp output high, or just below 3.3V to pull it low and thus turn on the P-channel MOSFET.
The voltage divider splits the Vin in half, which means that Vin would have to be just above 2 times the 3.3V reference on the inverting input (Vin>6.6V) to give a high (output) and not turn on the MOSFET.
Accordingly, Vin falling bellow 6.6V will produce a low (negative or 0V) output and turn the MOSFET on.
What this circuit does is to ensure an uninterrupted 5V on the +5V line (as in during programming through the USB port).
Since the Vin goes through a 5V voltage regulator (IC1, LD1117S50CTR), it has to be at least 1.3V above 5V to ensure voltage regulation (and it's at least 1.6V above in this case).
The MOSFET has a body diode which passes the current from the 5V USBVCC whether it is turned on or not, BUT because this diode has a voltage drop the MOSFET will not conduct (no USB current flowing because the right side of the MOSFET will be around +5V and the USBVCC would be at most +4.5V after passing through the diode) until it is turned on.
So, you're right, the current will not flow in from both the USBVCC and Vin at the same time.

  • 1
    \$\begingroup\$ Thanks! This should help me get a better understanding of Op-Amps and power supply circuits for future reference. \$\endgroup\$
    – Agriculex
    Apr 1, 2020 at 13:27
  • \$\begingroup\$ I looked more into the P-channel MOSFET and how it works and noticed some discrepancy. By the symbol of the MOSFET, it's in Enhancement mode by the dashed line in the 3 arrows (2 from the Source and 1 from the Drain). From learningaboutelectronics.com/Articles/P-Channel-MOSFETs, it said, the MOSFET turn ON when there is a negative voltage being applied to the gate (i.e the 3.3V from the op-amp). It turns OFF when there is no voltage going to the gate (i.e 0V to the gate). By that logic, If Vin is above 6.6V, Op-amp out is then 3.3V and the MOSFET is ON. \$\endgroup\$
    – Agriculex
    Apr 1, 2020 at 21:47
  • \$\begingroup\$ The same goes for the other way. If Vin is below 6.6V, then the MOSFET is off and USBVCC can't pass through it. By that logic, the Mega can't be powered by USB alone which is the opposite of what it should be. What is wrong or missing here? \$\endgroup\$
    – Agriculex
    Apr 1, 2020 at 21:50
  • \$\begingroup\$ @Agriculex: Your understanding is what's missing here ;) . You have missed the part where the gate voltage Vg is in reference to the source electrode. Whether it's a P-channel or N-channel enhancement type MOSFET, it will be off when the voltage between its gate and source (Vgs) is zero, and on when the gate is positive (relative to the source electrode) for N-channel MOSFET, or negative for P-channel MOSFET. In this schematic, the op-amp works as a comparator and its output is never 3.3V but swings to its positive or negative supply rail if its (+) input is above or below its (-) input. \$\endgroup\$ Apr 1, 2020 at 22:57
  • 1
    \$\begingroup\$ Thanks again for your help! Really appreciate it! \$\endgroup\$
    – Agriculex
    Apr 2, 2020 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.