This action might not be possible to undo. Are you sure you want to continue?
CHAPTER
23
Development of DiscreteTime 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 discretetime models rather than continuoustime models. In this chapter we present several approaches for converting dynamic models based on differential equations to discretetime models described by difference equations. We also consider a method for developing discretetime models from experimental data. This method is analogous to the empirical approach for developing continuoustime models that was discussed in Chapter 7.
23.1
FINITE DIFFERENCE MODELS
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 continuoustime models to discretetime form is to use finite difference techniques. In general, a nonlinear differential equation,
dy(t)
dt
=
fey,
x)
(231 )
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 approximation for the derivative. For example, the firstorder, backward difference approximation to the derivative at time t = 11M is [1]
dy
= y"

dt 
M
Yl/l
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 = (111)6.t. Substituting (232) into (231) and evaluating function fey, x) at the previous values of y and x (i.e., y,,1 and X,,I) gives
y" Yl/l M
==
f(y"b
X,,I)
549
550 or
DEVELOPMENT
OF DISCRETETIME
MODELS
(234)
Equation 234 is a firstorder difference equation that can be used to predict the value of Y at time step n based on information at the previous time step (n1), namely, YII_I and f(YIIb XIII)' This type of expression is called a recurrence relation. It can be used to numerically integrate Eq. 231 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 234 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,
(235)
that results from using a forward difference approximation to the derivative rather than the backward difference in Eqn. (233):
dy
dt
= Y"+l

 YII
D.t
(236)
Equation 234 can then be derived from Eq. 233 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. 234 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
Develop a difference equation that approximates the differential equation,
T
d~~t)
+
yet)
=
x(t)
(237)
or equivalently,
dy (t) dt
Solution
1
T
yet)
1 +  x(t) 'T
(238)
Note that if the initial condition is zero, that is, if y(O) = 0, these equations correspond to the firstorder transfer function with unity gain:
yes) Xes)
=
_1
TS
+ 1
(239)
Using a backward difference approximation for the derivative and substitutingy"_1 for yet) and X,,_I for x(t) in Eq. 238, we obtain
T(y"  YIIl)
t1t
+
y,,I
=
XIII
23.1 Finite Difference
Models
551
Table 23.1
The Elfect of Integration Interval on the Step Response of a FirstOrder Model (, = 1) 1.968 0.1 !:::.t ilt 0.900== 0.25 .990 .684 .997 0 0.985 0.958 0.879 0.651 0.995 0.410 0.438 Numerical
solution,
y"
!:::.t
Exact solution
= 0.01
o
yet)
o
0.395 0.634 0.866 0.951 0.982 0.993
0.393 0.632 0.865 0.951 0.982 0.993
Rearranging gives
Yll
'T = (1  M)
YIl\
+ M Xlll
"i
(2310)
The new value Yll is a weighted sum of the previous value YIll and the previous input, Note that the digital filter derived in Chapter 22 differs from (2310) because f is evaluated at the nth time step. This is because the filter is employed for smoothing the current measurement whereas (2310) is used for prediction. As D.t becomes infinitesimally small, the finite difference relation in Eq. 2310 becomes a better approximation of the differential equation in (238). If Eq. 2310 is used to numerically integrate (238) 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 (238) with the numerical solution obtained using (2310) for T = 1 and various integration intervals.
XI1].
The previous example has shown that a discretetime version of a firstorder differential equation can be derived using a backward difference approximation. Alternative discretetime models can be obtained by using other finite difference approximations. Next we consider how discretetime models can be derived for higherorder differential equations.
EXAMPLE
23.2
Develop a finite difference approximation for the secondorder differential equation, (2311)
Solution
The secondorder derivative at the nth time step can be approximated by the finite difference approximation [1]:
2YIll
+
YIl2
(D.tf
(2312)
552
DEVELOPMENT
OF DISCRETETIME
MODELS
Substituting (2312) and (232) into (2311), replacing and rearranging yields
Y
and x by
Y 1/1
and
XI/I>
[ (M)2 + t::.t 1 al]
Yn
= [2 (M)2 +
t::.t a]] 
ao
YI/I

(t::.tf YI/2 1
+
(2313)
XI/l
All of the terms on the right side of (2313) involve past information. Alternative discretetime models can be obtained by other finite difference approximations, as discussed by Davis [1].
23.2
EXACT DISCRETIZATION
FOR LINEAR SYSTEMS
For a process described by a linear differential equation, an alternative discretetime model can be derived based on the analytical solution for a piecewise constant input. This approach yields an exact discretetime model if the input variable is actually constant between sampling instants. Thus, this analytical approach eliminates the discretization error inherent in finite difference approximations for the important practical situation where the digital computer output (process input) is held constant between sampling instants. This signal is piecewise constant if the DAC acts as a zeroorder hold, as discussed in Chapters 21 and 22. As an illustrative example, consider the firstorder system in Eq. 237. Assume that x(t) is constant such that x(t) = x(O), and that y(O) # O. Taking the Laplace transform of (238) gives
1
sY(s) y(O)
_:.
Y(s)
+
l
T x(O) S
(2314)
Solving for
Y(s),
Y(s)
= s +1liT
[l s +
T
x(O)
y(O) ]
(2315)
and taking inverse Laplace transforms gives
y(t)
=
x(O)
(1 
etl,)
+
y(O) etl,
(2316)
Equation 2316 is valid for all values of t. Thus, after one sampling period, t = t::.t, and we have (2317) Next, we can generalize the analysis by considering the time interval, (n1) to nt::.t. For an initial condition y[(n1)M] and a constant input, x(t) x[(n1) t::.t] for (n1) M t < nt::.t, the analytical solution to (237) is
t::.t
s
=
y(nM)
=
x[(n1)t::.t](1

e:::.tl,)
+
y[(n1)M]e,,tl,
(2318)
Note that the exponential terms are the same as for Eq. 2317. Equation 2318 can be written more compactly as
Yl/

e MI, YI/_]
+ (1 
e MI.). XI/_]
(2319)
Equation 2319 is the exact solution to (237) providing that x(t) is constant over each sampling period of length t::.t. If Eq. 2319 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 DISCRETETIME
MODELS
Substituting (2312) and (232) into (2311), replacing and rearranging yields
Y and x by YIll
and Xll],
[ (~t)2 + 1
~t ] Yll a]
= [2 (~t)2 +
~t a]]
ao
Yll]

(M)" 1
YIl2
+
(2313)
Xlll
All of the terms on the right side of (2313) involve past information. Alternative discretetime models can be obtained by other finite difference approximations, as discussed by Davis [1].
23.2
EXACT DISCRETIZATION
FOR LINEAR SYSTEMS
For a process described by a linear differential equation, an alternative discretetime model can be derived based on the analytical solution for a piecewise constant input. This approach yields an exact discretetime model if the input variable is actually constant between sampling instants. Thus, this analytical approach eliminates the discretization error inherent in finite difference approximations for the important practical situation where the digital computer output (process input) is held constant between sampling instants. This signal is piecewise constant if the DAC acts as a zeroorder hold, as discussed in Chapters 21 and 22. As an illustrative example, consider the firstorder system in Eq. 237. Assume that x(t) is constant such that x(t) = x(O), and that y(O) oF O. Taking the Laplace transform of (238) gives
1
sY(s) Solving for Y(s), y(O)
_:.
yes)
+ ~ x(O) T S
(2314)
yes)
= =
+ liT _1_
s
T S [~X_(_O)
+
Y(O)]
(2315)
and taking inverse Laplace transforms
yet) x(O)
gives
eII,)
(1 
+
y(O) eII,
(2316)
Equation
t
= ~t,
2316 is valid for all values and we have
of
t. Thus, after one sampling period,
(2317)
Next, we can generalize the analysis by considering the time interval, (n1) to n~t. For an initial condition y[(n1)~t] and a constant input, x(t) x[(n 1) M] for (n 1) M:s t < n~t, the analytical solution to (237) is
y(n~t)
~t
=
=
x[(n 1)~t](l

eMI,)
+
y[(n1)M]e..'.II,
(2318)
Note that the exponential terms are the same as for Eq. 2317. Equation be written more compactly as
Yll e 6.11, Yll]
2318 can (2319)
+ (1 
e ..'.11,)_XIl]
Equation 2319 is the exact solution to (237) providing that x(t) is constant over each sampling period of length ~t. If Eq. 2319 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 DiscreteTime
Equations to Process Data
553
23.3
HIGHERORDER
SYSTEMS
To derive a discretetime version of a higherorder differential equation, we can use the analytical solution and proceed as in the previous section. An alternative approach based on ztransforms will be presented in Chapter 24. A linear differential equation of order p, when converted to discrete time, yields a linear difference equation also of order p. For example, consider the secondorder system:
Y(s) .
K(TaS
G(s)
= X(s)
= hs
+ 1) + l)(Tzs + 1)
(2320)
Using the analytical solution for a constant input provides the corresponding difference equation:
Yn
+
ajYnj eflt/T2
+
aZYnZ
bjxnj
+
bzxnz
(2321) (2322) (2323) (2324)
where
aj
_eM/T1 eM/TleM/T2
az 
(2325)
In Eq. 2321 the new value of Y depends on the values of Y and x at the two previous sampling instants; hence it is a secondorder difference equation. If T2 = Ta = 0 and K = 1 in Eq. 2321 through 2325, the firstorder difference equation in (2319) results. The steadystate gain of the secondorder difference equation model can be found by considering steadystate conditions. Let x denote a step change in x and y the resulting steadystate change in y. At steady state, Xn] = XnZ = x and Yn = YIlj = YnZ = Y. Substituting these values into (2321) gives
y
+
a[ y
+
a2Y
=
bjx
+
b2x
(2326)
Since Y and x are deviation variables, the steadystate gain is simply ylx, the steadystate change in Y divided by the steadystate change in x. Rearranging (2326) gives Gam =  =
x
. y
b[
+
aj
bo
1+
+
~
az
(2327)
Substitution of Eqs. (2322) through (2325) into (2327) gives, Gain K. This same result can be obtained by letting s 7 0 in (2320). Thus the transfer function model in (2320) and the corresponding discretetime model in (2321) have the same steadystate gains. This result also occurs for all other transfer function models. Sets of differential equations can be converted to a discretetime, difference equation model by using a technique referred to as the transition matrix approach [2]. General results for converting secondorder and thirdorder differential equations (transfer functions) to difference equations have been derived by Neuman and Baradello [3] and are presented in Chapter 24.
23.4 FITTING DISCRETETIME EQUATIONS TO PROCESS DATA
In Chapter 7 we discussed methods for fitting continuoustime models (transfer functions) to process data. If a discretetime model is desired, one approach is to
554
DEVELOPMENT
OF DISCRETETIME
MODELS
fit a continuoustime model to experimental data and then to convert it to discrete form using the approach of Section 23.2. An alternative approach is to fit a discretetime model to the data directly without first obtaining a continuoustime model. An important advantage of the latter approach is that the model parameters can be calculated using the wellknown linear regression technique (see Chapter 7). As a specific example, consider a rearranged version of the secondorder difference equation (2321). This model allows Y II to be predicted from data available at time (nl), or (2329) denotes the prediction of Y n that is made at time (n 1), G; =  G 1, and In developing a discretetime model, model parameters GJ, G2, bJ, and b2 are treated as unknowns to be estimated by fitting the data. Note that the right side of (2329) involves previous measurements of Y rather than previous predictions. In general, Yn 0/= Yn, due to a number of practical considerations which include model inaccuracy, unmeasured disturbances, and measurement noise. The objective of this parameter estimation problem is to determine numerical values for the unknown parameters so that the difference between the measurements and the predictions from Eq. 2329 are as small as possible. The leastsquares technique presented in Chapter 7 can be used here; the error criterion to be minimized is where
G2
Yn
=
G2'
n~l
2:
(Yn

Yllf
(2330)
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 secondorder difference equation (2321) to the above inputoutput data using 6.t = 1. Compare
07 6 110 2 4 9 8 5 3
aM
=
1;
for
n
<
0,
y"
=
Table 23.2 x" = O.
O.
0.833 0.058 0.692 0.600 0.217 0.888 0.772 0.488 0.360 0 y" 9 8 7 1 5 4 3 10 6 2 0.925 Step0 Response Data"
and n
X1/2 11 Yn 0.692 10.888 Yll2 ,,l 0.0580.772 0.217 0.360 0Xnl 0.058 0.217 0 0.888Matrix 0.833 1 0.772 0 0.692 0.600 0.925 0.600 0.488 0.360 0.488 23.4 Fitting 555 DiscreteTime Equations DataY0.833 for Estimating Parameters in Eq. 2321
to Process Data
these results with models obtained in Example 7.3 using Harriott's method and nonlinear regression.
Solution XIII> XII2),
For the linear regression problem, there are four independent variables (YII [, YII2, 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 discretetime model so as to minimize Eq. 2330. The results labeled "Harriott's method" and "Nonlinear Regression" were obtained by fitting a continuoustime model (secondorder, 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 continuoustime model was then converted to the corresponding discretetime model via Eqs. 2321 to 2325. 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. 2327. 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
Comparison of Estimated Model Parameters for Example 23.2
Linear Regression Harriott's Method 1.218  0.348 0.076 0.054 1. 000 Nonlinear Regression 1.310  0.425 0.066 0.050 1. 000
Table 23.4
a;
0.975 0.112 0.058 0.102 1.168
I
a2
556
23.5

Ys YH Y 0.192 0.0580.058 0.2170.217 0.3600.365 0.6000.596 0.6920.690 0.8330.835 0.7720.767 0.8880.886 0.925 0.066 0.375 0.496 0.602 0.695 0.924 0.833 0.768 0.201 0.076 0.374 0.493 0.599 0.691 0.921 0 0.830 0.764 0.876 0.4880.487 0.880 DEVELOPMENT YL OFofDISCRETETIMEResponses MODELS Comparison.932 Simulated
for Various Difference Equation Models"
"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. 2327 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 secondorder difference equation model to data directly. The linear regression approach can also be used for higherorder 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 data collection. In general, changing will result in different parameter estimates. An attractive feature of linear regression is that it is not necessary to make a step change in x to estimate model parameters. An arbitrary input variation over a limited period of time would suffice. In particular, we need not force the system to a new steady state, a beneficial feature for industrial applications. However, as noted above, enough data should be taken to give an accurate steadystate gain.
I:::.t I:::.t
SUMMARY In this chapter we have presented several methods for developing discretetime
process models in the form of linear difference equations. If a continuoustime process model is available as one or more linear differential equations, then the corresponding discretetime model can be derived analytically. This approach yields an exact discretetime model provided that the process inputs are piecewise constant over the sampling period. An alternative approach is to use finite difference techniques to develop approximate discretetime models. This approach is used when the continuoustime model consists of nonlinear differential equations and the analytical solution is not available. An important advantage of discretetime models is that they can be readily obtained by fitting experimental response data. Example 23.2 has illustrated that
Exercises
557
standard linear regression techniques can be employed to estimate the unknown model parameters in a linear difference equation model.
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, DiscreteTime and Computer Control Systems, PrenticeHall, Englewood Cliffs, NJ, 1970. 3. Neuman, C. P., and C. S. Baradello, Digital Transfer Functions for Microcomputer Control. IEEE Trans. Systems. Man, Cybernetics SMC9 (12), 856 (1979).
EXERCISES
23.1. Consider the firstorder differential equation
dy 5 dt
+
Y = 6x
y(O)
= 3
where
x(t)
is piecewise constant and assumes the following values: x(3) = 1 x(O) = 0 x(4) = 0 x(l) = 3 for t > 4 x(t) =0 x(2) = 2
t:.t
Develop a difference equation for this ordinary differential equation using (a) exact discretization (b) finite difference Compare the integrated results for 0 s; the finite difference model.
= 1 and
t
s; 10. Examine whether
t:.t
= 0.1 improves
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.
Time (s) y3 0 6.493 1 3.000 2.456 5.243 6.404 4.293 2.877 2.356 5.274 3.514 1.929 0 2 x
Fit a firstorder model, Yn = aiYnI + b1xnl' to the data using the leastsquares approach. Plot the responses of the fitted mcdel and the actual data. Can you also find a firstorder continuous transfer function to fit the data? 23.3. Fit a firstorder discretetime 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 DISCRETETIME
MODELS
23.4. A secondorder differential equation is given as
d2y dt2
+ 3
dy dt
+
2y
=
x
For a unit step change in x (x changes from a to 1.0 at t = 0), calculate the responses (0:::; t:::; 5) for t:.t = 0.1 and M = 0.5. Perform the integration using the exact solution and a finite difference approximation (see Example 23.2). The initial conditions y and dy/dt are both zero at t = O.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue listening from where you left off, or restart the preview.