500 MILLION PARTS FROM 12000 MANUFACTURERS

DSP56000/ DSP56001 APR15 DSP56000/DSP56001 REN-88 IRV-86 SAM-83 IRV-83 LAN-84 - Datasheet Archive

CT OR , IN C.2 006 Freescale Semiconductor, Inc. DU Motorola Digital Signal Processors ON Freescale Semiconductor, Inc. by Pascal Renard, Ph.D. Strategic Marketing Geneva, Switzerland CH IVE DB YF RE ES CA LE SE MIC Implementation of Adaptive Controllers on the Motorola DSP56000/ DSP56000/ DSP56001 DSP56001 MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. APR15 APR15 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. DU ON MIC SE LE CA CH IVE DB YF RE ES Motorola reserves the right to make changes without further notice to any products herein. Motorola makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Motorola assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. "Typical" parameters can and do vary in different applications. All operating parameters, including "Typicals" must be validated for each customer application by customer's technical experts. Motorola does not convey any license under its patent rights nor the rights of others. Motorola products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the Motorola product could create a situation where personal injury or death may occur. Should Buyer purchase or use Motorola products for any such unintended or unauthorized application, Buyer shall indemnify and hold Motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that Motorola was negligent regarding the design or manufacture of the part. Motorola and are registered trademarks of Motorola, Inc. Motorola, Inc. is an Equal Opportunity/Affirmative Action Employer. AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. DU SECTION 1 1.1 History of Adaptive Control 1.2 Theory of Adaptive Control ON Introduction 2.1 Parametric Models 2.2 Adaptive Control Techniques SECTION 2 3.1 Adaptive Control Using Reference Models 3.1.1 Introduction 3.1.2 Closed-Loop System 3.1.3 Control Law 3.1.3.1 Known System Parameters 3.1.3.2 Unknown System Parameters 3.1.4 Determination of Controller Parameters 3.1.5 Comment 3.2 Generalized Predictive Control 3.2.1 Introduction 3.2.2 Closed-Loop System 3.2.3 Control Law 3.2.3.1 Definition of Parametric Model 3.2.3.2 Definition of System Output Prediction 3.2.3.3 Determination of Polynomials 3.2.3.4 Determination of Control Law 3.2.4 Comment CH IVE DB YF RE ES CA LE Adaptive Control and Adaptive Controllers SE SECTION 3 MIC Numerical Domain Representation MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Table of Contents 1-1 1-2 2-1 2-6 3-1 3-1 3-2 3-4 3-4 3-9 3-10 3-14 3-15 3-15 3-18 3-19 3-19 3-19 3-21 3-21 3-25 iii For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. DU SECTION 4 4.1 Implementation 4.1.1 Simulation 4.2 Generalized Prediction Controllers 4.2.1 Implementation MIC 5.1 Advantages of Adaptive Control 5.2 Advantages of DSP56000/DSP56001 DSP56000/DSP56001 Architecture SE SECTION 5 LE Conclusion A.1 Equation Formulation A.2 Estimation of Model Parameters A.3 The Least-Squares Estimator A.3.1 Is the LSE biased? A.3.2 How accurate is the LSE? A.3.3 Conclusion (on LSE accuracy and bias) A.4 Improving the "LSE" A.4.1 What is required to minimize LSE bias? A.4.2 What is required to minimize LSE variance? A.5 Conclusion DB YF RE ES CA APPENDIX The Least MeanSquare Principle 4-1 4-2 4-2 4-2 ON Implementation and Simulation of Adaptive Controllers Using Reference Models IVE CH iv 5-1 5-3 A-1 A-3 A-6 A-6 A-7 A-7 A-8 A-8 A-8 A-9 Index-1 Reference-1 INDEX REFERENCES AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Table of Contents MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Basic principles of adaptive control Figure 2-1 Parametric model description in terms of process input and output 2-2 Figure 2-2 Adaptive controller in closed loop 2-6 Figure 2-3 Standard input and disturbance signals 2-7 Figure 2-4 Dynamic response in open loop 2-8 Figure 2-5 Desired dynamic response in closed loop 2-9 Figure 3-1 Adaptive control using reference models in closed loop 3-3 Figure 3-2 Generalized predictive control using closed loop 3-18 Figure 4-1 Simulation results for adaptive controller using parallel-serial reference models 4-3 Figure 4-2 Generalized Predictive Controller ON MIC SE LE CA ES Adaptive Controller RE Figure 4-3 DU Figure 1-1 Freescale Semiconductor, Inc. Parametric model description in terms of process input and output 1-6 4-4 4-15 A-1 CH IVE DB YF Figure A-1 MOTOROLA AR Freescale Semiconductor, Inc. Illustrations v For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. DU AR CH IVE DB YF RE ES CA LE SE MIC ON Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. SECTION 1 This ON DU section shows how Motorola DSP56000/ DSP56000/ DSP56001 DSP56001 digital signal processors can be used to solve real-time digital control problems. After reviewing the relevant basic theory of adaptive control, we look at a number of implementations. 1.1 History of Adaptive Control SE MIC "An adaptive control system measures a certain performance rating of the system (or plant) to be controlled." Very few of the microcontroller-based digital regulators developed to date fully exploit the key advantages of microprocessor technology. Most designers seem content to emulate the behavior of traditional PID analog regulators. Sad though it may be, this is indeed an accurate reflection of industrial reality, in many cases.Unfortunately, conventional PID controllers, whether analog or digital, are only efficient CH IVE DB YF RE ES CA LE Computerized industrial process control has advanced by leaps and bounds over the last ten years in hardware and methods. The development of new microcontrollers and digital signal processors (DSPs) has given rise to important changes in regulation system design. The capabilities and low cost of the latest DSPs make them ideal for a wide range of regulation applications. Further, and despite the fact that analog regulators still enjoy wide popularity, DSPs offer higher performance than their analog predecessors. MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Introduction 1-1 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. DU where the system to be controlled (the plant) - or rather the model of that system represented within the controller - is characterized by constant parameters applicable at all operating points. And yet, most complex industrial systems are characterized by parameters that vary with the system operating point [REN-88 REN-88], thus failing to meet the basic assumption just stated. Two examples are heat exchangers (such as those used in the production of textile fibers) and internal-combustion engines. In such cases, a control signal generated by a conventional PID controller (i.e. one for which the parameters are computed once and for all on the basis of a constant-parameter system model) will inevitably give rise to progressively more degraded operation of the overall control loop as the errors between controller and actual process parameters increase. This can only be corrected by modifying the controller coefficients . . . Which brings us to adaptive control. CA LE SE MIC ON Freescale Semiconductor, Inc. 1-2 Together or separately, microcontrollers and DSPs enable us to design higher performance regulation systems using more sophisticated digital control algorithms, many of which have already been developed under and tested in industrial conditions [IRV-86 IRV-86]. Adaptive control represents an advanced level of controller design. It is recommended for systems operating in variable environments and/or featuring variable parameters. CH IVE DB YF RE ES 1.2 Theory of Adaptive Control AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. DU Although adaptive control has only been around for a few years, it has already been successfully employed in a number of industrial applications. The basic principles were published by Kalman, in 1958, for the stochastic approach, and later by Whitaker for the deterministic approach. However, the technique was not viable for two reasons: ON · The solutions proposed at the time were not very "robust". MIC · The hardware (computers) required for implementation were either unavailable or far too expensive. CA LE SE Currently, however, the technique is rapidly gaining new supporters. This is largely a result of recent work that has improved algorithm robustness [SAM-83 SAM-83 and IRV-83 IRV-83] and of the development of microcontrollers and/or DSPs which make it possible to support and implement the new algorithms. YF RE ES Adaptive control is a set of techniques for the automatic, on-line, real-time adjustment of controlloop regulators designed to attain or maintain a given level of system performance where the controlled process parameters are unknown and/or timevarying. The use of microcontrollers and/or DSPs in control loops offers the following advantages: IVE DB · Wide range of alternative strategies for controller design and mathematical modelling,Freedom to use regulation algorithms that are more complex and offer higher performance than PID CH · Technique is suitable for process control applications involving time delays MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. 1-3 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. · Automatic estimation of process models for different operating points · Automatic adjustment of controller parameters DU · Real-time diagnostic capability Freescale Semiconductor, Inc. 1-4 Once the model and its structure have been identified, the next step is to select a control strategy. This choice depends in part on the nature of the problem (regulation or tracking) and on the system characteristics (minimum phase or not). The number of options available depends on the extent of our advance knowledge of these characteristics. The aim is to select a strategy yielding a satisfactory control law in the case where the system model and CH IVE DB YF RE ES CA LE SE MIC ON Adaptive control is based entirely on the following hypothesis: the process to be controlled can be mathematically modelled and the structure of this model (delay and order) is known in advance. The determination of the structure of a parametric system model is thus a vital step before going on to design an adaptive control algorithm. The identification technique should be selected by a specialist in automatic control. The capabilities of the adaptive control algorithm depends, to a large extent, on the faithfulness with which the model represents the system and its behavior. The chief advantage, in practical terms, of adaptive control appears to be the capability to ensure quasi-optimal system performance in the presence of a model with time-varying parameters. AR Freescale Semiconductor, Inc. · Constant control system performance in the presence of time-varying process characteristics MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. · For minimum-phase systems (or for systems where the non-minimum phase is fully determined): "minimum-variance control" or "control using reference models" ON DU · For non-minimum-phase systems: "pole-placement control" or "quadratic-criterion optimal control" YF RE ES CA LE SE MIC The adaptive control algorithm is then designed in accordance with the structure of the system model and the selected control strategy. As a rule, the adaptive control algorithm can be seen as a combination of two algorithms. An identification algorithm uses measurements made on the system and generates information (a succession of estimates) for input to a control law computation algorithm. This second algorithm determines, at each instant, the adaptive controller parameters and the control to be applied to the system. This type of adaptive control is termed indirect. However, the breakdown into two parts is not always apparent. For example, no control law computation algorithm is required at all if the parameters characterizing the adaptive controller are directly identified. This is known as direct adaptive control. CH IVE DB We will look first at adaptive control based on a direct scheme using a reference model. There are two main reasons for this choice: first, this type of control is relatively easy to implement; second, it has already found practical applications in industrial systems [LAN-84 LAN-84], [DAH-82 DAH-82]. MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. its environment are fully determined. The strategies most commonly encountered in adaptive control are: 1-5 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. MIC ON DU A discussion follows on an adaptive control system based on an indirect scheme which, to date, judging from our bibliographic research, offers the best system response. This type of control was introduced by Clarke [CLA-84 CLA-84]. It produces optimal control over any system, with or without time delays and irrespective of whether the inverse is stable or unstable. This scheme is known as generalized predictive control. Adaptive controller LE Desired performances Comparison system Disturbance Output Plant SE Reference input Performance rating measure ES CA Adjustment system RE Figure 1-1 Basic principles of adaptive control 1-6 The basic principle underlying adaptive control systems is relatively simple (see Figure 1-1). An adaptive control system measures a certain performance rating of the system (or plant) to be CH IVE DB YF The performance rating of a system is measured and compared to the design goal. The adaptive system modifies the parameters of the adaptive controller in order to maintain the performance rating close to the desired value. AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. controlled. Starting with the difference between the desired and measured performance ratings, the adjustment system modifies the parameters of the adaptive controller (or regulator) and the control law in order to maintain the system performance rating close to the desired value(s). SE MIC ON DU Note that, in order to design and correctly adjust (or tune) a good controller, we must specify the desired performance of the regulation loop and determine the dynamic process model describing the relation between variations in control signals and output. This means we must determine the representation model which, in turn, means that we must establish the system's order and time delay. RE ES CA LE The literature on adaptive control includes hundreds of papers on different approaches to the problem. As a result, engineers who are not specialists in adaptive control theory often find it very difficult to determine which approach they should use to solve a given problem. The aim of this application note is to introduce the reader to the two main principles of adaptive control identified to date and to guide the design engineer in the selection of control strategies applicable to a given situation. CH IVE DB YF The two principles selected for discussion were chosen on the basis of the goal of any design project, namely the determination of a real-time control law applicable to a given process. The total number of operations required to parameterize the control law is assumed to be one of the criteria most important to the design engineer. It is true that for high-speed industrial systems using microcontrollers - such as MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. 1-7 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. DU automotive Anti-lock Braking Systems (ABS) and active suspensions, to name but two - the total number of operations assigned to the control algorithm cannot be very high. Given their internal structure (Von Neumann), conventional microcontrollers only have a limited real-time computation capability, thus directly limiting the complexity of the control algorithms. The architecture of Motorola DSP56000/DSP56001 DSP56000/DSP56001 devices features a multi-bus processor that is highly parallel (extended Harvard architecture) and specially designed for real-time digital signal processing. In view of their computational power, these devices can be used to implement sophisticated control algorithms and thus to control highspeed industrial systems. SE MIC ON Freescale Semiconductor, Inc. 1-8 · Lower system component costs because a single DSP56000/DSP56001 DSP56000/DSP56001 controller can replace not only the microcontroller but also the components required for 3-D lookup tables to digitally map model characteristics (as in the case of injection systems, active suspensions, etc.). · Further savings can be achieved by using digital techniques (e.g. an observation model) to replace expensive sensors. · The computations performed by DSP56000/ DSP56000/ DSP56001 DSP56001 devices are more accurate than CH IVE DB YF RE ES CA LE Apart from the fact that digital signal processing is now widely employed, the chief advantages of Motorola DSP56000/DSP56001 DSP56000/DSP56001 controllers can be summarized as follows: AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. microcontroller interpolation between the inputs of a 3-D LUT (lookup table). SE MIC ON DU Each Motorola DSP56000/DSP56001 DSP56000/DSP56001 device is both a high-speed microcontroller and a powerful digital signal processor. The DSP56001 DSP56001 program RAM can accommodate 512 words of 24 bits. The RAM can be loaded, following a clear, from a 2K x 8-bit EPROM or from a host processor. For massproduced products, the DSP56000 DSP56000 offers a program ROM of 3.75K words of 24 bits which can be factory programmed for stand-alone applications. YF RE ES CA LE Apart from the amount of memory space allocated to the program field, the DSP56000 DSP56000 and DSP56001 DSP56001 controllers are identical, with two separate memory spaces for data. A further feature is multiplication with accumulation of previous values, a capability much used by real-time control algorithms. A DSP56000/DSP56001 DSP56000/DSP56001 controller can multiply two 24-bit numbers, add the 48-bit result to the contents of the 56-bit accumulator, and simultaneously access the two data memory fields, all in a single instruction cycle. CH IVE DB For fast input/output, DSP56000/DSP56001 DSP56000/DSP56001 devices feature three peripheral devices in the same package, namely: a host processor interface (HI), a synchronous serial interface (SSI), and a serial communications interface (SCI). When the SCI is not required for communications, the baud rate generators can be used as timers. Depending on the way MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. · A single DSP56000/DSP56001 DSP56000/DSP56001 controller can analyze and process several input parameters at a time. 1-9 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. DU in which the peripherals are configured, DSP56000/ DSP56000/ DSP56001 DSP56001 can offer up to 24 I/O lines. These features make DSP56000/DSP56001 DSP56000/DSP56001 controllers ideal for a wide range of real-time control applications where their processing power can be used to advantage. Applications include: disk drives, motor control, automotive active suspensions, active noise control, robotics, etc. s CH IVE DB YF RE ES CA LE SE MIC ON Freescale Semiconductor, Inc. 1-10 AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. SECTION 2 DU 2.1 Parametric Models ON Freescale Semiconductor, Inc. For any continuous, mono- or multi-variable physical LE SE MIC system, the search for a suitable parametric model - whether by empirical methods or on the basis of experimental data - leads to the use of linear differential equations to represent the process to be identified. These equations are of the form: Eqn. 2-1 CA d m U(t) d n 1 Y(t) d n Y(t) - + 1 - + . + n Y(t) = 0 - + . + m U(t) n1 n dt dt m dt Contrary to non-parametric models (finite impulse response), parametric models depend on a specific structure. The parametric model characterizes the dynamic behavior of a physical system in terms of its transmittance or transfer function. This may be deduced using a z-transform. Applying such a transform to expression Eqn. 2-1, we obtain: CH IVE DB YF RE ES In nature, no system is rigorously linear in the mathematical sense. However, most processes approach linear behavior over a limited operating range. MOTOROLA AR Freescale Semiconductor, Inc. Numerical Domain Representation 2-1 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Eqn. 2-2 DU where: Freescale Semiconductor, Inc. ON · (a1,. . .,an) and (b0,. . .,bm) represent the parameters of the sampled model MIC · d represents the time delay (for i d then, bi = 0) · n determines the order of the model (n m) · U (z) is the model input SE · Y (z) is the model output RE ES CA LE The most widely used parametric model is illustrated in Figure 2-1: q d B ( q 1 ) -A ( q 1 ) Y(k) Parametric model description in terms of process input and output 2-2 CH IVE Figure 2-1 b(k) DB YF U(k) AR Freescale Semiconductor, Inc. z d ( b0 + . + bm z m ) Y(z) z d B(z 1) G(z) = - = - = -U(z) A(z 1) 1 + a 1 z 1 + . + a n z n MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. with: · q-1 is the time delay operator. · A (q-1) = 1 + a1q-1 +. . .+anq-1 DU · b(k) represents all noise sources expressed in terms of their equivalent effect on output. CA LE SE MIC ON The model described by equation Eqn. 2-2 is known in the literature as the polynomial parametric model. Expression Eqn. 2-2 is solely in terms of the process input and output. The model can also be represented as a first-order differential equation by converting expression Eqn. 2-1. This representation is known as the parametric state model and is defined in accordance with equation Eqn. 2-3. Throughout the remainder of this application note we will assume that polynomial B(q-1) is of the same degree as polynomial A(q-1). ES Xk + 1 = P Xk + Q Uk Eqn. 2-3 RE Yk = C Xk YF where: · Xk is the state vector of dimension (n+d) x 1) DB · P is the state matrix of dimension (n+d) x (n+d) · Q is the input vector of dimension (n+d) x 1) IVE · C is the output vector of dimension (1 x (n+d) CH · n is the order of the system MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. · B (q-1) = b0+. . .+bmq-1 2-3 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. The relation between these two representations of the parametric model is given by: 1 0 -an 0 1 0 0 0 d (vector from Eqn. 2-2) 0 Eqn. 2-4 bn ON Freescale Semiconductor, Inc. } 0 Q = b0 C = 1 0 0 LE SE MIC While it is true that the parametric model approximates the behavior of the physical system, one must be cautious when it comes to the physical interpretation of the parameters contributing to the model's structure. IVE DB YF RE ES CA The purpose of the parametric model is to approximate as closely as possible the behavior of the system by ensuring the closest possible match between predicted and observed output. This is done, moreover, within the limits of an accuracy vs. simplicity trade-off that the automatic control specialist defines when choosing the parametric model to generate the control law. The advantages of the parametric model approach lie in its structure: · It enables us to describe, sufficiently accurately, the dynamics of an arbitrary physical process using fewer parameters that are required by the non-parametric model (finite impulse response). CH 2-4 AR Freescale Semiconductor, Inc. 0 P= 0 0 DU -a1 MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Y(k) = b 0 U(k d) + . + b n U(k n d) a 1 Y(k 1) . a n Y(k n) + e(k) DU Eqn. 2-5 ON with: · e (k) representing the generalized or residual noise MIC · e (k) = b (k).(1 + a1q-1 +. . .+anq-1) CA LE SE Given that we now have the time-history of the input and output signals, we can readily predict the model output values. This important point is widely used in modern regulation theory.The state parametric model is useful for describing multivariable systems. CH IVE DB YF RE ES The chief drawback of the parametric model is the difficulty of determining the order of the system. If the designer underestimates the process order, model predictions will not match actual system behavior. On the other hand, if the designer overestimates the order, the increased complexity of the model will mean longer computation times. This same comment also applies to the estimation of pure time delays. The automatic control specialist must therefore pay careful attention to this phase of the modelling procedure. With most industrial systems, we do not have access to the states values, which is a major handicap for the state parametric model. There are state observer techniques allowing the MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. · It is relatively simple to implement on the controller. Using a well-known property of the ztransform (time delay theorem), we can proceed from the polynomial parametric model to the difference equation of the following form: 2-5 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. DU 2.2 Adaptive Control Techniques MIC ON Consider the two adaptive control techniques applied to a closed-loop physical system as shown in Figure 2-2: SE Disturbance d(t) Input + + LE Proposed Adaptive Controller u(k) Plant G(z) Output y(k) CA r(k) Figure 2-2 ES Adaptive controller in closed loop 2-6 In these examples, G(z), the plant transfer function, is defined as follows: z 1 ( b0 + b1 z 1 ) Y(z) G(z) = - = -U(z) 1 + a1 z 1 + a2 z 2 CH IVE DB YF RE This system will be used to measure the performance of the adaptive controller as it works to maintain (or equal) the desired response in the presence of a disturbance. AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. state estimation, but having a heavy penalty in terms of computation time. Eqn. 2-6 MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. The nominal values for the process parameters are: b0 = 0.039 h = 0.031 a1 = -1.457 LE SE MIC ON DU The performance of the adaptive controls presented here will be evaluated on the basis of the system's capacity to equal the closed-loop response (Figure 2-2) with the desired performance. Before going on to make the different comparisons, we must first define the standard (input and output) signals to be used with the simulated system and the desired closed-loop performance. The input and disturbance signals are shown in Figure 2-3. Note, these signals will be assumed to be fixed throughout the remainder of this section. ES 3 Magnitude 2 RE 1 0 YF Magnitude Disturbance signal: D(t) CA Reference signal: R(t) 2 DB -1 IVE 0 Figure 2-3 1 0 -1 -2 -2 5 10 15 0 Time (sec.) Standard input and disturbance signals 5 10 15 Time (sec.) CH Noise free representation of the reference input and disturbance signals MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. a2 = 0.527 2-7 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. DU Output signal in open loop 1 0 -1 SE -2 MIC Magnitude ON 2 Freescale Semiconductor, Inc. 0 LE Figure 2-4 5 10 15 Time (sec.) Dynamic response in open loop ES CA Dynamic response of the uncorrected system when it has been excited by the reference signal of Figure 2-3. IVE DB YF RE The function of the different regulators presented in the following pages is to improve the dynamic behavior of the simulated system. Two constraints are imposed on these regulators. These constraints will be used, at first, to determine the desired performance of the closed-loop system. The constraints are defined as follows: · In order to respond more rapidly to variations in the reference value and/or the level of disturbance, we require that the simulated system have a settling time of no more than 2.5 seconds. CH 2-8 AR Freescale Semiconductor, Inc. In order to characterize the dynamic response of the uncorrected (i.e. without regulation) simulated system, we apply the input signal defined in Figure 2-3. The system dynamic response is illustrated in Figure 2-4. MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. DU The desired system dynamic response is illustrated in Figure 2-5 (without disturbance): ON Desired output signal in closed loop MIC 1 0 SE Magnitude 2 -1 LE -2 0 5 10 15 CA Time (sec.) ES Figure 2-5 Desired dynamic response in closed loop YF RE Dynamic response without disturbance of the closed loop system. CH IVE DB To illustrate and compare the performance of the different adaptive controllers, we introduce, for each method of adaptive regulation, a variation in the reference value (R(t), Figure 2-3), followed, as soon as the closed-loop system response has stabilized, by a disturbance (D(t), Figure 2-3). The impact of the disturbance is then monitored. s MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. · During the dynamic response, the variation in the output signal of the simulated system shall be set for an overshoot of 70% relative to the final value. 2-9 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. DU AR CH IVE DB YF RE ES CA LE SE MIC ON Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. SECTION 3 ON DU 3.1 Adaptive Control Using Reference Models An adaptive controller may be of conventional de- CA LE SE sign or it may be more complex in structure, including adjustable coefficients such that their tuning, using a suitable algorithm, either optimizes or extends the operating range of the process to be regulated. The different methods of adaptive control differ as to the method chosen to adjust (or tune) the control coefficients. This section discusses adaptive control using parallel-serial reference models which, along with selftuning control, are the only control schemes to have found practical applications to date. The adaptive control scheme using parallel reference models (i.e. located in parallel on the closed-loop system) was originally proposed by Whitaker in 1958. The version proposed at the time offered a solution to the tracking problem, but not the regulation problem. Note that a tracking problem is defined when the reference value CH IVE DB YF RE ES "The main advantage of generalized predictive control is that the control is always stable irrespective of the nature of the system to be regulated (the plant). " MIC 3.1.1 Introduction MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Adaptive Control and Adaptive Controllers 3-1 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. DU The parallel model structure is suitable for solving the tracking problem and is demonstrated by the fact that the model requires reasonable control signals; the structure is not suitable for solving regulation problems and is demonstrated by the fact that, in this case, the model requires unreasonable control signals. We obtain unreasonable control signals because the estimated error (differences between the output of the parallel reference model and that of the system) converges to zero during a single sampling interval. To attenuate the control signal, a serial reference model (i.e. in series with the estimated error) can be added to the general structure. This imposes a converge-to-zero requirement, with a chosen dynamic response, that is less severe than in the previous case [IRV-85 IRV-85]. Let us now look at this adaptive control method using parallel-serial reference models more closely. AR 3-2 3.1.2 Closed-Loop System An adaptive control system comprises not only a feedback-type control loop (or inner loop) including an adaptive controller, but also an additional, or outer, loop acting on the controller parameters in order to maintain system performance in the presence of CH IVE DB YF RE ES CA LE SE MIC ON Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. (r(k) varies and when no disturbances (d(k) are present in the output (y(k). A regulation problem is defined when the reference value is zero or steady and when there is a disturbance in the output such that its effect must be reduced by the control (u(k). MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. · ep represents the parallel estimated error DU where: · es represents the serial estimated error LE SE MIC ON This type of adaptive scheme offers the advantage of being able to accommodate separately both tracking and regulation problems. This is because the desired performance of the controlled system are defined by a parallel model for a tracking problem and by a serial model for a regulation problem. CA Parallel Reference yref(k) Model ES es Serial Reference Model ep + Identification Algorithm RE YF Adaptive Controller u(k) Plant G(z) y (k) DB r(k) Figure 3-1 Adaptive control using reference models in closed loop CH IVE Note that this system not only has a feedback type control loop that includes an adaptive controller but also an outer loop that acts on the controller to maintain performance in the presence of disturbances. MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. variations in the process parameters. This second loop also has a feedback-loop-type structure, the controlled variable being the performance of the control system itself. The arrangement is schematically shown in Figure 3-1. 3-3 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. 3.1.3 Control Law A(q 1) Y(k) = q d B(q 1) U(k) Eqn. 3-1 DU where: Freescale Semiconductor, Inc. ON · n = 2 (order) · d = 1 (time delay) MIC · A(q-1) = 1 + a1.q-1 + a2.q-2 · B(q-1) = b0 + b1.q-1 CA LE SE The order of polynomials A(q-1) and B(q-1) and also the time delay of the parametric model enable us to correctly dimension the control law. To bring us nearer to the formulation of the adaptive control law, we first consider the case where the system parameters are known. ES 3.1.3.1 Known System Parameters 3-4 The problem here is to determine a control (u(k) that will eliminate an initial disturbance (d(k) with a dynamic response defined by the relation: A r(q 1) Y(k + d) = 0 with: Eqn. 3-2 · d=1 · n = 2 (order) CH IVE DB YF RE With the objectives of tracking and regulation being independent, we can formalize their respective equations as: A: Regulation (r(k) = 0). AR Freescale Semiconductor, Inc. The dynamic behavior of the simulated system is defined by a parametric model. We recall that its general structure is given by the relation: MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Ar(q-1) = 1 + ar1.q-1 + ar2.q-2 Eqn. 3-3 ON DU The problem here is to determine a control (u(k) such that the system output (y(k) satisfies a relation of the form: where: SE · n = 2 (order) · d = 1 (time delay) Eqn. 3-4 MIC A p(q 1) Y(k + d) = B p(q 1) R(k) · Ap(q-1) = 1 + ap1.q-1 + ap2.q-2 LE · Bp(q-1) = bp0 + bp1.q-1 ES CA This corresponds to tracking a trajectory defined by the following reference model: Eqn. 3-5 YF RE q d B p(q 1) G p(q 1) = -A p(q 1) CH IVE DB In general, one may assume that there is some link between the tracking dynamic response Ap(q-1) and the regulation dynamic response Ar(q-1). However, in this application note, and for the sake of simplicity, we shall assume identical dynamic response to a variation in either load or reference value, i.e. we shall assume Ap(q-1) = Ar(q-1). We MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. The polynomial Ar(q-1) is determined by the design engineer to be asymptotically stable for order n. The polynomial represents the serial (or regulation) model. B: Tracking (d(k) = 0). 3-5 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. shall further assume a reference model such that the output is described by the relation: Eqn. 3-6 DU Under these conditions, the aims to be achieved by the control signal can be expressed in the form: e s(k + d) = A p(q 1) [ Y(k + d) Yref(k + d) ] = 0 Eqn. 3-7 ON Freescale Semiconductor, Inc. MIC The control law, with a parallel-serial reference model, can be deduced by minimizing the following quadratic criterion: SE 2 J(k + d) = e s (k + d) = [ A p(q 1) [ Y(k + d) Yref(k + d) ] ] 2 LE Eqn. 3-8 3-6 U(k) = F u(Y(k), Y(k 1), ., U(k 1), .) Eqn. 3-9 We must first rewrite the process output prediction in terms of the quantities measurable at time k and prior to time k. The prediction can be expressed in the form: CH IVE DB YF RE ES CA In the case of unit time delay (d = 1), we can determine the control law directly by minimizing criterion Eqn. 3-8 relative to u(k). The problem may be different, however, if the pure time delay of the controlled system is equal to or greater than twice the sampling period. In order to obtain a causal regulator, i.e. one such that u(k) is of the form: AR Freescale Semiconductor, Inc. A p(q 1) Yref(k + d) = B p(q 1) R(k) MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. A p(q 1) Y(k + d) = F y(Y(k), Y(k 1), ., U(k), U(k 1), .) ON DU In the literature, an expression of this form is known as a "d-step-ahead predictive model". An expression such as Eqn. 3-10 can be obtained directly using the general polynomial identity: Eqn. 3-11 MIC A p(q 1) = A(q 1) S(q 1) + q d R(q 1) where: · S(q-1) = 1 + s1.q-1 + . . . +sd-1.q-d+1 SE · R(q-1) = r0 + r1.q-1 + . . . + rn-1.q-n+1 LE This relation yields a unique solution for polynomials S(q-1) and R(q-1) when the degree of S(q-1) is d1. Polynomials S(q-1) and R(q-1) can be ob- RE ES CA tained either recursively or by dividing polynomial Ap(q-1) by polynomial A(q-1). Polynomial S(q-1) then corresponds to the quotient while q-d.R(q-1) corresponds to the remainder. Multiplying both sides of Eqn. 3-11 by y(k+d) and taking into account expression Eqn. 3-1, we obtain: YF A p(q 1) Y(k + d) = R(q 1) Y(k) + B(q 1) S(q 1) U(k) DB Eqn. 3-12 This can be rewritten in the form: IVE A p(q 1) Y(k + d) = R(q 1) Y(k) + b 0 U(k) + B s(q 1) U(k 1) Eqn. 3-13 B(q-1).S(q-1) = b0 + q-1.Bs(q-1) CH where: MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Eqn. 3-10 3-7 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Substituting Eqn. 3-13 into criterion expression Eqn. 3-8, we obtain: J(k + d) = [ R(q 1) Y(k) + b 0 U(k) + B s(q 1) U(k 1) A p(q 1) Yref(k + d) ] 2 Eqn. 3-15 ON J(k + d) - = 0 U(k) DU The criterion can now be minimized by determining the control u(k) for which: MIC Combining this with expression Eqn. 3-14, we obtain: SE J(k + d) -= U(k) CA LE b 0 [ R(q 1) Y(k) + b 0 U(k) + B s(q 1) U(k 1) A p(q 1) Yref(k + d) ] = 0 ES Eqn. 3-16 RE Now, using expression Eqn. 3-6, we obtain the required control in the form: 3-8 Eqn. 3-17 where polynomials Bp(q-1), R(q-1) and Bs(q-1) are defined by: Bp(q-1) = bp0 + bp1.q-1 R(q-1) = (ap1 - a1) + (ap2 - a2).q-1 = r0 + r1.q-1 Bs(q-1) = b1 = bs0 CH IVE DB YF 1 U(k) = - [ B p(q 1) R(k) R(q 1) Y(k) B s(q 1) U(k 1) ] b0 AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Eqn. 3-14 MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. ON DU In other words, in the case of regulation (r(t) = 0), criterion expression Eqn. 3-8 represents a minimum-variance condition on the process output. Physically, this criterion implies minimizing the mean energy of the "filtered error" expression in relation Eqn. 3-7. SE MIC The equations presented in this section were made possible by the fact that we knew the parameters of the controlled process. Let us now look at the case where these process parameters are unknown. 3.1.3.2 Unknown System Parameters RE ES CA LE In the adaptive case, the structure of the controller is the same as for known system parameters, except that we replace the fixed parameters by variable ones. With the role of the adaptive, or outer, loop being to determine the correct values of these parameters, the self-tuning controller equation can be derived from Eqn. 3-17 and written as: DB YF 1 ^ ^ U(k) = - [ B p(q 1) R(k) R(k, q 1) Y(k) B s(k, q 1) U(k 1) ] ^ b 0(k) Eqn. 3-18 bo(k), ro(k),. . ., bs1(k), . . ., are the controller parameter estimates at time k CH IVE where: MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. The control expressed in relation Eqn. 3-17 thus has the property of reducing criterion Eqn. 3-8 to zero while independently meeting the requirements of both tracking and regulation. 3-9 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. By defining the tuning vector (k) and the measurement vector (k) by the following expressions: ^ T(k) = ^ b 0(k) ^ b s0(k) ^ r 0(k) ^ r 1(k) U(k) U(k 1) Y(k) Y(k 1) DU (k) = Freescale Semiconductor, Inc. ON The controller equation can be rewritten in the form: ^ B p(q 1) R(k) = T(k) (k) MIC Eqn. 3-20 LE SE The next step is to determine the recursive parameter-vector self-tuning algorithm. CA 3.1.4 Determination of Controller Parameters IVE DB YF RE ES The self-tuning controller parameters are determined by recursive minimization of a least-squares type criterion starting from asymptotic stability conditions dictated by the model-process error. The aim then is to estimate the parameter vector at time k in such a way that it minimizes the sum of the squares of the filtered errors between the process and the model over a time-horizon of k measurements. This is expressed by the relation: k J 1(k) = 2 es (i) i=1 k = [ Ap(q 1) ( Y(i) Yref(i) ) ] 2 i=1 Eqn. 3-21 CH 3-10 AR Freescale Semiconductor, Inc. Eqn. 3-19 MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. This same condition can also be expressed in the form: k J 1(k) = ^ [ Bp(q 1) R(i) T(i) (i) ] 2 Eqn. 3-22 Eqn. 3-23 SE MIC J 1(k) - = 0 ^ (k) ON DU The values of (k) which minimize criterion Eqn. 3-22 are obtained by determining the value of (k) which cancels in the expression: LE Applying relation Eqn. 3-23 to relation Eqn. 3-22, we obtain: CA k J 1(k) ^ - = [ (i) [ B p(q 1) R(i) T(i) (i) ] ] = 0 ^ (k) i=1 RE ES Eqn. 3-24 YF From equation Eqn. 3-24 we have: k ^ (k) = (i) T (i) 1 k Bp(q 1) R(i) (i) i=1 Eqn. 3-25 CH IVE DB i=1 MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. i=1 3-11 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. In the previous expression, we now let: k ^ (k) = F(k) Bp(q 1) R(i) (i) k Eqn. 3-26 1 T (i ) (i ) DU where: F 1(k ) = i = 1 ON Freescale Semiconductor, Inc. LE SE MIC Expression Eqn. 3-25 corresponds to the non-recursive least-squares algorithm. To obtain a recursive algorithm, we recompute the optimal value of (k+1) for the minimization condition J(k+1) and express (k+1) as a function of (k). This yields: CA ^ ^ (k + 1) = (k) + F(k + 1) (k) e s(k + 1) Eqn. 3-27 T 3-12 Here, F(k+1) represents the estimator tuning gain. This is an important variable since it gives us an indication of the quality of estimation (covariance of parameter estimates). It has been shown elsewhere [LJU-83 LJU-83] that if k (experiment time) increases, the (k) estimates tend towards constants. In this case, the variance of the estimates tends towards zero (F(k+1) = 0). The CH IVE DB YF RE ES where: F 1(k + 1) = F 1(k ) + (k + 1) (k + 1) AR Freescale Semiconductor, Inc. i=1 MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. ON DU least-squares algorithm briefly presented here has progressively less effect on new measurement values. This is acceptable if the process is unvarying in time. However, this is not the case in this application note since the system parameters are explicitly assumed variable. This problem can be resolved by modifying the J1(k) criterion. We need to arrange for the criterion to "forget" earlier measurement values by adding a suitable weighting factor. When this is done, the criterion to be minimized becomes: 2 k i es (i) represents the weighting, or "forgetting factor" (0 < l 1) CA LE where: Eqn. 3-28 SE i=1 MIC k J 2(k) = YF RE ES The thus modified least-squares algorithm is detailed in APPENDIX A. The main difference between algorithms is which variables are contained in vector (k). In the literature, this quantity is referred to as the "measurement vector" while es(k) is termed the "post-prediction tuning error". DB In order to ensure the stability of the overall system, the recursive least-squares identification algorithm must meet the following three conditions: CH IVE · The rapid decrease in the prediction error (es(k) must occur during the periods when (k), the unknown parameter of the system to be identified, is constant. MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. 3-13 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. DU · The variation (k) - (k-1) in the estimated parameter must decrease at the same time as the prediction error es(k). If es(k) is below a certain threshold, then (k) - (k-1) must be zero. These conditions can only be met by making further changes to the recursive least-squares algorithm. Several authors [IRV-85 IRV-85 and BOD-87 BOD-87] have already tackled this problem. We have used their results to improve the robustness of the controller parameter estimation algorithm. SE MIC ON Freescale Semiconductor, Inc. 3.1.5 Comment IVE DB YF RE ES CA LE The use of a control strategy based on an outputsignal minimum-variance criterion theoretically requires that the system to be regulated (the plant) have a stable inverse (i.e. b0 > b1). It is therefore important to have some prior knowledge of the nature of the plant, and its behavior over its entire operating range. Parametric identification is used to determine not only the structure of the representation model (order and time delays), but also the nature of the system to be regulated (i.e. whether it is a minimum-phase system or not). Note also that this type of controller can be used to define tracking and regulation performance totally independently. The main disadvantage of a control strategy using a minimum-variance criterion applied to the variable CH 3-14 AR Freescale Semiconductor, Inc. · Irrespective of any variations in the domain bounded by (k), the adjusted parameter (k) of the identifier must remain within the appropriate bounded domain. MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. · Estimation of parameters of the system representative model, and DU · Adjustment of controller parameters using system parameters. CA LE SE MIC ON This method of breaking down control law parametering leads to an indirect adaptive scheme. Note, however, that it can be an advantage to have a means of monitoring system dynamic response in real time. Thus, the estimation of process parameters can be used for diagnostics, monitoring, etc. Let us now look at this indirect adaptive scheme more closely. RE ES 3.2 Generalized Predictive Control YF 3.2.1 Introduction CH IVE DB The adaptive control scheme presented in the previous section is useful when the system to be controlled has a stable inverse. This leads to investigations to see if other control schemes, associated with the least-squares identification method, can generate stable control signals irrespective of the nature of the system to be controlled. Given that the MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. to be regulated is that it always leads to a direct adaptive scheme. This presents a problem for the other control strategies where the control law parametering is broken down into two distinct steps, namely: 3-15 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. k J 3(k) = DU minimization of the mean tracking error energy (Eqn. 3-21) is not sufficient to ensure control stability in the case of a so-called "non-minimum phase system", it seems fairly natural to investigate what happens if one introduces a control weighting term into the expression for the criterion to be minimized [SAM-83 SAM-83]. This is expressed by the relation: Freescale Semiconductor, Inc. [ Ap(q 1) ( Y(i) Yref(i) ) ] 2 + U(k) 2 ON i=1 Eqn. 3-29 MIC where: is the strictly positive weighting term 3-16 From this we conclude, in other words, that to obtain a robust control scheme, we can use the predictions obtained from the identification of the system to be controlled and minimize a leastsquares criterion involving the difference between the predicted desired trajectory and the predicted trajectories in response to the control signals. This CH IVE DB YF RE ES CA LE SE An improvement in this criterion has been suggested on the basis of the following observation. A car driver does not need to have a complex mathematical model in mind in order to be able to drive. All he needs is the ability to recall a set of images of possible trajectories produced by a corresponding set of control actions on the car steering wheel. Given the driver's view of the road to be followed, the human control algorithm chooses the control action (or signal) that will produce the vehicle trajectory closest to the desired trajectory [IRV-85 IRV-85]. AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. criterion has been formulated by Clarke [CLA-84 CLA-84] and is expressed in the form: Ny 1 J 4(k) = Nu 1 ^ [ Yref(yk + i + d) Y(k + i + d) ] 2 + U(k + 1) 2 i=0 i=0 Eqn. 3-30 DU where: ON ^ · Y ( k + i + d ) is the output prediction with Ny MIC · Yref is the predicted output of the reference model over horizon Ny · U(k+i) represents the predicted control over Nu · Ny determines the horizon on the outputs SE · Nu determines the horizon on the control · is the control weighting factor CA LE · represents the differentiation operator ( = 1-q-1) DB YF RE ES Thus, the control weighting term () ensures control stability in all cases where the system has an unstable inverse, provided the time delay is greater than unity. The differentiation operator () enables us to obtain a control that is free of static error in the variable to be controlled (Y) relative to the reference trajectory (Yref). CH IVE On the basis of our bibliographic research, generalized predictive control is considered to be the best control technique currently available. This is why we chose to discuss it in detail in this application MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. 3-17 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Processing of Controller Parameters e Identification Algorithm Plant G(z) y(k) LE u(k) + _ ON MIC SE Adaptive Controller r(k) yref(k) DU Parallel Reference Model CA Figure 3-2 Generalized predictive control using closed loop 3-18 3.2.2 Closed-Loop System As with all adaptive control systems, the system discussed in this section features not only a conventional servo-type feedback loop, but also an additional loop designed to identify the on-line process and determine the parameters to be adjusted on the basis of the process parameters. The arrangement is schematically shown in Figure 3-2. CH IVE DB YF RE ES Note the presence of an additional loop to perform system identification on the process. The advantage is that the process parameters would be accessible with the main disadvantage that there is an increase time in the computation of the control law. AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. note and why we made it the subject of our simulation studies. An industrial application of this technique is described in [LIM-89 LIM-89]. MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. DU 3.2.3 Control Law ON 3.2.3.1 Definition of Parametric Model MIC The parametric model required to formulate the control law was defined earlier on. Recall that the mathematical structure is of the form: Eqn. 3-31 LE SE ^ ^ A(k, q 1) Y(k) = q d B(k, q 1) U(k) CA where: A(k,q-1) and B(k,q-1) are the polynomials estimated by the identifier at each sampling interval. YF RE ES In the remainder of this application note, we will simplify the mathematical notation by omitting the ^ symbols (indicating estimated variables) and the (k) portion of the different terms indicating that the variable is estimated at each sampling interval k.Te. DB 3.2.3.2 Definition of System Output Prediction CH IVE The prediction of the parametric model output - which is to say the probable behavior of the process output between time k1 and some future time kj - is deduced using a j-step-ahead prediction model. MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. The main advantage of this indirect adaptive scheme is that it gives access to the process parameters, which is important for monitoring, diagnostics, and the like. The main disadvantage is the increased computation time required to parameter the control law. 3-19 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. The general expression for such a model is: 1 = E j(q 1) A(q 1) + q d F j(q 1) where: · kj is the given future time-horizon DU · Fj(q-1) = f0j + . + f(kj-1)j.q-kj+1 · Ej = 1 + . + ej-1.q-j+1 Freescale Semiconductor, Inc. SE MIC ON This expression is known as a Diophantine equation. The expression for the predicted model output can be deduced by multiplying the two sides of equation Eqn. 3-30 by Ej., then substituting the expression for Ej.A(q-1). from equation Eqn. 3-32. This gives: LE ( 1 q j F j(q 1) ) Y(k) = q d E j(q 1) B(q 1) U(k) CA Eqn. 3-33 ES The expression for the predicted model output can now be rewritten in the form: 3-20 where: Eqn. 3-34 Gj(q-1) = Ej(q-1).B(q-1) The sequence of predicted parametric model outputs can now be represented by vector Y. Note that for all future sampling intervals smaller than or equal to the system time delay (i.e. for j d), the Y(k+j) values can be computed using the input and output data available up to time k. For sampling intervals greater than the system time delay (i.e. for j > d), CH IVE DB YF RE ^ Y(k + j) = F j(q 1) Y(k) + G j(q 1) U(k d + j) AR Freescale Semiconductor, Inc. · j = 1.kj Eqn. 3-32 MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. 3.2.3.3 Determination of Polynomials F (q-1) and G (q-1) j j CA LE SE MIC ON DU In Section 3.1.3.1 we showed that we could obtain the polynomials S(q-1) and R(q-1) by simple division. The disadvantage, however, of this technique is that it is very time consuming. Clarke proposes a recursive method for the determination of polynomials Fj(q-1) and Ej(q-1). This is the solution we have adopted. Readers interested in this reformulation of the polynomials in recursive form should refer to the bibliography, and particularly to [BOD-87 BOD-87], [CLA85 CLA85], and [AST-84 AST-84]. Note, the control algorithm encoded in Motorola DSP56000/DSP56001 DSP56000/DSP56001 digital signal processors is based on the same solution. 3.2.3.4 Determination of Control Law DB YF RE ES Above, we derived an expression (Eqn. 3-34) for predicting the behavior of the process output signal. The behavior of the reference model output signal, on the other hand, is predicted by expression (Eqn. 3-35). We must now solve this equation from sampling time (k+d) to the chosen time-horizon (k+d+N1). * Yref(k + d) = A p (q 1) Yref(k + d 1) + B p(q 1) R(k) IVE Eqn. 3-35 * A p (q 1) = a 1 q 1 + . + a n q n CH where: MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. we need to know the future control U(k+j). These assumptions form the basis of generalized predictive control. 3-21 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. DU Yref = [ Yref ( k + d ).Yref ( k + d + N 1 ) ] Eqn. 3-36 ON Freescale Semiconductor, Inc. LE SE MIC Recall that the parallel reference model plays the same role as that defined for the adaptive controller of a parallel-serial model (Section 3.1). In order to compare the performance of the two adaptive regulators, we choose the same structure (n = 2 and d = 1) for the parallel model and the same dynamic response. CA The prediction error at future time k+j is given by: ^ e(k + j) = Yref(k + j) Y(k + j) ES Eqn. 3-37 YF RE Proceeding as previously described, let us now define the prediction error vector: e = [ e ( k + d ).e ( k + d + N 1 ) ] Eqn. 3-38 3-22 e = Yref Y Eqn. 3-39 We saw earlier that at time k, certain elements of vector Y are functions of known and unknown data. Among the unknowns, we can define the predicted CH IVE DB Thus: AR Freescale Semiconductor, Inc. Determining the output of the parallel reference model at a future time is not difficult since the polynomials Ap and Bp are known and are constant at each sampling time. The sequence of reference model outputs from sampling time (k+d), can be expressed in vector form as follows: MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. control vector (U) as follows: Eqn. 3-40 Eqn. 3-41 MIC e = Yref G U f ON DU A clever decomposition of expression Eqn. 3-39 enables us to separate the terms that depend on known data at time k and those that are unknown at time k, such as vector U. We thus obtain: SE where: G is a triangular matrix of dimension N.N 0 g0 g1 YF · · · · · · · · · gN gN 1 · · · · 0 · · · · · · · · · · Eqn. 3-42 · · · 0 g0 CH IVE DB G = · · RE g0 ES CA LE The elements of G are generated by reformulating the Diophantine equation in recursive form. MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. U = [ .U(k).U(k+N-1) ] 3-23 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. The elements of vector f are the components of the part of the prediction depending on known data at time k. This vector can be written in the form: 1 1 ) Y ( k ) + q Gd ( q 1 ) g0 U ( k 1 ) 1 1 2 ) Y ( k ) + q Gd + 1 ( q ) g0 g1 q U(k 1) DU Fd + 1 ( q Freescale Semiconductor, Inc. ON f= F d + N 1(q 1) Y(k) + q N . SE MIC [ G d + N 1(q 1) g 0 g 1 q 1 .g N 1 q N + 1 ] U(k 1) Eqn. 3-43 ES CA LE The control vector, U, can be determined by minimizing criterion J4(k) as expressed in equation Eqn. 3-40. In vector form, this criterion is given by: J4 = e T e + U T U Eqn. 3-44 3-24 U = [ G T G + I ] 1 G T [ Yref f ] Eqn. 3-45 Control u(k) is computed from u(k) using the following expression: U(k) = U(k 1) + U(k 1) Eqn. 3-46 The power of generalized predictive control can be gauged from the fact that it allows us to reduce the CH IVE DB YF RE It can be shown that this criterion has a simple optimal solution for: AR Freescale Semiconductor, Inc. Fd ( q MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. ON DU control prediction time-horizon. The only difficulties are the mathematical problems posed by the inversion of matrix (GT.G + a.I) of dimension N.N and the associated computation times. But this can be overcome by defining a control prediction time-horizon such that Nu < N and an output prediction time-horizon such that Ny = N. This reduces the number of columns of matrix (GT.G) so that we can now write: Eqn. 3-47 MIC U(k + N u) = U(k + N u + 1) = . = 0 3.2.4 Comment ES CA LE SE The main advantage of generalized predictive control is that the control is always stable irrespective of the nature of the system to be regulated (the plant). Thus, without making any changes to the control law obtained by minimizing criterion Eqn. 340, generalized predictive control can readily control systems with an unstable inverse matrix. CH IVE DB YF RE The approach suffers, however, from one serious drawback. The weighting factor `a' plays a determining role in system dynamic response, enabling us to obtain reasonable control signals for trajectory tracking or for attenuating the effects of disturbance. This is not, however, very satisfactory since `a' defines the dynamic response of the loop system in a fashion that is difficult to determine in advance. In our study, the only way we found of approaching the desired performance through the adjustment of a was by iterative trial and error. This is a step backwards compared to the asymptotic performance of adaptive MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. 3-25 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. control using parallel-serial reference models where the desired dynamic response was explicitly contained in polynomials Ap and Ar. Worse still, when the parameters of an industrial system vary from one operating point to another, weighting factor a must be modified to match the variation in the process dynamic response. DU This is not to say that generalized predictive control is not promising, but rather that further improvements are still required. Irving [IRV-85 IRV-85], for instance, proposes generalized predictive control with dual parallel-serial reference models - one to attenuate tracking and/or regulation dynamic response, the other to moderate control dynamic response. s AR 3-26 CH IVE DB YF RE ES CA LE SE MIC ON Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. SE 4.1 Implementation The scheme for adaptive control using parallel-serial CA LE reference models presented in Section 3.1 has been used to implement an adaptive controller on Motorola DSP56000/DSP56001 DSP56000/DSP56001 digital signal processors. The controller logic is programmed in assembler using a Motorola DSP56000CLASA DSP56000CLASA macro cross-assembler. The following pages present listings of the linked adaptive control program and the object code generated by the macro cross-assembler. Note that the identification algorithm in this program and the one which follows is a slightly more complex algorithm but it enables us to avoid the problem of divergent realtime estimated parameters while ensuring improved parameter tracking during transitions. The adaptive controller using parallel-serial reference models presented requires about 5,000 instruction CH IVE DB YF RE ES "The identification algorithm in this program and the one which follows is a slightly more complex algorithm but it enables us to avoid the problem of divergent realtime estimated parameters while ensuring improved parameter tracking during transitions." MIC ON DU Implementation and Simulation of Adaptive Controllers Using Reference Models MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. SECTION 4 4-1 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. cycles from input signal acquisition (r(k), y(k) to control (u(k) output. With the DSP56000/ DSP56000/ DSP56001 DSP56001 devices running at 27 MHz, this represents a minimum sampling period of 410 µs. DU Using the same conventions for input signals (r(k) and disturbance (d(k) as in SECTION 2, Figure 4-1 shows the simulated system output signal (y(k) and the control (u(k) generated by the adaptive controller using parallel-serial reference models. In this simulation, the subroutine "saturation" was not activated. SE MIC ON Freescale Semiconductor, Inc. CA LE 4.2 Generalized Prediction Controllers ES 4.2.1 Implementation IVE DB YF RE The scheme for generalized prediction controller presented in Section 3.2 has been used to implement an adaptive controller on a Motorola DSP56000 DSP56000 Digital Signal Processor. It is coded with C language using the Motorola GNU 56K C compiler. This compiler offers two important advantages: first it enables us to insert assembly language code into the source code, secondly, it allows us to generate an object code when the compiling and linking have been completed. CH 4-2 AR Freescale Semiconductor, Inc. 4.1.1 Simulation MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. ON DU The following pages present a C language implementation of the Generalized Predictive Controller and the Adaptive Controller with Parallel and Serial Models.The identification algorithm takes about 3,100 instruction cycles. The control algorithm, which is based on the theory of the prediction of the output of the identified system (y(k) at a given time horizon (ny) and the prediction of the control (u(k) also at a given time-horizon (nu) takes about 8,200 instruction cycles. LE SE MIC The generalized predictive controller presented in Figure 4-2 requires about 12,000 instruction cycles from input signal acquisition to control output. With the DSP56001 DSP56001 running at 27 MHz, this represents a minimum sampling period of 890 microseconds. Output Signal Y(t) in Closed Loop CA Control Signal: U(t) 2 1 RE 0 Height ES 10 -20 5 DB 0 YF -10 0 -1 -2 10 Time (sec.) 15 0 5 10 15 Time (sec.) IVE Figure 4-1 Simulation results for adaptive controller using parallel-serial reference models CH Note the effects of the disturbance on the output signal in this closed loop. MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. 4-3 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. MIC ON Conversion to GNU based C compiler Based on Version 1.0 14 June 1990 Program Ed Martinez Motorola Inc. Digital Signal Processing Operations Austin, TX 78735 DU Name: Pascal RENARD Type: C_Program Version: 1.1 Last Change:1 April 1992 Function: Generalized Predictive Controller Device: DSP56000/1 DSP56000/1 File name: main.c */ Freescale Semiconductor, Inc. SE /* Global variables These variables are declared at the global level. They will be accessed from the different assembly language sections within the program */ int Ynew_u_asm("Ynew_u"); int Ynew_y_asm("Ynew_y"); int Ynew_r_asm("Ynew_r"); CA LE /* The following are variables that are defined later on using in-line assembly language. They are not available to the c program directly. Yin_y $ffe0 Yin_r $ffc0 Yout_u $ffe1 ES /* parallel parameters with the following structure: */ YF RE bm[0].z-1 + bm[1].z-2 -1 + am[0].z-1 + am[2].z-2 */ typedef struct { float am[2],bm[2]; } e_param; IVE DB /* parallel model parameters */ typedef struct { float am[2],bm[2]; }para_param; 4-4 CH Figure 4-2 Generalized Predictive Controller described in Section 3.2 has a sampling period of 890 µs using a 27MHz DSP56001 DSP56001.(sheet 1 of 11) AR Freescale Semiconductor, Inc. /* MOTOROLA GENEVA * MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. /* identification parameters structure of the estimated model ON DU */ typedef struct { int n,na; float theta[4],fi[4]; float p0,v_conv,tr_min,tr_max; float eps,eps1,lambda,trace; float diag[4],offdiag[7]; } estpartyp; MIC /* controller parameters */ typedef struct { float lambda2,du,u_low,u_high; int nu,ny; } r_param; LE SE /* input and output signals */ typedef struct { float tab_du[7],ui[7], yi[4], ri[4], ymi[4]; } io_param; ES CA /* pointer initializations */ e_param ep,*pep = &ep; estpartyp est,*pest = &est; r_param rp,*prp = &rp; io_param iop,*piop = &iop; RE /* main program */ YF main () { equ equ equ $ffe0"); $ffc0"); $ffe1"); DB _asm("\nYin_y _asm("\nYin_r _asm("\nYout_u IVE initialize(pest,prp,piop,pep);/* parameter initialization */ for (;) /* infinite loop */ { _asm volatile ("movep y:Yin_y,y0" : "y0"); /* Obtain system input */ (sheet 2 of 11) CH Figure 4-2 Generalized Predictive Controller MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. theta[2].z-1 + theta[3].z-2 -1 + theta[0].z-1 + theta[1].z-2 4-5 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. _asm volatile ("move y0,Y:Ynew_y" : "y0"); _asm volatile ("movep y:Yin_r,y0" : "y0"); /* Obtain system reference */ _asm volatile ("move y0,y:Ynew_r" : "y0"); /* ui[] data shift */ /* saturation of ui[0] */ /* output of control signal */ /* output of control signal */ ON _asm("move y:Ynew_u,y0" : "y0"); _asm("movep y0,y:Yout_u" : "y0"); DU /*(yi[], ri[]) data shift */ /* identification */ /* control signal computing */ datau_shift(piop,prp); saturation(piop,prp,&Ynew_u); Freescale Semiconductor, Inc. datadu_shift(piop); } /* tab_du[] data shift */ MIC } SE /* initialization */ initialize(pest,prp,piop,pep) IVE DB YF RE ES CA LE estpartyp *pest; r_param *prp; io_param *piop; e_param *pep; { int i; /* identification parameters initialization */ pest->n = 4; /* number of parameter estimated */ pest->na = 2; /* system order */ /* this parameter is proportional to variance of estimates */ pest->p0 = 1000.0; pest->v_conv = 0.1; /* convergence speed of estimates */ pest->tr_min = 5.0; /* minimum of trace */ pest->tr_max = 15.0; /*maximum of trace used to avoid estimate divergence */ pest->eps = 0.0; /* output of serial model at time tk */ pest->eps1 = 0.0; /* output of serial model at time tk-1 */ pest->lambda = 1.0; /* forgotten factor of identification algorithm */ pest->theta[0] = -1.936; /* preset value for estmates */ pest->theta[1] = 0.937; /* " */ pest->theta[2] = 0.0001; /* " */ pest->theta[3] = 0.0001; /* " */ pest->fi[0] = -1.0; /* preset value for input matrix */ pest->fi[1] = -1.0; /* " */ pest->fi[2] = 0.5; /* " */ pest->fi[3] = 0.5; /* " */ for (i=0 ; in)-1 ; i+) pest->diag[i] = pest->p0; /* initialization of diagonal matrix */ for (i=0 ; ina)*4)-2 ; i+) pest->offdiag[i] = 0.0; /* initialization of upper-triangular matrix */ /* controller parameters initialization */ 4-6 CH Figure 4-2 Generalized Predictive Controller AR Freescale Semiconductor, Inc. datain_shift(piop,&Ynew_r,&Ynew_y); ls(piop,pest); gene_pre_com(piop,pest,pep,prp); (sheet 3 of 11) MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. /* /* /* /* /* horizon on the control signal */ horizon on the plant output */ negative saturation for control signal */ positive saturation for control signal */ weighting factor on control signal criterion */ /* I/O parameters initialization */ for (i=0 ; ina)*4)-2 ; i+) piop->tab_du[i] = 0.0; /* vector of control signal variation */ DU for (i=0 ; ina)*4)-2 ; i+) piop->ui[i] = -0.5; /* preset value on control signal*/ for (i=0 ; in)-1 ; i+) piop->yi[i] = -1.0; /* preset value on model output */ ON Freescale Semiconductor, Inc. for (i=0 ; in)-1 ; i+) piop->ri[i] = -1.0;/* preset value on reference signal */ MIC for (i=0 ; in)-1 ; i+) piop->ymi[i] = -1.0; /* preset value on parallel model output */ /* parallel model parameters initialization */ -1.294; 0.630; 0.181; 0.155; /* preset value allowing to define desired performance */ /* " */ /* " */ /* " */ SE = = = = LE pep->am[0] pep->am[1] pep->bm[0] pep->bm[1] } YF RE ES CA /* ri[], yi[] data shift reference signal vector : ri[] plant output vector : yi[] */ datain_shift(piop,pnew_r,pnew_y) io_param *piop; float *pnew_r,*pnew_y; { piop->ri[1] = piop->ri[0];/* r(k-1) = r(k) */ piop->ri[0] = *pnew_r;/* r(k) = new_r(k) */ piop->yi[1] = piop->yi[0]; piop->yi[0] = *pnew_y; } IVE DB / * ui[] data shift control signal vector : ui[] */ datau_shift(piop,prp) io_param *piop; r_param *prp; { piop->ui[1] = piop->ui[0]; /* u(k-1) = u(k) */ (sheet 4 of 11) CH Figure 4-2 Generalized Predictive Controller MOTOROLA AR Freescale Semiconductor, Inc. prp->nu = 3; prp->ny = 8; prp->u_low = -5.0; prp->u_high = 5.0; prp->lambda2 = 0.5; 4-7 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. piop->ui[0] += prp->du; /* u(k) = u(k) + du(k) */ DU / * tab_du[] data shift control signal variation vector : tab_du[] */ datadu_shift(piop) io_param *piop; { piop->tab_du[1] = piop->tab_du[0]; /* tab_du(k-1) = tab_du(k) */ piop->tab_du[0] = piop->ui[0] - piop->ui[1];/* tab_du(k) = u(k) - u(k-1)*/ Freescale Semiconductor, Inc. ON } LE SE MIC / * saturation of control signal */ saturation(piop,prp,pnew_u) io_param *piop; r_param *prp; float *pnew_u; { if (piop->ui[0] < prp->u_low) piop->ui[0] = prp->u_low; /* u(k) = u_low */ else if (piop->ui[0] > prp->u_high) piop->ui[0] = prp->u_high; /* u(k) = u_high */ *pnew_u = piop->ui[0]; } DB YF RE ES CA / * identification by using a recursive method (see appendix : equation A-11) This algorithm is based on the Bierman's and Thornton's theory. This subroutine computes the least squares estimate using the U-D method. The recursion involves an inversion of matrix F(k) which is not well-suitable from a numerical point of view. Another way to do the calculations is to use the U-D algorithm. This method is based on a factorization of F as : F = U.D.UT , where D is diagonal (called diag[] in algorithm) and U is upper-triangular matrix (called offdiag[] in algorithm). This program gives estimates of the parameters of the process : y(k) = - theta[0]*y(k-1) - theta[1]*y(k-2) + theta[2]*u(k-1) + theta[3]*u(k-3) + e(k) which has the same behaviour than the plant. */ ls(piop,pest) io_param *piop; estpartyp *pest; { fj,vj,alphaj,ajlast,pj,w,perr,k[7]; kf,ku,i,j; perr = piop->yi[0]; for (i=0 ; in)-1 ; i+) IVE float int 4-8 CH Figure 4-2 Generalized Predictive Controller AR Freescale Semiconductor, Inc. } (sheet 5 of 11) MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. IVE DB YF RE ES CA LE SE MIC ON DU perr -= pest->theta[i] * pest->fi[i]; /* calculate prediction error */ pest->eps1 = pest->eps; pest->eps = perr; fj = pest->fi[0]; vj = pest->diag[0] * fj; /* calculate gain and covariance using U-D method */ k[0] = vj; alphaj = 1.0 + vj * fj; pest->diag[0] = pest->diag[0]/alphaj/pest->lambda; if (pest->n > 1) { kf = 0; ku = 0; for (j=1 ; jn )-1 ; j+) { fj = pest->fi[j]; for (i=0 ; ifi[i] * pest->offdiag[kf]; } vj = fj * pest->diag[j];/* v = D*f */ k[j] = vj; ajlast = alphaj; alphaj = ajlast + vj * fj; pest->diag[j] = pest->diag[j] * ajlast/alphaj/(pest->lambda); pj = -fj/ajlast; for (i=0 ; ioffdiag[ku] + k[i] * pj; k[i] = k[i] + pest->offdiag[ku] * vj; pest->offdiag[ku] = w; } } } for (i=0 ; in)-1 ; i+) pest->theta[i] += perr * k[i] / alphaj;/* update parameter estimates */ for (i=0 ; in)-2 ; i+) pest->fi[(pest->n)-1-i] = pest->fi[(pest->n)-2-i];/* updating of fi */ pest->fi[0] = -(piop->yi[0]); pest->fi[(pest->na)] = piop->tab_du[0]; pest->trace = 0.0; for (i=0 ; in)-1 ; i+) pest->trace += pest->diag[i]; /* computing of the D matrix trace */ if (abs(pest->eps) - abs(pest->eps1) < pest->v_conv) /* test variation of prediction error */ if (pest->trace < pest->tr_max) /* test if trace > trace_max */ pest->lambda = 0.9; else pest->lambda = 1.0; else if (pest->trace < pest->tr_min) /* test if trace < trace_min */ { for (i=0 ; in)-1 ; i+) pest->diag[i] = 1.005 * (pest->diag[i]); pest->lambda = 0.9; } else pest->lambda = 1.0; } (sheet 6 of 11) CH Figure 4-2 Generalized Predictive Controller MOTOROLA AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. 4-9 For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. /* initialization */ ON for (i=0 ; iny)-1 ; i+) f[i] = 0.0; for (i=0 ; inu)-1 ; i+) { y[i] = 0.0; du_futur[i] = 0.0; } DU /* computing of control signal main program */ gene_pre_com(piop,pest,pep,prp) io_param *piop; estpartyp *pest; e_param *pep; r_param *prp; { float f[10],y[5],du_futur[5],g[10][10],gtg[5][5]; int i,j; MIC /* " */ /* " */ for (i=0 ; iny)-1 ; i+) for (j=0 ; jny)-1 ; j+) g[i][j] = 0.0; /* " */ CA LE SE for (i=0 ; inu)-1 ; i+) for (j=0 ; jnu)-1 ; j+) gtg[i][j] = 0.0; /* " */ prepare(prp,pest,piop,g,f); /* initialise f[i] and g[i][j] */ square(g,gtg,prp); /* calculate gtg */ add_lambda(prp,gtg); /* calculate gtg + lambda2 */ do_y(g,f,y,prp,pep,piop);/* calculate plant output prediction */ gauss(gtg,y,du_futur,prp);/* calculate y[i]*[gtg]-1 = du_futur[i] */ prp->du = du_futur[0]; } IVE DB YF RE ES /* calculate f[i] and g[i][j] of the equation : y[i] = g[i][j] * (y_par[j+2] - f[j]) */ prepare(prp,pest,piop,g,f) r_param *prp; estpartyp *pest; io_param *piop; float g[10][10],f[10]; { int i,j,nn,nk,n1,j_delay; float ]; n1 = pest->na + 1; nk = n1 - 2; for (i=0 ; iny)-1 ; i+) e[i] = 0.0; for (i=0 ; iny)+(pest->na)-1 ; i+) w[i] = 0.0; for (i=0 ; ina)+1 ; i+) fk[i] = 0.0; for (i=0 ; iny)-1 ; i+) 4-10 CH Figure 4-2 Generalized Predictive Controller Figure 4-2 Generalized Predictive Controller (continued) AR Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. Freescale Semiconductor, Inc. (sheet 7 of 11) MOTOROLA For More Information On This Product, Go to: www.freescale.com For More Information On This Product, Go to: www.freescale.com CT OR , IN C.2 006 Freescale Semiconductor, Inc. IVE DB YF RE ES CA LE SE MIC ON DU for (j=0 ; jny)-1 ; j+) g[i][j] = 0.0; for (i=1 ; ina) ; i+) par_a[i] = pest->theta[i-1]; par_a[0] = 1.0; for (i=0 ; ina)-1 ; i+) par_b[i] = pest->theta[i+(pest->na)]; delta[0] = 1.0 delta[1] = -1.0; mul_pol(delta,0,1,par_a,0,pest->na,ad,0,n1); for (j=0 ; jny)-1 ; j+) { if (j=0) { e[0] = 1.0; for (i=0 ; ina+j); j_delay = j; if (j_delay >= 0) { f[j_delay] = 0.0; for (i=0 ; iyi[i]; for (i=1 ; itab_du[i]); for (i=0 ; i ad(q-1) = a(q-1) * (1 - q-1) second call => w(q-1) = e(q-1) * b(q-1) */ mul_pol(mat1,l1,h1,mat2,l2,h2,resu,l3,h3) float mat1[],mat2[],resu[]; int l1,h1,l2,h2,l3,h3; { int i,j; for (i=l3 ; i