Voltage Regulation in Mega 2560

Hi, I am trying to understand the Mega 2560 schematic to build my own board. I’m struggling to figure out one part involving the Op Amp Comparator and MOSFET in the voltage regulation. Can someone please explain to me why it was designed this way?

From what I can tell, the goal of the Comparator + MOSFET is to ensure both USBVCC and VIN don’t compete to provide voltage for the 5V rail. See below for the relevant part of the schematic.

The way I’m reading this is that VIN (~12V) is divided into 6V, and the Comparator emits a positive voltage when it exceeds 3.3V. This activates the MOSFET so current can… flow from USBVCC? I’m sure I’m missing something.

Thanks!

That's a P channel MOSFET so it turns on when the gate is grounded, not when it sees a positive voltage.

So when the + input of the opamp exceeds 3.3V, the output goes high and the MOSFET turns off. If the + input is less than 3.3V then Vin is less than 6.6V, the output goes low and USBVcc is enabled.

At least, that's the theory. Unfortunately a lot of boards use a jelly bean LM358 rather than a rail to rail LMV358 and its output doesn't get high enough to turn the MOSFET off. A 10K resistor from the output of the opamp (or MOSFET gate) to 5V fixes that, and it's easier than replacing the itty bitty opamp for most of us. Since you're DIYing it, you could use an LMV358 right from the start or go the LM358 + resistor route.

Ahhh that’s the part I missed, thank you! Punchline is that I had P-channel MOSFET activation conditions backwards.

Where did you get this schematic?

If you want to know how the mosfet works, then Google "ideal diode".
Leo..