**6. Case study**

Discrete PID controller tuned continuously by technique introduced above is applied now to control of two nonlinear systems. Both of them are compiled by a combination of nonlinear static part and linear dynamical system – see Fig. 11.

Fig. 11. System to control

#### **6.1 First order nonlinear system**

The static element of the first demo system is defined by (Eq. 27) and dynamical system is defined by differential equation (28).

$$
\mu \,\,\mu \,\,\mathrm{\,^\*\,(t)} = \left(\frac{2}{1 + e^{-2u(t)}} - 1\right)^3 \,\,\mathrm{\,^\*\,(t)}\tag{27}
$$

$$
\ln y(t) + 10 \frac{dy(t)}{dt} = \mu \,\, ^\ast (t) \tag{28}
$$

Graphic characteristics of the system are shown in Fig. 12.

Control loop is designed as shown in paragraph 5. At first, dynamical piecewise-linear neural model in shape of Fig. 9 is created. This procedure involves training and testing set acquisition, neural network training and pruning and neural model validating. As this sequence of processes is illustrated closely in many other publications (Haykin, 1994), (Nguyen, 2003) it is not referred here in detail. Briefly, training set is gained by controlled system excitation by set of step functions with various amplitudes while both *u* and *yS* are measured (sampling interval *T* = 1 s) – see Fig. 13. Then, order of the neural model is set: *n =* 1 (Eq. 19) because the controlled system is first order one, too. After that, artificial neural network is trained by Backpropagation Gradient Descent Algorithm repeatedly (see Fig. 14) while pruning is applied – optimal neural network topology is determined as two inputs, four neurons in hidden layer and one output neuron. Finally, the neural model is validated (Fig. 15).

dynamical element (Eq. 28)

dynamical element (Eq. 28)

Discrete PID Controller Tuning Using Piecewise-Linear Neural Network 205

*u\**(*t*) *yS*(*t*) *<sup>u</sup>*(*t*)

LINEAR DYMANICAL ELEMENT

LINEAR DYMANICAL ELEMENT

A/D A/D

*z*-1

*yS*(*k*)

*yM*(*k*) *<sup>z</sup>*-1 *u*(*k*)

*z*-1

*u\**(*t*) *yS*(*t*) *<sup>u</sup>*(*t*)

A/D A/D

Next step is to determine polynomial *D*(*z*-1). Common ways of *D*(*z*-1) determination are

Control dynamics of closed loop equals to dynamics of defined second order system

Let us use the c) possibility and define the standard for control dynamics as second order

0.2642z 0.1353z (z ) 1 0.7358z 0.1353z




1 2 *D dd* (z ) 1 z z 1 0.7358z 0.1353z (30)

Special dynamics of closed control loop (defined by customer) is achieved

*<sup>F</sup>*


*<sup>z</sup>*-1 *u*(*k*)

NONLINEAR STATIC ELEMENT

A/D

Fig. 14. Neural network training

Fig. 15. Neural model validating

mentioned below (Hunt, 1993). Dead beat is achieved

Thus,

Quadratic criterion is satisfied

system with Z – transfer function (29).

NONLINEAR STATIC ELEMENT

*yM*(*k*)

**<sup>+</sup> -**

**<sup>+</sup> -**

*Mean Square Error*

(29)

Fig. 12. Graphic characteristics of the first order nonlinear system

element (Eq. 27)

Fig. 13. Training set for the neural model

Fig. 14. Neural network training

four neurons in hidden layer and one output neuron. Finally, the neural model is validated

0 20 40

*t,* s

Step response of linear dynamical element (Eq. 28)

0 1000 2000 3000 4000 5000 6000

*t*, s


*Real axis*

Nyquist plot of linear dynamical element (Eq. 28)

= 1

 = 0 = 0.01

= 0.1

*u yS*


*Imag. axis*

0

Fig. 12. Graphic characteristics of the first order nonlinear system

0.2

0.4

*yS*

0.6

0.8

1

(Fig. 15).



Fig. 13. Training set for the neural model



0

*u, yS*

1

2

3


0

*u\**

0.5

1


*u*

Characteristics of the static element (Eq. 27)

Fig. 15. Neural model validating

Next step is to determine polynomial *D*(*z*-1). Common ways of *D*(*z*-1) determination are mentioned below (Hunt, 1993).


Let us use the c) possibility and define the standard for control dynamics as second order system with Z – transfer function (29).

$$F(\mathbf{z}^{\cdot 1}) = \frac{0.2642\mathbf{z}^{\cdot 1} + 0.1353\mathbf{z}^{\cdot 2}}{1 - 0.7358\mathbf{z}^{\cdot 1} + 0.1353\mathbf{z}^{\cdot 2}}\tag{29}$$

Thus,

$$D(\mathbf{z}^{\cdot 1}) = 1 + d\_1 \mathbf{z}^{\cdot 1} + d\_2 \mathbf{z}^{\cdot 2} = 1 - 0.7358 \mathbf{z}^{\cdot 1} + 0.1353 \mathbf{z}^{\cdot 2} \tag{30}$$

Discrete PID Controller Tuning Using Piecewise-Linear Neural Network 207

As shown in Figs. 16 and 17, control performance is stable and desired dynamics of the

0 50 100 150 200 250 300 350 400 450

*yS*

*Standard*

*k*

Second demo system is structurally identical as the previous one (Fig. 11). Even the static element is the same. However, the dynamic system is defined now by differential equation

> () () ( ) 5 50 \* ( ) *dy t d y t <sup>y</sup> <sup>t</sup> u t dt dt*

The system is controlled on equal terms as previous one. However, the neural model now has four inputs as original system is second order one. Thus, Diophantine equation (35)

However, equation (35) is unsolvable. Thus, algorithm of discrete PID controller has to be extended into Z – transfer function (36) which is kind a filtered discrete PID controller.

( )

1 1 2 01 2 1 11

 -1 -2 -1 -2 -1 -1 -1 -2 -1 -2 12 12 1 2 01 2 1 z z 1 z z 1z 1 z z z z z *dd aa*

 

( ) (1 )(1 ) *Q z q q z q z Pz z z*

2 2

 -1 -2 -1 -2 -1 -1 -2 -1 -2 12 12 1 2 01 2 1 z z 1 z z 1z z z z z *dd aa b b qq q* (35)

(34)

(36)

*b b qq q* (37)

Fig. 17. Comparison to standard – first order nonlinear system

Graphic characteristics of the system are shown in Fig. 18.

Now, Diophantine equation (11) turns to (Eq. 37).

**6.2 Second order nonlinear oscillative system** 

closed loop is close to defined standard.



0

*yS, Standard*

(34).

should be solved.

0.5

1

Polynomial *D*(*z*-1) is stable with double pole equal to 0.3679.

Essential part of next three steps of the control algorithm is to solve Diophantine equation (11). In this particular example, (Eq. 31) is to be solved.

$$\left(\mathbf{1} + d\_1 \mathbf{z}^{\cdot 1} + d\_2 \mathbf{z}^{\cdot 2} = \left(\mathbf{1} + a\_1 \mathbf{z}^{\cdot 1}\right)\left(\mathbf{1} - \mathbf{z}^{\cdot 1}\right) + b\_1 \mathbf{z}^{\cdot 1}\left(q\_0 + q\_1 \mathbf{z}^{\cdot 1} + q\_2 \mathbf{z}^{\cdot 2}\right) \tag{31}$$

Method of undetermined coefficients is one possibility how to solve this equation. The initial matrix equation is

$$
\begin{bmatrix} b\_1 & 0 & 0 \\ 0 & b\_1 & 0 \\ 0 & 0 & b\_1 \end{bmatrix} \begin{bmatrix} q\_0 \\ q\_1 \\ q\_2 \end{bmatrix} = \begin{bmatrix} d\_1 - a\_1 + 1 \\ d\_2 + a\_2 \\ a\_2 \end{bmatrix} \tag{32}
$$

And the solution is

$$\begin{aligned} q\_0 &= \frac{d\_1 - d\_1 + 1}{b\_1} \\ q\_1 &= \frac{a\_1 + d\_2}{b\_1} \\ q\_2 &= 0 \end{aligned} \tag{33}$$

Now it is possible to perform control simulation. For defined reference variable course (combination of step functions and linearly descending and ascending functions), the control performance is shown in Fig. 16. Comparison of system output to standard (Eq. 29) is shown then in Fig. 17.

Fig. 16. Control performance – first order nonlinear system

Essential part of next three steps of the control algorithm is to solve Diophantine equation

Method of undetermined coefficients is one possibility how to solve this equation. The

0 0 1

1 0 11 1 1 22 12 2

 

1 1

*d a <sup>q</sup> <sup>b</sup>*

*a d <sup>q</sup> <sup>b</sup>*

1

Now it is possible to perform control simulation. For defined reference variable course (combination of step functions and linearly descending and ascending functions), the control performance is shown in Fig. 16. Comparison of system output to standard (Eq. 29)

0 50 100 150 200 250 300 350 400 450

0 50 100 150 200 250 300 350 400 450

*k*

*k*

0

1 1 2 1

*b q da b q da bq a*

0 0 0 0

0

1

2

*q*


12 1 1 01 2 1 z z 1 z 1z z z z *d d a b qq q* (31)

(32)

(33)

*r yS*

Polynomial *D*(*z*-1) is stable with double pole equal to 0.3679.

(11). In this particular example, (Eq. 31) is to be solved.

initial matrix equation is

And the solution is

is shown then in Fig. 17.


1


Fig. 16. Control performance – first order nonlinear system


0

*r, yS*

0.5

0

*u*

5

As shown in Figs. 16 and 17, control performance is stable and desired dynamics of the closed loop is close to defined standard.

Fig. 17. Comparison to standard – first order nonlinear system

#### **6.2 Second order nonlinear oscillative system**

Second demo system is structurally identical as the previous one (Fig. 11). Even the static element is the same. However, the dynamic system is defined now by differential equation (34).

$$
\ln y(t) + 5\frac{dy(t)}{dt} + 50\frac{d^2y(t)}{dt^2} = \mu \,\,\mathrm{(t)}\tag{34}
$$

Graphic characteristics of the system are shown in Fig. 18.

The system is controlled on equal terms as previous one. However, the neural model now has four inputs as original system is second order one. Thus, Diophantine equation (35) should be solved.

$$(\mathbf{1} + d\_1 \mathbf{z}^{\cdot 1} + d\_2 \mathbf{z}^{\cdot 2} = \left(\mathbf{1} + a\_1 \mathbf{z}^{\cdot 1} + a\_2 \mathbf{z}^{\cdot 2}\right) \left(\mathbf{1} - \mathbf{z}^{\cdot 1}\right) + \left(b\_1 \mathbf{z}^{\cdot 1} + b\_2 \mathbf{z}^{\cdot 2}\right) \left(q\_0 + q\_1 \mathbf{z}^{\cdot 1} + q\_2 \mathbf{z}^{\cdot 2}\right) \tag{35}$$

However, equation (35) is unsolvable. Thus, algorithm of discrete PID controller has to be extended into Z – transfer function (36) which is kind a filtered discrete PID controller.

$$\frac{Q(z^{-1})}{P(z^{-1})} = \frac{q\_0 + q\_1 z^{-1} + q\_2 z^{-2}}{(1 - z^{-1})(1 + \chi z^{-1})}\tag{36}$$

Now, Diophantine equation (11) turns to (Eq. 37).

$$\left(1+d\_1\mathbf{z}^{\cdot 1}+d\_2\mathbf{z}^{\cdot 2}\right) = \left(1+a\_1\mathbf{z}^{\cdot 1}+a\_2\mathbf{z}^{\cdot 2}\right)\left(1-\mathbf{z}^{\cdot 1}\right)\left(1+\mathbf{y}\mathbf{z}^{\cdot 1}\right) + \left(b\_1\mathbf{z}^{\cdot 1}+b\_2\mathbf{z}^{\cdot 2}\right)\left(q\_0+q\_1\mathbf{z}^{\cdot 1}+q\_2\mathbf{z}^{\cdot 2}\right) \tag{37}$$

Discrete PID Controller Tuning Using Piecewise-Linear Neural Network 209

0 50 100 150 200 250 300 350 400 450

*r yS*

*yS*

*Standard*

0 50 100 150 200 250 300 350 400 450

0 50 100 150 200 250 300 350 400 450

*k*

As shown in Figs. 19 and 20, control performance is stable and satisfying. On the other

Fig. 20. Comparison to standard – Second order nonlinear oscillative system

hand, oscillative nature of the controlled system is not fully stifled.

*k*

Fig. 19. Control performance – Second order nonlinear oscillative system

*k*


1




0

*yS, Standard*

0.5

1


0

*r, yS*

0.5

0

*u*

5

Step response of linear dynamical element (Eq. 34)

Nyquist plot of linear dynamical element (Eq. 34)

#### Fig. 18. Graphic characteristics of the second order nonlinear oscillative system

After applying of method of undetermined coefficients, solution can be obtained by solving of following matrix equation.

$$
\begin{vmatrix} b\_1 & 0 & 0 & 1 \\ b\_2 & b\_1 & 0 & a\_1 - 1 \\ 0 & b\_2 & b\_1 & a\_2 - a\_1 \\ 0 & 0 & b\_2 & -a\_2 \end{vmatrix} \begin{vmatrix} q\_0 \\ q\_1 \\ q\_2 \\ \mathcal{I} \end{vmatrix} = \begin{vmatrix} d\_1 - a\_1 + 1 \\ d\_2 + a\_1 - a\_2 \\ a\_2 \\ 0 \end{vmatrix} \tag{38}
$$

And the solution is

$$
\begin{bmatrix} q\_0 \\ q\_1 \\ q\_2 \\ \mathcal{I} \end{bmatrix} = \begin{bmatrix} b\_1 & 0 & 0 & 1 \\ b\_2 & b\_1 & 0 & a\_1 - 1 \\ 0 & b\_2 & b\_1 & a\_2 - a\_1 \\ 0 & 0 & b\_2 & -a\_2 \end{bmatrix}^{-1} \begin{bmatrix} d\_1 - a\_1 + 1 \\ d\_2 + a\_1 - a\_2 \\ a\_2 \\ 0 \end{bmatrix} \tag{39}
$$

Now it is possible to perform control simulation. For defined reference variable course, the control performance is shown in Fig. 19. Comparison of system output to standard (Eq. 29) is shown then in Fig. 20.

0 50 100

*t,* s


*Real axis*

Nyquist plot of linear dynamical element (Eq. 34)

After applying of method of undetermined coefficients, solution can be obtained by solving

00 1 1

1

00 1 1

1 0 11 21 1 1 212 21212 2

*b q da bb a q daa bbaaq a*

0 0 0

0 1 1 1 1 21 1 212 2 2121 2 2 2

*q b d a q bb a daa q bbaa a*

0 1

0 0 0

Now it is possible to perform control simulation. For defined reference variable course, the control performance is shown in Fig. 19. Comparison of system output to standard (Eq. 29)

Fig. 18. Graphic characteristics of the second order nonlinear oscillative system

2 2

*b a*

0

*b a*

0 1

Step response of linear dynamical element (Eq. 34)

0 = 0

= 1

= 0.01

= 0.1

(38)

(39)

0


0



*Imag. axis*

of following matrix equation.

And the solution is

is shown then in Fig. 20.

0.5

*yS*

1

1.5

Fig. 19. Control performance – Second order nonlinear oscillative system

Fig. 20. Comparison to standard – Second order nonlinear oscillative system

As shown in Figs. 19 and 20, control performance is stable and satisfying. On the other hand, oscillative nature of the controlled system is not fully stifled.

**Part 6** 

**Fractional Order PID Controllers** 
