And old farts alike.
I'm building Dave's constant current load device. Easy enough - an afternoon's work. What could go wrong?
1. Input Common-Mode Voltage Range
I made the mistake of assuming that 'rail to rail output' somehow implied 'rail to rail input' too. I'm using an LMC662 dual op-amp, though only half of it. Luckily I checked what happened if you simply connect the wiper of a pot to the + input. On a 5V supply, when the input approaches about 3.6V, the output jumps to 5V. Oops. I have to include a resistor in series with the pot, so that the input never exceeds 3.6V. In hindsight, this information is obvious on page 1 of the datasheet, where it says, under 'Features'; " Input Common-Mode Voltage Range includes V-". This can now be interpreted as saying " Input Common-Mode Voltage Range doesn't include V+". I will always read these sections in future, inverting the statements to find the true meaning.
2. Gain
So now the input swing is limited to 3.6V, I presumably need to introduce some gain, so that I get a full 5V output swing? I hope so, because that's what I've done. If I ever get it working, and need to dial it down a bit, I suppose I could.
3. Oscillation
"The output attempts to do whatever is necessary to make the voltage difference between the inputs zero". Well it does, up to some strangely shifting voltage where the two part company. You already know what the problem is, but I didn't, so it took me a while to connect an oscilloscope to it. Oscillation. Suddenly the hysteresis is explained - once it's oscillating, the voltage needs to drop back appreciably below the voltage where the oscillation started, in order to calm down.
Glancing at my circuit, how can I fix the oscillation? I have a spare half-an-opamp, if that helps. I substituted an STP36NF for the MOSFET.
Cheers
John