Professional Documents
Culture Documents
Development of Discrete-
Time Models
Digital control systems inherently involve the processing of sampled signals. Thus,
unless the sampling period is very small, it is more appropriate and convenient to
perform the design and analysis of digital control systems using discrete-time models
rather than continuous-time models. In this chapter we present several approaches
for converting dynamic models based on differential equations to discrete-time
models described by difference equations. We also consider a method for developing
discrete-time models from experimental data. This method is analogous to the
empirical approach for developing continuous-time models that was discussed in
Chapter 7.
A digital computer by its very nature deals internally with discrete data or numerical
values of functions. To perform analytical operations such as differentiation and
integration, numerical approximations must be utilized. Fortunately, formulas for
such approximations are well established in the field of numerical analysis [1].
One way of converting continuous-time models to discrete-time form is to use
finite difference techniques. In general, a nonlinear differential equation,
dy(t)
dt
= fey, x) (23-1 )
where y is the output variable and x is the input variable, can be numerically
integrated (although with some error) by introducing a finite difference approxi-
mation for the derivative. For example, the first-order, backward difference ap-
proximation to the derivative at time t = 11M is [1]
dy = y" - Yl/-l
dt - M
where 6.t is the integration interval that is specified by the user, y" is the value
of yet) at t = 116.t and Yl/-l denotes the value at the previous sampling instan1
t = (11-1)6.t. Substituting (23-2) into (23-1) and evaluating function fey, x) at the
previous values of y and x (i.e., y,,-1 and X,,-I) gives
y" - f(y"-b
MYl/-l == X,,-I)
549
550 DEVELOPMENT OF DISCRETE-TIME MODELS
or
(23-4)
Equation 23-4 is a first-order difference equation that can be used to predict
the value of Y at time step n based on information at the previous time step (n-1),
namely, YII_I and f(YII-b XII-I)' This type of expression is called a recurrence
relation. It can be used to numerically integrate Eq. 23-1 by calculating y" for
n = 0,1,2,3, ... starting from known initial conditions, y(O) and x(O). In general,
the resulting numerical solution, {Y,,, n = 1, 2, 3, ... }, becomes more accurate
and approaches the correct solution yet) as t1t decreases. However, for extremely
small values of t1t, computer roundoff errors can be a significant source of error
[1,2].
Equation 23-4 is the simplest numerical integration scheme and is referred to
as Euler integration. The algorithm for Euler integration can also be expressed in
the analogous form,
(23-5)
that results from using a forward difference approximation to the derivative rather
than the backward difference in Eqn. (23-3):
dy = Y"+l - YII
(23-6)
dt - D.t
Equation 23-4 can then be derived from Eq. 23-3 by evaluating f(y, x) at the nth
time step, followed by shifting all indices back one step. The forward difference
derivation is the standard approach presented in numerical analysis books
(e.g., [1]).
An important application of Eq. 23-4 in digital control is that it can be used
as an approximate process model if the input and output signals are sampled. In
this case, t::..t is interpreted as the sampling period rather than the integration
interval.
EXAMPLE 23.1
or equivalently,
dy (t) 1 1
dt --
T
yet) + -'T x(t) (23-8)
Solution
Note that if the initial condition is zero, that is, if y(O) = 0, these equations
correspond to the first-order transfer function with unity gain:
yes) = _1 (23-9)
Xes) TS + 1
Using a backward difference approximation for the derivative and substitutingy"_1
for yet) and X,,_I for x(t) in Eq. 23-8, we obtain
T(y" - YII-l)
t1t + y,,-I = XII-I
23.1 Finite Difference Models 551
Table 23.1 The Elfect of Integration Interval on the Step Response of a First-Order
Model (,- = 1)
ilt == 0.25
10.990
.900
.968
.684
.997
00.410
0.651
0.879
0.958
0.985
0.995
!:::.t 0.1 0.438
Numerical solution, y" Exact
solution
!:::.t = 0.01 yet)
o o
0.395 0.393
0.634 0.632
0.866 0.865
0.951 0.951
0.982 0.982
0.993 0.993
Rearranging gives
(23-10)
Yll = (1 - M)
'T
YIl-\ + M Xll-l
"i
The new value Yll is a weighted sum of the previous value YIl-l and the previous
input, XI1-].Note that the digital filter derived in Chapter 22 differs from (23-10)
because f is evaluated at the nth time step. This is because the filter is employed
for smoothing the current measurement whereas (23-10) is used for prediction.
As D.t becomes infinitesimally small, the finite difference relation in Eq. 23-10
becomes a better approximation of the differential equation in (23-8). If Eq. 23-
10 is used to numerically integrate (23-8) to t = 5 (nearly steady state) for a unit
step change in x(t), the integration error becomes substantial as D.t becomes quite
large compared to,-, the time constant. Table 23.1 compares the analytical solution
of (23-8) with the numerical solution obtained using (23-10) for T = 1 and various
integration intervals.
EXAMPLE 23.2
(23-11)
Solution
The second-order derivative at the nth time step can be approximated by the finite
difference approximation [1]:
2YIl-l + YIl-2
(23-12)
(D.tf
552 DEVELOPMENT OF DISCRETE-TIME MODELS
Substituting (23-12) and (23-2) into (23-11), replacing Y and x by Y 1/-1 and XI/-I>
(23-13)
1 + al]
[ (M)2 t::.t Yn = [2(M)2 + a]] -
t::.t ao YI/-I - 1 YI/-2
(t::.tf + XI/-l
All of the terms on the right side of (23-13) involve past information. Alternative
discrete-time models can be obtained by other finite difference approximations, as
discussed by Davis [1].
(23-15)
Y(s) = s +1liT [l -s- +
T x(O) y(O) ]
Equation 23-16 is valid for all values of t. Thus, after one sampling period,
t = t::.t, and we have
(23-17)
Next, we can generalize the analysis by considering the time interval, (n-1) t::.t
to nt::.t. For an initial condition y[(n-1)M] and a constant input, x(t) =
x[(n-1) t::.t] for (n-1) M s
t < nt::.t, the analytical solution to (23-7) is
Note that the exponential terms are the same as for Eq. 23-17. Equation 23-18 can
be written more compactly as
Yl/ - e -MI, YI/_] + (1 - e -MI.). XI/_] (23-19)
Equation 23-19 is the exact solution to (23-7) providing that x(t) is constant over
each sampling period of length t::.t. If Eq. 23-19 had been used in Example 23.1 to
obtain the step response, the analytical solution y(t) would have resulted for any
sampling period (no integration error for the constant input).
552 DEVELOPMENT OF DISCRETE-TIME MODELS
Substituting (23-12) and (23-2) into (23-11), replacing Y and x by YIl-l and Xll-],
and rearranging yields
(23-13)
[ (~t)2
1 + ~t
a] ] Yll = [2(~t)2 + ~t
a]] - ao Yll-] - 1
(M)" YIl-2 + Xll-l
All of the terms on the right side of (23-13) involve past information. Alternative
discrete-time models can be obtained by other finite difference approximations, as
discussed by Davis [1].
(23-15)
yes) = _1_
s+ liT T S
[~X_-(_O) + Y(O)]
Equation 23-16 is valid for all values of t. Thus, after one sampling period,
t = ~t, and we have
(23-17)
Next, we can generalize the analysis by considering the time interval, (n-1) ~t
to n~t. For an initial condition y[(n-1)~t] and a constant input, x(t) =
x[(n -1) M] for (n -1) M:s t < n~t, the analytical solution to (23-7) is
Note that the exponential terms are the same as for Eq. 23-17. Equation 23-18 can
be written more compactly as
Equation 23-19 is the exact solution to (23-7) providing that x(t) is constant over
each sampling period of length ~t. If Eq. 23-19 had been used in Example 23.1 to
obtain the step response, the analytical solution yet) would have resulted for any
sampling period (no integration error for the constant input).
23.4 Fitting Discrete-Time Equations to Process Data 553
(23-24)
(23-25)
In Eq. 23-21 the new value of Y depends on the values of Y and x at the two previous
sampling instants; hence it is a second-order difference equation. If T2 = Ta = 0
and K = 1 in Eq. 23-21 through 23-25, the first-order difference equation in (23-
19) results.
The steady-state gain of the second-order difference equation model can be
found by considering steady-state conditions. Let x denote a step change in x and
y the resulting steady-state change in y. At steady state, Xn-] = Xn-Z = x and
Yn = YIl-j = Yn-Z = Y. Substituting these values into (23-21) gives
y + a[ y + a2Y = bjx + b2x (23-26)
Since Y and x are deviation variables, the steady-state gain is simply ylx, the steady-
state change in Y divided by the steady-state change in x. Rearranging (23-26) gives
. y b[ + bo
Gam = - = ~ (23-27)
x 1+ aj + az
Substitution of Eqs. (23-22) through (23-25) into (23-27) gives, Gain K. This
same result can be obtained by letting s --7 0 in (23-20). Thus the transfer function
model in (23-20) and the corresponding discrete-time model in (23-21) have the
same steady-state gains. This result also occurs for all other transfer function
models.
Sets of differential equations can be converted to a discrete-time, difference
equation model by using a technique referred to as the transition matrix approach
[2]. General results for converting second-order and third-order differential equa-
tions (transfer functions) to difference equations have been derived by Neuman
and Baradello [3] and are presented in Chapter 24.
where Yn is the nth data point, Yn is the corresponding prediction made with
measured values of x and Y up to and including time (n -1), and r is the number
of data points.
EXAMPLE 23.3
Consider the step response data {Yn} in Table 23.2 which were obtained from
Example 7.3 and Fig. 7.8. At t = 0 a unit step change in x occurs, but the first
output change is not observed until the next sampling instant. Fit the second-order
difference equation (23-21) to the above input-output data using 6.t = 1. Compare
0 76 -
Table 23.2
x" = O.
0.833
0.058
0.692
0.217
0.600
0.772
0.888
0.360
0.488
0987154310
Step 0y"Response Data"
620.925
110249853
aM = 1; for n < 0, y" = O. n
and
011
0.058
0.217
0.360
0.888
0.833
0.772
0.692
0.600
0.925
Yn
0.488
Data 10.833
0.058
0.217
0,,-l
0.772
0.692
0.888
0.600
0.488
0.360
YXn-l 10
Yll-2
Matrix
X1/-2
for Estimating Fitting 555
Parameters
23.4 in Eq. 23-21
Discrete-Time Equations to Process Data
these results with models obtained in Example 7.3 using Harriott's method and
nonlinear regression.
Solution
For the linear regression problem, there are four independent variables (YII- [, YII-2,
XII-I> XII-2),one dependent variable (YII)' and four unknown parameters (a;, a2,
bj, b2). We structure the data as shown in Table 23.3 and, using the least squares
equations, solve four linear algebraic equations in four unknowns.
Table 23.4 compares the parameter values obtained by the three different
approaches. The "Linear Regression" results were obtained by fitting a discrete-
time model so as to minimize Eq. 23-30. The results labeled "Harriott's method"
and "Nonlinear Regression" were obtained by fitting a continuous-time model
(second-order, overdamped) to the data to obtain time constants T) and T2 (see
Example 7.3). In both cases, the model gain K was set equal to unity because the
step responses were normalized. The continuous-time model was then converted
to the corresponding discrete-time model via Eqs. 23-21 to 23-25.
The parameters obtained from linear regression in Table 23.4 are similar to
the results for the other two methods but the differences are noteworthy. Using
linear regression, four parameters were fit independently; with nonlinear regression
only two parameters, TI and T2, were estimated. Because the model gain was fixed
at unity for nonlinear regression, this optimization method contained an implicit
constraint. No such constraint was included in the linear regression approach.
Consequently, the calculated model gain for linear regression, K = 1.168, is about
17% too large. This value was calculated from Eq. 23-27.
Linear regression would yield model parameters closer to those for continuous
time, nonlinear regression if 10 to 20 additional data points at or near the steady
state were added to the data set. Alternatively, the values of a;, a2, b), and b2
23.5
"y, exact response for continuous system; Y L, linear regression; .v H' Harriott's method; ,I's. nonlinear
regression.
could be optimized subject to the constraint that the process gain in Eq. 23-27 is
unity; however, this would require a modified linear regression approach.
Table 23.5 compares the simulated responses for the three empirical models.
Linear regression gives the best predictions because it fits the most parameters.
Most of the differences among the models occur for the initial response en < 2).
In this particular example, it is difficult to distinguish graphically among the three
models and the step response data for n > 2.
The above example has shown how we can fit a second-order difference equa-
tion model to data directly. The linear regression approach can also be used for
higher-order models, provided that the parameters still appear linearly in the model.
It is important to note that the calculated parameter values depend on the sampling
period that is selected, which in turn may be determined by the frequency of
I:::.t
SUMMARY
REFERENCES
1. Davis, M. E., Numerical Methods and Modeling for Chemical Engineers, Wiley, New York, 1984,
Chapter 2.
2. Cadzow, J. A., and H. R. Martens, Discrete-Time and Computer Control Systems, Prentice-Hall,
Englewood Cliffs, NJ, 1970.
3. Neuman, C. P., and C. S. Baradello, Digital Transfer Functions for Microcomputer Control. IEEE
Trans. Systems. Man, Cybernetics SMC-9 (12), 856 (1979).
EXERCISES
23.1. Consider the first-order differential equation
dy
5 dt + Y = 6x y(O) = 3
where x(t) is piecewise constant and assumes the following values:
x(O) = 0 x(3) = 1
x(l) = 3 x(4) = 0
x(2) = 2 x(t) =0 for t > 4
Develop a difference equation for this ordinary differential equation using t:.t = 1 and
(a) exact discretization
(b) finite difference
Compare the integrated results for 0 s; t s; 10. Examine whether t:.t = 0.1 improves
the finite difference model.
23.2. The following data were collected from a temperature sensor immersed in a gas stream.
The input x is the flow rate deviation (in dimensionless units) and the sensor output
y is given in millivolts. The flow (input) is piecewise constant over the intervals shown.
The process is not at steady state initially, so y can change even though x = O.
Fit a first-order model, Yn = aiYn-I + b1xn-l' to the data using the least-squares
approach. Plot the responses of the fitted mcdel and the actual data. Can you also
find a first-order continuous transfer function to fit the data?
23.3. Fit a first-order discrete-time model to the step response data in Table 23.2. Compare
your results with the graphical method for step response data, fitting the gain and
time constant. Plot the two simulated step responses for comparison with the observed
data.
558 DEVELOPMENT OF DISCRETE-TIME MODELS