Engee documentation
Notebook

Creating models of continuous systems

In this example, let's look at how to create a model of a time-continuous system using the functions tf zpk ss.


The ControlSystems library.jl allows you to define linear models of continuous systems in three different ways:

  • Transfer functions (tf)
  • Setting poles and zeros (zpk)
  • State space (ss)
In [ ]:
Pkg.add(["ControlSystems"])
In [ ]:
#Подключение библиотеки для работы с САУ
using ControlSystems

Transfer functions

For SISO systems, the transfer function is a ratio of polynomials and , which are Laplace images of the output and input values.

In Engee, a polynomial is defined as a vector of coefficients. For example, for a polynomial: , vector of coefficients: .

We get a transfer function of the form:

In [ ]:
num = [1, 0]; #Задаем числитель
den = [1, 2, 10]; #Задаем знаменатель
W1 = tf(num, den)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
      s
-------------
s^2 + 2s + 10

Continuous-time transfer function model

Alternatively, you can go to the Laplace domain and pass a polynomial with a variable s instead of a vector with coefficients.

In [ ]:
s = tf('s'); #Создаем переменную Лапласа
W2 = s/(s^2 + 2*s + 10)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Int64}}
      s
-------------
s^2 + 2s + 10

Continuous-time transfer function model

Setting poles and zeros

Set using the function zpk() The model description looks like a transfer function.

The roots of the numerator are called zeros, and the denominator poles. Scalar coefficient - gain factor.

To set the model using the function zpk(), it is necessary to transmit a vector of poles, zeros and a gain factor.

In [ ]:
z = [0]; # Нули
p = [2,1+1im,1-1im]; # Полюса
k = -2; # коэффициент усиления
H = zpk(z,p,k)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoZpk{Int64, Complex{Int64}}}
            s
-2---------------------
  (s - 2)(s^2 - 2s + 2)

Continuous-time transfer function model

Just as for models defined by transfer functions, you can go to the Laplace domain and transfer a polynomial with a variable s instead of a vector with coefficients.

In [ ]:
s = zpk("s");
H = -2*s/(s - 2)/(s^2 - 2*s + 2)
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoZpk{Float64, ComplexF64}}
                                 1.0s
-2.0---------------------------------------------------------------
    (1.0s - 2.0)(1.0s^2 - 1.9999999999999996s + 1.9999999999999991)

Continuous-time transfer function model

A model in the state space

The state space model is a representation of differential equations in matrix form. The complete model of an object in the state space contains two equations:

where - the vector of the system state, - input vector(control signal), - output vector; - matrices.

To define a model in the state space, there is a function ss(). To do this, the described matrices must be set as the input to the function.

In [ ]:
A = [0  1 ; -5  -2];
B = [0 ; 3];
C = [1  0];
D = 0;
H = ss(A,B,C,D)
Out[0]:
StateSpace{Continuous, Int64}
A = 
  0   1
 -5  -2
B = 
 0
 3
C = 
 1  0
D = 
 0

Continuous-time state-space model

The description of the system model allows you to start analyzing its behavior. For example, to plot time and frequency characteristics. The functions for analyzing ACS models can be found in the [Analysis] section (https://engee.com/helpcenter/stable/julia/ControlSystems/lib/analysis.html ).