Self-tuning controllers Simulink library
Self-tuning controllers Simulink library contains various discrete single input single output (SISO) controllers that can be used to control systems of second and third order. All controllers contain on-line identification of controlled process and thus can be used also for time varying processes.
The library has been designed under Matlab Release 12.1 (version 6.1) and Simulink version 4.1. For minimum and recommended system configuration see installation guide for Matlab. It is also possible to port the library to be used in previous versions of Simulink and Matlab, but in this case some functional limitations can occur. Dialog boxes used in library requires screen resolution at least 800x600 pixels.
Self-tuning controllers Simulink library is available in two versions:
· stcsl_std.zip – the standard version using the Matlab programming language (m-files)
· stcsl_rtw.zip – the version to be used with Real Time Workshop, using C language functions
To install the library simply unzip the appropriate file to an empty folder (for example using Winzip or pkunzip) and than add this folder to the matlab path. There are several possible approaches of adding a folder to the Matlab path (for example you can use path command), but the simplest way is to use the Set Path dialog, which can be accessed through the File menu.
Prof. Ing.
Ing.
Department of Control Theory
Faculty of Applied Informatics
Mostni 5139
760 01 Zlin
The library file stcsl_std.mdl (or stcsl_rtw.mdl) contains 32 controller blocks, 20 of them can be used to control second order systems and 12 to control third order systems. Each controller block has 3 inputs and 2 outputs. The inputs are:
· Current process input (action value) u_in,
· Current process output y
· Reference value w
The controller outputs are:
· Current action value u
· Vector of current parameter estimations of controlled process
Input u_in should be as close as possible to actual control value (input to control process) to get the most appropriate results of the process identification. In simplest case this input is directly connected to controller output u. This situation is shows in following model:
figure 1
Usually there are some limitations of action value in industrial applications and thus computed action value is not the same as input to the process. This situation is shown in sample model circuit.mdl in figure 2.
To use blocks in your own Simulink models just copy the block from library into your model (for example using drag and drop operation), connect appropriate input and output signals, set block parameters (for example by double-clicking on block) and than you can start simulation. It is also possible to start with sample model circuit.mdl and modify it to represent process you want to simulate. Controller parameters can be divided into two groups: the parameters common to all blocks and the controller-specific parameters. These two groups will be discussed in following two chapters.
This section describes the controllers’ parts and their parameters that are common for several or all controllers in the library. There are three subsections: description of on-line identification methods used in all controllers in the library, computation of ultimate gain and period used in controller based on Ziegler-Nichols method and the list of common controller parameters.
This section describes methods used in the library for an on-line process identification. You can select one of three offered methods: Least squares method (LSM), LSM with exponential forgetting and LSM with adaptive directional forgetting. All these methods can be used for the discrete on-line identification of processes that are described by the following transfer function:
|
(1) |
The estimated output of the process in step k ( ) is computed on base of the previous process inputs u and outputs y according to the equation (2):
|
(2) |
where are the current estimations of process parameters. This equation can be also written in vector form, which is more suitable for further work - see equation (3).
|
(3) |
The vector contains the process parameter estimations
computed in previous step and the vector contains output and input values for
computation of current output
Recursive least square method (LSM)
Least square methods are based on minimisation of the sum of prediction errors squares:
|
(4) |
Where yI is process output in i-th step and the product represents predicted process output. Solving this equation leads to the recursive version of least square method where vector of parameters estimations is updated in each step according to equation (5):
|
(5) |
The covariance matrix C is then updated in each step as defined by the equation (6):
|
(6) |
Initial value of matrix C determines influence of initial parameter estimations to the identification process.
LSM with exponential forgetting
The main disadvantage of this pure recursive least square method is an absence of signal weighting. Each input and output affect result by the same weight, but actual process parameters can change in time. Thus newer inputs and outputs should affect output more than older values. This problem can be solved by exponential forgetting method, which uses forgetting coefficient j and decreases the weights of the data in previous steps. Weights jk-i are assigned to values ui and yi. Parameter estimations are computed according to following equations:
|
(7) |
|
(8) |
LSM with adaptive directional forgetting
The exponential forgetting method can be further improved by adaptive directional forgetting which changes forgetting coefficient with respect to changes of input and output signal. Process parameters are updated using recursive equation:
|
(9) |
where
|
(10) |
Matrix C is updated in each step according to equation (11):
|
(11) |
where
|
(12) |
Forgetting coefficient is updated as follows:
|
(13) |
where
|
(14) |
|
(15) |
|
(16) |
All described on-line identification methods are realized in s-function sid where further details can be found. See help text for this function (type “help sid” in Matlab command prompt) or study the code of sid.m or sid.c.
Self-tuning controllers based on Ziegler-Nichols method needs to know process ultimate gain and period in each step and these parameters must be calculated in each step. The basic idea of this calculation is to find feedback gain to reach stability border of closed loop. For process transfer function defined by equation (1), the characteristic equation of closed loop is:
|
(17) |
where is feedback gain.
When the closed system is on the stability border, one or more roots of its characteristic equation are on stability border and the other roots are stable. In complex variable z, the stable region is the inner of unit circle, the stability border is unit circle and rest is unstable region. The ultimate root z=1 must be omitted in calculation because this is asymptotic stability border and thus ultimate period cannot be calculated.
The are two possible types of roots positions when calculating ultimate gain and ultimate period:
The algorithm of computation ultimate gain and ultimate period is placed in file ultim.m or ultim.c. For further details see help of this file (type “help ultim” in Matlab command prompt) or study the code.
Following controller parameters are common to all self-tuning controllers in the library. The common parameters are: Sample time T0, Identification type, ID Initial parameters estimations, ID Initial covariance matrix C, ID Initial phi (forgetting coefficient), ID Initial lambda, ID Initial rho and ID Initial nu The table bellow contains a short description of each of these parameters.
Group |
Parameter |
Description |
|
Sample time T0 |
Defines sample time of self-tuning controller. This value is used for both parts of controller: process identification and calculation of action value |
On-line Recursive Identification |
Identification type |
You can select from following on-line identification methods: · Least squares method (LSM) – The simplest method where all process input-output pairs affect identified parameters with the same weight. · LSM with exponential forgetting – The newest process input-output pairs affect identified parameters more than older pairs. This method can be used for systems with time varying parameters. · LSM with adaptive directional forgetting – The most sophisticated method, the weight of current process input-output pair is determined with respect to changes of input and output signal. This method is useful for systems with time varying parameters. |
ID Initial parameters estimations |
Initial process parameter estimation used by on-line identification. This is a column vector of parameters in the form [a1; a2; b1; b2] for most second order controllers, [a1; a2; b1] for Dahlin’s controller and [a1; a2; a3; b1; b2; b3] for third order systems. Details are given in description of individual controller in next chapter. |
|
ID Initial covariance matrix C |
Initial value of the covariance matrix used in on-line identification process. This must be a square positive definite matrix with dimension the same as number of identified parameters. Usually a diagonal matrix is used in the form G*I, where I is identity matrix and G is gain. The gain than determines the influence of initial parameter estimations to the identification process: the greater gain, the smaller influence of initial estimations. |
|
ID Initial phi (forgetting coefficient) |
Initial value of forgetting coefficient j used in on-line identification of controlled process. This parameter is used only if Identification type is LSM with exponential forgetting or LSM with adaptive directional forgetting and should be in range 0 < j £ 1 When LSM with exponential forgetting is used, this parameter determines the forgetting rate of older process input-output pairs: the smaller j, the smaller influence of older pairs to the current parameter estimations. When LSM with adaptive directional forgetting is used, then j is changing during identification process according to process of input (u) and output (y) values |
|
ID Initial lambda |
Initial value of parameter l used in on-line identification of controlled process. This parameter is used only if Identification type is LSM with adaptive directional forgetting. |
|
ID Initial rho |
Initial value of parameter r used in on-line identification of controlled process. This parameter is used only if Identification type is LSM with adaptive directional forgetting. |
|
ID Initial nu |
Initial value of parameter u used in on-line identification of controlled process. This parameter is used only if Identification type is LSM with adaptive directional forgetting. |
This chapter describes individual self-tuning controllers included in the library and their parameters. The library contains 29 self-tuning controllers: 18 of them are designed to control second order processes and remaining 11 are designed to control third order processes.
Each self-tuning controller can be divided into three parts:
· On-line identification – Recursive identification using least squares method on base of parameters described in previous chapter. This block is realized by Simulink s-function sid and to get more detailed help type help sid in matlab command prompt.
· Calculation of controller parameters – The main function of each controller used to compute coefficients of control law on base of identified process parameters and controller-specific parameters. This function is specific to each controller. The function name is the same as controller name thus to get detailed help of each function use Matlab help command (e.g. help ba2).
· Calculation of output (action value) – This block computes controller output (action value) on base of reference value, process output and coefficients computed by previous block. There are 4 s-functions which realizes the computation for different controllers:
§ scqp used for feed-back controllers ba2, da2, pp2a_1, pp2a_2, zn2br, zn2fd, zn2fr, zn2pi, zn2tr, zn3br, zn3fd, zn3fr, zn3pi and zn3tr;
§ scrqp used for feed-back feed-forward controllers db2s, db2w, mv2, pp2b_1, pp2b_2, zn2pd, zn2tak, db3s, db3w, zn3pd and zn3tak;
§ scast used for Astrom’s controllers zn2ast and zn3ast
§ scfpd used for four point difference controllers zn2fpd and zn3fpd.
§ scfbfw used for 2DOF controllers pp2chp, pp3chp and pp2lq
To get detailed help of these s-functions use help command in Matlab command prompt (e.g. help scqp)
The structure of all controller names is as follows: xxnyyyy, where xx - controller type, n = 2 or 3 process model order and yyyy - controller further details. The library consists of following self-tuning controllers (their parameters are described in following sections):
Contr. No. |
Controller algorithm |
Input parameters Controller type |
1
|
; ; |
KPu; Tu; T0
PID controller using forward rectangular method |
2
|
; ; |
KPu; Tu; T0
PID controller using backward rectangular method |
3
|
; ;
|
KPu; Tu; T0
PID controller using trapezoidal rectangular method |
4
|
; |
KPu; Tu; T0
PD controller |
5
|
; |
KPu; Tu; T0
PI controller |
6
|
; ; ; ; |
KPu; Tu; T0; Tf
PID controller using filtration of
D-component, |
7
|
|
KPu; Tu; T0
PID - Takahashi's controller |
8
|
|
KPu; Tu; T0
PID - Åström's controller |
9
|
|
KPu; Tu; T0
PID controller using backward rectangular method, replacing derivation by a four- point difference |
10
|
; ; (g = 0); (g > 0); |
d - time delay
PID - Bányász - Keviczky's controller |
11
|
; ; |
B - adjustment factor T0
PID - Dahlin's controller |
12
|
; ; ; ; |
wn - natural frequency x - damping factor
PID A-1 pole placement controller |
13
|
; ; ; ; ; ; |
a, w - real and imaginary component of the pole
PID A-2 pole placement controller
|
14
|
; ; ;
|
wa - natural frequency x - damping factor
PID B-1 pole placement controller |
15
|
; ; ; ; ; ;
|
a, w - real and imaginary component of the pole
PID B-2 pole placement controller
|
16 |
|
Dead-beat controller (weak version) |
17 |
|
Dead-beat controller (strong version) |
18 |
|
q - penalisation factor
Minimum variance controller |
|
D –
characteristic polynomial, Reference
signal type T0 Generic pole placement controller |
|
20 |
|
Φ –
weight of controller output signal in LQ criterion Reference
signal type T0 Controller based on minimisation of LQ
criterion |
21
|
|
wn - natural frequency x - damping factor 2DOF pole placement controller with compensator |
Notes:
m-file name: xx(x)a(yyyy).m: xx(x) -
controller type, n = 2 or 3 -
process model order, (yyyy) -
controller further details
Controllers number 1, 2, 3, 4, 5, 6, 7, 8 and 9:
; ;
Controllers number 12, 14 and 21:
for ,
for ,
Controllers number 13 and 15: