Author Topic: Simple constant current with op-amp, oscillating at very low currents  (Read 1082 times)

0 Members and 1 Guest are viewing this topic.

Offline DavidAlfaTopic starter

  • Super Contributor
  • ***
  • Posts: 5243
  • Country: es
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  :D)


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?
« Last Edit: May 31, 2023, 05:11:42 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Weston

  • Regular Contributor
  • *
  • Posts: 217
  • Country: us
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.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5641
  • Country: de
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.
 

Offline DavidAlfaTopic starter

  • Super Contributor
  • ***
  • Posts: 5243
  • Country: es
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).
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12361
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.
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1243
  • Country: au
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.
You have used a SPDT switch, so why not just change R4 value with that ?
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5641
  • Country: de
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.

Agreed.
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.

 

Offline DavidAlfaTopic starter

  • Super Contributor
  • ***
  • Posts: 5243
  • Country: es
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!
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1243
  • Country: au
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!

You could also measure the leakage current of the TIP47, the data says < 1mA
Mosfets are more typically < 1uA an typ 0.02uA

If 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. 
« Last Edit: June 01, 2023, 12:42:19 am by PCB.Wiz »
 

Offline Circlotron

  • Super Contributor
  • ***
  • Posts: 3107
  • Country: au
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.
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6319
  • Country: pl
I wanted to avoid current through the switch, but meh, 500ma is nothing,
Back to the simple way then!
It 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.
 

Offline DavidAlfaTopic starter

  • Super Contributor
  • ***
  • Posts: 5243
  • Country: es
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.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12361
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
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5641
  • Country: de
The 1ma scale does a slight oscillation of about 30uA, ok-ish, the DMM should integrate and make the average.
At which frequency?
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1243
  • Country: au
The 1ma scale does a slight oscillation of about 30uA, ok-ish, the DMM should integrate and make the average.
You 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.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5641
  • Country: de
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
After 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, not the 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.pdf

The 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.
 

Offline r6502

  • Regular Contributor
  • *
  • Posts: 105
  • Country: de
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 Manual

Principe of the current source see below:
« Last Edit: June 02, 2023, 11:16:27 am by r6502 »
Science can amuse and fascinate us all, but it is engineering that changes the world - - Isaac Asimov
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf