DISCRETE-TIME SYSTEMS AND DIGITAL CONTROLLERS
In practice controllers are nowadays almost exclusively implemented digitally. This means that the controller operates in discrete time, although the controlled systems usually operate in continuous time. Therefore, the digital controller has to be connected to the system by interfaces which: transform the continuous-time system output y(t) to a discrete sequence {y k } which the digital controller can process, and transform the digital control sequence {u k } to a continuoustime control signal u(t) sent to the system. 2
A typical digital control system is shown in the figure. r k e k u k u H (t) G d D/A + H u(t) G p y(t) A/D y k Here: G p is the system to be controlled. G d is the digital controller. The block A/D transforms the continuous-time (analog) system output y(t) to a discrete-time (digital) sequence y k, k = 0, 1, 2,.... The block D/A transforms the (digital) control sequence u k, k = 0, 1, 2,... to a continuous-time (analog) control signal u H (t). H is a filter to smooth out discontinuities due from the digital-to -analog transformation. 3
The system output y(t) has first to be sampled at discrete time instants kh in an A/D (analog-to-digital) transformer to generate a discrete sequence, y k = y(kh), k = 0, 1, 2,... Here h is the sampling time. Sampling of a continuous-time signal implies loss of information, since several analog signals can give rise to the same discrete-time signal Example: Sampling of three different sinusoidal signal give the same discrete sequence ( o ). 4
Therefore, an analog low-pass prefilter is used to filter out high frequency components before sampling: y(t) y f (t) F A/D y k The digital controller G d then takes the sequence e k = r k y k, k = 0, 1, 2,... as its input to generate a discretetime control sequence u k, k = 0, 1, 2,.... The discrete-time control sequence u k is then transformed to a continuous-time control signal u H (t) using a D/A (digital-to-analog) transformer. Typically the D/A transformer generates a piecewise constant control signal given by u H (t) = u k, kh t < kh + h Finally, the discontinuities in u H (t) are smoothed out by a continuous-time filter H. See figure: 5
u k u H (t) D/A H u(t) H t 6
Digital controllers The continuous-time standard P-, I-, PI- and PID-controllers can be generalized in a straightforward way to obtain their discrete-time counterparts: Discrete-time (digital) P-controller: Digital I-controller: Digital PID-controller: u k = K p e k + K i u k = K p e k u k = K i k n=1 k e n n=1 e n + K d [e k e k 1 ] The digital PID-controller is usually implemented using the so-called velocity form, u k = u k 1 +K p [e k e k 1 ]+K i e k +K d [e k 2e k 1 + e k 2 ] which is obtained by subtracting u k 1 from u k. An advantage of the velocity form is that there is no need to keep track of the sum. 7
Discrete-time systems In order to study systems under digital control we should describe how the sampled, discrete-time, system output y k depends on the discrete-time input u k. The discrete-time counterpart of continuous-time systems described by differential equations are systems described by difference equations. A first-order discrete-time system is described by the difference equation y k+1 + ay k = bu k Similarly, a second-order discrete-time system is described by the difference equation y k+2 + a 1 y k+1 + a 2 y k = b 1 u k+1 + b 2 u k Remark: Observe that the systems above are discrete-time systems, but not digital, as the signals real numbers. A digital system has the additional property that the signals and parameters are represented digitally. 8
Discrete-time transfer functions The theory for continuous-time dynamical systems has a counterpart for discrete-time systems. In particular, instead of the differential operator, we can for discrete-time systems define the forward shift operator q such that qy k = y k+1 Then the first-order system takes the form y k+1 + ay k = bu k qy k + ay k = bu k or y k = b q + a u k Here G[q] = b q + a is the discrete-time transfer function. 9
Similarly, the second-order system y k+2 + a 1 y k+1 + a 2 y k = b 1 u k+1 + b 2 u k can be written as q 2 y k + a 1 qy k + a 2 y k = b 1 qu k + b 2 u k or where y k = G[q]u k b 1 q + b 2 G[q] = q 2 + a 1 q + a 2 10
Response of discrete-time systems In analogy with continuous-time systems, the response of a discrete-time systems is obtained by solving the difference equation. Example - First-order system As a simple example, we can determine the output of the first-order system y k+1 + ay k = bu k By applying the system equation recursively to compute y 1, y 2,..., y k we obtain y k = ( a) k y 0 + k 1 ( a) k n 1 bu n n=0 In particular, the step response for the input u k = u step with initial condition y 0 = 0 is y k = k 1 n=0 ( a) k n 1 b u step = ( 1 a + ( a) 2 + ( a) 3 + + ( a) k 1) b u step = 1 + ( a)k 1 + a b u step The response of second-order and higher-order discretetime systems can be determined in a way similar to the continuous-time case. 11
Stability The above example shows that the output of the firstorder system remains bounded for bounded inputs if and only if a < 1. Equivalently, the pole q p = a of the transfer function G[q] = b q + a should be less than 1 in magnitude. This feature generalizes to higher-order discrete-time systems, and we have: A discrete-time system is stable if and only if all the poles q p,i of its transfer function G[p] (i.e., the zeros of its denominator) satisfy q p,i < 1. Observe that for second and higher order systems, the poles may be complex numbers, and q p,i is then the absolute value of this complex number. 12
Backward shift operator An alternative to the forward shift operator q is to use the backward shift operator q 1, such that Then the first-order system or, equivalently, takes the form q 1 y k = y k 1 y k+1 + ay k = bu k y k + ay k 1 = bu k 1 y k + aq 1 y k = bq 1 u k 1 or y k = bq 1 1 + aq 1u k = G[q]u k where the discrete transfer function G[q] is given by G[q] = bq 1 1 + aq 1 Expressing G[q] in terms of q (instead of q 1 ), we have G[q] = b q + a which is the same expression as before. 13
Construction of discrete-time models for continuous-time systems When dealing with digital controller, an important question is to construct a discrete-time model which relates the inputs, u(t) and d(t), to the sampled outputs y k = y(kh) of a system described by a differential equation. Example consider the first-order system dy(t) dt + ay(t) = bu(t) + cd(t) A simple way to construct an approximate discrete-time model is to introduce the finite-difference approximation dy(t) dt 1 [y(t + h) y(t)] h Using this approximation at time t = kh would give the discrete-time approximation 1 [y(kh + h) y(kh)] + ay(kh) = bu(kh) + cd(kh) h or y(kh + h) + (ha 1)y(kh) = hbu(kh) + hcd(kh) 14
Second derivative: similarly, a finite-difference approximation of a second derivative is given by dy 2 (t) dt 2 1 h y(t + h) y(t) h y(t) y(t h) h = 1 [y(t + h) 2y(t) + y(t h)] h2 Problems with finite-difference approximations of the derivatives: the resulting discrete-time model is often not very accurate. the discrete-time model may be unstable even though the original system is stable, or vice versa. For example, in the above first-order example, the continuoustime system is stable if a > 0, but the discrete-time model will be unstable if the sampling time is too long, so that ha 1 > 1 (or h > 2/a) holds. 15
Tustin s method (bilinear transform) A more accurate way to discretize a continuous-time system is to use the trapezoidal rule. Again, we illustrate the method on the first-order system dy(t) dt + ay(t) = bu(t) (omitting d(t) for simplicity). Given y(kh) at time t = kh, we obtain y(kh + h) by integration: y(kh + h) = y(kh) + kh+h kh [ ay(τ) + bu(τ)] dτ Here we can approximate the integral using the trapezoidal rule: t 2 t 1 f(τ)dτ t 2 t 1 2 [f(t 2 ) + f(t 1 )] 16
This gives: I = kh+h kh h 2 [ ay(τ) + bu(τ)] dτ [ ay(kh) + b(kh) ay(kh + h) + b(kh + h)] Introducing the approximation into the expression for y(kh): y(kh + h) = y(kh) + h [ ay(kh) + bu(kh) 2 ay(kh + h) + bu(kh + h)] Solving for y(kh + h): y(kh+h) = 1 ah/2 1 + ah/2 or where bh/2 y(kh)+ [u(kh + h) + u(kh)] 1 + ah/2 y k+1 + a d y k = b d u k+1 + b d u k a d = 1 ah/2 1 + ah/2, b d = bh/2 1 + ah/2 17
There is an interesting and important relation between the transfer function of the continuous-time system and the discrete-time transfer function of the discretized system obtain by the trapezoidal approximation. Recalling the transfer function of a discrete-time system, the discrete-time system can be expressed as y(kh) = G[q] u(kh) where the transfer function is given by G[q] = b dq + b d q + a d bh/2 = 1 + ah/2 q + 1 q 1 ah/2 1+ah/2 This can be simplified to: G[q] = b 2 q 1 h q+1 + a Recalling that the original continuous-time system has the transfer function G(p) = b p + a we see that G[q] and G(p) are related by according to: G[q] = G(p) p= 2 h q 1 q+1 18
This property can be generalized, so that approximating the solution of a linear differential equation by the trapezoidal rule is equivalent to substituting the differential operator p in the continuous-time transfer function by p = 2 q 1 h q + 1 to obtain the corresponding discrete-time transfer function. This transformation is known as the Tustin transform or the bilinear transform. An important and valuable property of the transformation is that it preserves stability properties. We have: The discrete-time system G[q] = G(p) p= 2 h q 1 q+1 is stable if and only if the continuous-time system G(p) is stable 19