Engee documentation
Notebook

Estimation of the influence of the gain on the stability margin

This example shows how to investigate the effect of gain on the stability margin and on the response characteristics of a closed-loop control system.

Stability of a closed-loop system

Stability usually means that all internal signals remain constrained. This is a standard requirement for control systems to avoid loss of control and damage to equipment. For linear feedback systems, stability can be evaluated by looking at the poles of the closed loop transfer function. Consider a system with the following structural diagram:

image.png

Assume that the gain is $K=1$. Define the description of the closed loop transfer function using the library ControlSystems.jl.

In [ ]:
Pkg.add(["ControlSystems"])
In [ ]:
using ControlSystems
In [ ]:
G = tf([.5, 1.3],[1, 1.2, 1.6, 0]);
T = feedback(G,1)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
         0.5s + 1.3
----------------------------
1.0s^3 + 1.2s^2 + 2.1s + 1.3

Continuous-time transfer function model

Let us obtain the poles of the system.

In [ ]:
pole(T)
Out[0]:
3-element Vector{ComplexF64}:
 -0.2305351757522727 + 1.306198675535976im
 -0.2305351757522727 - 1.306198675535976im
 -0.7389296484954546 + 0.0im

The closed system at $K=1$ is stable since all poles have negative real values.

How stable is the system?

Checking the poles of a closed loop gives us an idea of stability. In practice, it is more useful to know how stable or unstable a system is. One measure of reliability is how much the loop gain can change before stability is lost. For this purpose, we can use a root-mean-square plot to estimate the range of values $K$, for which the system is stable:

In [ ]:
plot(rlocus(G))
Out[0]:

The asymptote marked in blue intersects the real axis (Y-axis) at the point with the value $2.7$. You can put the cursor on the graph and see for yourself. From this we can conclude that if the gain lies in the range $0<K<2.7$, the system will be stable.

Amplitude and phase margin

Changes in loop gain are only one aspect of stability. In general, imperfect modelling of the control object means that both gain and phase are not known exactly. Since modelling errors are most dangerous near the cut-off frequency (the frequency at which the open loop gain is 0 dB), it is also important how much phase variation is allowed at this frequency.

The phase margin indicates how much phase change can be tolerated before stability is lost. Similarly, the amplitude margin shows how much gain change is needed at the cutoff frequency to lose stability. Together, these two measures provide an estimate of the "stability margin" for closed loop stability. The smaller the stability margin, the more fragile the stability.

Let us plot the LFCC and LFCC with stability margins. The stability margins can be determined using the function marginplot().

In [ ]:
marginplot(G)
Out[0]:

The amplitude margin in this case is about 9 dB. You can put the cursor on the point of crossover of the wind line and the LFC and see for yourself. The stability limits of the system can be seen above the graph. However, it should be taken into account that the amplitude stability limit $Gm=2.75$ is expressed as the limit value of the gain, not in dB.

The phase margin (Pm) is about 45 degrees.

Let's consider the response of the system to a step signal.

In [ ]:
S1 = stepinfo(step(T,25));
plot(S1)
Out[0]:

The overshoot in this case is 21% and there are some oscillations.

Let's increase the gain by a factor of 2. Enter the values of stability reserves by the function margin() and plot the transient response.

In [ ]:
M = margin(2*G)
GmdB = 20*log(10,M.gm[1][1])
Pm = M.pm[1][1]
display(GmdB) 
display(Pm)
2.758136634183228
8.596209050239025

To derive the transient characteristic we use the function stepinfo(). Such parameters as steady-state time, overshoot, etc. are plotted using plot().

In [ ]:
S2 = stepinfo(step(feedback(2*G,1),60));
plot(S2, title = "Реакция замкнутого контура при k=2")
Out[0]:

We can see on the LFCC that the phase margin (Pm) has decreased, overshoot and settling time have increased. This indicates that we are approaching an unstable position.

Systems with multiple amplitude stability margins

Some systems have multiple amplitude stability margins or multiple phase transitions through 180 degrees. For example, consider the following structural diagram.

image.png

The transient of the closed-loop system in this case comes to a steady-state value - the system is stable.

In [ ]:
G1 = tf([20],[1, 7]) * tf([1, 3.2, 7.2],[1, -1.2, 0.8]) * tf([1, -8, 400],[1, 33, 700]);
T1 = feedback(G1,1);
plot(step(T1,7), title = "Реакция замкнутого конура при K=1")
Out[0]:

In order to evaluate how stable this system is $G1$, we plot the LFC and LFCC of the system.

In [ ]:
marginplot(G1)
Out[0]:

Note that there are two phase transitions through 180 degrees with corresponding gain values of -9.35 dB and +10.6 dB. Negative gain values indicate a loss of stability as the gain decreases. Whereas positive values of gain indicate loss of stability when the gain is increased. This is confirmed by plotting the step response of the closed loop for a change in gain $\pm$6 dB at k=1:

In [ ]:
k2 = 2;     
T2 = feedback(G1*k2,1);
k3 = 1/2;  
T3 = feedback(G1*k3,1);
step([T1 T2 T3],12)
plot(step([T1 T2 T3],12), label = ["K = 1" "K = 2" "K = 0.5"])
Out[0]:

The graph shows an increase in oscillation at both lower and higher gain values.

Conclusion

Thus, we have considered the effect of gain on closed loop stability and amplitude stability margin in particular.