A Microprocessor Implementation of a Self-tuning Controller

A Microprocessor Implementation of a Self-tuning Controller

Copnight © l L 'l.C ,-'l.dapti \'e S' st e m s in Control and Signal Processing, LlInd . S"'ed e n . 19H6 A MICROPROCESSOR IMPLEMENTATION OF A SELF-T...

1MB Sizes 22 Downloads 85 Views

Copnight © l L 'l.C ,-'l.dapti \'e S' st e m s in Control and Signal Processing, LlInd . S"'ed e n . 19H6

A MICROPROCESSOR IMPLEMENTATION OF A SELF-TUNING CONTROLLER A. L. Oliveira, F. V. Coito, L. M. Silveira, and J. S. Marques

J.

M. Lemos*,

een lro de AllIi lise e Processa lllelllo de Sillais (CAPS ) - Complexo I Illslitulo Superior T eCllico. 1096 Lisboa Codex - Portugal

Abstract. The software implementation of a self-tuning controller in a 16 bit microprocessor (INTEL 8086) is discribed and discussed at the light of the experimental results obtained. The algorithm used combines generalized m nimum variance servo-control, the UD implementation of least-squares estimation and a variable forgetting factor. Problems that confront the implementation of adaptive controllers in a 16 bit environment with fixed point arithmetic (16+16 bits) and limited available memory are discussed. A series of real time experimental case-studies are presented in order to evaluate the implementation done. The aplication of the self-tuning controller to a thermal diffusion process is ilustrated. Keywords. Adaptive control, computer control, self-adjusting systems, predictive control, time varying systems, thermostats.

INTRODUCTION The implementation of low-cost robust adaptive controllers is an important step towards its industrial applications. The advent of microprocessors opened the possibility of implementing in real time and with reduced cost elaborated control algorithms. The use of short wordlenght microprocessors risks however to degrade the performance of digital controllers and special care must be taken in order to avoid round-off and overflow errors and to minimize the computational delay.

most important to avoid numerical problems arising from the use of a short wordlenght. The variable forgetting factor assures good adatability of the controller to timevarying systems while eliminating the risk of covariance Wind-up in equilibrium situations. In order to evaluate and exhibit the features of the implementation done, a series of real-time experimental case studies are presented.

SELF-TUNING ALGORITHM The self-tuning generalized minimum variance plus least-squares controller (STURE) is an important base-line to wich more sophisticated controllers may be compared. As an important e xample algorithms based on a multi step cost-functional such as MUSMAR ( Greco, 1984) are known to enjoy important robustness properties, and at the same time be amenable to be implemented using similar technics to the ones used in STURE

The STURE controller is an non-linear,double feedback system with two main blocks (fig.1): the identification block, where the control parameters are estimated in real time, and the controller, that uses the reference, the input/output plant data and the parameter estimates to generate the control signal u(t).

In this paper software for the implementation of the STURE adaptive controller in a 16 bit microprocessor (INTEL 8086) is discussed and evaluated by experiments. The algoritm used combines generalized minimum variance servo-control, the UD implementation of recursive least-squares estimation (Bierman, 1977) and a variable forgetting factor (Fortescue, 1981).This combination was choosen in order to provide a balance between simplicity, computational load and performance. UD factorization is (*)-To whom all correspondence should be

fig.1-Structure of the STURE controller.

sent.

243

244

A. L. Oli\eira , et al.

Plant model The plant is modeled by the predictive model y(t): eT 'I' (t)te(t)

with wIt) the parameter that and is given by

reference to follow and a weights the control effort,

(1 ) (4 )

with According to a certainty equivalence strategy, e is replaced by its most recent estimate B ( t).

e T:[a 1 , "ana

b 1 ,,·nnb) a vector of parameters, and 'I'T(t):[y(t-d-l) ... y(t-d-na) d-nb»)

u(t-d-1) ... u(t-

the record of past input/output pairs with dtl being plant's delay and na, nb its orders. The zero mean stochasti~ perturbation e(t) can be supposed to be white according to the self-tuning property. Estimation algorithm The vector of parameters El is estimated using recursive least-squares. Being El(t-1) the estimate available at time t-l, the estimate at time t is obtained by the updating equation 8(t):e (t-l)tK(t)[y(t)- eT(t-l) 'I' (t») (2) where K(t) is the Kalman gain, dependent of the error covariance matrix P. The standard recursive least-squares algorithm is sensitive to numerical errors that destroy the simmetry and definitepositive character of the P matrix. In order to avoid this problem, Bierman's (1977) UD covariance updating algorithm is used. In this algorithm the P matrix is factorized as

where U is an unit upper triangular matrix and D is a diagonal matrix. The covariance matrix is thus forced to be symetric and positive definite and the precision increases since the dinamyc range of the numbers used is small er . The forgetting factor is variable according to Fortescue's algorithm (Fortescue, 1981)

with f

and

a

:y(t)- El T(t-1) rp (t) parameter

that

commands

the

the estimator. Eq. (3) sensibility of is complemented with a test to prevent the value of A to become smaller than some specified Amin The use of a variable forggeting factor improves the adaptability of the controller to situations where the plant parameters are changing, and at the same time prevents the risk of covariance windup in equilibrium situations. Control algorithm The control is such that it minimizes the generalized minimum variance cost functional J:E[ (y (ttd) -101 (ttd) ) at P u a (t ) )

IMPLENENTATION Hardware The hardware used is an SDK-86 development kit with the microprocessor 8086 in minimum mode. The SDK-86 is provided with 4 Kbyte of static RAM memory and 3 I/O ports of 16 bits each. The clock is working at 5 MHz. In a board outside the SDK-86 there are available A/D and D/A converters with a 12 bit resolution ( ADC 1211 ) . Software environment The STURE controller is embedded in a special purpose environment for control systems definition, called LPD (dedicated programming language - Rosa, 1984). The LPD language is build up of a set of routines (Macros) that constitute the language intructions. The sintax is defined by Macro programming rules. The existence of a monitor dedicated to LPD allows an easy modification of parameters, sample times and even control system structure. In order to be integrated in LPD, the STURE controller is programmed in only one Macro block. There are macro subroutines that take care of operations not directly concerned with the control algorithm such as for instance data input/output. Sampling sincronization is performed by a timer instaled on the AD/DA card, working by interrupts. STURE routine The order of the operations performed by the STURE routine is the following

o-

Wait for an interrupt. Reads the AD converter and converts to internal format. 2 - Identification. 3 - Control. 4 - Converts data to DAC format and writes to DAC.

1

Arithmetic operations are performed in the internal format of two's complement, fixed point with 32 bits (16t16), in order to optimize the trade-off between small calculation delay and minimization of the memory ocupied. Floating point implies more memory and/or more calculation delay, and was therefore not used. With the implementation performed th. maximum sampling time is lOOms for a syst~m with 6 parameters to estimate. In order to minimize the delay between the sampling instant and the output of the control (Bicudo, 1986),it would be better to invert the operations of identification and control. This presents some advantages when the calculation time is near the sampling interval and the parameters of the plant varies slowly. This is however not convenient in the LPD environment.

Microprocessor Implementation Special care is taken in order to avoid overflow and round-off errors. The operations of multiplication and division are ordered so that the intermediate results are as near the unit as possible. When an overflow is detected the result of the corresponding equation is saturated.

degrades

245

the precision of the b and

estimates effects.

cause

parameter. i nonminimum phase

At startup, the control action is exerced by a PID controller in order to provide reasonable estimates before the control routine comes in action. f1g.2.. Open loop response of a two real pole system, excited by a square signal.

EXPERIMENTAL RESULTS The performance of the control was tested using an analog simulated plant and a thermal diffusion process. Analog simulations Fig.2.a shows the open loop step response of a plant with two stable real poles (one much closer to the origin than the other). Fig.2.b shows the response of the same system when controlled. When controlling very slow systems, two problems that eventually may appear are the saturation of the control and the underflow of the b i parameters. In order to avoid this the sampling time should be choosen carefully. Fig.3.a shows the transient due to the startup of the identifier/controller (at t=t ) when a system with two imaginary poles 1 starts being regulated to zero. Fig.3.b refers to the same system, but the controller starts only some samples after the startup of the identifier. The use of a variable forgetting factor allows a quick adaptation of the parameters (typically 4 to 8 samples with a convenient value of Eo)'

fig.2.b Response of the same system when controlled by the self-tuning adaptive controller. ( p =O.002, 1:0=1 )

fig.3.. Control to with two imaginary

the origin of a system poles. At t=t , the 1

identifier -controller is started. ( p=O.004, E =1) o

During the adaptation transient, problems may arise due to overflow or underflow, specialy for systems with a small relative stability. The influence of the parameters weight), T (sampling time) (estimation filter ilustrated in figs.4 to 6. The

influence

of

Eo

in

(control and Eo sensibility) is the

p

velocity of

fig.3.b origin.

The The

same system controlled to the identifier starts at t=t and 1 the controller only after t=t 2 ·

adaptation of the controller in reaction to abrupt changes may be seen on figs.4.a and 4.b. An excessively high value of Eo leads to a longer adaptation time. In both figs.4.a and 4.b the plant changes abruptly at time t=t from a system with two real 1 poles to a system with a real pole and a pole at the origin.

I t1

ligs.S.a and S.b show how the e x istence of • control weight improves the performance. The greater settling time of fig.S.b is a fair price to pay by the diminuishing of intersample riple and smaller control values. The correct choice of the sampling time is an important issue and depends on the trade-off between the time needed to exerce the control action and the maximum time that the system can be working in open loop, between samples . Fig6.b shows how the controller is performing badly with a plant (integrator) that, with a smaller sampling time, is conveniently controlled (fig.6. a ). A too small sampling interval, however, ASC-I

fig.4 Transient due to an abrupt change in the controlled system. At t=t a two stable 1 real pole system k/ (( s+a)(s+b» changes to a system with a real pole and a pole at the origin k/ ( s(s+b» . ( pzO, E (4.b)/ E (4.a)=1.S ) o o

A. L. Oliveira, et al.

246

o utput output

c o ntrol

control

fig.6.il T=140ms

fig.5.a Without weight in control (

__r

~ output

p=O.OOZ

p = O ).

ou t put

\

~

/I/{ifwj ~.N""~ control fig.6.b T=Z80ms

control

P=O.OOZ

fig . 6 Effects of varying the sampling time in the control of the system k/s.

fig.5.b With some weight in control (

p=O.063).

Thermal diffusion process The experimental thermal diffusion process sketched in fig.7 is controlled with the fig.5 Control of a system with a stable pole algorithm developed. The objective is to and a pole at the origin l/(s(s+a» keep the temperature y of a point of the diffusion media as constant as possible following a square signal. around a specified reference value .

STURE

HEATER

PLANT

fig.7 - Thermal diffusion process.

DIFFUSION MEDIA

v

24 7

Micro processo r Impleme ntatio n The control of this difficult questions

plant

rises

some

rapid 1 ) The undergoes system perturbations associated with a time constant much slower than the one of the ones due to the plant (e.g. convection and air movement) . 2) Parameter variations (e.g. variations of the ambient temperature, variation of the resistance of the heating element wiht the temperature). Figs.8.a and 8.b show the open loop and controlled responses of the system with (incremental) null reference, when subject to perturbations. Perturbation rejection is achieved in one sampling period. The sampling interval choosen is a compromi5e between a rapid rejection of perturbations and a good estimation of the biparameters.

increase the computational load, but the robustness properties are greatly enhanced, in what respects for instance unmodelled dynamics and systems with pathological noise. This is an important topic when applications to real systems are considered, such as the thermal diffusion system described. Another topic concerns the maximum speed available with the algorithm. With the implementation done this is of 100 ms for a third order system, which is more than enough for the great majority of industrial processes. If one considers the control of electromechanical devices this is however insuficient, and should be lowered to less than 10 ms, calling for a change in hardware. For instance a numerical processor should be used or a dedicated digital signal processor such as the TEXAS TMS 320.

ACKNOWLEDGMENT The authors wich to acknowledge the cooperation of Agostinho C. Rosa who has kindly informed on all details of his thesis and the SDK-86.

REFERENCES fig.8.a Open-l o op T

H

v

fig.8.b 20s.

Closed-loo p, with a samplingtime of

fig.8 Output of the t ermal diffusion process, controlled to a fixed reference and submited to fast disturbances.

DISCUSSION AND CONCLUSIONS The implementation of the generalized minimum variance plus least-squares selftuning controller in a microprocessor requires additional cares in order to be successfull. Important points are the roundoff and overflow errors that demand the use of special technics such as VD factorization. In order to have a good compromise between adaptability and safety against covariance windup in equilibrium situations,the use of a variable forgetting factor is mandatory. This paper uses one algorithm due to Fortescue (1981), but other alternatives are pos5ible. Despite its simplicity, the algorithm is able to have a good performance even in limite situations, such as for instance the control of the double integrator. However, its performance can be greatly improved by ' the use of more robust algorithms, such as MVSMAR (Greco, 1984). As shown in Manfredi (1983) the use of aultipredictors does not significantly

Bicudo, P., F. Garcia and J. M. Lemos (1986 ) . Implementing an adaptive controller in an 8 bit microprocessor. Presented at 2nd Simposio de Electronica das Telecomunicayoes, Lisbon 21 - 23 May. Bierman ( 1977). Factorization methods for discrete sequential estimation. Academic Greco, C., G. Menga, E. MOSCA and G. Zappa (1984). Performance improvements of self-tuning controllers by multi step horizons the MVSMAR approach. Automatica, 20,5,681-699. Fortescue, T. F., L. S. Kershenbaum and B. E. Ydstie (1981).Self-tuning regulators with variable forgetting factors. Automatica , 12, 6, 831-835. Manfredi, C. (1983). VD implementation of the MVSMAR algorithm. DSI, RT-3/83, Firenze. Rosa, A. C. (1984). Real time interactive digital controller COnIP 86 (in Portuguese). Thesis, DEEC-IST, Lisbon. Sheirah, M. A. H., O. P. Malik and G. S. Hope (1982). Self-tuning microprocessor universal controller. IEEE Trans. on Industrial Electronics, 29, 1, 31-38.