Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

08 Implementation of Digital Controllers

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

08 Implementation of Digital Controllers

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Implementation of Digital Controllers

Introduction
One approach to designing a digital control system is to take an acceptable continuous-time controller for the system and
approximate it as a discrete-time controller. There are a number of approximations which can be used, two of which are
considered in this topic. It is very important to realize that the approach used in previous lectures for determining a discrete-
time transfer function of the controlled system cannot be used for the controller. The reason is that the controlled system is
actually modelled as a continuous system with ZOH; this is not applicable when modelling the controller which has no ZOH
and thus has a more complex input form.

General approach
One method of designing a digital sampled-data control system is first to design a satisfactory continuous system in the s-plane
and then convert this equivalent this into the equivalent discrete-time form in the z-plane as illustrated in figure 8.1.

CONTROLLER CONTROLLER PROCESS


PROCESS 𝑧 = 𝑒 𝑇𝑠
+ 𝐺𝑐 (𝑠) approx. 𝐺𝑝 (𝑠)
𝐺𝑝 (𝑠) + 𝐷(𝑧) ZOH
- -

Figure 8.1.

Given a performance specification for the required control system, the procedure is as follows:
1. Select a suitable sampling time T seconds.
2. Take account of the effect of the introduction of the ZOH.
3. Design a suitable controller 𝐺𝑐 (𝑠) to meet the specification.
4. Convert 𝐺𝑐 (𝑠) to a discrete form 𝐷(𝑧).
5. Express 𝐷(𝑧) as a digital algorithm.
6. Implement the algorithm and check results.

Choice of the sampling period T seconds


The sampling period T seconds is often a cost/speed/safety compromise which takes account of the following:

Nyquist sampling theorem requirements


2𝜋
It states that the sampling frequency, 𝜔𝑠 = , should be at least twice the highest frequency component, 𝜔𝑐 , in the sampled
𝑇
signal to avoid aliasing, i.e. 𝜔𝑠 ≥ 2𝜔𝑐 .

Rules of thumb
The following rules of thumb give a useful guide to suitable rates. Note that in some situations they may contradict and tria l
and error and experience will have to be used.
1. For underdamped systems, i.e. 𝜁 < 1, try sampling 8 to 12 times each damped oscillation period, e.g. put 𝜔𝑠 =
10𝜔𝑑 𝑟𝑎𝑑/𝑠.
2. For overdamped systems, i.e. 𝜁 > 1, try sampling 8 to 12 times in the 10% − 90% rise time of the step response.
3. Sample at 10 to 30 times the closed loop bandwidth 𝜔𝐵 𝑟𝑎𝑑/𝑠, e.g. put 𝜔𝑠 = 10𝜔𝐵 𝑟𝑎𝑑/𝑠.
4. Make T one tenth of the smallest significant time constant in the system.

Effect of introducing a ZOH


The transfer function of the ZOH is given as:
1−𝑒 −𝑇𝑠
𝐺0 (𝑠) = 𝑠

67
This introduces a delay into the system because
𝑇𝑠
1 𝑒 (− ⁄2) 1 1−𝑇𝑠⁄ 𝑇
𝐺0 (𝑠) = 𝑠 [1 − 𝑇𝑠 ] ≈ 𝑠 [1 − 1+𝑇𝑠⁄2] = 1+𝑇𝑠⁄ (1)
𝑒 ( ⁄2) 2 2

Thus, the effect of the ZOH is approximately that of a first-order system with time constant 𝑇/2 seconds. Hence, the
approximate form of the ZOH given in equation (1) can be combined with the process 𝐺𝑝 (𝑠) before a suitable continuous
1
controller is designed in step (3) of the above procedure. Some designers use the simpler form 1+𝑇𝑠⁄ leaving the T in the
2
numerator to be calculated in the overall gain value.

Transform methods of converting 𝑮𝒄 (𝒔) to 𝑫(𝒛)


When finding the discrete-time equivalent of a continuous process preceded by ZOH the approach adopted in previous topics
enables a table of z-transforms to be used. In contrast the problem here is to approximate a continuous transfer function 𝐺𝑐 (𝑠)
with a discrete time transfer function 𝐷(𝑧). A number of suitable approximations have been developed and two will be
considered here. Others are described and used in standard textbooks on digital control and in general the ones which
approximate best are the most complex. Many of these approximations including the two described here are based on
approximations to the power series expansion of an exponent thus:
(𝑇𝑠)2 (𝑇𝑠)3
𝑧 = 𝑒 𝑇𝑠 = 1 + 𝑇𝑠 + + +⋯
2! 3!

Backward difference method


The s-plane to z-plane mapping is approximated as:
1 1
𝑧 = 𝑒 𝑇𝑠 = −𝑇𝑠 ≈
𝑒 1−𝑇𝑠

Hence a first approximation to the mapping is:


1 𝑧−1 1−𝑧 −1
𝑧= i.e. 𝑠= = (2)
1−𝑇𝑠 𝑇𝑧 𝑇

Thus, given the continuous controller 𝐺𝑐 (𝑠), a digital equivalent is:


𝐷(𝑧) = 𝐺𝑐 (𝑠)| 1−𝑧−1 (3)
𝑠=
𝑇

Example 8.1
For a given sampled-data control system it has been determined that the following continuous-time controller will satisfy the
𝑠+𝑎
requirements: 𝐺𝑐 (𝑠) = 𝑠+𝑏

Then,
(1−𝑧 −1 )⁄
𝑠+𝑎 𝑇 +𝑎 1+𝑎𝑇−𝑧 −1 𝑈(𝑧)
𝐷 (𝑧 ) = | −1 = (1−𝑧 −1 )⁄
= = say
𝑠+𝑏 𝑠=1−𝑧 1+𝑏𝑇−𝑧 −1 𝐸(𝑧)
𝑇 𝑇+𝑏

Then,
(1 + 𝑏𝑇 − 𝑧 −1 )𝑈(𝑧) = (1 + 𝑎𝑇 − 𝑧 −1 )𝐸 (𝑧)

Take the inverse z-transform of each side and write 𝑢(𝑘) for 𝑢(𝑇), etc
(1 + 𝑏𝑇)𝑢(𝑘) − 𝑢(𝑘 − 1) = (1 + 𝑎𝑇)𝑒(𝑘) − 𝑒(𝑘 − 1)

and the required control algorithm is


1 1+𝑎𝑇 1
𝑢(𝑘) = 1+𝑏𝑇 𝑢(𝑘 − 1) + 1+𝑏𝑇 𝑒(𝑘) − 1+𝑏𝑇 𝑒(𝑘 − 1)

Advantages and disadvantages


The advantages of the backward difference method are:
1. It is easy to implement and does not entail factorizing 𝐺𝑐 (𝑠).
2. A stable 𝐺𝑐 (𝑠) produces a stable 𝐷(𝑧) since the method maps the LH half of the s-plane into a disc inside the unit circle
of the z-plane, as shown in figure 8.2.

68
Im Im Im

Re Re Re
0 0 0

Z-PLANE

S-PLANE BACKWARD DIFFERENCE BILINEAR TRANSFORM

Figure 8.2.

The disadvantage of the method is that the mapping approximation distorts the frequency and transient responses. This
distortion can be reduced by reducing T, i.e. by increasing 𝜔𝑠 .

Bilinear (or Tustin’s) transform method


A better approximation to the mapping is obtained as follows:
2 3
(𝑇𝑠⁄2) (𝑇𝑠⁄2)
𝑇𝑠
𝑒 ( ⁄2) 1+(𝑇𝑠⁄2)+ + +⋯ 1+(𝑇𝑠⁄ )
𝑧 = 𝑒 𝑇𝑠 = 𝑇𝑠 = 2! 3!
𝑇𝑠⁄ )2 (𝑇𝑠⁄ )3
≈ 1−(𝑇𝑠⁄2)
𝑒 −( ⁄2) ( 2
1−(𝑇𝑠⁄2)+ 2 − 2 +⋯
2! 3!

So, as a second approximation to the mapping we have


1+(𝑇𝑠⁄ ) 2 (𝑧−1) 2 (1−𝑧 −1 )
𝑧 = 1−(𝑇𝑠⁄2) i.e. 𝑠 = 𝑇 (𝑧+2) = 𝑇 (1+𝑧 −1) (4)
2

Then given 𝐺𝑐 (𝑠), an equivalent form is:


𝑠+𝑎
𝐷 (𝑧 ) = | 2(1−𝑧−1) (5)
𝑠+𝑏 𝑠=
𝑇(1+𝑧−1 )

Example 8.2
For a given sampled-data system it has been determined that the following continuous-time controller will satisfy the
𝑠+𝑎
requirements (same as example 8.1): 𝐺𝑐 (𝑠) = 𝑠+𝑏

Then,
2 (1−𝑧−1 )
+𝑎 2(1−𝑧−1 )+𝑎𝑇(1+𝑧 −1 )
𝑠+𝑎 𝑇(1+𝑧−1 ) 𝑈(𝑧)
𝐷(𝑧) = 𝑠+𝑏 | 2 (1−𝑧−1 ) = −1
2 (1−𝑧 )
= 2(1−𝑧−1 )+𝑏𝑇(1+𝑧−1 )
= 𝐸(𝑧)
say
𝑠= +𝑏
𝑇(1+𝑧−1 ) 𝑇(1+𝑧−1 )

Then,
[(2 + 𝑏𝑇) + (𝑏𝑇 − 2)𝑧 −1 ]𝑈(𝑧) = [(2 + 𝑎𝑇) + (𝑎𝑇 − 2)𝑧 −1 ]𝐸(𝑧)

Take the inverse z-transform of each side and write 𝑢(𝑘) for 𝑢(𝑇), etc.
(2 + 𝑏𝑇)𝑢(𝑘) + (𝑏𝑇 − 2)𝑢(𝑘 − 1) = (2 + 𝑎𝑇)𝑒(𝑘) + (𝑎𝑇 − 2)𝑒(𝑘 − 1)

and the required control algorithm is


2−𝑏𝑇 2+𝑎𝑇 2−𝑎𝑇
𝑢(𝑘) = 2+𝑏𝑇 𝑢(𝑘 − 1) + 2+𝑏𝑇 𝑒(𝑘) + 2+𝑏𝑇 𝑒(𝑘 − 1)

Advantages and disadvantages


This transform has the same advantages as the backward difference method. It maps the LH s-plane into the unit circle in the
z-plane as shown in figure 8.2.

69
Digital PID controllers
The general form of a continuous PID controller is
1
𝐺𝑐 (𝑠) = 𝑘𝑐 [1 + 𝑇 𝑠 + 𝑇𝐷 𝑠] (6)
𝐼

This can be approximated in digital form using either of the above methods.

Using backward difference method


𝑇 𝑇𝐷 (1−𝑧 −1 )
𝐷(𝑧) = 𝑘𝑐 [1 + + ]
𝑇𝐼(1−𝑧 −1 ) 𝑇

𝑘
i.e. 𝐷(𝑧) = 𝑘𝑃 + (1−𝑧𝐼−1) + 𝑘𝐷 (1 − 𝑧 −1 ) (7)
𝑘 𝑇 𝑘 𝑇
where 𝑘𝑃 = 𝑘𝑐 , 𝑘𝐼 = 𝑐 ⁄𝑇 , 𝑘𝐷 = 𝑐 𝐷⁄𝑇
𝐼

In the form of an algorithm


2
𝑘𝑃 (1−𝑧 −1 )+𝑘𝐼+𝑘𝐷 (1−𝑧 −1 ) (𝑘𝑃 +𝑘𝐼 +𝑘𝐷 )−(𝑘𝑃 +2𝑘𝐷 )𝑧 −1 +𝑘𝐷 𝑧 −2
𝐷 (𝑧 ) = (1−𝑧 −1 )
= (1−𝑧 −1 )
(8)

giving the general PID algorithm


𝑢(𝑘) = 𝑢(𝑘 − 1) + (𝑘𝑃 + 𝑘𝐼 + 𝑘𝐷 )𝑒(𝑘) − (𝑘𝑃 + 2𝑘𝐷 )𝑒(𝑘 − 1) + 𝑘𝐷 𝑢(𝑘 − 2) (9)

From this general form a PI controller (𝑘𝐷 = 0) can be obtained


(𝑘𝑃 +𝑘𝐼 )−𝑘𝑃 𝑧 −1 (𝑘𝑃 +𝑘𝐼 )𝑧−𝑘𝑃
𝐷 (𝑧 ) = (1−𝑧 −1 )
= (𝑧−1)

that is, of the form


𝑧−𝑎
𝐷 (𝑧 ) = 𝑘
𝑧−1

𝑘𝑃
where 𝑘 = (𝑘 𝑃 + 𝑘 𝐼 ) , 𝑎= ⁄(𝑘 + 𝑘 )
𝑃 𝐼

Using the bilinear transform


A better PID is obtained by using the bilinear transform on the integral part of equation 6. This is equivalent to evaluating the
integral using the trapezoidal approximation.
𝑇 (1+𝑧 −1 ) 𝑇𝐷 𝑇 2 𝑇𝐷 𝑈 ( 𝑧)
𝐷(𝑧) = 𝑘𝑐 [1 + + (1 − 𝑧 −1 )] = 𝑘𝑐 [1 + ( − 1) + (1 − 𝑧 −1 )] =
2𝑇𝐼 (1−𝑧 −1 ) 𝑇 2𝑇𝐼 1−𝑧 −1 𝑇 𝐸( 𝑧 )

𝑘′
𝐷(𝑧) = 𝑘 ′ 𝑃 + (1−𝑧𝐼−1) + 𝑘 ′ 𝐷 (1 − 𝑧 −1 )
𝑘𝑐 𝑇 𝑘𝑐 𝑇𝐷⁄
where 𝑘 ′ 𝑃 = 𝑘𝑐 (1 − 𝑇⁄2𝑇 ) , 𝑘′𝐼 = ⁄𝑇 , 𝑘′𝐷 = 𝑇
𝐼 𝐼

𝑧−𝑎
So, by this method also, the digital PI is of the form 𝐷(𝑧) = 𝑘 𝑧−1

Note that the PI algorithm will add a pole at 𝑧 = 1, thus improving steady-state accuracy as discussed in an earlier topic.

Working (please verify for accuracy)


𝑈(𝑧) 2𝑇𝑇𝐼 (1−𝑧−1 )+2𝑇−(1−𝑧−1 )𝑇+2𝑇𝐷 𝑇𝐼 (1−𝑧−1 )2
= 𝑘𝑐 [ ]
𝐸(𝑧) 2𝑇𝑇𝐼 (1−𝑧−1 )

2𝑇𝑇𝐼 (1 − 𝑧 −1 )𝑈(𝑧) = 𝑘𝑐 [2𝑇𝑇𝐼 (1 − 𝑧−1 ) + 2𝑇 − (1 − 𝑧−1 )𝑇 + 2𝑇𝐷 𝑇𝐼 (1 − 𝑧−1 )2]𝐸(𝑧)

2𝑇𝑇𝐼 (1 − 𝑧 −1 )𝑈(𝑧) = 𝑘𝑐 [2𝑇𝑇𝐼 (1 − 𝑧−1 ) + 2𝑇 − (1 − 𝑧−1 )𝑇 + 2𝑇𝐷 𝑇𝐼 (1 − 2𝑧−1 + 𝑧−2 )]𝐸(𝑧)

2𝑇𝑇𝐼 𝑢(𝑘) − 2𝑇𝑇𝐼 𝑢(𝑘 − 1) = 𝑘𝑐 (2𝑇𝑇𝐼 + 2𝑇 − 𝑇 + 2𝑇𝐷 𝑇𝐼 )𝑒(𝑘) + 𝑘𝑐 (2𝑇𝑇𝐼 + 𝑇 + 4𝑇𝐷 𝑇𝐼 )𝑒(𝑘 − 2) + 2𝑘𝑐 𝑇𝐷 𝑇𝐼 𝑒(𝑘 − 2)
𝑘𝑐 (2𝑇𝑇𝐼 +𝑇+2𝑇𝐷 𝑇𝐼) 𝑘𝑐 (2𝑇𝑇𝐼+𝑇+4𝑇𝐷𝑇𝐼 ) 𝑘𝑐 𝑇𝐷
𝑢 (𝑘 ) = 𝑢 (𝑘 − 1 ) + 𝑒(𝑘) + 𝑒(𝑘 − 2) + 𝑒(𝑘 − 2)
2𝑇𝑇𝐼 2𝑇𝑇𝐼 𝑇

70
Implementation of the digital PID
Whatever digital approximation is used the following piece of code shows the basic form of the program which implements
the algorithm. The basic structure is also common to any discrete-time controller although the details may change.

{Initialize variables}
kp := <kp>
ki := <kI>
kd := <kD>
r := <set point>

error_last := <previous error> {normally initialised to 0.0}


error_last_last := <previous error but one> {normally initialised to 0.0}
output_last := <previous output> {normally initialised to 0.0}

{The following continuous loop will be repeated forever or until the controller is
stopped}

WHILE true DO
y := ADCin {read y from the system}
error := r-y {calculate error}
u := output_last+(kp + ki + kd)*e-(kp +2*kd)*error_last+kd*error_last_last
{calculate the control actions, change this expression for another
algorithm}
DAC(u) {output u to the system}
error_last_last := error_last {save previous error for the next cycle}
error_last := e {save present error for the next cycle}
output_last := u {save present output for the next cycle}
delay() {delay until next sample period}
END WHILE

Chapter 8 Tutorial Questions


1. Turn the analogue controller
1  0.1s
G c (s) 
1  0.4s
into a digital algorithm using
 T  0.1 0.1 0.4 
(i) backward difference method u(k)  T  0.4 e(k)  T  0.4 e(k  1)  T  0.4 u(k  1)
 
 T  0.2 T - 0.2 T_0.8 
(ii) the bilinear transform u(k)  T  0.8 e(k)  T  0.8 e(k  1)  T  0.8 u(k  1)
 

2. The system shown below is to have dominant poles with a damping ratio of 0.5 and a settling time of 2 seconds:

+ 1
Gc(s)
- s(s  2)

(i) What are the corresponding values of n and d? [ 4 rad/s 3.464 rad/s]
(ii) To turn this system into a discrete one, choose a sampling period which will sample 10 times each damped
period and thus give the corresponding ZOH approximation.
 2 
T  0.18 seconds, G 0 (s)  s  11 
 
20(s  2)
(iii) A suitable continuous controller is then G c (s)  . Turn this into an equivalent digital algorithm
(s  7)
using the backward difference method. [ u(k)  12.04e(k)  8.85e(k  1)  0.44u(k  1) ]
(iv) Determine the resultant steady-state system error for unit step and ramp inputs. [ 0; 0.35]

71

You might also like