Engee documentation
Notebook

Investigation of frequency characteristics of ACS

In this example, let's consider the capabilities of Engee environment to study the frequency characteristics of ACS.

Structural transformations

A model of a UAS is a structural diagram, which includes blocks of typical dynamic links. The transfer function of the ACS is found by operating with the transfer functions of these links.

When connected in series, the transfer function of a chain of links is equal to the product of their transfer functions:

$$ W(p)=\prod_{i=1}^n W_i(p) $$

The transfer function of a group of parallel connected links is equal to the sum of their transfer functions:

$$ W(p)=\sum_{i=1}^n W_i(p) $$

If a link with the transfer function $W_1(p)$ is covered by a feedback in which there is a link $W_{ос}(p)$, then the transfer function of the closed loop $W(p)$ is determined by the formula:

$$ W(p)=\frac{W_1(p)}{1 \pm W_1(p)W_{oc}(p)} $$ The plus or minus sign in the denominator corresponds to negative and positive feedback, respectively.

Let's consider the functions of the library ControlSystems.jl, which allow you to make structural transformations of the circuit.

In [ ]:
Pkg.add(["ControlSystems"])
In [ ]:
#Подключим библиотеку для работы с САУ
using ControlSystems

#Зададим передаточные функции
W1 = tf([1],[0.5, 1]);
W2 = tf([1],[1, 1]);

There is a function ControlSystemsBase.series for successive multiplication of transfer functions.

In [ ]:
#Последовательное перемножение систем
series(W1,W2)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
        1.0
-------------------
0.5s^2 + 1.5s + 1.0

Continuous-time transfer function model

The transfer function of a group of parallel links can be determined using the function ControlSystemsBase.parallel.

In [ ]:
#Параллельное соединение звеньев
parallel(W1,W2)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
    1.5s + 2.0
-------------------
0.5s^2 + 1.5s + 1.0

Continuous-time transfer function model

To determine the transfer function of a loop consisting of a link covered by feedback, there is a function ControlSystemsBase.feedback.

In [ ]:
#Если звено охвачено единичной обратной связью, вторым аргументом указывается 1
W3 = feedback(W1,1)

#Если обратная связь проходит через звено W2
W4 = feedback(W1,W2)

display([W3,W4])
2-element Vector{TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}}:
 TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
   1.0
----------
0.5s + 2.0

Continuous-time transfer function model
 TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
    1.0s + 1.0
-------------------
0.5s^2 + 1.5s + 2.0

Continuous-time transfer function model

By default, when using the function ControlSystemsBase.feedback, a negative feedback link is formed. However, it is possible to specify that the connection should be positive by passing -1 as the second argument.

In [ ]:
#Звено охвачено единичной положительной обратной связью
feedback(W1, -1)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
1.0
----
0.5s

Continuous-time transfer function model

Obtaining and studying the frequency characteristics of the ACS

Let's set the transfer function of ACS, shown in the picture below.

image.png

In [ ]:
#Зададим параметры САУ
Ku = 10;
Tu = 0.001;
Km = 3;
Tm = 0.1;
Te = 0.02;
Kp = 0.01;
In [ ]:
#Задаем передаточные функции звеньев САУ
W_1 = Ku*tf([1],[Tu, 1]);
W_2 = Km*tf([1],[Tm*Te, 1, 1]);
W_3 = Kp*tf([1],[1, 0]);

display([W_1, W_2, W_3])
3-element Vector{TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}}:
 TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
    10.0
------------
0.001s + 1.0

Continuous-time transfer function model
 TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
         3.0
---------------------
0.002s^2 + 1.0s + 1.0

Continuous-time transfer function model
 TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
0.01
----
1.0s

Continuous-time transfer function model

The links are in series, so we obtain the overall transfer function of the open loop system using the familiar ControlSystemsBase.series.

In [ ]:
#Получаем передаточную функцию разомкнутой системы
W = series(W_1, W_2)
W = series(W, W_3)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
                 0.3
--------------------------------------
2.0e-6s^4 + 0.003s^3 + 1.001s^2 + 1.0s

Continuous-time transfer function model

Let's plot the AFCC and LAFCC.

In [ ]:
#Получение АФЧХ
w = -100:0.1:100
nyquistplot(W,w,title="АФЧХ",label="W")
Out[0]:

Also plot the LFCC of the open loop system with the display of stability reserves in amplitude and phase. For this purpose we use the function ControlSystemsBase.marginplot.

In [ ]:
#Определим запасы устойчивости по амплитуде и по фазе
marginplot(W,label="W")
Out[0]:

The stability margins are shown in the title of the graphs. The amplitude margin is 1111.76 dB and the phase margin is 73.89 degrees. The LFCC crosses 180 degrees at 18.26 rad/s and the cutoff frequency is 0.29 rad/s. You can also move the cursor over the graph and see the values of amplitude, phase and frequency at any selected point.

Conclusion

In this example, we have learnt the Engee functionality for investigating the frequency response of a UAS. We have also learnt how to transform the structural diagram using the library functions ContolSystems.jl. To learn more about plotting frequency response plots, see Plotting Functions.