6
\$\begingroup\$

I'm trying to make a 0-25 mA current limiter. I want to take a control voltage of 0-5 V as input and have it control a current of 0-25 mA through a restive load (the restive load may vary between 0-200Ω, it's represented as R2 below).

Here is my circuit:enter image description here

T1 is a P-channel mosfet (P/N FQT5P10) and O1/2 is a rail-to-rail op-amp (P/N OPA2170). I want the varying voltage at V2 to control the current through R2.

The O2 op-amp is used to make a differential amplifier with a gain of 2. Example: 25mA of current through the load R2, op-amp O2's output should be 5V (marked CSense). The output from op-amp O2 is then the input to op-amp O1. Op-amp O1 compares the control voltage with O2's feedback to limit the current. Or at least that's my intention.

I have simulated this circuit in NL5 circuit simulator, and it works great in the simulation. But today I actually built the circuit, and it oscillates.

I have triple checked my pin-out and wiring, and messed around with lots of other things, but the circuit still just oscillates. When V2 is a higher value the oscillation is slower. What I am seeing on the DSO is that mosfet T1 goes between full on and full off, and CSense is a triangle wave that varies in amplitude with the control voltage. A higher control voltage makes CSense have higher amplitude and lower frequency. The oscillation frequency varies from about 50kHz to 150kHz.

I can post screen shots from my DSO if it helps.

I've been working on this all night, and it's starting to drive me crazy. Any help at all would be greatly appreciated.

Thanks!

Edit: I built the circuit in CircuitLab. It works perfectly there too. Why not in real life?

schematic

simulate this circuit – Schematic created using CircuitLab

Update: I have changed R3 to 10K. It reduced the frequency of oscillation to ~20-30 kHz.

Update Everyone is focusing on O1, but I think the problem is in the O2 circuit. Below is a DSO screen shot. V2 is at 1.25 VDC. The yellow trace is the voltage over R2 @ 100Ω. The red trace is the output of O2 (marked as CSense in my schematics). I would expect the red trace to be 2x the yellow trace, but instead it's a completely different shape! What in the world is going on?

For clarity: I would expect the yellow line to be 0.625 VDC, and the red line to be 1.25 VDC (same as the V2 input). Also my power supply is ~8 VDC here, things blow up at 24.

enter image description here

\$\endgroup\$
13
  • \$\begingroup\$ I just ran the simulation in CircuitLab and got a nice 50 Hz sine wave. \$\endgroup\$
    – gbarry
    Apr 12, 2013 at 15:01
  • \$\begingroup\$ The V2 input is a sine wave. The output is supposed to follow the input. If you change V2 to DC, the output will also simulate as DC. On my bench, V2 is DC, but the output oscillates between 30kHz-250kHz. \$\endgroup\$
    – Imbue
    Apr 12, 2013 at 15:38
  • \$\begingroup\$ Is the second op-amp slewing? According to the datasheet, the slew rate is 0.5V/us. If I read your o-scope capture correctly, the rise and fall time for the red trace is approximately the slew rate of the OPA2170 \$\endgroup\$ Apr 12, 2013 at 17:03
  • \$\begingroup\$ Did you by chance wire that transistor upside down, drain-source reversed? Then you have positive feedback. \$\endgroup\$
    – Kaz
    Apr 12, 2013 at 17:11
  • 1
    \$\begingroup\$ The half-wave clipping on the trace is suspicious. Note that the circuit doesn't show power connections for the op-amps and the simulation likely assumes they are on a dual-voltage supply. Is that how the real circuit is built? How are the op-amps powered, and what exactly is the ground that the white triangles connect to? \$\endgroup\$
    – Kaz
    Apr 12, 2013 at 17:18

4 Answers 4

5
\$\begingroup\$

The problem is that the current thru M1 as a function of gate voltage is highly non-linear. At some point in the function, the gain is very high, which is making things unstable.

If you don't need high speed response from this circuit, you can dampen it somewhat past the point where you experimentally determine it won't oscillate at any operating point. To do that, add some resistance in series with the input signal going into the negative input of O1, then add some capacitance immediately between the O1 output and its negative input. Due to the non-linear nature of the current source this is driving, the capacitance value that guarantees no oscillation over any part of the operating range will also overdamp the system at others. That may be OK if you're not looking for fast response.

I would do the above anyway, but I wouldn't use a FET in the first place. You only need a 5 V compliance range (200 Ω times 25 mA), so you have plenty of voltage headroom. You have 24 V to start with. The load can take up to 5 V, and the current sense resistor another 2.5 V. That leaves 16.5 V headroom for the current source. You really don't need all that, but you can easily spend 5 V or so to get a reasonably linear current source.

Ditch the PFET and use a PNP transistor with 200 Ω or so in series with its emitter. The other end of the resistor is tied to the 24 V supply, the collector becomes the controlled current output, and the base is driven directly by the opamp output. This assumes the opamp output can swing to within half a volt of the positive supply, which many can't. The top schematic doesn't specify the opamp at all, and the bottom shows a TL082, which definitely can't get to within 500 mV of the top supply. Either use a opamp that can, or add a resistor divider between the opamp output and the transistor base so that the transistor is off with something the opamp can achieve. You can also add a diodes or even a zener in series with the emitter to drop the base voltage range if you need to.

With this scheme you still add the compensation cap as described earlier (it's usually a good idea to build that in anyway, you can always leave the cap off if you discover it's not needed), but the same value should apply well accross the whole operating range.

Another advantage of the PNP scheme is that much of the variations of the load are dealt with immediately by the transistor. The larger feedback loop then is mostly driven by the set point, and doesn't need to react as quickly to load changes. That allows more damping for more stability without sacrificing load regulation. It will slow down response to control inputs. From what you say, we don't know how important those two are and therefore how much this matters.

In general, you need to think about stability of circuits with feedback before building them and realizing they oscillate. The "Oh, crap" method of loop stability design is really not very good.

\$\endgroup\$
6
  • \$\begingroup\$ Thanks for your detailed reply. I'm still learning, and I found it very helpful. My op-amp is a OPA2170 (it's specified right under the top schematic. The bottom schematic is just a CircuitLab simulation and I used whatever model they had available). The voltage control signal is almost DC (changes at much < 1Hz anyway), but the 24VDC may have some 60 Hz ripple. Do you think my circuit with your modifications will be okay, or should I start all over with another current source circuit design altogether? \$\endgroup\$
    – Imbue
    Apr 12, 2013 at 13:35
  • \$\begingroup\$ I have tried a 100n cap from O1's IN- to its output. V2 already has a fairly high output impedance in my actual circuit. The capacitor cut the frequency of oscillation in half, but didn't fix it. I don't care if the the entire circuit becomes over-damped, I would be happy to just have it work on DC inputs at this point. Thanks! \$\endgroup\$
    – Imbue
    Apr 12, 2013 at 14:46
  • \$\begingroup\$ @Imbue: Put a deliberate series resistor after V2. If it is low pass filtering PWM, then it probably has a cap to ground on its output. That will partially defeat the compensation cap around the opamp. Basically it's make a voltage divider and reduces gain but without the same rolloff. \$\endgroup\$ Apr 12, 2013 at 15:31
  • \$\begingroup\$ Yes, there is a cap to ground. I will try what you said and let you know. Thanks again. \$\endgroup\$
    – Imbue
    Apr 12, 2013 at 15:40
  • 1
    \$\begingroup\$ @Imbue: I am confused what circuit you actually ended up with. Show the circuit you have now exactly as you built it, perhaps in another question. Then explain what you want it to do and what it is actually doing. \$\endgroup\$ Apr 19, 2013 at 18:45
5
\$\begingroup\$

The negative feedback loop of the left Op-Amp goes thru the FET and second Op-Amp, which makes analyzing stability a nightmare (and stability itself intuitively improbable).

There is hope you could damp that left Op-Amp by adding a series resistor on the negative input, and a small cap between output and negative input. For a start try R = 1/(6.f.C), e.g. C=100pF, R = 22k. Increase R if that has no effect.

Update: if you try it, please tell us the effect!

\$\endgroup\$
3
  • \$\begingroup\$ Thanks for your reply. I'll try out your suggestions tomorrow. Can you suggest any resources for me to learn about these things? I would like to fix this circuit, but I would also like to learn why it's not stable and avoid these things in the future. \$\endgroup\$
    – Imbue
    Apr 12, 2013 at 6:30
  • \$\begingroup\$ The theory tells how to predict stability from a Bode plot or better Nyquist plot. Try a search. My intuition does not replace that, and could well be wrong. \$\endgroup\$
    – fgrieu
    Apr 12, 2013 at 7:05
  • \$\begingroup\$ The V2 supply in my actual circuit already has a fairly high impedance (it's a PWN into a low pass filter). I tried adding a 100n cap from O1 IN- to its output. It cut the frequency of oscillation in half, but didn't fix the problem. \$\endgroup\$
    – Imbue
    Apr 12, 2013 at 14:47
3
\$\begingroup\$

If your op-amp OA2 circuit is not perfectly matched with its resistors then it won't truly amplify the differential signal - it'll also amplify the common-mode signal i.e. the voltage that appears on M1's drain. You don't want this to happen because it's more likely to oscillate.

TL082 also has a figure for CMRR (common-mode rejection ratio) but it isn't specified at high frequencies - it could easily be a paltry 20dB at 50kHz and get worse at higher frequencies. This will do the same as not having perfectly matched resistors.

I'm assuming also that you do have a true negative supply for the TL082 because if you don't have it will not work correctly down to 0V - when you set a demand of close to 0mA you'll be expecting OA2's circuit to work properly and it just won't do that.

Putting an op-amp in the feedback loop of another op-amp can be asking for trouble and usually, the only way around this is to reduce the high-frequency gain of one of them. To this end, it might be appropriate to place capacitance across the 100 ohm sense resistor. It's easy to do and test. You might find that at (say) 100nF, things settle down.

There is also the FET to consider - this will have plenty of signal gain in it's configuration and I would recommend putting a resistor between OA1's output and the gate in order to reduce gain. Try 10k to start with and make it as big as you can whilst still being able to turn the fet on properly.

It's all about reducing the "gain" of the circuit in order to stop oscillations building up and measuring the current through the 100R without "collecting" errors.

There are better circuits should your endeavor prove fruitless but good luck anyway.

Here's one: -

enter image description here

1mA for every volt inputted flows thru the 1k resistors. This "forces" the top op-amp to put Vin across the source resistor of 100 hence 10mA flows through the final load for every volt on Vin

\$\endgroup\$
4
  • \$\begingroup\$ Thank you for your explanations and suggestions. I found your explanations helpful, and I will try out your suggestions later today. Could you suggest better designs for this (voltage controlled current source)? I did look at some other designs before, but I didn't understand how they worked, so I designed my own circuit using what I knew. It ran well in simulators, so I guess that gave me false confidence. The circuit can be low frequency. The voltage control will change at < 1Hz. \$\endgroup\$
    – Imbue
    Apr 12, 2013 at 11:59
  • \$\begingroup\$ I changed R3 to 10k (the mosfet gate series resistor). It reduced the oscillation frequency greatly, but still didn't fix it. The cap in parallel with R1 (current sense resistor) didn't seem to help, it only changed the shape of the oscillations. \$\endgroup\$
    – Imbue
    Apr 12, 2013 at 16:19
  • 1
    \$\begingroup\$ @Imbue I've added a constant current generator I have used in the past - it worked but make sure you use rail-to-rail opamps that are suitable for the supply voltage and use a 200R resistor in the source of the top fet to give you 5mA per volt. My circuit was running off 5v so I used AD8605 op-amps but you can't use those because of the supply voltage being higher. \$\endgroup\$
    – Andy aka
    Apr 12, 2013 at 16:46
  • \$\begingroup\$ Thanks for the circuit. I don't understand why it works yet, but I'll study it and probably use it next time. \$\endgroup\$
    – Imbue
    Apr 12, 2013 at 17:28
2
\$\begingroup\$

Basically, any negative-feedback circuit will oscillate if the phase delay around the feedback loop reaches 180° before the loop gain falls below unity.

Poles in the frequency response introduce lagging phase that approaches 90° per pole as the frequency rises. Every opamp has at least one low-frequency pole in its open-loop response that causes the gain to drop off with frequency and the phase delay to approach 90°.

You are operating OA1 with no feedback whatsoever, so its dominant pole is a major factor in the overall response. Furthermore, you are driving a MOSFET, whose gate capacitance, in conjunction with the impedance driving it, introduces another pole. Together, these poles are rapidly driving the phase to 180°.

There are two ways to get away from this situation. You can reduce the gain of OA1 significantly (using local negative feeback) in order to reduce the effect of its pole on the overall loop response, or you can reduce the phase shift by introducing one or more zeros (leading phase shift — essentially a high-pass element with a low cutoff frequency) into the loop.

The other solutions that have been proposed, which would add additional poles into the loop response, are essentially counterproductive, and rather than solving the problem, will simply shift the frequency of oscillation.

\$\endgroup\$
9
  • 1
    \$\begingroup\$ According to this argument, "compensation" capacitors shouldn't ever help with stability when there is any other pole in the system. However, note that such a capacitor also reduces the open loop gain at high frequencies, so at some point that gain should be low enough at the frequency where the phase shift gets high enough that it would cause trouble. Put another way, you end up with a single dominant pole with the other poles irrelevant due to there being insuffucient gain at their frequencies for them to matter. \$\endgroup\$ Apr 12, 2013 at 13:53
  • \$\begingroup\$ @Olin, yes that works. I was just trying to emphasize the fact that running OA1 with no local feedback whatsoever is a major source of the OP's problem, due to both its high gain and its inherent pole. \$\endgroup\$
    – Dave Tweed
    Apr 12, 2013 at 14:10
  • \$\begingroup\$ I tried adding a 100n capacitor from O1's IN- to its output. It cut the frequency of oscillation in half, but that doesn't help me. V2 in my actual circuit has fairly high output impedance (it's a PWM into a low pass filter), so I didn't add any series resistor to O1 IN-. I can see on the scope the O1 IN- is now oscillating with it's output (whereas it was a steady DC before, obviously). \$\endgroup\$
    – Imbue
    Apr 12, 2013 at 14:42
  • \$\begingroup\$ That simply turns OA1 into an integrator (another pole!) without addressing its extremely high DC gain. \$\endgroup\$
    – Dave Tweed
    Apr 12, 2013 at 14:50
  • \$\begingroup\$ So how can I reduce the gain of O1 with local feedback? I think if I add a resistor from O1 IN- to its output, that would offset the input voltage and defeat the entire purpose of the circuit. \$\endgroup\$
    – Imbue
    Apr 12, 2013 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.