I designed a constant current load around the ACS712 Hall-effect current sensor (module from eBay). This module gives a voltage output of 185mV/A superimposed on VCC/2. Its current range is +-5A altho I'm only interested in +I for this design. The schematic below shows the basics of the design.
simulate this circuit – Schematic created using CircuitLab I had some trouble stabilising the feedback loop. The "error amp" (OA3) was open loop and gave a bang-bang output. The loop was unstable producing an oscillation in the 100's of Hz. Then I added C2 and increased the value of R13 to 100k. This reduced the oscillation to a great extent but there was still a low-level less than 100Hz oscillation producing a sawtooth gate drive on the MOSFET. After poking around adding bypass and roll-off caps to the opamps without much success I instinctively added C1, bypassing the "Gain Amp" OA2 and this completely cured the oscillation. My question is why did these changes kill the oscillations? I'm not the best at this kind of circuit design but my instincts led me in the right direction and I would like to understand why adding caps C1 and C2 made the difference. Also, do I have them in the right place or what other changes would you recommend to ensure stability.
I have not checked the impulse response of this loop nor how it behaves under dynamic conditions. I would appreciate some guidance on how to approach such tests.