Advanced Control using
M
ATLAB
or Stabilising the
unstabilisable
David I. Wilson
Auckland University of Technology
New Zealand
April 12, 2013
Auckland University of Technology
New Zealand
Creation date: April, 2013.
All rights reserved. No part of this work may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior permission.
Contents
1 Introduction 1
1.1 Scope . . . 2
1.2 Matlab for computer aided control design . . . 2
1.2.1 Alternative computer design aids . . . 3
1.3 Economics of control . . . 4
1.4 Laboratory equipment for control tests . . . 6
1.4.1 Plants with one input and one output . . . 6
1.4.2 Multi-input and multi-output plants . . . 8
1.5 Slowing down Simulink . . . 10
2 From differential to difference equations 13 2.1 Computer in the loop . . . 13
2.1.1 Sampling an analogue signal . . . 14
2.1.2 Selecting a sample rate . . . 14
2.1.3 The sampling theorem and aliases . . . 16
2.1.4 Discrete frequency . . . 17
2.2 Finite difference models . . . 20
2.2.1 Difference equations . . . 20
2.3 The z transform . . . 22
2.3.1 z-transforms of common functions . . . 23
2.4 Inversion of z-transforms . . . 24
2.4.1 Inverting z-transforms with symbolically . . . 25
2.4.2 The partial fraction method . . . 26
2.4.3 Long division . . . 28
2.4.4 Computational approach . . . 29
2.4.5 Numerically inverting the Laplace transform . . . 31
2.5 Discretising with a sample and hold . . . 34
2.5.1 Converting Laplace transforms to z-transforms . . . 37
2.5.2 The bilinear transform . . . 38
2.6 Discrete root locus diagrams . . . 42
2.7 Multivariable control and state space analysis . . . 43
2.7.1 States and state space . . . 46
2.7.2 Converting differential equations to state-space form . . . 47
2.7.3 Interconverting between state space and transfer functions . . . 50
2.7.4 Similarity transformations . . . 54
2.7.5 Interconverting between transfer functions forms . . . 55
2.7.6 The steady state . . . 56
2.8 Solving the vector differential equation . . . 58
2.8.1 Numerically computing the discrete transformation . . . 61
2.8.2 Using MATLABto discretise systems . . . 63
2.8.3 Time delay in state space . . . 67
2.9 Stability . . . 69 iii
2.9.1 Stability in the continuous domain . . . 70
2.9.2 Stability of the closed loop . . . 72
2.9.3 Stability of discrete time systems . . . 73
2.9.4 Stability of nonlinear differential equations . . . 74
2.9.5 Expressing matrix equations succinctly using Kronecker products . . . 80
2.9.6 Summary of stability analysis . . . 82
2.10 Summary . . . 83
3 Modelling dynamic systems with differential equations 85 3.1 Dynamic system models . . . 85
3.1.1 Steady state and dynamic models . . . 86
3.2 A collection of illustrative models . . . 86
3.2.1 Simple models . . . 86
3.3 Chemical process models . . . 92
3.3.1 A continuously-stirred tank reactor . . . 92
3.3.2 A forced circulation evaporator . . . 94
3.3.3 A binary distillation column model . . . 95
3.3.4 Interaction and the Relative Gain Array . . . 103
3.4 Regressing experimental data by curve fitting . . . 107
3.4.1 Polynomial regression . . . 107
3.4.2 Nonlinear least-squares model identification . . . 112
3.4.3 Parameter confidence intervals . . . 116
3.5 Numerical tools for modelling . . . 120
3.5.1 Differential/Algebraic equation systems and algebraic loops . . . 123
3.6 Linearisation of nonlinear dynamic equations . . . 125
3.6.1 Linearising a nonlinear tank model . . . 127
3.7 Summary . . . 129
4 The PID controller 131 4.1 Introduction . . . 131
4.1.1 P, PI or PID control . . . 131
4.2 The industrial PID algorithm . . . 132
4.2.1 Implementing the derivative component . . . 133
4.2.2 Variations of the PID algorithm . . . 134
4.2.3 Integral only control . . . 135
4.3 Simulating a PID process in SIMULINK . . . 135
4.4 Extensions to the PID algorithm . . . 138
4.4.1 Avoiding derivative kick . . . 138
4.4.2 Input saturation and integral windup . . . 140
4.5 Discrete PID controllers . . . 143
4.5.1 Discretising continuous PID controllers . . . 144
4.5.2 Simulating a PID controlled response in Matlab . . . 146
4.5.3 Controller performance as a function of sample time . . . 148
4.6 PID tuning methods . . . 148
4.6.1 Open loop tuning methods . . . 150
4.6.2 Closed loop tuning methods . . . 155
4.6.3 Closed loop single-test tuning methods . . . 159
4.6.4 Summary on closed loop tuning schemes . . . 166
4.7 Automated tuning by relay feedback . . . 166
4.7.1 Describing functions . . . 168
4.7.2 An example of relay tuning . . . 170
4.7.3 Self-tuning with noise disturbances . . . 173
4.7.4 Modifications to the relay feedback estimation algorithm . . . 176
4.8.1 Inverse response processes . . . 181
4.8.2 Approximating inverse-response systems with additional deadtime . . . . 183
4.9 Dead time compensation . . . 185
4.10 Tuning and sensitivity of control loops . . . 187
4.11 Summary . . . 191
5 Digital filtering and smoothing 193 5.1 Introduction . . . 193
5.1.1 The nature of industrial noise . . . 194
5.1.2 Differentiating without smoothing . . . 196
5.2 Smoothing measured data using analogue filters . . . 197
5.2.1 A smoothing application to find the peaks and troughs . . . 197
5.2.2 Filter types . . . 197
5.2.3 Classical analogue filter families . . . 201
5.3 Discrete filters . . . 209
5.3.1 A low-pass filtering application . . . 209
5.3.2 Digital filter approximations . . . 212
5.3.3 Efficient hardware implementation of discrete filters . . . 214
5.3.4 Numerical and quantisation effects for high-order filters . . . 217
5.4 The Fourier transform . . . 219
5.4.1 Fourier transform definitions . . . 221
5.4.2 Orthogonality and frequency spotting . . . 224
5.4.3 Using MATLAB’s FFT function . . . 225
5.4.4 Periodogram . . . 227
5.4.5 Fourier smoothing . . . 228
5.5 Numerically differentiating industrial data . . . 230
5.5.1 Establishing feedrates . . . 231
5.6 Summary . . . 233
6 Identification of process models 235 6.1 The importance of system identification . . . 235
6.1.1 Basic definitions . . . 236
6.1.2 Black, white and grey box models . . . 237
6.1.3 Techniques for identification . . . 238
6.2 Graphical and non-parametric model identification . . . 239
6.2.1 Time domain identification using graphical techniques . . . 239
6.2.2 Experimental frequency response analysis . . . 246
6.2.3 An alternative empirical transfer function estimate . . . 253
6.3 Continuous model identification . . . 254
6.3.1 Fitting transfer functions using nonlinear least-squares . . . 254
6.3.2 Identification using derivatives . . . 256
6.3.3 Practical continuous model identification . . . 258
6.4 Popular discrete-time linear models . . . 260
6.4.1 Extending the linear model . . . 262
6.4.2 Output error model structures . . . 264
6.4.3 General input/output models . . . 265
6.5 Regressing discrete model parameters . . . 266
6.5.1 Simple offline system identification routines . . . 268
6.5.2 Bias in the parameter estimates . . . 269
6.5.3 Using the System Identification toolbox . . . 270
6.5.4 Fitting parameters to state space models . . . 274
6.6 Model structure determination and validation . . . 276
6.6.1 Estimating model order . . . 277
6.6.3 Common nonlinear model structures . . . 280
6.7 Online model identification . . . 280
6.7.1 Recursive least squares . . . 281
6.7.2 Recursive least-squares in MATLAB . . . 286
6.7.3 Tracking the precision of the estimates . . . 290
6.8 The forgetting factor and covariance windup . . . 292
6.8.1 The influence of the forgetting factor . . . 294
6.8.2 Covariance wind-up . . . 295
6.9 Identification by parameter optimisation . . . 296
6.10 Online estimating of noise models . . . 300
6.10.1 A recursive extended least-squares example . . . 302
6.10.2 Recursive identification using the SI toolbox . . . 305
6.10.3 Simplified RLS algorithms . . . 306
6.11 Closed loop identification . . . 307
6.11.1 Closed loop RLS in Simulink . . . 309
6.12 Summary . . . 309
7 Adaptive Control 317 7.1 Why adapt? . . . 317
7.1.1 The adaption scheme . . . 318
7.1.2 Classification of adaptive controllers . . . 319
7.2 Gain scheduling . . . 319
7.3 The importance of identification . . . 321
7.3.1 Polynomial manipulations . . . 321
7.4 Self tuning regulators (STRs) . . . 322
7.4.1 Simple minimum variance control . . . 323
7.5 Adaptive pole-placement . . . 325
7.5.1 The Diophantine equation and the closed loop . . . 326
7.5.2 Solving the Diophantine equation in Matlab . . . 327
7.5.3 Adaptive pole-placement with identification . . . 330
7.6 Practical adaptive pole-placement . . . 334
7.6.1 Dealing with non-minimum phase systems . . . 335
7.6.2 Separating stable and unstable factors . . . 338
7.6.3 Experimental adaptive pole-placement . . . 340
7.6.4 Minimum variance control with dead time . . . 341
7.7 Summary of adaptive control . . . 345
8 Multivariable controller design 351 8.1 Controllability and observability . . . 352
8.1.1 Controllability . . . 352
8.1.2 Observability . . . 354
8.1.3 Computing controllability and observability . . . 355
8.1.4 State reconstruction . . . 356
8.2 State space pole-placement controller design . . . 359
8.2.1 Poles and where to place them . . . 362
8.2.2 Deadbeat control . . . 364
8.3 Estimating the unmeasured states . . . 366
8.4 Combining estimation and state feedback . . . 367
8.5 Generic model control . . . 369
8.5.1 The tuning parameters . . . 371
8.5.2 GMC control of a linear model . . . 373
8.5.3 GMC applied to a nonlinear plant . . . 375
8.6 Exact feedback linearisation . . . 380
8.6.2 The input/output feedback linearisation control law . . . 380
8.6.3 Exact feedback example . . . 382
8.7 Summary . . . 386
9 Classical optimal control 387 9.1 Introduction . . . 387
9.2 Parametric optimisation . . . 388
9.2.1 Choosing a performance indicator . . . 388
9.2.2 Optimal tuning of a PID regulator . . . 389
9.2.3 Using SIMULINKinside an optimiser . . . 395
9.2.4 An optimal batch reactor temperature policy . . . 396
9.3 The general optimal control problem . . . 397
9.3.1 The optimal control formulation . . . 399
9.3.2 The two-point boundary problem . . . 401
9.3.3 Optimal control examples . . . 402
9.3.4 Problems with a specified target set . . . 406
9.4 Linear quadratic control . . . 409
9.4.1 Continuous linear quadratic regulators . . . 409
9.4.2 Analytical solution to the LQR problem . . . 411
9.4.3 The steady-state solution to the matrix Riccati equation . . . 415
9.4.4 The discrete LQR . . . 418
9.4.5 A numerical validation of the optimality of LQR . . . 423
9.4.6 An LQR with integral states . . . 427
9.5 Estimation of state variables . . . 431
9.5.1 Random processes . . . 431
9.5.2 Combining deterministic and stochastic processes . . . 437
9.5.3 The Kalman filter estimation scheme . . . 438
9.5.4 The steady-state form of the Kalman filter . . . 442
9.5.5 Current and future prediction forms . . . 443
9.5.6 An application of the Kalman filter . . . 447
9.5.7 The role of the Q and R noise covariance matrices in the state estimator . . 448
9.5.8 Extensions to the basic Kalman filter algorithm . . . 452
9.5.9 The Extended Kalman Filter . . . 454
9.5.10 Combining state estimation and state feedback . . . 457
9.5.11 Optimal control using only measured outputs . . . 457
9.6 Summary . . . 459
10 Predictive control 461 10.1 Model predictive control . . . 461
10.1.1 Constrained predictive control . . . 464
10.1.2 Dynamic matrix control . . . 468
10.2 A Model Predictive Control Toolbox . . . 474
10.2.1 A model predictive control GUI . . . 474
10.2.2 MPC toolbox in MATLAB . . . 474
10.2.3 Using the MPC toolbox in SIMULINK . . . 476
10.2.4 Further readings on MPC . . . 477
10.3 Optimal control using linear programming . . . 478
11 Expert systems and neural networks 487
11.1 Expert systems . . . 487
11.1.1 Where are they used? . . . 488
11.1.2 Features of an expert system . . . 488
11.1.3 The user interface . . . 490
11.1.4 Expert systems used in process control . . . 490
11.2 Neural networks . . . 493
11.2.1 The architecture of the neural network . . . 495
11.2.2 Curve fitting using neural networks . . . 499
11.3 Summary . . . 503
A List of symbols 505 B Useful utility functions in Matlab 507 C Transform pairs 509 D A comparison of Maple and MuPad 511 D.1 Partial fractions . . . 511
D.2 Integral transforms . . . 511
D.3 Differential equations . . . 512
D.4 Vectors and matrices . . . 513
E Useful test models 515 E.1 A forced circulation evaporator . . . 515
List of Figures
1.1 Traditional vs. Advanced control . . . 5
1.2 Economic improvements of better control . . . 6
1.3 Blackbox configuration. The manual switch marked will toggle between either 7 or 9 low-pass filters. . . 7
1.4 The “Black-box” . . . 7
1.5 Balance arm . . . 8
1.6 The flapper wiring . . . 9
1.7 Flapper . . . 9
1.8 Helicopter plant with 2 degrees of freedom. See also Fig. 1.9(a). . . 10
1.9 Helicopter control . . . 11
1.10 Helicopter flying . . . 12
1.11 Real-time Simulink simulations . . . 12
2.1 The computer in the control loop . . . 14
2.2 3 bit sampling . . . 15
2.3 A time series with unknown frequency components . . . 18
2.4 The frequency component of a sampled signal . . . 18
2.5 Frequency aliases . . . 19
2.6 The Scarlet Letter . . . 20
2.7 H´enon’s attractor in Simulink . . . 21
2.8 H´enon’s attractor . . . 22
2.9 Inverting z-transforms using dimpulse . . . 29
2.10 Numerically inverting the Laplace transform using the Bromwich integral . . . 33
2.11 Numerically inverting the Laplace transform . . . 33
2.12 Numerically inverting Laplace transforms . . . 34
2.13 Ideal sampler and zeroth-order hold . . . 35
2.14 Zeroth-order hold effects on the discrete Bode diagram . . . 41
2.15 Bode plot . . . 42
2.16 The discrete root locus . . . 44
2.17 Various discrete closed loop responses . . . 44
2.18 A binary distillation column with multiple inputs and multiple outputs . . . 45
2.19 A block diagram of a state-space dynamic system, (a) continuous system: ˙x = Ax+ Bu, and (b) discrete system: xk+1= Φxk+ ∆uk. (See also Fig. 2.20.) . . . . 47
2.20 A complete block diagram of a state-space dynamic system with output and direct measurement feed-through, Eqn. 2.41. . . 48
2.21 Unsteady and steady states for level systems . . . 57
2.22 Submarine step response . . . 66
2.23 Issues in assessing system stability . . . 69
2.24 Nyquist diagram of Eqn. 2.94 in (a) three dimensions and (b) as typically presented in two dimensions. . . 73
2.25 Liapunov (1857–1918) . . . 75 2.26 Regions of stability for the poles of continuous (left) and discrete (right) systems . 82
3.1 A stable and unstable pendulum . . . 87
3.2 Simple buffer tank . . . 89
3.3 The UK growth based on the GDP . . . 91
3.4 A CSTR reactor . . . 93
3.5 A forced circulation evaporator . . . 94
3.6 Schematic of a distillation column . . . 96
3.7 Wood-Berry step response . . . 97
3.8 Wood-Berry column in SIMULINK. . . 98
3.9 Distillation tower . . . 99
3.10 Sparsity of the distillation column model . . . 101
3.11 Open loop distillation column control . . . 102
3.12 Distillation column control . . . 103
3.13 Distillation column control (in detail) . . . 103
3.14 Distillation interactions . . . 104
3.15 Dynamic RGA . . . 106
3.16 Dynamic RGA . . . 106
3.17 Density of Air . . . 109
3.18 Fitting a high-order polynomial to some physical data . . . 111
3.19 A bio-chemical reaction . . . 114
3.20 Model of compressed water . . . 115
3.21 Experimental pressure-rate data . . . 119
3.22 Parameter confidence regions . . . 119
3.23 Linear and nonlinear trajectories . . . 121
3.24 Linearising a nonlinear tank model . . . 128
4.1 Comparing PI and integral-only control for the real-time control of a noisy flapper plant with sampling time T = 0.08. . . 135
4.2 PID simulation . . . 135
4.3 PID internals in Simulink . . . 136
4.4 Block diagram of PID controllers as implemented in SIMULINK(left) and classical text books (right). . . 136
4.5 Realisable PID controller . . . 137
4.6 PID controller in Simulink . . . 137
4.7 PID controller with anti-derivative kick. . . 139
4.8 Avoiding derivative kick . . . 139
4.9 Illustrating the improvement of anti-derivative kick schemes for PID controllers when applied to the experimental electromagnetic balance. . . 140
4.10 Derivative control and noise . . . 141
4.11 Anti-windup comparison . . . 142
4.12 Discrete PID controller in SIMULINK . . . 145
4.13 Headbox control . . . 146
4.14 Headbox controlled response . . . 147
4.15 A PID controlled process . . . 148
4.16 Sample time and discrete PID control . . . 149
4.17 The parameters T and L to be graphically estimated for the openloop tuning method relations given in Table 4.2. . . 151
4.18 Cohen-Coon model fitting . . . 152
4.19 Cohen-Coon tuning . . . 153
4.20 PID tuning using a GUI . . . 154
4.21 Solving for the ultimate frequency . . . 157
4.22 Ziegler-Nichols tuned responses . . . 158
4.23 Typical response of a stable system to a P-controller. . . 160
4.24 A Yuwana-Seborg closed loop step test . . . 163
4.26 A self-tuning PID controlled process . . . 167
4.27 A process under relay tuning with the PID regulator disabled. . . 167
4.28 An unknown plant under relay feedback exhibits an oscillation . . . 169
4.29 Nyquist & Bode diagrams . . . 171
4.30 PID Relay tuning . . . 172
4.31 Relay tuning with noise . . . 174
4.32 Relay tuning of the blackbox . . . 175
4.33 Relay tuning results of the blackbox . . . 176
4.34 A relay with hysteresis width h and output amplitude d. . . 177
4.35 Relay feedback with hysteresis width h. . . 178
4.36 Relay feedback with hysteresis . . . 178
4.37 Relay feedback with an integrator . . . 178
4.38 2-point Relay identification . . . 180
4.39 The J curve . . . 181
4.40 An inverse response process . . . 182
4.41 A NMP plant controlled with a PI controller . . . 183
4.42 Approximating inverse-response systems with additional deadtime . . . 184
4.43 The Smith predictor structure . . . 185
4.44 The Smith predictor structure from Fig. 4.43 assuming no model/plant mis-match. 186 4.45 Smith predictor in Simulink . . . 186
4.46 Dead time compensation . . . 187
4.47 Deadtime compensation applied to the blackbox . . . 188
4.48 Closed loop with plant G(s) and controller C(s) subjected to disturbances and measurement noise. . . 189
4.49 Sensitivity transfer functions . . . 190
4.50 Sensitivity robustness measure . . . 190
5.1 A filter as a transfer function . . . 193
5.2 A noisy measurement . . . 194
5.3 Noise added to a true, but unknown, signal . . . 195
5.4 Derivative action given noisy data . . . 196
5.5 Smoothing industrial data . . . 198
5.6 Low-pass filter specification . . . 199
5.7 Three single low-pass filters cascaded together to make a third-order filter. . . 199
5.8 Amplitude response for ideal, low-pass, high pass and band-pass filters. . . 200
5.9 Analogue Butterworth filter . . . 202
5.10 Analogue Chebyshev filter . . . 207
5.11 Butterworth and Chebyshev filters . . . 208
5.12 Using a Butterworth filter to smooth noisy data . . . 211
5.13 The frequency response for Butterworth filters . . . 212
5.14 Various Butterworth filters . . . 213
5.15 Advantages of frequency pre-warping . . . 214
5.16 Hardware difference equation in Direct Form I . . . 215
5.17 An IIR filter with a minimal number of delays, Direct Form II . . . 216
5.18 Cascaded second-order sections to realise a high-order filter. See also Fig. 5.19. . . 217
5.19 A second-order section (SOS) . . . 218
5.20 Comparing single precision second-order sections with filters in direct form II transposed form. Note that the direct form II filter is actually unstable when run in single precision. . . 219
5.21 Approximating square waves with sine waves . . . 223
5.22 The Fourier approximation to a square wave . . . 223
5.23 Two signals . . . 224
5.24 Critical radio frequencies . . . 228
5.26 Smoothing by Fourier transform . . . 230
5.27 Differentiating and smoothing noisy measurement . . . 232
5.28 Filtering industrial data . . . 233
6.1 The prediction problem: Given a model and the input, u, can we predict the out-put, y? . . . 235
6.2 A good model,M, duplicates the behaviour of the true plant, S. . . 237
6.3 An experimental setup for input/output identification. We log both the input and the response data to a computer for further processing. . . 238
6.4 Typical open loop step tests . . . 240
6.5 Areas method for model identification . . . 241
6.6 Examples of the Areas method . . . 242
6.7 Identification of the Blackbox . . . 242
6.8 Balance arm step test . . . 243
6.9 Random signals . . . 244
6.10 A 5-element binary shift register to generate a pseudo-random binary sequence. . 245
6.11 Pseudo-random binary sequence generator in SIMULINK . . . 245
6.12 Black box experimental setup . . . 247
6.13 Black box response analysis using a series of sine waves . . . 247
6.14 Black box response using an input chirp signal. . . 249
6.15 Black box frequency response analysis using a chirp signal. . . 249
6.16 Flapper response to a chirp signal. . . 250
6.17 Experimental setup to subject a random input into an unknown plant. The in-put/output data was collected, processed through Listing 6.2 to give the frequency response shown in Fig. 6.18. . . 250
6.18 The experimental frequency response compared to the true analytical Bode dia-gram. See the routine in Listing 6.2. . . 251
6.19 Black box response given a pseudo-random input sequence. . . 252
6.20 Black box frequency response . . . 252
6.21 Empirical transfer function estimate . . . 253
6.22 Experimental data from a continuous plant . . . 255
6.23 A continuous-time model fitted to input/output data . . . 256
6.24 Continuous model identification strategy . . . 257
6.25 Continuous model identification simulation . . . 259
6.26 Continuous model identification of the blackbox . . . 260
6.27 Identification using Laguerre functions . . . 261
6.28 A signal flow diagram of an auto-regressive model with exogenous input or ARX model. Compare this structure with the similar output-error model in Fig. 6.30. . . 262
6.29 A signal flow diagram of a ARMAX model. Note that the only difference between this, and the ARX model in Fig. 6.28, is the inclusion of the C polynomial filtering the noise term. . . 263
6.30 A signal flow diagram of an output-error model. Compare this structure with the similar ARX model in Fig. 6.28. . . 264
6.31 A general input/output model structure . . . 265
6.32 ARX estimation exhibiting bias . . . 270
6.33 Offline system identification . . . 271
6.34 Identification of deadtime from the step response . . . 278
6.35 Deadtime estimation at fast sampling . . . 278
6.36 Deadtime estimation . . . 279
6.37 Blackbox step model . . . 279
6.38 Hammerstein and Wiener model structures . . . 281
6.39 Ideal RLS parameter estimation. (See also Fig. 6.41(a).) . . . 286
6.40 Recursive least squares estimation . . . 287
6.42 RLS under SIMULINK(version 2) . . . 289
6.43 Estimation of a two parameter plant . . . 291
6.44 Confidence limits for estimation . . . 291
6.45 RLS and an abrupt plant change . . . 292
6.46 The memory when using a forgetting factor . . . 293
6.47 Identification using various forgetting factors . . . 294
6.48 Covariance wind-up . . . 296
6.49 The MIT rule . . . 299
6.50 Optimising the adaptation gain . . . 300
6.51 Addition of coloured noise to a dynamic process. See also Fig. 6.31. . . 301
6.52 RLS with coloured noise . . . 303
6.53 Nonlinear parameter estimation . . . 304
6.54 Recursive extended least-squares estimation . . . 305
6.55 A simplified recursive least squares algorithm . . . 307
6.56 Furnace input/output data . . . 308
6.57 Closed loop estimation using Simulink . . . 309
6.58 RLS in Simulink . . . 315
7.1 The structure of an indirect adaptive controller . . . 319
7.2 Varying process gain of a spherical tank . . . 320
7.3 Simple minimum variance control . . . 324
7.4 Simple minimum variance control (zoomed) . . . 325
7.5 Adaptive pole-placement control structure . . . 325
7.6 Adaptive pole-placement control structure with RLS identification . . . 331
7.7 Control of multiple plants with an adapting controller. We desire the same closed loop response irrespective of the choice of plant. . . 332
7.8 Three open loop plants . . . 332
7.9 Desired closed loop response . . . 332
7.10 Adaptive pole-placement with identification . . . 334
7.11 Comparing the adaptive pole-placement with the reference trajectory . . . 335
7.12 Bursting in adaptive control . . . 336
7.13 A plant with poorly damped zeros . . . 336
7.14 Adaptive pole-placement with an unstable B . . . 339
7.15 Pole-zero map of an adaptive pole-placement . . . 340
7.16 Areas of well-damped poles . . . 340
7.17 Adaptive pole-placement of the black-box . . . 342
7.18 Adaptive pole-placement of the black-box . . . 343
7.19 A non-minimum phase plant with an unstable zero which causes an inverse step response. . . 345
7.20 Moving average control . . . 346
8.1 Reconstructing states . . . 360
8.2 Pole-placement . . . 363
8.3 Deadbeat control . . . 365
8.4 Simultaneous control and state estimation . . . 368
8.5 Control and estimation . . . 370
8.6 GMC tuning . . . 372 8.7 GMC tuning characteristics . . . 372 8.8 Linear GMC response . . . 374 8.9 Linear GMC comparison . . . 375 8.10 GMC CSTR control . . . 378 8.11 A CSTR phase plot . . . 379
8.12 The configuration of an input/output feedback linearisation control law . . . 381
9.1 IAE areas . . . 389
9.2 ITAE breakdown . . . 390
9.3 Optimal responses . . . 390
9.4 Optimal PID tuning . . . 393
9.5 Optimum PI tuning of the blackbox plant . . . 394
9.6 SIMULINKmodel . . . 395
9.7 Production of a valuable chemical in a batch reactor. . . 396
9.8 Temperature profile optimisation . . . 397
9.9 Temperature profile optimisation using 3 temperatures . . . 398
9.10 Optimum temperature profile comparison for different number of temperatures . 398 9.11 Optimal control . . . 404
9.12 Optimal control . . . 406
9.13 Optimal control with targets . . . 408
9.14 Steady-state and time-varying LQR control . . . 414
9.15 Steady-state continuous LQR controller . . . 417
9.16 Comparing discrete and continuous LQR controllers . . . 420
9.17 LQR control . . . 423
9.18 Pole-placement and LQR . . . 424
9.19 Pole-placement and LQR showing the input . . . 425
9.20 Trial pole locations . . . 425
9.21 Trial pole-placement performance . . . 426
9.22 State feedback control system with an integral output state . . . 428
9.23 State feedback with integral states . . . 429
9.24 Black box servo control . . . 430
9.25 A state-based estimation and control scheme . . . 431
9.26 PDF of a random variable . . . 432
9.27 Correlated noisy x, y data . . . 435
9.28 2D ellipse . . . 436
9.29 Kalman filter . . . 442
9.30 A block diagram of a steady-state prediction-type Kalman filter applied to a linear discrete plant. Compare with the alternative form in Fig. 9.31. . . 444
9.31 A block diagram of a steady-state current estimator-type Kalman filter applied to a linear discrete plant. Compare with the alternative prediction form in Fig. 9.30. . 445
9.32 Kalman filter demonstration . . . 448
9.33 The performance of a Kalman filter for different q/r ratios . . . 451
9.34 A random walk process . . . 456
9.35 LQG in SIMULINK. . . 458
10.1 Horizons used in model predictive control . . . 462
10.2 Predictions of the Reserve Bank . . . 462
10.3 Inverse plant . . . 465
10.4 Predictive control . . . 466
10.5 Acausal response . . . 467
10.6 Varying the horizons of predictive control . . . 468
10.7 MPC on the blackbox . . . 468
10.8 Step response coefficients, gi, for a stable system. . . 469
10.9 DMC control details . . . 471
10.10DMC control . . . 472
10.11Adaptive DMC of the blackbox . . . 473
10.12An MPC graphical user interface . . . 474
10.13Multivariable MPC . . . 476
10.14SIMULINKand MPC . . . 476
10.15MPC . . . 477
10.17LP optimal control . . . 484
10.18LP optimal control with active constraints . . . 485
10.19Non-square LP optimal control . . . 485
10.20LP optimal control showing acausal behaviour . . . 486
11.1 Possible neuron activation functions. . . 495
11.2 A single neural processing unit with multiple inputs . . . 496
11.3 Single layer feedforward neural network . . . 497
11.4 A 3 layer fully interconnected feedforward neural network . . . 497
11.5 Single layer network with feedback . . . 498
11.6 An unknown input/output function . . . 499
11.7 Fitting a Neural-Network to an unknown input/output function . . . 501
List of Tables
1.1 Computer aids . . . 3
2.1 Final and initial value theorems . . . 24
2.2 Inverting a z transform . . . 30
2.3 Laplace transform pairs used for testing . . . 34
3.1 Standard nomenclature used in modelling dynamic systems . . . 90
3.2 Parameters of the CSTR model . . . 93
3.3 The important variables in the forced circulation evaporator . . . 94
3.4 Compressed water . . . 114
3.5 The parameter values for the CSTR model . . . 122
3.6 The initial state and manipulated variables for the CSTR simulation . . . 123
4.1 Alternative PID tuning parameter conventions . . . 132
4.2 Ziegler-Nichols open-loop PID tuning rules . . . 152
4.3 PID controller settings based on IMC for a small selection of common plants where the control engineer gets to chose a desired closed loop time constant, τc. . . 154
4.4 Various alternative ‘Ziegler-Nichols’ type PID tuning rules as a function of the ultimate gain, Ku, and ultimate period, Pu. . . 155
4.5 Closed-loop single-test PID design rules . . . 161
4.6 Relay based PID tuning . . . 172
5.1 Filter transformations . . . 201
6.1 Experimentally determined frequency response of the blackbox . . . 248
6.2 Identification in state-space . . . 276
8.1 The relationship between regulation and estimation . . . 367
8.2 Litchfield nonlinear CSTR . . . 376
9.1 Common integral performance indices . . . 391
11.1 Comparing expert systems and neural networks . . . 494
Listings
2.1 Symbolic Laplace to z-transform conversion . . . 37
2.2 Symbolic Laplace to z-transform conversion with ZOH . . . 37
2.3 Extracting the gain, time constants and numerator time constants from an arbitrary transfer function format . . . 56
2.4 Submarine simulation . . . 65
2.5 Example of the Routh array using the symbolic toolbox . . . 71
2.6 Solve the continuous matrix Lyapunov equation using Kronecker products . . . . 77
2.7 Solve the matrix Lyapunov equation using thelyaproutine . . . 78
2.8 Solve the discrete matrix Lyapunov equation using Kronecker products . . . 79
3.1 Computing the dynamic relative gain array analytically . . . 105
3.2 Computing the dynamic relative gain array numerically as a function of ω. See also Listing 3.1. . . 105
3.3 Curve fitting using polynomial least-squares . . . 109
3.4 Polynomial least-squares using singular value decomposition. This routine fol-lows from, and provides an alternative to Listing 3.3. . . 111
3.5 Curve fitting using a generic nonlinear optimiser . . . 113
3.6 Curve fitting using the OPTIoptimisation toolbox. (Compare with Listing 3.5.) . . 113
3.7 Fitting water density as a function of temperature and pressure . . . 115
3.8 Parameter confidence limits for a nonlinear reaction rate model . . . 118
3.9 Comparing the dynamic response of a pendulum to the linear approximation . . . 121
3.10 Usinglinmodto linearise an arbitrary SIMULINKmodule. . . 127
4.1 Constructing a transfer function of a PID controller . . . 133
4.2 Constructing a discrete (filtered) PID controller . . . 145
4.3 A simple PID controller . . . 146
¿ . . . 157
4.4 Ziegler-Nichols PID tuning rules for an arbitrary transfer function . . . 159
4.5 Identifies the characteristic points for the Yuwana-Seborg PID tuner from a trial closed loop response . . . 164
4.6 Compute the closed loop model from peak and trough data . . . 165
4.7 Compute the ultimate gain and frequency from the closed loop model parameters. 165 4.8 Compute the open loop model, Gm, Eqn. 4.31. . . 165
4.9 Compute appropriate PI or PID tuning constants based on a plant model, Gm, using the IMC schemes. . . 165
4.10 Calculates the period and amplitude of a sinusoidal time series using least-squares. 174 5.1 Designing Butterworth Filters using Eqn. 5.4. . . 203
5.2 Designing a low-pass Butterworth filter with a cut-off frequency of fc = 800 Hz. . 203
5.3 Designing a high-pass Butterworth filter with a cut-off frequency of fc= 800 Hz. . 203
5.4 Designing Chebyshev Filters . . . 206
5.5 Computing a Chebyshev Filter . . . 207
5.6 Converting a 7th-order Butterworth filter to 4 second-order sections . . . 218
5.7 Comparing DFII and SOS digital filters in single precision. . . 219
5.8 Routine to compute the power spectral density plot of a time series . . . 226 xix
5.9 Smoothing and differentiating a noisy signal . . . 232
6.1 Identification of a first-order plant with deadtime from an openloop step response using the Areas method from Algorithm 6.1. . . 241
6.2 Frequency response identification of an unknown plant directly from input/out-put data . . . 250
6.3 Non-parametric frequency response identification usingetfe. . . 253
6.4 Function to generate output predictions given a trial model and input data. . . 255
6.5 Optimising the model parameters. . . 255
6.6 Validating the fitted model. . . 256
6.7 Continuous model identification of a non-minimum phase system . . . 258
6.8 Generate some input/output data for model identification . . . 268
6.9 Estimate an ARX model from an input/output data series using least-squares . . . 269
6.10 An alternative way to construct the data matrix for ARX estimation using Toeplitz matrices. See also Listing 6.9. . . 269
6.11 Offline system identification usingarxfrom the System Identification Toolbox . . 271
6.12 Offline system identification with no model/plant mismatch . . . 271
6.13 Demonstrate the fitting of an AR model. . . 272
6.14 Create an input/output sequence from an output-error plant. . . 273
6.15 Parameter identification of an output error process usingoeandarx. . . 273
6.16 A basic recursive least-squares (RLS) update (without forgetting factor) . . . 284
6.17 Tests the RLS identification scheme using Listing 6.16. . . 286
6.18 A recursive least-squares (RLS) update with a forgetting factor. (See also List-ing 6.16.) . . . 293
6.19 Adaption of the plant gain using steepest descent . . . 299
6.20 Create an ARMAX process and generate some input/output data suitable for sub-sequent identification. . . 302
6.21 Identify an ARMAX process from the data generated in Listing 6.20. . . 303
6.22 Recursively identify an ARMAX process. . . 303
6.23 Kaczmarz’s algorithm for identification . . . 306
7.1 Simple minimum variance control where the plant has no time delay . . . 323
7.2 A Diophantine routine to solve F A + BG = T for the polynomials F and G. . . 328
7.3 Alternative Diophantine routine to solve F A + BG = T for the polynomials F and G. Compare with Listing 7.2. . . 328
7.4 Constructing polynomials for the Diophantine equation example . . . 329
7.5 Solving the Diophantine equation using polynomials generated from Listing 7.4. . 330
7.6 Adaptive pole-placement control with 3 different plants . . . 333
7.7 The pole-placement control law when H = 1/B . . . 337
7.8 Factorising a polynomial B(q) into stable, B+(q) and unstable and poorly damped, B−(q) factors such that B = B+B−and B+is defined as monic. . . 338
7.9 Minimum variance control design . . . 343
8.1 A simple state reconstructor following Algorithm 8.1. . . 359
8.2 Pole-placement control of a well-behaved system . . . 362
8.3 A deadbeat controller simulation . . . 365
8.4 Pole placement for controllers and estimators . . . 369
8.5 GMC on a Linear Process . . . 373
8.6 GMC for a batch reactor . . . 377
8.7 The dynamic equations of a batch reactor . . . 377
8.8 Find the Lie derivative for a symbolic system . . . 383
8.9 Establish relative degree, r (ignore degree 0 possibility) . . . 384
8.10 Design Butterworth filter of order r. . . 384
8.11 Symbolically create the closed loop expression . . . 384
9.1 Returns the IAE performance for a given tuning. . . 392
9.2 Optimal tuning of a PID controller for a non-minimum phase plant. This script file uses the objective function given in Listing 9.1. . . 392
9.3 Returns the ITSE using a SIMULINKmodel. . . 395
9.4 Analytically computing the co-state dynamics and optimum input trajectory as a function of states and co-states . . . 405
9.5 Solving the reaction profile boundary value problem using the boundary value problem solver,bvp4c.m. . . 405
9.6 Computes the full time-evolving LQR solution . . . 413
9.7 The continuous time differential Riccati equation. This routine is called from List-ing 9.8. . . 413
9.8 Solves the continuous time differential Riccati equation using a numerical ODE integrator. . . 414
9.9 Calculate the continuous optimal steady-state controller gain. . . 416
9.10 Closed loop simulation using an optimal steady-state controller gain. . . 416
9.11 Solving the algebraic Riccati equation for P∞using Kronecker products and vec-torisation given matrices A, B, Q and R. . . 417
9.12 Calculate the discrete optimal steady-state gain by ‘iterating until exhaustion’. Note it is preferable for numerical reasons to uselqrfor this computation. . . 419
9.13 Comparing the continuous and discrete LQR controllers. . . 419
9.14 An LQR controller for the blackbox . . . 423
9.15 Comparing an LQR controller from Listing 9.14 with a pole-placement controller . 424 9.16 Computing the closed loop poles from the optimal LQR controller from Listing 9.14.426 9.17 Comparing the actual normally distributed random numbers with the theoretical probability density function. . . 432
9.18 Probability and inverse probability distributions for the F -distribution. . . 434
9.19 Generate some correlated random data. . . 434
9.20 Plot a 3D histogram of the random data from Listing 9.19. . . 435
9.21 Compute the uncertainty regions from the random data from Listing 9.20. . . 436
9.22 Validating the uncertainty regions computed theoretically from Listing 9.21. . . 436
9.23 Solving the discrete time Riccati equation using exhaustive iteration around Eqn. 9.98 or alternatively using thedareroutine. . . 443
9.24 Alternative ways to compute the Kalman gain . . . 445
9.25 State estimation of a randomly generated discrete model using a Kalman filter. . . 447
9.26 Computing the Kalman gain usingdlqe. . . 449
9.27 Demonstrating the optimality of the Kalman filter. . . 450
9.28 Potter’s algorithm. . . 453
10.1 Predictive control with input saturation constraints using a generic nonlinear op-timiser . . . 465
10.2 Objective function to be minimised for the predictive control algorithm with input saturation constraints . . . 466
10.3 Dynamic Matric Control (DMC) control . . . 471
10.4 Setting up an MPC controller . . . 475
10.5 Optimal control using linear programming . . . 482
11.1 Generate some arbitrary data to be used for subsequent fitting . . . 500
B.1 Polynomial addition. . . 507
B.2 Multiple convolution. . . 507
Chapter 1
Introduction
Mathematicians may flatter themselves that they posses new ideas which mere human language is as yet unable to express. Let them make the effort to express those ideas in appropriate words without the aid of symbols, and if they succeed, they will not only lay us laymen under a lasting obligation but, we venture to say, they will find themselves very much enlightened during the process, and will even be doubtful whether the ideas expressed as symbols had ever quite found their way out of the equations into their minds. James Clerk Maxwell, 1890
Control, in an engineering sense, is where actions are taken to ensure that a particular physi-cal process responds in some desired manner. Automatic control is where we have relieved the human operator from the tedium of consistently monitoring the process and supplying the nec-essary corrections. Control as a technical discipline is therefore important not only in the fields of engineering, but also in economics, sociology and indeed in most aspects of our life. When studying control, we naturally assume that we do conceivably have some chance of influencing things. For example, it is worthwhile to study the operation of a coal fired power plant in order to minimise possibly polluting emissions, but it is not worth our time to save the world from the next ice age, or as the results of a special study group who investigated methods designed to pro-tect the world from a stray comet (such as the one postulated to have wiped out the dinosaurs 80 million years ago) concluded, there was nothing feasible we could do, such as change the earth’s orbit, or blast the asteroid, to avoid the collision. In these latter examples, the problem exists, but our influence is negligible.
The teaching of control has changed in emphasis over the last decade from that of linear single-input/single-output systems elegantly described in the Laplace domain, to general nonlinear multiple-input/multiple-output systems best analysed in the state space domain. This change has been motivated by the increasing demands by industry and public to produce more, faster or cleaner and is now much more attractive due to the impressive improvements in computer aided tools, such as MATLABused in these notes. This new emphasis is called advanced (or modern) control as opposed to the traditional or classical control. This set of notes is intended for students who have previously attended a first course in automatic control covering the usual continuous control concepts like Laplace transforms, Bode diagrams, stability of linear differential equations, PID controllers, and perhaps some exposure to discrete time control topics like z transforms and state space.
This book attempts to describe what advanced control is, and how it is applied in engineering applications with emphasis on the construction of controllers using computer aided design tools such as the numerical programming environment MATLAB from the MathWorks, [134]. With
this tool, we can concentrate on the intentions behind the design procedures, rather than the mechanics to follow them.
1.1
Scope
Part one contains some revision material in z-transforms, modelling and PID controller tuning. The discrete domain, z-transforms, and stability concepts with a brief discussion of appropriate numerical methods are introduced in chapter2. A brief potpourri of modelling is summarised in chapter3. Chapter4is devoted to the most common industrial controller, the three term PID controller with emphasis on tuning, implementation and limitations. Some basic concepts from signal processing such as filtering and smoothing are introduced in chapter5. Identification and the closely related adaptive control are together in chapters6and 7. State space analysis and optimal control design are given in the larger chapters8and9.
Notation conventions
Throughout these notes I have used some typographical conventions. In mathematical expres-sions, scalar variables are written in italic such as a, b, c, or if Greek, γ, ϕ while vectors x, y are upright bold lower case and matrices, A, ∆ are bold upper case. More notation is introduced as required.
Computer commands and output and listings are given in a fixed-width font asA=chol(B*B’). In some cases where you are to type an interactive command, the MATLABprompt>>is given, and the computed solution returned. If no ambiguity exists such as in the case for functions, the prompt is omitted.
1.2
Matlab for computer aided control design
Modern control design has heavy computing requirements. In particular one needs to: 1. manipulate symbolic algebraic expressions, and
2. perform intensive numerical calculations and simulations for proto-typing and testing quickly and reliably, and finally
3. to implement the controller at high speed in special hardware such as an embedded con-troller or a digital signal processing (DSP) chip perhaps using assembler.
To use this new theory, it is essential to use computer aided design (CAD) tools efficiently as real-world problems can rarely be solved manually. But as [170] point out, ‘the use of computers in the design of control systems has a long and fairly distinguished history’. This book uses MATLABfor the design, simulation and prototyping of controllers.
MATLAB, (which is short for MATrix LABoratory), is a programming environment that grew out of an effort to create an easy user-interface to the very popular and well regarded public domain FORTRANlinear algebra collection of programmes, LINPACKand EISPACK. With this direct inter-pretive interface, one can write quite sophisticated algorithms in a very high level language, that are consequently easy to read and maintain. Today MATLABis a commercial package, (although
some public domain lookalikes exist), that is supported with a variety of toolboxes comprising of collections of source code subroutines organised in areas of specific interest. The toolboxes we are most interested in, and used in this book are:
Control toolbox containing functions for controller design, frequency domain analysis, conver-sions between various models forms, pole placement, optimal control etc. (Used through-out)
Symbolic toolbox which contains a gateway to the symbolic capabilities of MAPLE.
Signal processing toolbox containing filters, wave form generation and spectral analysis. (Used principally in chapter5.)
System identification toolbox for identifying the parameters of various dynamic model types. (Used in chapter6.) You may also find the following free statistics toolbox useful available at:www.maths.lth.se/matstat/stixbox/.
Real-time toolbox can be used to interface MATLABto various analogue to digital converters.
The student version of MATLAB(at time of writing) has a special SIGNALS& SYSTEMS TOOLBOX
that has a subset of routines from the control and signal processing toolboxes. Other toolboxes used for some sections of the notes are the OPTIMISATION TOOLBOX, used in chapter9and the NEURALNETWORKtoolbox.
Additional documentation to that supplied with MATLABis the concise and free summary notes [183] or the more recent [68]. Recently there has been exponential growth of other texts that heav-ily use MATLAB(such as this one), and a current list is available from the Mathwork’s anonymous
ftp server atwww.mathworks.com. This server also contains many user contributed codes, as well as updates, bug fixes etc.
If MATLAB, or even programming a high level language is new to you, then [201] is a cheap recommended compendium, similar in form to this, covering topics in numerical analysis, again with many MATLABexamples.
1.2.1
Alternative computer design aids
Table1.1lists a number of alternatives computer-aided design and modelling environments sim-ilar and complimentary to MATLAB.
Product WWW site comment
SCILAB www.scilab.org Free Matlab/Simulink clone OCTAVE www.octave.org Free Matlab clone, inactive RLAB rlabplus.sourceforge.net Matlab clone, Linux VISUALMODELQ www.qxdesign.com shareware Simulink clone MATHVIEWS www.mathwizards.com shareware
MUPAD www.mupad.de Interfaces with SCILAB
MAPLE www.maplesoft.com commercial CAS MATHEMATICA www.mathematica.com commercial CAS
Table 1.1: Shareware or freeware Matlab lookalikes and computer algebra systems
Unlike MATLAB, symbolic manipulators are computer programs that by manipulating symbols
CAS. The most well known examples are MATHEMATICA, MAPLE, MUPAD, and MACSYMA, (see Table1.1). These programs can find analytical solutions to many mathematical problems involving integrals, limits, special functions and so forth. They are particularly useful in the controller design stage.
The Numerics in Control1group in Europe have collect together a freeware FORTRANsubroutine
library SLICOTfor routines relevant in systems and control.
Problem 1.1 1. Familiarise yourself with the fundamentals of MATLAB. Run the MATLAB
demo by typingdemoonce insideMATLAB.
2. Try theMATLABtutorial (part 1).
3. Read through the MATLABprimer, [183] or [68], and you should get acquainted with the
MATLABusers manual.
1.3
Economics of control
Most people would agree that Engineers apply technology, but what do these two words really mean? Technology is derived from two Greek words, techne which means skill or art, and logia which means science or study. The interesting point here is that the art component is included. The English language unfortunately confuses the word engine with engineering so that many peo-ple have the mistaken view that engineers drive engines (mostly). Actually engineer is derived from the Latin ingeniatorium which means one who is ingenious at devising. A far cry from the relatively simple act of piloting jumbos. An interesting American perspective of the professional engineer and modern technology is given as light reading in [2] and Florman’s The Existential Pleasures of Engineering, [66].
Chemical engineering is, succinctly put, chemistry constrained by cost. The chemist wants the reaction to proceed, the chemical engineer takes that for granted, but is interested in increasing the rate, or pushing the equilibrium, or in most cases both at the same time. As the incentive to produce better products increases, accompanied by an awareness of potent global competition driving one to reduce costs, process control becomes an important aspect of engineering.
Obviously modern computerised process control systems are expensive. They are especially ex-pensive compared with other computers such as office or financial computers because the market is smaller, the environment harsher, the graphical requirements more critical, the duties more var-ied, and the potential payoffs larger. Process control has at least two main duties to perform; first to ensure that the plant is operated safely (that is protect the plant, environment and people), and second that the product quality is consistent with some customer or regulatory body demanded specifications. There is always a trade off between how much control you apply and the bene-fits that result. An automobile manufacturer could produce an almost totally indestructible car (ie, tank), but the expense of raw materials required, and the high running costs would certainly deem the project an economic failure.
On the other hand, in 1965 Ralph Nader complained in the aptly named Unsafe at Any Speed about the poor quality of American automotive engineering, the lack of controls and the unsafe result. This influential book challenged the balance from between commercial profits and more quality control. A product with less variation in quality may be worth more than a product that has a higher average quality, but more variation. A potentially dangerous production facility that regularly destroys equipment, people or surroundings is not usually tolerated by the licensing authorities.
Safety concerns motivate better control. Fig.1.1, adapted from [6], gives an industrial perspective of the status of process control in 1994. The techniques are divided into those considered “classical” or traditional, which demand only modest digital online computing power, (if any), little in the way of explicit process models or understanding, and those termed loosely “advanced”.
compensation
Valves Onstream analysers
Process computer multivariable feedforward control smart transmitters DCS single variable Online simulation Deadtime Transmitters Advanced control PLCs PID algorithm dynamic methods Rule definition Direct search Regulatory Constraint Optimisation Basic Field Signal condition Steady state analogue control Traditional control
Figure 1.1: A comparison of traditional vs. advanced process control techniques. Adapted from [6].
One of the major concerns for the process control engineer is to reduce the output variance. If the variation about the setpoint is small, then the setpoint can be shifted closer to the operating constraint, without increasing the frequency of alarms. Fig.1.2demonstrates the ideal case that while popular in the advertising literature, is harder to achieve unambiguously in practice. Many text books in the control field are very vague about the actual configuration of real pro-cess control systems used today. Other books that take a more trade oriented approach, are vague about the academic side of the control performance. There are a number of reasons for this. First many texts try hard to describe only the theoretical aspects of digital control, and any-thing remotely applied is not considered worthy of their attention. Secondly, the control systems are rapidly changing as the cost of micro-processors drop in price, and different programming methods come into flavour. Thirdly many industries are deliberately vague about publishing the details of their control system since they perceive that this information could help their com-petitors. However some information of this type is given in [63, pp131-149] and [17]. One good
spt #3
manual control
advanced control upper quality constraint
process output regulatory loss ($) violations time setpoint #1 spt #2
Figure 1.2: Economic improvements owing to better control. If the control scheme can reduce the variance, the setpoint can be shifted closer to the operating or quality constraint, thereby decreasing operating costs.
balance for the practitioner is [143].
1.4
Laboratory equipment for control tests
Obviously if we are to study automatic control with the aim to control eventually chemical plants, manufacturing processes, robots, undertake filtering to do active noise cancellation and so forth, we should practice, preferably on simpler, more well understood, and potentially less hazardous equipment.
In the Automatic Control Laboratory in the Department of Electrical Engineering at the Karlstad University, Sweden we have a number of simple bench-scale plants to test identification and control algorithms on.
1.4.1
Plants with one input and one output
The blackboxFig.1.3and Fig.1.4(a)shows what we perhaps unimaginatively refer to as a “black-box’. It is a box, and it is coloured black. Subjecting the box to an input voltage from 0 to 5 volts delivers an output voltage also spanning from around 0 to 5 volts, but lagging behind the input voltage since the internals of the blackbox are simply either 7 or 9 (depending on the switch position) low-pass passive filters cascaded together.
The blackbox is a relatively well behaved underdamped stable system with dominant time con-stants of around 5 to 10 seconds. Fig.1.4(b)shows the response of the blackbox to two input steps. The chief disadvantage of using this device for control studies is that the output response
-
-D/A A/D
Earth input indicator blue
blue GND Input Output (connector #1) (connector #10) (connector #11) BLACK-BOX -Sluggish Fast To computer From computer
Figure 1.3: Blackbox configuration. The manual switch marked will toggle between either 7 or 9 low-pass filters.
(a) Black-box wiring to the National Instruments LabPC terminator. input output 15 20 25 30 35 40 45 50 −0.05 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 ipnut/output time (s) Blackbox step response
(b) The response of the blackbox to 2 step inputs
Figure 1.4: The “Black-box”
is not ‘visible’ to the naked eye, and that we cannot manually introduce disturbances. One com-plication you can do is to cascade two blackboxes together to modify the dynamics.
Electro-magnetic balance arm
The electromagnetic balance arm shown in Fig.1.5(a) is a fast-acting, highly oscillatory, plant with little noise. The aim is to accurately weigh small samples by measuring the current required to keep the balance arm level, or alternatively just to position the arm at different angles. The output response to a step in input shown in Fig.1.5(b)indicates how long it would take for the oscillations to die away.
(a) The electromagnetic balance arm 20 30 40 50 60 70 80 90 100 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 arm position
Step response of the balance arm
20 30 40 50 60 70 80 90 100 −0.2 −0.1 0 0.1 0.2 0.3 time ∆T=0.05 seconds input
(b) The response of the arm to a step changes in input.
Figure 1.5: The electromagnetic balance arm
Flapper
Contrary to the balance arm, the flapper in Fig.1.6and Fig.1.7(b)has few dynamics, but signif-icant low-pass filtered measurement noise. An interesting exercise is to place two flapper units in close proximity. The air from one then disturbs the flapper from the other which makes an interacting multivariable plant.
Stepper motors
A stepper motor is an example of a totally discrete system.
1.4.2
Multi-input and multi-output plants
It is possible to construct multivariable interacting plants by physically locating two plants close to each other. One possibility is to locate two flappers adjacent to each other, another possibility is one flapper and one balance arm. The extent of the interaction can be varied by adjusting the relative position of the two plants.
Helicopter
The model helicopter, Fig. 1.8, is an example of a highly unstable, multivariable (3 inputs, 2 outputs) nonlinear, strongly interacting plant. It is a good example of where we must apply control (or crash and burn). Fig.1.9(b)shows the controlled response using 2 PID controllers to control the direction and altitude. Fig. 1.10(a)shows a 3 dimensional view of the desired and actual flight path.
manual auto/man 6 6 Digital to Analogue (Fan speed) 6 6 6 ? N Flapper arm ? ? A/D On/Off switch Motor -position transducer angle O 6
power to the motor
Figure 1.6: The flapper wiring
(a) The fan/flapper equipment
0 5 10 15 20 25 30 35 40 45 50 −0.1 0 0.1 0.2 0.3 0.4 input time (sec) dt=0.05 0 5 10 15 20 25 30 35 40 45 50 0.1 0.15 0.2 0.25 0.3 0.35 output
Step response of the flapper
(b) Step response of the flapper
top rotor
side rotor
support stand )
1 moveable counter weight -azimuth plant outputs z }| { control inputs elevation angle
Figure 1.8: Helicopter plant with 2 degrees of freedom. See also Fig.1.9(a).
1.5
Slowing down Simulink
For some applications like the development of PID controllers you want to be able to slow down the SIMULINK simulation to have time to manually introduce step changes, add disturbances, switch from automatic to manual etc. If left alone in simulation mode, SIMULINKwill run as fast as possible, but it will slow down when it needs to sub-sample the integrator around discontinu-ities or periods when the system is very stiff.
The SIMULINKExecution Control block allows you to specify that the simulation runs at a multi-ple of real-time. This is most useful when you want to slow down a simulation, or ensure that it runs at a constant rate.
The block is available from:http://www.mathworks.com/matlabcentral/fileexchange
The implementation is shown in Fig.1.11where the Simulation Execution Control block looks like an A/D card but in fact is not connected to anything, although it does export some diagnostic timing information.
An alternative method to slow down a Simulink simulation and force it to run at some set rate is to use the commercial Humusoft real-time toolbox, but not with the A/D card actually interfaced to anything.
(a) The ‘flying’ helicopter balanced using 2 PID controllers since it is openloop unstable and would otherwise crash. 0 10 20 30 40 50 60 70 80 90 100 −1.5 −1 −0.5 0 0.5 1 1.5 output Helicopter 0 10 20 30 40 50 60 70 80 90 100 −1 −0.5 0 0.5 1 input Time (sec)
(b) Multivariable PID control of the helicopter exhibiting mediocre controlled response and severe derivative kick.
0 50 100 150 200 250 −1.5 −1 −0.5 0 0.5 1 1.5 −1 −0.5 0 0.5 time Helicopter flight path
East/West
Up/Down
(a) Multivariable helicopter control (b) Model helicopter in the trees
Figure 1.10: Helicopter flying results
1 s+1 Transfer Fcn Simulink Execution Control Signal Generator Scope1 Scope
Figure 1.11: Real-time Simulink simulations. A parameter in the SIMULINK EXECUTIONCON
Chapter 2
From differential to difference
equations
Excerpt from What a sorry state of affairs, Martin Walker, Guardian Weekly, June 29, 1997. . . . But then he said something sensible, as he quite often does. . . . “We need to treat individuals as individuals and we need to address discrete problems for what they are,
and not presume them to be part of some intractable racial issue.” Gingrich, properly understood, is a national treasure, and not only because he is one of the few Americans who understand the difference between “discreet” and “discrete”.
2.1
Computer in the loop
The cost and flexibility advantages of implementing a control scheme in software rather than fabricating it in discrete components today are simply too large to ignore. However by inserting a computer to run the software necessitates that we work with discrete regularly sampled signals. This added complexity, which by the way is more than compensated by the above mentioned advantages, introduces a whole new control discipline, that ofdiscrete control.
Fig.2.1shows a common configuration of the computer in the loop. For the computer to respond to any outside events, the signals must first be converted from an analogue form to a digital signal, say 1 to 5 Volts, which can, with suitable processing be wired to an input port of the computer’s processor. This device that accomplishes this conversion is called an Analogue to Digitalconverter or A/D. Similarly, any binary output from the pins on a processor must first be converted to an analogue signal using aDigital to Analogue converter, or D/A. In some micro-controllers, (rather than micro-processors), such as Intel’s 8048 or some versions of the 8051, these converters may be implemented on the microcontroller chip.
Digital to analogue conversion is easy and cheap. One simply loads each bit across different re-sistors, and sums the resultant voltages. The conversion is essentially instantaneous. Analogue to digital is not nearly as easy nor cheap, and this is the reason that the common data acquisition cards you can purchase for your PC will often multiplex the analogue input channel. There are various schemes for the A/D, one using a D/A inside a loop using a binary search algorithm. Obviously this conversion is not instantaneous, although this is not normally considered a prob-lem for process control applications. Any introductory electrical engineering text such as [171]
-Process control computer
D/A -A/D + 6 - --+ - computer r(t) setpoint − y(t) output Plant
Figure 2.1: The computer in the control loop
will give further details on the implementation details.
2.1.1
Sampling an analogue signal
It is the A/D converter that is the most interesting for our analysis of the discrete control loop. The A/D converter will at periodic intervals defined by the computer’s clock sample the continu-ous analogue input signal. The value obtained is typically stored in a device called azeroth-order holduntil it is eventually replaced by the new sample collected one sample time later. Given con-straints on cost, the A/D converter will only have a limited precision, or limited number of bits in which to store the incoming discrete value. Common A/D cards such as the PCLabs card, [3], use 12 bits giving 212or slightly over 4 thousand discretisation levels. The residual chopped away is referred to as thequantisation error. For a given number of bits, b, used in the converter, the amplitude quantisation is
δ = 2−b
Low cost analogue converters may only use 8 bits, while digital audio equipment use between 16 and 18 bits.
Fig.2.2shows the steps in sampling an analogue signal with a three bit (8 discrete levels), A/D sampler. The dashed stair plot gives an accurate representation of the sampled signal, but owing to the quantisation error, we are left with the solid stair plot. You can reproduce Fig. 2.2 in MATLABusing the fixcommand to do the chopping, andstairsto construct the stair plot. While other types of hold are possible, anything higher than a first-order hold is rarely used.
2.1.2
Selecting a sample rate
Once we have decided to implement discrete control, rather than continuous control, we must decided on a reasonable sampling rate. This is a crucial parameter in discrete control systems. The sample time, (T or sometimes denoted ∆t ), is measured in time units, say seconds or in industrial applications, minutes. The reciprocal of the sample time is the sample frequency, f , and is usually measured in cycles/second or Hertz. The radial or angular velocity (which some confusingly also term frequency) is denoted ω and is measured in radians/second. The inter-relationships between these quantities are
f = 1 T cycles second = ω 2π radians/s radians/cycle (2.1)
0 2 4 6 8 10 12 0 1 2 3 4 5 6 7 Sample time, (k∆T) Signal
Sampling a continuous signal Analogue Sampled
Sampled & quantisized
Figure 2.2: Sampling an analogue signal (heavy solid) with a three bit (8 discrete levels) A/D con-verter and zeroth-order hold. The sampled val-ues, •, are chopped to the next lowest discrete integer level giving the sampled and quantisied output
The faster the sampling rate, (the smaller the sampling time, T ), the better our discretised signal approximates the real continuous signal. However, it is uneconomic to sample too fast, as the computing and memory hardware may become too expensive. When selecting an appropriate sampling interval, or sample rate, we should consider the following issues:
• The maximum frequency of interest in the signal
• The sampling theorem which specifies a lower limit required on the sampling rate to resolve any particular frequency unambiguously. (See §2.1.3following.)
• Any analogue filtering that may be required (to reduce the problem of aliasing) • The cost of the hardware and the speed of the A/D converters.
Ogata discusses the selection of a sample time qualitatively in [148, p38]. However for most chemical engineering processes, which are dominated by relatively slow and overdamped pro-cesses, the sample time should lie somewhere between ten times the computational delay of the hardware tcand some small fraction of the process dominant time constant τ , say
10tc≤ T ≤ τ
10 (2.2)
For most chemical engineering applications, the computational delay is negligible compared with the process time constant, (tc → 0), so we often choose T ≈ τ/10. Thus for a simple first order rise, we would expect to have about 20–30 data samples from 0 to 99%. Some may argue that even this sampling rate is too high, and opt for a more conservative (larger) sample time down to τ /6. Note that commonly used guidelines such as presented in Table 22.1 in [179, p535] span a wide range of recommended sample times.
Overly fast sampling
Apart from the high cost of fast A/D converters, there is another argument against fast sampling. When one samples a continuous system, the poles of a stable continuous system map to the poles of a stable discrete system as T goes to zero. However the zeros in the LHP of a continuous system may not map to zeros inside the unit disk of a discrete system as T tends to zero. This nonintuitive result could create problems if one samples a system, and then uses the inverse of this system within a one step controller, since now the zeros outside the unit circle become