Файл: Microcontroller based applied digital control (D. Ibrahim, 2006).pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 14.06.2025

Просмотров: 3271

Скачиваний: 1

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

PARALLEL REALIZATION

249

1

2

ek

+

z−1

0.6

+

z−1

z−1

4

+

uk

−0.4

−0.1

−0.3

Figure 10.9 Cascaded realization for Example 10.4

10.3 PARALLEL REALIZATION

The parallel realization also avoids the coefficient sensitivity problem. In this method the transfer function is factored and written as a sum of first-order and second-order transfer functions:

D(z) = α0 + D1(z) + D2(z) + · · · + Dm (z), 1 < m < n.

First-order transfer functions are of the form

D1(z) =

α

(10.21)

,

1 + β z−1

as shown in Figure 10.10. With reference to this figure, we can write

rk

= ek − βrk−1

(10.22)

and

uk = αrk .

(10.23)

Second-order transfer functions are of the form

D

2

(z)

=

a1 + a2z−1

,

(10.24)

1 + b1z−1 + b2z−2

as shown in Figure 10.11. With reference to this figure, we can write

rk

= ek − b1rk−1 − b2rk−2

(10.25)

and

uk

= a0rk + a1rk−1 + rk−2.

(10.26)

ek

+

rk

α

uk

−β

z−1

rk−1

Figure 10.10 First-order element for parallel realization


250 CONTROLLER REALIZATION

a0

a1

ek

+

+

uk

z−1

z−1

rk

rk−1

rk−2

−b1

−b2

Figure 10.11 Second-order element for parallel realization

Example 10.5

The transfer function of a digital controller is given by

D(z)

=

(1 + z−1)(1 + 2z−1)

.

(1

+

3z

1)(1

+

4z

1)

Realize this transfer function using first-order parallel transfer functions.

Solution

The controller transfer function can be factorized as follows:

D(z)

=

(1 + z−1)(1 + 2z−1)

A

B

C.

= 1

3z

1 +

1

4z

1 +

(1

+

3z

1)(1

+

4z

1)

+

+

From the partial fraction expansion, we obtain A = − 23 , B = 32 and C = 16 . Thus,

D(z) = −

2

+

3

+

1

.

3(1

+

3z

1)

2(1

+

4z

1)

6

With reference to Figure 10.10, the controller implementation is shown in Figure 10.12.

10.4 PID CONTROLLER IMPLEMENTATIONS

PID controllers are very important in many process control applications. In this section we shall look at the realization of this type of controller.

1/6

ek

+

−2/3

+

uk

−3 z−1

+ 3/2

− 4 z−1

Figure 10.12 Realization for Example 10.4


PID CONTROLLER IMPLEMENTATIONS

251

wk

Kp

ek

α

pk

+

pk−1

z−1

+

uk

qk

ek

+

β

z−1 −1

ek−1

α = KpT/Ti β = KpTD/T

Figure 10.13 PID controller as a parallel structure

The z-transform of the PID controller was derived in (9.19), and is reproduced here for convenience:

K T

K T (1

z−1)

D(z) = K p +

p

+

p d

.

(10.27)

T (1

z

1)

T

i

As shown in Figure 10.13, this transfer function may be implemented as a parallel structure by summing the proportional, integral and derivative terms.

With reference to Figure 10.13 we can write the following difference equations: for the proportional section,

wk = K p ek .

(10.28)

for the integral section,

pk = αek + pk−1;

(10.29)

and for the derivative section,

qk = β(ek − ek−1).

(10.30)

The output is given by

uk = wk + pk + qk .

(10.31)

An alternative implementation of the PID would be to find a second order transfer function for (10.27) and then use the direct structure to implement it. Equation (10.27) can be written as

D(z) = K p (1 − z−1) + K p T / Ti + (K p Td / T )(1 − z−1)2

1 − z−1

=

K p − K p z−1 + K p T / Ti + K p Td / T + (K p Td / T )z−2 − 2(K p Td / T )z−1

1

z

1

=

K p + K p T / Ti + K p Td / T − (K p + 2K p Td / T )z−1 + (K p Td / T )z−2

1

z

1


252 CONTROLLER REALIZATION

ek +

−1

a0 = Kp(1+ T/Ti+TD/T) a1 = −Kp(1+ 2TD/T) a2 = KpTD/T

rk

a0

+

uk

z−1

rk−1 a1

z−1

a2

rk−2

Figure 10.14 PID implementation as a direct canonical structure

which is in the form

a0 + a1z−1 + a2z−2

,

(10.32)

1 + b1z−1 + b2z−2

where

a0 = K p (1 + T / Ti + Td / T ), a1 = −K p (1 + 2Td / T ), a2 = K p Td / T

and

b1 = −1, b2 = 0.

Figure 10.14 shows the implementation of the PID controller as a second-order direct canonical structure.

The velocity form of the PID controller is used frequently in practice and the difference equation for this controller was derived in Chapter 9 – see (9.20). Considering this equation again and replacing kT simply by subscript k, we can write

uk = uk−1 + K p [ek − ek−1] +

K p T

ek +

K p Td

[ek − 2ek−1 − ek−2

]

(10.33)

Ti

T

or

Ti

+

T

ek −

K p

+

T

ek−1 +

T

ek−2.

uk = uk−1 + K p +

K p T

K p Td

2K p Td

K p Td

Alternatively, we can write this in a simpler form as

where

uk

= uk−1 + aek + bek−1 + cek−2

(10.34)

a = K p +

K p T

+

K p Td

,

Ti

T

b = − K p +

T

,

2K p Td

c = K p Td .

T


MICROCONTROLLER IMPLEMENTATIONS

253

By taking the z-transform of (10.34) we obtain

U (z)

=

z−1U (z)

+

a E (z)

+

bz−1 E (z)

+

cz−2 E (z)

or

D(z)

=

U (z)

=

a + bz−1 + cz−2

.

(10.35)

E (z)

1

z

1

Equation (10.35) can easily be implemented using a direct realization. Notice that if only proportional plus integral (PI) action is required, the derivative constant Td can be set to zero and we get the PI equation

D(z)

U (z)

a + bz−1

,

(10.36)

= E (z)

=

1

z

1

with

a = K p + K p T , Ti

b = K p .

Equation (10.36) can easily be implemented as a first-order transfer function.

10.5 MICROCONTROLLER IMPLEMENTATIONS

The final stage of a digital control system design is the implementation of the controller algorithm (set of difference equations) on a digital computer. In this section, we shall explore the implementation of digital controller algorithms on PIC microcontrollers. The PIC 16F877 microcontroller will be used in the examples since this microcontroller has a built-in A/D converter and a reasonable amount of program memory and data memory. There are many other microcontrollers in the PIC family with built-in A/D converters, and in general any of these can be used since the operation of microcontrollers in the PIC family with similar features is identical.

Microcontrollers have traditionally been programmed using the assembly language of the target hardware. Assembly language has several important disadvantages and is currently less popular than it used to be. One important disadvantage is that the code generated using the assembly language can only run on the specific target hardware. For example, the assembly program developed for a PIC microcontroller cannot be used, say, on an Intel 8051 microcontroller. Assembly language programs also tend to be more difficult to develop, test and maintain.

In this section, the Hi-Tech PICC language as described in Chapter 4 is used in the implementation of the algorithms. As described in Section 1.6 there are several methods that can be used to implement the controller algorithm. One of the most common, which has the advantage of accurate implementation, is the use of a timer interrupt to generate the required loop delay (or the sampling interval). In this method the software consists of two parts: the main program and the interrupt service routine. As shown in Figure 10.15(a) Figure 10.15, in the main program various variables, as well as the A/D converter and the timer interrupt mechanism, are initialized. The timer is set to interrupt at an interval equivalent to the sampling interval of the required digital controller. The main program then enters a loop waiting for the timer interrupts to occur. Whenever a timer interrupt occurs the program jumps the interrupt service