Electronic – Understanding this LPF in opamp feedback loop

basicconstant-currentoperational-amplifier

I'm using a basic opamp driven mosfet to implement a precision low current sink for an LED:

enter image description here

This seems to work just fine within the range that I want it (10mA or so). I've seen other circuits that put an lpf in the feedback loop (R3 was 1K in the one I saw):

enter image description here

I'm trying to understand how that works. With the values of 100n and 10k, the -3dB point is 160Hz. What I don't understand is why the capacitor is connected to the opamp output instead of to ground. Wouldn't that divert noise above 160Hz back into the output? Of course, there'd be a phase shift as well but I cannot see why you wouldn't connect the capacitor to ground.

I'm guessing this is a really basic opamp circuit in a slightly different form but I'm not understanding what that form takes. I may have it backwards as high frequencies at the output of the opamp will "short" back to the inverting input and reduce the opamps output.

Best Answer

The purpose of this circuit is to make sure the circuit has sufficient phase margin (does not oscillate). It's a particular problem with MOSFETs and not BJTs. 100nF is a very large capacitor- 1nF would work as well here (10nF is a good value), but maybe they wanted a bit of a LP filter or just wanted to be sure.

The problem is that the MOSFET (with such a low sense resistor) represents almost a purely capacitive load on the (exceptionally wimpy in this case) op-amp output. That produces a phase shift with the (relatively large) open-loop output impedance of the op-amp. In the case of the MCP6002 the maximum capacitance you can safely put on the output is less than 100pF with G=1. The Cgs is relatively low on that MOSFET (31pF typically, 46 max) but Miller capacitance comes into it too. Fortunately, with an LED load it's almost looking like a cascode arrangement, so you may be out of the woods.

You'd have to do a bit more calculation or simulation to be 100% sure- maybe try feeding a square wave to the non-inverting input and look to see how much overshoot you get in the current waveform. Varying when someone touches it sounds like it might be oscillating!

It's poor form IMO to do this in general- the second circuit above is the right way to do it. Even if you conclude it's working well enough, be careful that in production the MOSFET does not get replaced with something with substantially more capacitance. For example, the inexpensive AO3418 has a Cgs of 235pF (typical).