Simple constant current with op-amp, oscillating at very low currents  - Page 1
Forum section: electronics / projects

author: DavidAlfa
author_rank: Super Contributor
timestamp: May 31, 2023, 05:01:48 pm
content: I'm trying to make a simple current injector to calibrate DMMs, the idea is to connect the reference and testing ammeters in series.I don't need a reference standard, just something that doesn't drift like crazy depending on temperature or voltage changes, so if I set it to 99.8mA it won't slowly drift to 110mA as it heats up while I'm adjusting the trimmers.A TL431 should do a pretty nice job here, it worked as expected in the 20-500mA range, then I though it would be nice to add a second range to provide 0-1mA for the micro amps.So I simply amplified the shunt voltage by ~500 using the second op-amp in the LM358.Made this circuit in a small board, taking care of grounding loops and current voltage drops, with heavy ground and all that (sorry no pictures).Sadly this gave me nasty oscillations, I guess the loop gain is too high or/and the loop itself might cause phase reversal?Dont hesitate to correct me and call this design absolute trash, changes I'm very wrong with this are huge, I'm not an expert in analog (Nor in anything)Tried adding caps in several places, best I got was a slow sawtooth ripple of 50-200Hz.Later I got the simulator to produce the same spikes by toggling the switch several times until it started oscillating. (Sorry, cropped the image and realized later, it's about 20KHz)How to improve this? Or better just trash it and simply use the TL431 output with different resistors to output 50-100-200-500-1000uA?

author: Weston
author_rank: Regular Contributor
timestamp: May 31, 2023, 06:05:08 pm
content: Does your low current range work at all? Or does it just oscillate at the low end of the range?A gain of 500 is asking a lot for the LM358. The offset voltage can be up to 7mV, which which is an output of up to +/-3.5V. If this is causing the opamp to saturate it could be causing some non-linear effects that lead to oscillation.In addition to the offset voltage of the LM358, some people report issues using the LM358 for control loops because of hysteresis in the output due to crossover distortion. Thats another non-linear effect that is hard to model.If the oscillation is due to a poor phase margin that can be modeled with small signal analysis you can simulate it in LTSpice and its a bit easier to discuss. For a feedback system to be stable you want to have only one pole before your crossover frequency. The current amplifier is adding another pole at ~700KHz GBP/500 gain = 1.4 kHz, which is going to be before the crossover frequency.From a control loop perspective you need to add one or more zeros to null the added poles from the additional amplifier. And possibly change your loop gain.I would have to model the system to be sure about the frequency and implementation, but I think you should be able to stabilize it by adding a resistor between the switch and pin 2 of the LM358 and adding a capacitor from pin 1 to pin 2. This will bypass the added amplifier at high frequency, eliminating its effect on the phase margin at crossover. You effectively just have a single op-amp in the unity gain configuration, which should be stable.You also might be able to stabilize it with some combination of increasing R1 to reduce loop gain and a capacitor across R7 to add a zero and cancel the first pole of the current amplifier.

author: Benta
author_rank: Super Contributor
timestamp: May 31, 2023, 06:25:23 pm
content: You have a heck of a lot of gain your loop, and I doubt if you'll ever get it stable.Even "simple" current sinks can give problems with this.It would be nice if your plot includes labels, It's impossible to interpret.

author: DavidAlfa
author_rank: Super Contributor
timestamp: May 31, 2023, 08:38:16 pm
content: Tried lots of caps, still getting oscillations, the larger the cap the lower it is,but still there.Any other op-amp better for this job? I have a pretty big inventory of - everything, as it's a fab, I'm allowed to steal few parts from time to time (Pick'n place machines drop few anyways).

author: Ian.M
author_rank: Super Contributor
timestamp: May 31, 2023, 08:55:31 pm
content: Ditch the second x500 OPAMP and switch in a second 500 ohm shunt using a DPDT switch, one pole to switch the shunt and the other to switch the sense connection so it doesn't 'see' the voltage drop across the switch ON resistance.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: May 31, 2023, 08:56:09 pm
content: Quote from: DavidAlfa on May 31, 2023, 05:01:48 pmYou have used a SPDT switch, so why not just change R4 value with that ?

author: Benta
author_rank: Super Contributor
timestamp: May 31, 2023, 09:21:40 pm
content: Quote from: Ian.M on May 31, 2023, 08:55:31 pmAgreed.Even easier: place a 500-ohm resistor in series with the 1-ohm resistor and short-circuit the 500-ohm with a switch when the high range is needed.I'd say the switch resistance is negligible, current needs to be adjusted with the pot anyway.

author: DavidAlfa
author_rank: Super Contributor
timestamp: May 31, 2023, 09:44:14 pm
content: Yeah, that was going to be my tomorrow test.I wanted to avoid current through the switch, but meh, 500ma is nothing,Back to the simple way then!

author: PCB.Wiz
author_rank: Super Contributor
timestamp: May 31, 2023, 09:57:25 pm
content: Quote from: DavidAlfa on May 31, 2023, 09:44:14 pmYou could also measure the leakage current of the TIP47, the data says < 1mAMosfets are more typically < 1uA an typ 0.02uAIf you are worried about the switch, you can get sub 10mohm mosfets easily these days.Addit: or, if this is a bench tester, a shunt/jumper is an alternative,Samtec have 4.3A rated ones and molex have 5A rated 0.1" jumpers, and 3A seems very common.

author: Circlotron
author_rank: Super Contributor
timestamp: May 31, 2023, 10:34:08 pm
content: If you use a mosfet you won’t have any base current adding to the shunt current, especially if the required base current to maintain a constant collector current varied with transistor temperature.

author: magic
author_rank: Super Contributor
timestamp: June 01, 2023, 08:47:34 am
content: Quote from: DavidAlfa on May 31, 2023, 09:44:14 pmIt may work reasonably well. You only need variations in switch resistance to be much less than 1Ω.With SPDT switch even better solution is possible: swap 1Ω with 560Ω and switch Q1 emitter so that it connects either to the top or the bottom of 560Ω. Connect U1A feedback to the top of 560Ω permanently.

author: DavidAlfa
author_rank: Super Contributor
timestamp: June 01, 2023, 09:42:43 am
content: Mounted the switch with 510R, does the job: 0-500mA / 0-1mA.The result was the same with the Tip41 and a irf530, however the voltage had to be cranked up to 8V to make the N-gatr conduct enough, so I left the bjt.The 1ma scale does a slight oscillation of about 30uA, ok-ish, the DMM should integrate and make the average.

author: Ian.M
author_rank: Super Contributor
timestamp: June 01, 2023, 09:49:38 am
content: The usual fix for oscillating OPAMP current sinks is to roll-off the HF gain of the OPAMP with local negative feedback. Try 1K in series with -in and 1nF direct from -in to its output

author: Benta
author_rank: Super Contributor
timestamp: June 01, 2023, 07:56:05 pm
content: Quote from: DavidAlfa on June 01, 2023, 09:42:43 amAt which frequency?

author: PCB.Wiz
author_rank: Super Contributor
timestamp: June 01, 2023, 07:59:07 pm
content: Quote from: DavidAlfa on June 01, 2023, 09:42:43 amYou may be bumping into cross over distortion too, at those very low base currents, maybe try a pull down resistor (10k~1k?) on the OpAmp output, so the drive current does not sweep decades.

author: Benta
author_rank: Super Contributor
timestamp: June 01, 2023, 08:06:06 pm
content: Quote from: Ian.M on June 01, 2023, 09:49:38 amAfter having had problems with CC LED drivers oscillating in the MHz range, I started to investigate.The very interesting outcome was, that it's actually the output emitter-follower oscillating,notthe op-amp.There are several articles freely available on the subject, plus a number of IEEE papers (where I only know the titles, members only).Example:https://www.hifisystemcomponents.com/downloads/articles/Prevent-Emitter-Follower-Oscillation.pdfThe easiest way to kill it is to include a suitable base resistor. After doing that, all my LED drivers were stable.These CC circuits are not as harmless as they look.

author: r6502
author_rank: Regular Contributor
timestamp: June 01, 2023, 08:40:59 pm
content: hello DavidAlfa,have a look at the Keithley K263 current calibrator manual. It can deliver currents from 20mA down to 2pA range. In the manual the schematic is included. It is performing really great.Manual is available at the TEK website:K263 ManualPrincipe of the current source see below: