Engee documentation
Notebook

Modelling of automatic control systems using object models

A model of an automatic control system (ACS) is represented in the form of a structural diagram. It contains blocks that describe the dynamics of individual objects. For example, the actuator, sensors and controllers. In this article we will consider the functions for working with the model of automatic control system. We will define the ways of setting models of objects, some functions for structural transformations and construction of time characteristics.


Let's consider the structural diagram of the ACS, which contains blocks of filter $F(s)$, control object $G(s)$, controller $C(s)$ and sensor $S(s)$.

controlsystemmodelingwithmodelobjectsexample_01.png

Engee uses the ControlSystems.jl library to work with control systems.

In [ ]:
Pkg.add(["ControlSystems"])
In [ ]:
#Подключение библиотеки
using ControlSystems

Each of the system components can be represented as an object model. For example, the control object $G(s)$ can be modelled as a double-pole gain in s=-1 using the function zpk(). The controller, labelled $C(s)$, can be represented as a PID controller using the function pid(). The models $F(s)$ and $S(s)$ can be specified as transfer functions using tf().

In [ ]:
G = zpk([], [-1, -1], 1)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoZpk{Int64, Int64}}
       1
1--------------
 (s + 1)(s + 1)

Continuous-time transfer function model
In [ ]:
C = pid(2, 1.3, 0.3; Tf = 0.5)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
0.6s^2 + 2.0s + 1.5384615384615383
----------------------------------
     0.125s^3 + 0.5s^2 + 1.0s

Continuous-time transfer function model
In [ ]:
S = tf(5, [1, 4])
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
  5
-----
s + 4

Continuous-time transfer function model
In [ ]:
F = tf(1, [1, 1])
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
  1
-----
s + 1

Continuous-time transfer function model

The specified transfer functions of the circuit elements can be combined with each other. For example, we obtain the transfer function of an open loop system using the operator *.

In [ ]:
op = C*G*S
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoZpk{Float64, ComplexF64}}
                       (1.0s + 2.128916830187693)(1.0s + 1.2044165031456413)
24.0-------------------------------------------------------------------------------------------
    (1.0s^2 + 3.999999999999999s + 7.999999999999997)(1.0s)(1.0s + 1.0)(1.0s + 1.0)(1.0s + 4.0)

Continuous-time transfer function model

To construct the transfer function of a closed-loop system, use the function feedback().

In [ ]:
cl = feedback(C*G,S)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoZpk{Float64, ComplexF64}}
                          (1.0s + 4.000000000000038)(1.0s + 2.1289168301875057)(1.0s + 1.2044165031463534)(1.0s^2 + 1.9999999999994214s + 0.9999999999994851)
4.8----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   (1.0s + 1.0)(1.0s + 1.0)(1.0s + 3.433002308222685)(1.0s^2 + 5.173461151904168s + 9.378541159192764)(1.0s^2 + 0.21173364799880784s + 1.6173060165378987)(1.0s + 1.1818028918743357)

Continuous-time transfer function model

Let's obtain the transfer function of the whole system taking into account the filter $F$. To do this, apply the function series().

In [ ]:
W = series(cl, F)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoZpk{Float64, ComplexF64}}
                                (1.0s + 4.000000000000039)(1.0s + 2.1289168301875256)(1.0s + 1.2044165031460183)(1.0s^2 + 1.9999999999997238s + 0.9999999999997489)
4.8----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   (1.0s + 1.0)(1.0s + 1.0)(1.0s + 1.0)(1.0s + 3.433002308222685)(1.0s^2 + 5.173461151904168s + 9.378541159192764)(1.0s^2 + 0.21173364799880784s + 1.6173060165378987)(1.0s + 1.1818028918743357)

Continuous-time transfer function model

All obtained functions can be analysed using the ControlSystems.jl library. For example, let's turn to time characteristics. Let's build the transient response of the system using the function step(), and the impulse response using impulse().

In [ ]:
#Подключение библиотеки для построения графиков
using Plots

ht = step(W,30)
plot(ht, title="Переходная функция", label="h(t)")
Out[0]:
In [ ]:
#Построение импульсной характеристики
kt = impulse(W,30)
plot(kt, title="Импульсная функция", label="k(t)")
Out[0]:

There are other functions for analysing models of automatic control systems in ConrtrolSystems.jl library. They can be studied in Time and frequency response analysis.