Engee documentation
Notebook

Modeling of automatic control systems using object models

The model of the automatic control system (ACS) is presented in the form of a block 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 ACS model. We will define ways to set object models, some functions for structural transformations and the construction of time characteristics.


Let's consider the structural scheme of the ACS, which contains filter blocks , a management object , controller and the sensor .

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, a management object set as a gain factor with a double pole in s=-1 using the function zpk(). The controller indicated by , represented as a PID controller using the function pid(). Models and 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 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 system, we 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

We obtain the transfer function of the entire system, taking into account the filter . To do this, use 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 the received functions can be analyzed using the ControlSystems.jl library. For example, let's look at the time characteristics. We construct the transition characteristic 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 analyzing models of automatic control systems in the ConrtrolSystems.jl library. They can be studied in the section [Analysis of time and frequency characteristics] (https://engee.com/helpcenter/stable/julia/ControlSystems/lib/timefreqresponse.html ).