Electronic – Opamp + NPN and MOSFET in the feedback network, how to prevent oscillations

negative feedbackoperational-amplifieroscillation

Background

The task is to add an electronic means to limit the power applied to an electric motor in an industrial setting. The operator normally controls the motor power through a lever that is mated to a 5KΩ pot:

schematic

simulate this circuit – Schematic created using CircuitLab

The electronic device I want to add should be able to cap the signal to a limit, so that the signal fed to the ESC follows the relation

$$V_{\text{out}} = \text{min}(V_{\text{in}}, V_{\text{limit}})$$

or (thanks to @GlennW9IQ for suggesting it!)

$$V_{\text{out}} = V_{\text{in}} * V_{\text{limit}}$$

(in the second case, assume Vlimit is 0..1, i.e. just a normalized multiplier).

One very important detail is that whatever I add should not be able to generate a phantom signal, i.e. Vout MUST be always less or equal to Vin, even in the event of software bugs and reasonable hardware failures. To this end, I initially drafted something like this:

Draft 1

schematic

simulate this circuit

There are also other details, e.g. a relay to bypass the whole circuit if my device is unpowered. The purpose of OA1 is to buffer the input signal so it can be read through a MCU ADC pin.
With this schematic, I can be reasonably sure I cannot inject a positive voltage on ESC's input, since I can only pull the pot's signal down.
The problem is that OA2 cannot bring the signal to 0V if the limit signal says so, because the output will always be at least the Vf of the diode. In theory that can be fixed if I add a negative rail to V- of OA2. But in practice this is unfeasible.

Draft 2

So I have this new draft, shown here just the part to the right of OA2:

schematic

simulate this circuit

Problem

The schematic in Draft 2 is capable of pulling the pot readout hard to 0V, but I fear the feedback loop is too complicated, too high gain, and the output is going to oscillate a lot.

I've intentionally left the ?? box, because I think that's where some oscillation/stabilization components should be added (e.g. 220k||1µF to ground). The good news is that the input is fairly low-bandwidth, say 10 Hz (how fast can you turn a pot?) and it's okay if the output has some defects/overshoots, since the motor has a lot of inertia. I just don't want it to oscillate all the time.

Problem

So: how to stabilize this feedback loop and prevent any oscillations?

EDIT

Based on suggestions in comments, I've updated Draft 2 to include an integrator around OA2:

schematic

simulate this circuit

If I'm understanding the theory correctly, OA2's feedback loop is now bandwidth-limited to around 50 Hz, with -3dB corner frequency around 5Hz. Will these additions suffice?

EDIT #2

As suggested by @GlennW9IQ, I presented the option that the limit value modulates the input, i.e. you can still use the full range of the pot, however your output range is rescaled according to the limit. See the updated formulas for Vout.

EDIT #3

Additional circuit/system details:

  • My device has a 3.3V power rail, hence the need for resistive dividers, opamp buffers, etc.
  • I don't have a 5V rail handy (I don't want to use the one from the ESC-to-pot cable).
  • The Vlimit signal is generated by a 8-bit DAC and its Vref can be either 3.3V or 2.048V.

Best Answer

Compensating the loop

Using the original circuit, you might be able to stabilize that loop just by adding a relative large capacitor (e.g., >1nF) from the drain of Q2 to the Pot readout node. That, together with the Thevenin resistance around your pot, will introduce an extremely low frequency pole (it will be Miller multiplied by a factor of >>1 million) that will only be active during limiting, thus compensating the loop without impacting desired performance. Your other solution, that adds even more amplifiers in the loop, will just make it worse.

Edit: After looking at it more closely, I realized that adding a pole in that location would make things worse as it directly applies the whole gain in the feedback path of the amplifier. So adding it across the op-amp is the way to go. I have updated the schematic to reflect this.

If OA2 is unity gain compensated, you just have to add a pole that is ~< 0.1*op amp compensation pole (GBW/gain) the only issue will become response time. To reduce the need for compensation by reducing the gain, add an emitter resistor to Q1.

I have incorporated both ideas into the following circuit modification. You don't have to combine all of them.

  • Rgain reduces the loop gain by making the gain of Q1 ~ 10
  • Ccomp and Rcomp together introduce a compensation pole whose frequency will be given by w = Ccomp * OpAmpGain * Rcomp. The addition of Rcomp removes the dependency of this pole on the potentiometer value.

schematic

simulate this circuit – Schematic created using CircuitLab

Alternative

But you could considerably reduce your circuit complexity and probably increase reliability by building your limit comparator from scratch. Something like this:

schematic

simulate this circuit

Make sure that the transistors have low Threshold (you can get all of those, well-matched, in a single array). It is just a differential pair with an added gain from the output stage. This makes it intrinsically stable as it is only a 2-stage amplifier.

I added an indicator LED because transistor arrays would have 4 transistors in them. It's biased awkwardly as its intensity depends on R2, but it's free. It can be made a more conventional quasi-digital on/off by adding 2 resistors...

Implementing an option

You can achieve an intermediate solution that somehow approaches your multiplication option by reducing the gain of the loop (for example by reducing R8 or adding source-degeneration resistors on the differential pair). It is a non-linear dependency, but the output will still track the value of the potentiometer with a degree of compression set by the gain and the value of Vlimit.

Scaling to a 3.3V supply

Of course, by changing the values of the resistors and using transistors with a low enough threshold (<1V), it is possible to scale down the supply. The main issue is given by the divider of R3 & R4, this sets the worst-case bias of the differential pair. With a 5V input, the worst case, this divider should probably provide ~2V, leaving 1.3V for the MOSFET Vthreshold and defining the minimum current through R1.