# AC analysis of opamp loop in LTspice

I'm building an electronic DC dummy load and have a problem with stability/oscillations.

This is my circuit:

Vset - controls current, when set to 100mV it makes 500mA at the shunt
Vout1 - Vshunt multiplied by 40 by U1
Vout2 - output from U2, drives mosfet M1
power_in - it is 10V and I added some noise to it

Vout1 and Vout2 oscillate.

power_in:

Vout1:

I'm trying to do AC analysis, so I could make some tweaking.
I understand that loop is not stable if phase shift is 180° and gain higher than 0dB.
I read that I have to break feedback and insert small signal for AC analysis.
This is what I have done:

AC analysis is this:

Is this method correct? I googled for some examples, but I was able to find only simple examples that I was not able to apply to my circuit.
Problem is that result of AC analysis tells that gain is always less than 0dB and phase shift below 180° (well, maybe for higher frequency reaches 180°).

At this point I'm stuck, I appreciate any help or advice how to properly do AC analysis.

UPDATE:
I uploaded source file for LTspice:

• This type of current sink (controlled via a feedback loop) is highly likely to need an integrator. I would try a smallish (1 nF) cap across R7 for a start. I don't think C5 is doing much for you. Oct 27, 2017 at 14:31
• Did you verify the DC solution is correct after breaking the AC feedback loop? Oct 27, 2017 at 17:33
• @PeterSmith Thanks for hints, but my interest is to solve that AC analysis problem. Oct 27, 2017 at 17:35
• @ThePhoton No, I did not do "DC solution". What do you mean by that? Oct 28, 2017 at 7:00
• @ThePhoton I did "DC operating point". ".op 0 1m 0", which gave me voltages which are correct (Vset=0.1V, Vshunt=0.0025V, Vout1=0.09999V) Oct 28, 2017 at 7:11

@Chupacabras In your simulation for the loop gain, you set C7 to 100F. This are in Spice 100 femto Farad. But L1 and C7 should have very large values. 1G or 100G is no problem, because it is only a simulation.

The correct expression for the loop gain is V(Vout1)/V(X), where X is the node between (V4,L1,R9).

• I tried 100F and 100G, it makes no difference. I tried V(Vout1)/V(X) but the graph shows that there is no such frequency where gain is more than 0dB and phase shift -180°. As far as I know those are the conditions for oscillation. Phase shift is between +122° and -27° when gain is above 0dB. Am I missing something? Nov 7, 2017 at 10:09
• I missed a sign. The loop gain is -V(Vout1)/V(VX). A nice description is in allaboutcircuits.com/technical-articles/… Nov 7, 2017 at 12:45
• Excellent! That's it. Thanks for the link. Now I have proper AC analysis for my circuit, I can tweak it, and I can see, that it really works :) Nov 7, 2017 at 17:55

The problem is you are mistaking your control input, you still have a closed loop system as shown below, but you need to identify which parts are which.

U1 is H, if you found a transfer function for U1 you could subsitute it in for H

U2 is G and the summing point

$\theta_1$ is your input, which you want to be a DC value, however, if you want to analyze the loop, you need to change your control point.

There are a few ways to identify a control system, one of them is by sweeping the frequency, you want to do this at the control input then look at the output. (or different points in the system)

In your second attempt you were trying to inject the AC analysis after H and before the summing point, which I suppose could be done, but there is a much easier way, and you could use control theory to check the stability. Yes an AC block and injecting AC in your 'sensor loop' can work, but so will an AC analysis of your control input.

Edit: actually I should have been checking Vshunt (in the analisys below , I was checking Vout2). Vshunt is your real output $\theta_o$ but they are pretty close in AC response so I digress...

Here is how I changed your file to do a proper closed loop analysis, I put a new voltage source V4 at the positive terminal of U2 (your control reference point). I also gave it a amplitude of 0.5V and a DC parameter that varied from 1 to 5V.

.step param R list 0.1 0.3 0.6 1 1.5 2 2.5 3 3.5 4 4.5 5
V4 N003 0 {R} AC 0.5


Wait, what if we zoom in, yep, there is a resonance of 3dB at vout1, but 40dB at vout2. that is bad (at the first two runs that correspond to the 0.1 and 0.3 V DC params). All the rest of the runs have no resonance.

What if we move that capacitor... Yep 6db, thats better, not great, might be acceptable. I'll let you sort out the rest.

• First of all, thanks for your answer and food for thought. But there is something unclear to me. So, you are completely ignoring phase shift in this analysis? How do you decide from those graphs whether the loop is stable or there will be oscillations? Nov 7, 2017 at 9:36
• If you see a hump higher than the passband (like you see in all the figures, then that means oscillations) Whether these are a problem is up to the design requirements of your design which I do not know (like how much bandwidth you need.) Secondly these a oscillations only happen at lower powers (at 0.1V and 0.3V DC) so that may not be a problem for your design. If it is then bandwidth will need to be sacrificed and another 'pole' could be used in the loop to knock down that oscillatory behavior. Or increasing C5 Nov 7, 2017 at 17:48
• I have not defined any passband, so oscillations at any frequency is a problem. I modified my circuit (so it does not oscillate) but your method still shows some hump. When I look at this graph I am not able to determine whether the loop will oscillate or not. Actually JosefC gave me an answer to my question what I was looking for. Anyway, your answer helped me to identify another problem. Mosfet that is used (IRF530) in this simulation is not proper. It has too high Rdson which causes U2 to saturate, and that breaks oscillations for higher voltages at Vset. Nov 7, 2017 at 19:26