Laboratory 2. Exercise 8. Exercise 8. Identification and control of linear systems Introduction This exercise presents some practical aspects of the material presented in the Control Theory course. The aim of the exercise is to provide a working knowledge in the field of dealing with signals measured on physical processes, modeling based on signal processing and model-based controller design. Students will also practice (and hopefully develop) skills of data acquisition on physical systems, design of closed-loop system parameters and real-time realization of control systems. The laboratory exercise follows the path the engineer tracks during the design and implementation of control systems: data acquisition carried out on the plant, determination of the process model, development of the control algorithm and its software realization, final test and evaluation of the control system. Aim of the exercise Exercise 8 allows the students to broaden their knowledge on parametric model identification by practical experience and to realize state-space controller for a physical system in order to achieve prescribed closed-loop dynamics. The physical process to be controlled is represented by an analogous circuit. Identification, design and real-time implementation of the controller are carried out using the PC available at the lab with the support of industry standard software such as Matlab, Simulink and Control System Toolbox. The schedule of the exercise is as follows. (1) Excitation of the analogous plant and determining its typical parameters (speed, damping). (2) Selection of the adequate sampling time. (3) Selection of an excitation signal for identification, computer-based data acquisition and model-fitting. (4) Conversion from discrete-time transfer function model to a continuous-time one. (5) Specification of the parameters of the desired closed loop dynamics. (6) Design of a state-feedback compensator with state estimator in discrete time. (7) Verification of the controller by simulation. (8) Real-time realization of the compensator in state-space. (9) Evaluation of reference signal tracking and disturbance rejection properties according to prior assumptions by the calculations. (10) Test of the robustness of the control loop. Preliminaries Dynamic properties of control loops The decay of a transient corresponding to a stable pole (a pole placed on the left-hand-side half plane of s ) is slower if the real part of the pole is closer to zero. The pole or complex conjugate pair of poles of the closed loop which is the closest to the imaginary axis is referred to as the dominant pole or dominat pair of poles of the closed loop. Since the acceleration of the system and the higher damping are generally conflicting requirements, the control engineer has to choose a tradeoff. 1 Laboratory 2. Exercise 8. As a rule of thumb, one can conclude that if the other poles are placed leftwards to the dominant poles such that the absolute value of their real parts are at least three times the absolute value of real part of the dominant pair of poles, then the transients caused by these poles decay before the first peak of the step response and therefore the dynamic properties of the system are overwhelmingly determined by the dominant pair of poles. Since a complex pair of poles corresponds to a prototype second order term, the closed loop can be well approximated by the prototype second order term as specified by the dominant pair of poles. A typical pole-zero map of a closed loop with a dominant pair of poles is shown in Fig. 8-1. s1 −3σ e ω0 + jωe cos −σ e s1 remaining poles − jωe dominant poles Fig. 8-1 Typical pole-zero map of a closed loop A typical transient, the step response of the closed loop is shown in Fig. 8-2. v(t ) Δv 1.02v(∞ ) v(∞) 0.98v(∞) 0.9v(∞ ) 0.1v(∞) Trise Tm T2% t Fig. 8-2 Dynamic properties of the control loop The figure shows that the steady state error can be defined by 1 − v(∞) . The dynamic properties of the closed loop are the overshoot Δv = [v(Tm ) − v(∞)] / v(∞) , the time to the first peak Tm , the settling time T2% and the rise time Trise . There is a direct connection between 2 Laboratory 2. Exercise 8. the dynamic properties and the location of the dominant pair of poles of the closed loop, defined by its undamped natural frequency ω 0 and damping factor ξ . The dynamic properties of the closed loop can be than approximated using the known formulae for the prototype second order term, e.g. assuming zero steady-state error: v(t ) = 1 − ω0 exp (−σ e t ) sin (ω e t + ϕ ) = ωe =1− 1 1−ξ 2 exp (−ξω 0 t ) sin ( 1 − ξ 2 ω 0 t + arccos ξ ) s1, 2 = −ξω 0 ± jω 0 1 − ξ 2 = −σ e ± jω e , πξ Δv = exp(− Tm = T2% = 1−ξ 2 ), π π , = ωe ω 1 − ξ 2 0 ln 50 σe ≈ 4 σe és T5% = ln 20 σe ≈ 3 σe . The damping factor ξ of the dominating pair of poles can be obtained from the allowed overshoot Δv . We would like to approximate the best the transfer function Wclosed ( s ) ≈ 1 in order to assure that the output signal tracks the reference signal with the smallest error possible. Therefore the marginal frequency of the closed loop (which is approximately the crossover frequency ω c of the open loop transfer function) is nearly identical to the corner frequency ω 0 = 1 / T of the second order prototype system approximating the closed loop. The undamped natural frequency ω 0 of the dominating pair of poles can be determined from the marginal frequency ω h ≈ ω c affecting the speed of closed-loop transients. However, if we have identified the model of the plant from its step response, and determined the time constants Ti from it, then the relative error of the step response of the plant will be significant in the neighborhood of v(t ) ≈ 0 . Therefore, we have a slight chance to be able to accelerate the system such that we can approach the given time interval, since the model of the plant is unreliable due to the high relative error. However, by introducing the aggregate time constant Ts = ∑ Ti of the plant (by approximating the denominator of the plant by a first-order Taylor-series, so considering the plant as a first order prototype term with the time constant Ts ), the thumb rule of choosing ω 0 ≈ 5 / Ts can be used, especially in case of aperiodic systems (systems which can be considered as a serial interconnection of first order terms). The acceleration of the system is also limited by nonlinearities appearing in case of large signals (saturation etc.) and high frequency disturbances (their effects have to be cut down significantly by the closed loop). Typical discrete-time process models Various system identification models exist including the ones implemented in the Matlabbased System Identification Toolbox (IDENT) developed by Ljung. Amongst them we will focus only on the models of discrete-time SISO systems. The naming convention of the system models corresponds to their properties. AR stands for Auto Regressive, MA stands for Moving Average, X refers to a model containing eXogenous input signal, OE denotes Output Error (additive error reduced to the output). BJ stands for the Box-Jenkins model 3 Laboratory 2. Exercise 8. while PEM denotes the most general Parameter Estimation Model. The normalized time used for the description of the models is t = iT , where T is the sampling time and i is the index of the sampling instance. x(t ) is a possible sample-series, while z − k denotes the shift operator defined by z − k x(t ) := x(t − k ) . Although only the ARX and ARMAX models will be used during the exercise, here we present also the most simple and most general models supported by IDENT, namely the AR and PEM models too: A( z −1 ) y (t ) = e(t ) , (AR) A( z −1 ) y (t ) = B( z −1 )u (t − n k ) + e(t ) , (ARX) (ARMAX) (PEM) A( z −1 ) y (t ) = B( z −1 )u (t − n k ) + C ( z −1 )e(t ) , A( z −1 ) y (t ) = B ( z −1 ) F ( z −1 ) u (t − n k ) + C ( z −1 ) D ( z −1 ) e(t ) . The external input (control signal on the input of the plant) is denoted by u (t ) , the white noise is denoted by e(t ) and the output signal with the added noise is denoted by y(t ) . A( z −1 ), B( z −1 ), C ( z −1 ), D( z −1 ), F ( z −1 ) are polynomials in the shift operator z −1 and IDENT considers n k as time delay or time lag ( nk T , where T is the sampling time). The A( z −1 ), C ( z −1 ), D( z −1 ), F ( z −1 ) polynomials are monic polynomials of the shift operator z −1 such that A( z −1 ) = 1 + a1 z −1 + Λ + a na z − na . In order to allow an arbitrary gain for the system without noise, B( z −1 ) cannot be monic: B ( z −1 ) = b1 + b2 z −1 + Λ + bnb z − ( nb −1) . The gain of the noise channel can be set by the appropriate standard deviation of the white noise e(t ) ∈ N (0, σ ) . IDENT uses the λ := σ 2 parameter instead of the normal deviation. According to the conventions of Matlab, the polynomials A( z −1 ), Κ , F ( z −1 ) have to be defined by their coefficients in the descending order of the powers of z, e.g. as A = [1 a1 a 2 Κ a na ] for A( z −1 ) . Note that n k and B are defined simultaneously by inserting n k leading zeros into B . Services of the IDENT toolbox The system model is described by a special data structure named "th”. If the system is known (i.e. the coefficients of the polynomials and the square of the standard deviation of the white noise are numerically determined, e.g. because we would like to generate signals for the simulation of a known system in order to test the identification algorithms on a given benchmark system) the IDENT toolbox stores the system to a th-type variable by the function call th = poly2th ( A, B, C , D, F , λ , T ) . The latter parameters ( C , D, F , λ , T ) are optional, the value 1 will be substituted if they are omitted. A noisy or no-noise output of the system can be generated from known input and noise data series u and e by y = idsim ([u e}, th) y = idsim (u , th) . Input signals are to be defined as column vectors and resulting output data points will be also returned in a column vector. Appropriate input signals can be generated by, for example, the rand and sign functions of Matlab. 4 Laboratory 2. Exercise 8. The identification of an unknown system starts with the measurement of the input signal u (t ) and the noisy output signal y (t ) . These measurements are then collected to the column vectors u and y , and they are contracted to the matrix z = [ y u ] containing two columns. The identification using the services of IDENT has to be preceded by the selection of the adequate system model class (ARX, ARMAX, OE, etc.), the determination of the order of its polynomials and the specification of the time delay. The aim of identification methods is to obtain the optimal parameters of the polynomials by assuming that the noise e(t ) is unknown. The least square (LS) method, or more general parameter estimation techniques, like instrumental variable (IV) methods for obtaining white noise, numerical optimization or the combination of these methods can be used for finding optimal parameters. The IDENT toolbox chooses the identification method according to the type of the system. The instrumental variable (IV) method can be used only for ARX system models. The number of the nontrivial parameters in the polynomials of the system models, which is the order of the polynomial expect e(t ) , is to be given in a column vector, e.g. nn = [n a nb nc n d n f n k ] in case of a PEM model. The zero order is allowed, e.g. if n a = 0 , then A( z −1 ) = 1 , so therefore it has no effect. If the chosen system model does not contain all polynomials A( z −1 ), Κ , F ( z −1 ) , then the orders of the missing polynomials is forbidden to include in nn . The following polynomial orders have to be given in the order presented for the PEM model: (AR) nn = n a (ARX) nn = [n a nb n k ] (IV4) nn = [n a nb n k ] (ARMAX) nn = [n a nb nc n k ] (PEM) nn = [n a nb nc n d n f n k ] . Identification methods of IDENT store the results (identified parameters and λ ) to the th structure specified by the user: (AR) thar = ar ( y, nn) (ARX) tharx = arx ( z, nn) (IV4) thiv4 = iv4( z, nn) (ARMAX) tharmax = armax ( z, nn) (PEM) thpem = pem ( z, nn) . By considering the non-noisy output of the identified system, or the known noise e(t ) in case of simulation studies, the output of the noisy system can be obtained, e.g. in case of a PEM model: y = idsim (u , thpem) y = idsim ([u e], thpem). The results of the identification can be displayed by the command idplot([ y u ]) . Coefficients of the polynomials can be extracted, e.g. in case of a PEM model by the function call [ A, B, C , D, F ] = th2poly (thpem) . 5 Laboratory 2. Exercise 8. Measurements and identification results can be displayed on the same plot and can be visually compared by general Matlab services (plot etc.). Note that several functions listed here can be called by a more general way, and they also allow the identification of MIMO systems. The IDENT toolbox provides methods not only for discrete-time parameter identification as presented afore, but also for the estimation of continuous-time linear state equations in case of special noise models. Its services include recursive realizations of parameter estimation, which have paramount importance in the field of adaptive control. Moreover, non-parametric identification and the computation of correlation functions and spectra are also possible. Latter computations are based on the fast Fourier-transform (FFT) and adequately chosen windowing method due to the periodicity of FFT. Theoretical background of the algorithms of the IDENT toolbox is given in details in Ljung: System identification: Theory for the user. Identification methods In the sequel we omit the time delay since it can be modeled by the appropriate shift of the values of u (t ) if n k is known. Assume that an appropriate model type M has been chosen, and the corresponding M (ϑ ) models can be parameterized by the parameter vector ϑ , which potentially have to meet given requirements (stability etc.): ϑ ∈ DM ⊂ R p . Clearly, every model provides a possibility for prediction. Especially, if the model class is y (t ) = G ( z −1 , ϑ )u (t ) + H ( z −1 , ϑ )e(t ) , (8-1) then the prediction can be carried out with the one-step-ahead predictor defined by M (ϑ ) : yˆ (t t − 1) = H −1 ( z −1 , ϑ )G ( z −1 , ϑ )u (t ) + [1 − H −1 ( z −1 , ϑ )] y (t ) . (8-2) Then the prediction error is given by ε (t , ϑ ) = H −1 ( z −1 , ϑ )[ y (t ) − G( z −1 , ϑ )u (t )] (8-3) The one-step-ahead predictor gives an approximation which is optimal in the estimated value of the square error if the following conditions are met: i) e(t + 1) and z (1 − H −1 ( z −1 , ϑ ))[ y (t ) − G ( z −1 , ϑ ) u (t )] are independent. ii) e(t + 1) and G( z −1 )u (t + 1) are independent. iii) E e(t ) = 0, ∀t . The condition iii) is always fulfilled in case of white noise. If the system has a low-pass characteristics then the conditions i) and ii) are also fulfilled in case of external noise. However, signals measured in closed loop or quantizing errors can cause problems. The data available for the parameter estimation is Z N = { y (1), u (1), y (2), u (2), Κ y ( N ), u ( N )} . The problem is to choose the appropriate parameter vector Z N and therefore the adequate model M (ϑˆ N ) from the class of systems M∗ = {M (ϑ ) :ϑ ∈ D M } : Z N → ϑ̂ N ∈ D M . (8-4) Such a mapping is referred to as parameter estimation for model identification. We seek such a model which "describes" the measured data, and we consider that the essence of the model is its prediction capability. It means that the following procedure has to be performed in 6 Laboratory 2. Exercise 8. order to choose a “good” model: The prediction error ε (t , ϑ ) is determined from the information in Z t . We choose the value of ϑ̂ N at the time instance t = N such that the prediction errors ε (t , ϑˆ ), t = 1,2, Κ , N would be the smallest possible ones. N However, we shall at first define what do we mean by the word “small”. The series of prediction errors is a vector in R N , so therefore the error can be characterized by the square of its norm. In order to improve the correlation conditions, it is practical to let the series of prediction errors through a stable linear filter L( z −1 ) : ε F (t , ϑ ) = L( z −1 )ε (t , ϑ ) = H −1 ( z −1 , ϑ )[ L( z −1 ) y (t ) − G ( z −1 ) L( z −1 )u (t )] (8-5) We can define the prediction error by the following metric: V N (ϑ , Z N ) = 1 N N 1 ∑ 2 ε F (t , ϑ ) 2 . (8-6) t =1 The approximation ϑ̂ N is defined as a solution to an optimization problem: ϑˆ N = arg min V N (ϑ , Z N ). ϑ∈D M (8-7) In case of the ARX model, the optimum can be determined algebraically, if we do not restrict the class of models ( DM = R p ). In other cases, a suitable optimization method shall be used. Therefore we shall study the derivative of V N (ϑ , Z N ) . If L( z −1 ) = 1 (i.e. the prediction error is not filtered), then the gradient can be obtained by V N′ (ϑ , Z N ) = d 1 dϑ N N 1 1 ∑ 2 ε 2 (t , ϑ ) = N t =1 ψ (t , ϑ ) = − N d ∑ dϑ [ε (t , ϑ )]ε (t , ϑ ), d d [ε (t , ϑ )] = [ yˆ (t , ϑ )], dϑ dϑ V N′ (ϑ , Z N ) = − 1 N (8-8) t =1 (8-9) N ∑ψ (t , ϑ )ε (t , ϑ ). (8-10) t =1 Let us now determine the second derivative (Hess-matrix). Since ε is a scalar and its first derivative with respect to ϑ is the vector −ψ , its second derivative with respect to ϑ equals to the first derivative of −ψ with respect to ϑ , which is a matrix, and therefore V N′′ (ϑ , Z N ) = − 1 N N ∑ψ ′(t , ϑ )ε (t , ϑ ) + t =1 1 N N ∑ψ (t , ϑ )ψ T (t , ϑ ) (8-11) t =1 Since ε (t , ϑ ) is small in the neighborhood of the optimum, the Hess-matrix V N′′ (ϑ , Z N ) can be approximated at the neighborhood of the optimum by V N′′ (ϑ , Z N ) ≈ H N (ϑ ) := 1 N N ∑ψ (t , ϑ )ψ T (t , ϑ ) . (8-12) t =1 We need to use an approximation because there is no suitable formula for calculating ψ ′(t , ϑ ) . The approximation of the Hess-matrix by H N (ϑ ) allows using the quasi Newton- 7 Laboratory 2. Exercise 8. method having good convergence properties. The IDENT toolbox uses a quasi-Newton method for the identification of ARMAX and even more complex models. The main problem of optimization is that there can be more local optima (especially in case of complex system models), so there is a significant risk of finding not the global, but only a local optimum. Therefore it can be necessary to repeat the optimization several times starting from different initial guesses. Identification of an ARX model using the least square method (LS) For an ARX model y (t ) = B ( z −1 ) −1 A( z ) u (t ) + 1 −1 A( z ) e(t ) =: G ( z −1 )u (t ) + H ( z −1 )e(t ) , (8-13) the predictor reads yˆ (t , ϑ ) = A( z −1 ) B ( z −1 ) −1 A( z ) u (t ) + [1 − A( z −1 )] y (t ) = [1 − A( z −1 )] y (t ) + B ( z −1 )u (t ), and let us introduce the notations ϕ T (t ) := [− y (t − 1) Κ − y(t − n a ) u (t ) Κ u (t − nb + 1)] , (8-14) (8-15) ϑ := (a1 Κ a na b1 Κ bnb ) T (8-16) Then a predictor linear in ϑ can be defined by yˆ (t , ϑ ) = ϕ T (t )ϑ . (8-17) The prediction error and the criterion to minimize are as follows. ε (t , ϑ ) = y (t ) − ϕ T (t )ϑ , V N (ϑ , Z N ) = 1 N N 1 ∑2 (8-18) 2 y (t ) − ϕ T (t )ϑ , (8-19) t =1 The latter is a linear parameter estimation problem, and its solution can be computed from the condition V N′ (ϑ , Z N ) = 0 : V N′ (ϑ , Z N ) = − 1 N ⎡1 ϑˆ NLS := ⎢ ⎣N The introduction of Φ = [ϕ (1), ϕ (2), Κ , ϕ ( N )]T the N N 1 ∑ ϕ (t ) y(t ) + N ∑ ϕ (t )ϕ T (t )ϑ = 0 , t =1 ⎤ ∑ ϕ (t )ϕ (t )⎥ t =1 ⎦ N (8-20) t =1 T notations −1 1 N N ∑ ϕ (t ) y(t ) . (8-21) t =1 Y = ( y (1), y (2), Κ , y( N )) T (matrix) lead to another form with V = (vector) 1 Y − Φϑ 2 and 2 and ϑˆ LS = (Φ T Φ ) −1Φ T Y . 8 Laboratory 2. Exercise 8. A stochastic interpretation can be given by introducing the notations R( N ) := and h( N ) := 1 N 1 N N ∑ ϕ (t )ϕ T (t ) t =1 N ∑ ϕ (t ) y(t ) , where R(N ) is a matrix and h(N ) is a vector. Then the formula of t =1 LS approximation reads ϑˆ NLS = [ R( N )] −1 h( N ) . Note that the matrix R(N ) needs to be invertible, which physically means that the signals has to be "persistently” excitable. If the observed data have been generated by the noisy system y (t ) = ϕ T (t )ϑ0 + ν 0 (t ) corresponding to the real parameter ϑ 0 , then ϑˆ NLS = [ R( N )] −1 1 N N 1 N ∑ ϕ (t )[ϕ T (t )ϑ0 + ν 0 (t )] = ϑ0 + [ R( N )] −1 N ∑ ϕ (t )ν 0 (t ). t =1 (8-22) t =1 We require that the estimation ϑ̂ NLS would be in the neighborhood of ϑ 0 and would tend to ϑ 0 if N → ∞ . If the signals are stationary and ergodic (averages of sufficiently long representation of the signal approximate well the probability averages), then R( N ) → Rϕϕ i.e. it tends to the autocorrelation function and h( N ) → Rϕν 0 i.e. it tends to the cross-correlation function. The LS estimation is consistent if ϑˆ NLS → ϑ0 , where ϑ 0 is the real parameter (the one corresponding to the real system). This condition is equivalent to Rψν 0 = 0 , so therefore the measurements ϕ (t ) and the noise ν 0 (t ) have to be uncorrelated. However, generally only the observations ϕ T (t ) are available for the computation of the y (t ), u (t ), 1 ≤ t ≤ N regression vectors, so the initial values corresponding to the time instances t ≤ 0 , necessary for the LS estimation, are missing. The number of these initial values depend on n a and nb . Therefore we consider the data series only from t = n + 1 , where n = max {n a , nb − 1} . By that way, the problem can be transformed to the original problem by reindexing and redefinition of N . Identification of an ARX model using the instrumental variables method (IV) As it has been shown, the correlation of the observation ϕ (t ) and the noise ν 0 (t ) can cause problems in case of the linear regression model yˆ (t , ϑ ) = ϕ T (t )ϑ . In order to decrease the correlation, we can substitute ϕ (t ) by an appropriate instrumental variable ξ (t ) at a properly chosen position of the formula of estimation. If the real system is given as y (t ) = ϕ T (t )ϑ0 + ν 0 (t ) , then ν 0 (t ) = y (t ) − ϕ T (t )ϑ0 , so the LS estimation problem can be conceived in the following form: ⎧1 ϑˆ NLS = sol ⎨ ⎩ N ⎫ t =1 ⎭ ∑ ϕ (t )[ y(t ) − ϕ T (t )ϑ ] = 0⎬ , N (8-23) where “sol” corresponds to the solution. Therefore we seek such a ξ (t ) instrumental variable which fulfils ⎧1 ϑˆ NIV = sol ⎨ ⎩ N ⎫ t =1 ⎭ ∑ ξ (t )[ y(t ) − ϕ T (t )ϑ ] = 0⎬ . N (8-24) Then the form of the IV estimation is as follows. 9 Laboratory 2. Exercise 8. ⎡1 ϑˆ NIV := ⎢ ⎣N N ⎤ t =1 ⎦ ∑ ξ (t )ϕ T (t )⎥ −1 1 N N ∑ ξ (t ) y(t ) . (8-25) t =1 The estimation ϑ̂ N tends to the real parameter ϑ 0 in case of large N if the condition N 1 / N ∑ ξ (t )ν 0 (t ) → 0 is fulfilled. If we substitute the averages by the expectations, then the t =1 instrumental variable ξ (t ) has to fulfill the following conditions: Eξ (t )ϕ T (t ) is non-singular (8-26) Eξ (t )ν 0 (t ) = 0 . (8-27) It means that the instrumental variable ξ (t ) has to be correlated with the ϕ (t ) observations, but also has to be uncorrelated with the noise ν 0 (t ) . The IDENT toolbox uses a numerically suitable IV4 algorithm for determining the parameters of the ARX model by the instrumental variable method. The steps of this algorithm are the following 1. Obtain the model structure in the linear regression form yˆ (t , ϑ ) = ϕ T (t )ϑ and determine the estimation of ϑ using an ordinary LS method. Denote the resulting estimated parameter by ϑˆN(1) and the corresponding transfer function by Gˆ N(1) ( z −1 ) . Let us choose x (1) (t ) = Gˆ (1) ( z −1 )u (t ) . N 2. Define instrumental variables ξ (1) (t ) = [− x (1) (t − 1) Κ − x (1) (t − n a ) u (t ) Κ u (t − nb + 1)]T and determine the corresponding IV estimation ϑˆ ( 2) := ϑˆ IV . Denote the transfer function N N corresponding to ( 2 ) ( 2) − 1 x (t ) = Gˆ ( z )u (t ) . Gˆ N( 2) ( z −1 ) = Bˆ N( 2) ( z −1 ) / Aˆ N( 2) ( z −1 ) ϑˆ ( 2) by N and define N 3. Define the equation error of the second model by wˆ N( 2) (t ) := Aˆ N( 2) ( z −1 ) y (t ) − Bˆ N( 2) ( z −1 )u (t ) and prescribe an AR model with the order n a + nb for wˆ N( 2) (t ) : L( z −1 ) wˆ N( 2) (t ) = e(t ) . Determine the LS estimation of L( z −1 ) (the terms corresponding to u are missing from ϕ ). Denote the result of the LS estimation by Lˆ ( z −1 ) . N 4. Define new instrumental variables ( 2) − 1 ( 2 ) ( 2 ) T ξ (t ) = Lˆ N ( z ) [− x (t − 1) Κ − x (t − n a ) u (t ) Κ u (t − nb + 1)] . Apply the filter Lˆ ( z −1 ) also on ϕ (t ) and y (t ) , and determine the final IV estimation using the filtered N ⎡1 signals ϕ F (t ), y F (t ) by ϑˆ N := ⎢ ⎣N N ∑ξ t =1 ( 2) (t )ϕ FT ⎤ (t )⎥ ⎦ −1 1 N N ∑ ξ (2) (t ) y F (t ) t =1 Identification of an ARMAX model using quasi-Newton method The IDENT toolbox uses a quasi-Newton optimization method for the identification of ARMAX models given as A( z −1 ) y (t ) = B( z −1 )u (t ) + C ( z −1 )e(t ) . The algorithm of the onestep-ahead predictor is applicable for ARMAX models, so yˆ (t , ϑ ) and ε (t , ϑ ) can be computed. Based on the results, the gradient of the error criterion V N′ (ϑ , Z N ) and the term 10 Laboratory 2. Exercise 8. d [ yˆ (t , ϑ )] used for the approximation of the Hess-matrix H N (ϑ ) can be obtained. dϑ The IDENT toolbox uses a multiple-step algorithm for the identification of ARMAX models with an IV4 estimation as initial step. ψ (t , ϑ ) = Requirements to be met by the identified model We require that the identification results for discrete-time linear models correspond to sampled continuous-time (analogous) linear systems. It is known that if s i is a pole of the continuous-time system, then it is mapped to the pole z i = e siT of the discrete-time transfer function of the sampled system. It means that if z i is a negative real pole of the identified model with an odd multiplicity, then the model does not correspond to any continuous-time linear system (with the same dimension) since si = ln( z i ) / T -valued poles of the latter can appear only beside their complex conjugate pairs, which is impossible if z i is a pole on the negative real axis with odd multiplicity. The IDENT toolbox assures that (assuming a stable system) the poles appearing outside the unity disk due to numerical inaccuracy return to the region of stability (the unity disk) by substituting z i−1 instead of z i if z i > 1 . However, it is possible that even though the signals of the ARX model, obtained by using the LS method, approximate well the input and output signals measured on the unknown system, some poles of the discrete-time model appear in the [−1, 0) interval of the negative real axis with odd multiplicity (a reason for such a phenomenon can be a quantization error). In that case the use of more time-consuming but more accurate IV4 or ARMAX models is recommended. State space-based compensator design in continuous-time Assuming a known model of the identified plant, compensators can be designed by various strategies. One of these strategies, which can be considered classical nowadays, is based on the use of state feedback (SF), state observer (SO) and reference gain terms ( N x , N u ) allowing setpoint control. The compensator design method assumes that the system is controllable and observable, i.e. the ranks of the controllability matrix M c and the observability matrix M o are the same as the dimension of the state-space of the system. Pole placement with state feedback The state equation of a continuous-time system is x&= Ax + Bu , y = Cx , where the size of the matrices are An×n , Bn×r , C m×n . In SISO case m = r = 1 . The controllability matrix is defined by M c = [ B AB Κ A n −1 B] while the observability matrix is M o = [C T AT C T Κ ( AT ) n −1 C T ]T . If the state feedback is u = − Kx , where the size of the gain is K r×n , then the state equation of the closed-loop system is x&= ( A − BK ) x and the characteristic equation of the closed loop reads det(sI − ( A − BK )) = 0 . It is known that the poles of the transfer function and the eigenvalues of the state matrix are the same. Therefore, if one would like to place the poles of the plant ϕ ( s ) = det(sI − A) in order to stabilize and/or accelerate the system, one can choose ϕ c ( s) = ( s − s1 )(s − s 2 ) Λ ( s − s n ) = s n + p1 s n −1 + Λ + p n −1 s + p n as the characteristic polynomial of the closed-loop system and seek for the state feedback K which assures ϕ c ( s) = det(sI − ( A − BK )) (pole placement problem). For SISO systems the algebraic problem can be solved using the Ackermann formula: K = (0 Λ 0 1) M c−1ϕ c ( A) , (8-28) 11 Laboratory 2. Exercise 8. where (0 0 Λ 1) ∈ R n is a unity row–vector and ϕ c ( A) = A n + p1 A n −1 + Λ + p n −1 A + p n I . In the sequel the use of the Ackermann formula will be referenced by ϕ (s) ( A, B ) ⎯⎯c ⎯ ⎯→ K . Mc (8-29) Control System Toolbox provides the acker function for the computation of K using the Ackermann formula. Realization of state feedback using an observer Since the state x appearing in the state-feedback is usually not available for measurement (sensors measure only the output y ), it has to be substituted by a suitable approximation x̂ . If the signals are deterministic, then the term calculating x̂ is referred to as the state observer (in case of stochastic signals the notation state estimator is used, and the term is a Kalman filter in the majority of cases). In case of an asymptotic observer, the estimation error ~ x := x − xˆ should tend to zero. The full order linear state observer is a continuous-time, linear time-invariant (LTI) dynamic system with the estimated state x̂ as its output: dxˆ = Fxˆ + Gy + Hu, dim xˆ = dim x = n. dt (8-30) x = x − xˆ tends to zero, the following condition In order to assure that the estimation error ~ has to be fulfilled: d~ x dx dxˆ = − = Ax + Bu − Fxˆ − GCx − Hu + ( Fx − Fx) → 0 , dt dt dt (8-31) It can be assured if F = A − GC, H = B, ~ x&= F~ x stable and fast. . (8-32) Therefore if the roots of the characteristic equation ϕ o ( s) = det(sI − F ) , corresponding to the decay of estimator error, are chosen to be suitably fast compared to the roots of ϕ c (s) , then the transients of the estimator decay rapidly and (if the model of the system was adequate) the error of the state estimator vanishes. Exploiting the properties of the determinant, the goal is to determine G T appearing in ϕ o ( s) = det(sI − ( A − GC )) = det(sI − ( AT − C T G T )) , which can be tracked back to the Ackermann-formula: ϕ (s) ( A, C ) I ↔ ( AT , C T ) II ⎯⎯o ⎯ ⎯→ K II → G = K IIT → F = A − GC , H = B M c , II (8-33) Setpoint control In the previous discussions on the controller design, we have assumed zero reference signal, which is unrealistic. Let us assume that the reference signal is constant (or more precisely, it changes rarely and stays constant afterwards). We would like to assure that the difference N x r − x ∞ is zero in steady state and that there is no steady-state error on the output, i.e. y ∞ = r . The required control signal will be provided by u ∞ = N u r in steady state. Since the correction contains only feed-forward terms with respect to the state feedback, it leaves the characteristic equation of the closed loop unchanged, i.e. ϕ c ( s) = det(sI − ( A − BK )) . If dim y = dim r = dim u = m , then the size of the matrices N x and N u is n × m and m × m , 12 Laboratory 2. Exercise 8. respectively (in SISO case m = 1 ). According to the conditions, the gains N x and N u can be computed by −1 ⎛ N x ⎞ ⎡ A B ⎤ ⎛ 0 n× m ⎞ ⎟⎟ . ⎜⎜ ⎟⎟ = ⎢ ⎥ ⎜⎜ ⎝ N u ⎠ ⎣C 0 ⎦ ⎝ I m ⎠ (8-34) The output of the controller by using state feedback, state observer and reference gains x + ( KN x + N u )r , therefore the allowing setpoint control is u = K ( N x r − xˆ ) + N u r = − Kx + K~ poles of the closed loop are the roots of the characteristic equation ϕ c, total ( s) = det ( sI − A + BK ) det (sI − F ) . On the other hand, each numerator of the transfer function of the closed loop (which is a matrix in MIMO case) contains the term ϕ o ( s) = det ( sI − F ) , therefore the observer causes pole-zero cancellation. If the model of the plant is improperly known, or the system changes during the operation due to the transition to another operating point, or a disturbance appears, the compensator should be extended by integrating control or by a load estimator. These methodologies will be presented for discrete-time controllers. State feedback and observer design in discrete time In discrete time the state equation of the plant reads xi +1 = Φxi + Γu i , y i = Cxi , where T Φ = e AT and Γ = ∫ e Aσ dσ B assuming that a zero-order hold element was used as digital0 analog converter. Control System Toolbox provides the c2dm function with 'zoh' (default) model for the conversion to such representations. In discrete time the controllability M c = [Γ ΦΓ Κ Φ n −1 Γ ] and observability matrices read and M o = [C T Φ T C T Κ (Φ T ) n −1 C T ]T , respectively. Pole placement with state feedback If the state feedback is defined by u i = − Kxi , then the state equation of the closed loop is xi +1 = (Φ − ΓK ) xi and its characteristic equation reads ϕ c ( z ) = ( zI − (Φ − ΓK )) . Note that the problem of obtaining the state feedback K in discrete-time is algebraically equivalent to the similar continuous-time problem. The region of stability in z is the unity disk and fast poles are in the neighborhood of z = 0 since s i ≈ −∞ is mapped to z i ≈ e −∞T = 0 . Therefore the state feedback gain K can be obtained by the Ackermann-formula if the polynomial ϕ c ( z ) = ( z − z1 )( z − z 2 ) Λ ( z − z n ) , chosen to meet the requirements of stability and speed, is known. K = (0 Κ 0 1) M c−1ϕ c (Φ ) , (8-35) ϕ ( z) (Φ , Γ ) ⎯⎯c ⎯ ⎯→ K . Mc (8-36) State feedback with actual observer To estimate the state variable x not available for measurement, a state observer is to be used also in discrete time. However, in discrete time it is practical to exploit the fact that the measurement y i is available at the time instant t = iT , so by taking this property into consideration a delay of one sampling period can be eliminated in the controller. This strategy is not applicable on the input, since an algebraic loop would appear in the system, making the computations more difficult. Let us consider that (Φ , CΦ ) is observable, e.g. 13 Laboratory 2. Exercise 8. (Φ , C ) is observable and ∃Φ −1 , i.e. there exists the inverse of the matrix Φ . Then the state x = x − xˆ reads equation of the observer and its error ~ xˆi = F xˆi −1 + G yi + H ui −1 , (8-37) ~ xi = F (xi −1 − xˆ i −1 ) + (Γ − GCΓ − H ) u i −1 + (Φ − GCΦ − F ) xi −1 . (8-38) so we can obtain an asymptotic state observer if we choose the following parameters in order xi → 0 : to assure ~ F = Φ − GCΦ, H = Γ − GCΓ, ~ xi = F~ xi −1 is stable and fast (8-39) If the speed of the transient of the observer is prescribed by the characteristic equation ϕ o (z ) of the observer, where ϕ o (z ) = det (z I − F ) = det (z I − (Φ − GCΦ )), then G and F can be obtained by using the Ackermann-formula (or any other equivalent method) in SISO case: (Φ ,C )I ( ↔ Φ T ,Φ T CT ) II ϕ ( z) ⎯⎯o ⎯ ⎯→ K II → G = K IIT → F = Φ − GCΦ M c, II (8-40) Finally, H can be computed if G is known. The computation of x̂i can be transformed into a form more suitable for real-time realization since xˆ i = Φ xˆ i −1 + Γ u i −1 + G{ y i − C (Φ xˆ i −1 + Γ u i −1 )}. Note that the computation of Φ xˆ i −1 + Γ u i −1 can be executed directly after the latest sampling while G y i can be computed at the next sampling instance after measuring y i . It results efficient CPU-use, especially if n = dim x is large. By introducing xi (which can be computed between two sampling instances) the state equation of the actual observer can be transformed into the following form: xi = Φ xˆ i −1 + Γ u i −1 " time − update" xˆ i = x i + G ( y i − C x i ) " measurement − update" (8-41) Setpoint control in discrete time Setpoint control in discrete time can be realized in a similar way to the continuous-time case. Although the principles are the same, we have to take into consideration that the solution of the state equation in steady-state is characterized by the equivalence of the previous and actual states in discrete time: x ∞ = Φ x ∞ + Γ u ∞ ⇔ (Φ − I ) x ∞ + Γ u ∞ = 0 , so therefore ⎛ N x ⎞ ⎡Φ − I ⎜⎜ ⎟⎟ = ⎢ ⎝ Nu ⎠ ⎣ C −1 Γ ⎤ ⎛ 0 n×m ⎞ ⎜ ⎟. 0 ⎥⎦ ⎜⎝ I m ⎟⎠ (8-42) Integrating control In order to reject the effects of disturbances, an integrator should be placed in the controller. Therefore, let us augment the system with the state of the integrator x I = ∫ y dt and use the left side rule (LSR) for its computation: xI ,i +1 = xI ,i + T yi = xI ,i + T C xi (8-43) x = ( x T , x TI ) T the state equation reads By introducing the extended state variable ~ 14 Laboratory 2. Exercise 8. ⎛ xi +1 ⎞ ⎡ Φ 0⎤ ⎛ x i ⎞ ⎛ Γ ⎞ ~~ ~ ~ ⎟=⎢ ⎟ ⎜ ⎜ ⎟ T C I ⎥ ⎜ x ⎟ + ⎜⎜ 0 ⎟⎟ u i ⇒ x i +1 = Φ x i + Γ u i , ⎜x ⎦ ⎝ I ,i ⎠ ⎝ ⎠ ⎝ I ,i +1 ⎠ ⎣ ⎛ xi ⎞ ~ ⎟ ⇒ yi = C ~ y i = [C 0]⎜⎜ xi . ⎟ x ⎝ I ,i ⎠ (8-44) The state feedback applied to the extended state variable with the signal of the integrator is ~ ui = −K ~ x = −[K ⎛ xi ⎞ ⎟ = − K xi − K I x I , i , K I ] ⎜⎜ ⎟ x I , i ⎝ ⎠ (8-45) while the state equation of the closed loop reads ~ ~~ ~ x = (Φ − Γ K ) ~ x. i +1 (8-46) i ~ ~~ If we prescribe the characteristic polynomial ϕ~c ( z ) = det ( zI − (Φ − Γ K )) of the closed loop, ~ then the state feedback gain K = [ K K I ] required for pole placement can be computed by ~ ~ ϕ~ ( z ) ~ (Φ , Γ ) ⎯⎯c~⎯ ⎯→ K . Mc (8-47) using the Ackermann formula in SISO case. We can exploit the property of the integrator that it is able to provide non-zero output even in case of zero input in steady state, so it can realize the effect of Nu r . The input of the integrator can be chosen to be r − y instead of y , see Fig. 8-3. The integrator can also be implemented by using the right side rule (RSR). The procedure of the controller design is as follows. ~ ~ ~ ~ (Φ, Γ, C ) → K = [ K K I ] (SF ) ( Φ , Γ, C ) → ( F , G , H ) ( Φ , Γ, C ) → ( N x , N u ) r + − TK u + I I z −1 + Nx + xi +1 = Φxi + Γui (8-48) x y C xi = Φxˆi −1 + Γui −1 xˆi = xi + G( yi − Cxi ) K LSR u (SO ) − x̂ Fig. 8-3. Integrating control in discrete time. 15 Laboratory 2. Exercise 8. Disturbance estimation The disturbance is assumed to be reduced to the input of the plant ("load change”). If we have knowledge about the characteristics of the disturbance then it can be modeled. We may assume for instance that the disturbance is constant, so its differential equation is d&= 0 ( d is a constant with unknown value). If we augment the system with the state variable xd = d x = ( x T , x T ) T then the extended state equation reads and we introduce the notation ~ d ⎛ x&⎞ ⎡ A B ⎤⎛ x ⎞ ⎡ B ⎤ ~& ~ ~ ~ ⎜⎜ ⎟⎟ = ⎢ ⎥⎜⎜ x ⎟⎟ + ⎢ 0 ⎥ u ⇒ x = A x + B u , & x 0 0 ⎦⎝ d ⎠ ⎣ ⎦ ⎝ d⎠ ⎣ ⎛ x⎞ ~ y = [C 0]⎜⎜ ⎟⎟ ⇒ y = C ~ x. ⎝ xd ⎠ (8-49) The corresponding state equation in discrete time, assuming a zero order hold on the input of the plant, reads ~ ~ ~ ~ xi +1 = Φ ~ xi + Γ u i , yi = C ~ xi . (8-50) ~ ~ ~ Since the system (Φ , Γ , C ) is not controllable (the external signal x d obviously cannot be controlled internally by u ), we have to obtain the state feedback and the reference gains allowing setpoint control for the original system. However, the observer has to be designed for the extended system in order to make it capable of estimating both x̂ and x̂ d : (Φ, Γ, C ) → K (SF ) ~ ~ ~ ~ ~ ~ (Φ, Γ, C ) → ( F , G , H ) (SO ) (8-51) (Φ , Γ, C ) → ( N x , N u ) The realization of the control loop including load estimation is illustrated by Fig. 8-4. Nu ri Nx + − K + u + i − x̂di x̂i DAC u d + y Szakasz z −1 ⎛ xˆi ⎞ ~⎛ xˆi −1 ⎞ ~ ~ ⎜⎜ ⎟⎟ = F ⎜⎜ ⎟⎟ + Gyi + Hui −1 ˆ ˆ ⎝ xdi ⎠ ⎝ xdi −1 ⎠ yi ADC Fig. 8-4. Control with load estimation in discrete time. The essence of load estimation is that after the decay of the transients of the observer the term − x̂ d added to the output of the controller and the disturbance d on the input of the plant compensate each other, and therefore the system is operating as in case of no disturbance. However, an adequately exact model of the system is indispensable. Nevertheless, the load estimator is able to compensate parameter changes. For further details and illustrative examples, see [1] and [2]. . 16 Laboratory 2. Exercise 8. References [1] Lantos - Kiss - Harmati Practices in Control Theory, Department of Control Engineering and Information Technology, Budapest University of Technology and Economics, 2008. Practice 5 (Design of continuous-time controllers in state-space), Practice 6 (Design of discrete-time controllers in state space), Practice 7 (Identification algorithms) Preparatory tasks As a homework, accomplish these tasks individually before the beginning of the laboratory exercise. 1. Read over carefully the Preliminaries chapter. 2. Download the questions assigned to you from the web page of the course and answer them in writing. 3. Read and think over the Laboratory tasks. 4. Answer the Review questions at the end of the document. The written tasks (in a hand-written form) have to be presented to the teacher. Their acceptance is a precondition of starting the laboratory exercise. The teacher may check your knowledge by oral questions. Measurement instruments Oscilloscope Agilent 54622A Power supply Agilent E3630 Function generator Agilent 33220A Digital multimeter (3½ digits) Metex ME-22T Data acquisition card Advantech PCI-1711 (in the PC on site) External connector panel for PCI-1711 data acquisition card Advantech PCLD-8710 Test panel: input scaling circuit and plant The test panel comprises a scaling circuit and the plant itself. The scaling circuit converts the inputs to the operating voltage range [-10V, +10V] of the plant from the voltage range [0V, +10V] of the Advantech PCI-1711 data acquisition card. Most relevant tasks of the exercise are to carry out on the plant. The plant is a third order linear dynamical system realized as an electronic circuit, comprising the serial interconnection of a first order and a prototype second order term. The system shows linear time-invariant behavior in a wide range of signals with a good approximation. However, it has an output offset in case of zero input. The front panel of the device is shown by Fig. 8-3. The plant can operate in more than hundred operating modes, 17 Laboratory 2. Exercise 8. which realize systems with different parameters in the class of third-order systems. During the exercise the parameter values are unknown, and they have to be identified. d u y=x1 +12V GND -12V SZAKASZ x2 x3 Fig. 8-5. Front panel of the plant (SZAKASZ in English means PLANT) The identification has to be carried out on the nominal system, and the assigned controller is to be designed for the nominal system. Studies (simulation and real-time experiments) should be carried out on the nominal system at first. Afterwards, the experiments have to be carried out on the plant with perturbed parameters (small parameter changes in negative and/or positive directions) in order to verify whether the controller is robust enough to deal with parameter changes. The plant is powered by the power supply available at the lab (plugs at the left-hand side of the front panel). Take care of connecting it with right polarity and accurate voltage settings (+12V, -12V). The plant has two inputs: u and d (BNC connectors), where u is the control signal and d is the external disturbance on the input of the plant. All three states of the plant are available for measurement (BNC connectors at the right-hand side of the front panel), amongst which x1 is assumed to be the output. The voltages applied on the input can vary between 0 and +10 V and these levels are converted to the [-10 V,+10 V] range by the scaling circuit of the panel. This conversion, originated from the properties of the Advantech data acquisition card, remains hidden since also Matlab and Windows-based software modules use input signal in the [-10 V, +10 V] range. The voltage measured on the outputs varies in the [-10 V,+10 V] range. Signals with higher amplitudes result saturation and the plant leaves the region of linear operation hence such amplitudes should be avoided. The offset of the output is compensated by a constant term added to the controller output in the real-time control algorithm. 18 Laboratory 2. Exercise 8. Laboratory tasks The tasks (1)-(10) defined in the Goals section are to be accomplished in the order indicated in Table 8-1. The table also lists the hardware and software components needed for the tasks. The power supply, the Advantech data acquisition card and the connection board are considered to be the included in the plant. Matlab refers to its version 6.0.0.88 (release 12). The Windows-based real-time software RT_DataAqu_Control realizes data acquisition and control functions. The Matlab-based Consol application (referred to as the Matlab application in the sequel) and the RT_DataAqu_Control application (referred to as the Windows application in the sequel) both have graphical user interfaces in the form of dialog windows. Programs have to be started before using them. After the startup, the desired features can be selected using the user interface. Task Platform Selection and setup of instruments Analysis of the plant using a square signal generator and an oscilloscope Function generator, oscilloscope, plant Generation of input signal for identification Matlab Data acquisition for identification Plant, Windows data acquisition software Identification Matlab Controller design Matlab Simulation analysis Matlab Online control Plant, Windows data acquisition and control software Analysis of simulated and real transients Matlab Online control on perturbed system (parameters changed to the positive direction) Plant, Windows data acquisition and control software Analysis of the transients of the perturbed system (parameters changed to the positive direction) Matlab Online control on perturbed system (parameters changed to the negative direction) Plant, Windows data acquisition and control software Analysis of the transients of the perturbed system (parameters changed to the negative direction) Matlab Table 8-1. Tasks and platforms 19 Laboratory 2. Exercise 8. 1. Identification and state-space based control of an unknown linear system (compulsory task) The aim of the exercise is to present engineering tasks necessary for the control of an unknown system, namely data acquisition on the plant, identification of the plant, development and realization of control software, test of the controller on the real system and its evaluation compared to simulated results. A further goal is to provide a possibility to gain experience on the limitations of the realization of specifications against the closed loop in control systems. 1.1. Analysis of the plant with external instruments. 1.1.1. Selection of a square wave signal as the input signal of the plant such that the transients of the step response decay during one half-period of the square signal. 1.1.2. Approximation of the DC gain, undamped natural frequency (ω 0 ) and damping (ξ ) of the plant including a second order prototype term (dominant poles). 1.1.3. Proposition for an adequate sampling time. Recall that the sampling time should be appropriate for every signal of the closed loop by Shannon's theorem. For an initial guess, use e.g. 0.2 / ω 0 . 1.2. Generation of input signal for identification 1.2.1. Based on the approximated parameters of the plant, design an input signal for the plant in Matlab which is adequate for identification Recall the values of sampling time, minimal pulse width and signal level change probability parameters. The proposed sampling time should be at least 20 ms. 1.2.2. The sampling time and data length, as well as the series of input samples are passed as individual files to the RT_DataAqu_Control application. 1.3. Data acquisition for identification 1.3.1. The RT_DataAqu_Control application tries to set the sampling time to the value passed in the aforementioned file. The sampling time can not be smaller than 20 ms. However, the scheduler is not able to keep to the prescribed sampling time precisely, so a sampling time different from the proposed one can be expected during data acquisition. On the other side, sampling instances are also recorded, so the real sampling time is determined automatically during the identification. Data acquisition can be started from the user interface of the Windows application (Data aquisition for Identification). 1.3.2. After data acquisition, the recorded transient data has to be saved to a file (Quit/Save). 1.4. Identification of the plant 1.4.1. Load the measured data to Matlab workspace using the Matlab application (Load measured output). The software will automatically calculate the real sampling time and the offset of the output measured at steady state with zero input. It will also display the plots of the input signal and the measured output signal, decreased by the value of the offset. It is necessary since the identification determines a model for changes in the neighborhood of the operating point (zero input and output offset). The 20 Laboratory 2. Exercise 8. offset of the output can be omitted during the analysis of future simulation results. 1.4.2. Identification of the process with LS, ARX, IV4 and ARMAX methods (in the increasing order of accuracy). At first, verify whether there exists a continuous-time model corresponding to the identified discrete-time one. Evaluate the identification methods and select the best resulting model with corresponding continuous-time model for controller design. For the selected model, plot its output for the input signal used for identification and the measured output signal of the real plant. 1.5. State-space based controller design, simulation and real-time control In addition to the normal control, study the behavior of integrating or load estimation-based control (according to the assignment of the teacher). The assigned controllers are to be realized in the following steps. 1.5.1. Controller design. Choose and set the roots of the characteristic polynomials of the closed loop and the observer in continuous time ( s domain). The conversion to discrete time ( z -domain) will be carried out automatically according to the sampling time used during the identification. 1.5.2. Simulation of the controller on the identified model. Evaluate the efficiency of the controller and check whether the controlled system meets the prescribed specifications. 1.5.3. Real-time implementation of the controller on the physical plant using the RT_DataAqu_Control Windows application. Import the signals recorded during the operation of the control loop to Matlab and compare them to the results of the simulation. Although the sampling time used during controller design differs from the one actually used, the simulation will be automatically executed with the real sampling time in order to allow correct comparision. Study how successful the controller design and simulation based on identification is if we apply the designed compensator on the physical plant. 1.6. Evaluate the results. To accomplish the tasks, use the Consol Matlab application and the RT_DataAqu_Control Windows application alternately, exploiting the communication between. Always carry out the controller design in Matlab environment and pay attention to simulate the behavior of the control loop before connecting the controller to the physical plant. Additional laboratory tasks 2. Measurements with various environmental effects and controller modes Another aim of the exercise is to enrich the knowledge of students about control methods if the closed loop is subject to variations (robustness analysis). 2.1. Evaluate the efficiency of control if the parameters of the system change. Study the behavior of the closed loop with higher and lower plant parameter settings. Is the controller, designed for the nominal plant, robust for the perturbed plant if the parameters change in negative/positive directions? Evaluate the efficiency of control in case of a constant disturbance appearing on the input of the plant (load). How much the quality of control decreases? 21 Laboratory 2. Exercise 8. 2.2. Study the final value of the estimated disturbance signal in case of parameter change and load estimation. Summarize your experiences in case of positive and negative parameter changes. 2.3. Study the efficiency of control in case of various pole placement and observer specifications, or in the case of accelerating the system. Can acceleration result saturation of the controller? How much the specifications limit real-time realization? 3. Substitution of the used Matlab functions to ones of your own 3.1. Substitute the identification function (assigned by the teacher) by a function of your own in Matlab environment: LS method: [theta]=ownid_ls(yd,u) ARMAX method: [theta]=ownid_arx(yd,u) In the function declarations theta denotes the parameter vector describing the identified model, yd and u are the output and input signals of the plant, respectively. All three variables are column vectors. 3.2. Substitute the controller design function (assigned by the teacher) by a function of your own in Matlab environment: Normal control: [K,Nx,Nu,F,G,H]=owncd_normal(Ad,Bd,Cd,Dd,phicz,phioz) Integrating control: [K,Nx,F,G,H,Ki]=owncd_integral(Ad,Bd,Cd,Dd,T,phichz,phioz) where T sampling time, K gain matrix (actually a vector) of the state feedback, Nx,Nu reference gains allowing setpoint control, F,G,H matrices of the state equation of the observer, Ki gain of the integrator, Ad,Bd,Cd,Dd matrices of the discrete-time state equation of the identified plant, phicz vector containing the prescribed poles of the closed loop in z phioz vector containing the eigenvalues of the observer in z . Use the right-hand side rule for realizing integrating control. 3.3. Simulation of the control loop with the designed controllers Between two sampling instances, the simulation function computes the actual control signal and the next estimated state based on the previous estimation of the state, the actual output signal, the actual reference signal and the previous control signal. Normal control: [xhati,ui]=sim_normal(K,Nx,Nu,F,G,H,xhatim1,yi,refi,uim1), Integrating control: [xhati,xIi,ui]=sim_integral(K,Ki,Nx,F,G,H,xhatim1,xIm1,yi,refi,uim1,T), 22 Laboratory 2. Exercise 8. where K,Ki,Nx,Nu,F,G,H are the parameters of the controller designed by the function of your own. Furthermore, xhatim1 xˆ i −1 the estimated state vector corresponding to the previous sampling, xhati x̂i the estimated state vector corresponding to the actual sampling, xIim1 x I ,i −1 the state of the integrator corresponding to the previous sampling instance, xIi x I ,i the state of the integrator corresponding to the actual sampling instance, yi y i value of the output signal at the actual (i th) cycle. refi ri value of the reference signal at the actual (i th) cycle, uim1 ui −1 the value of the control signal at the previous cycle, ui u i value of the control signal at the actual (i th) cycle, T sampling time. The assigned function(s) are to be saved to the Own sub-directory of the directory containing the Consol Matlab application. Some useful hints Recall that the sampling time should be appropriate for each signal of the closed loop by Shannon's theorem. For an initial guess, use e.g. 0.2 / ω 0 . Apply such a (so-called persistent) signal on the input of the plant during the identification which excites the dynamics of the system. For this purpose, a signal with frequent amplitude-changes is more suitable than a constant one. The identification is carried out in sampled time, and in some special cases it's possible that there exists no continuous-time model corresponding to the identified discrete-time one. In that case, it is worth considering changing the sampling time so that the data acquisition has to be carried out again with the new sampling time. Ensure that the simulation time interval set in the Matlab application is long enough to represent the whole dynamics of the plant. During this interval, two reference signal changes and one disturbance change is applied to the system, and their compensation may need significant time. We are interested in the whole transient of the controlled loop. However, the identification is carried out at the same time interval, which should contain several amplitude changes. Recall that significant acceleration of the system may result large control signals which can cause saturation in the controller. On the other hand one of the most important goals of control design is to accelerate the systems as much as possible to have a quick closed loop behavior. Finding a suitable tradeoff between these requirements is a crucial point of control engineering. When designing the observer, mind that the observation of state variables not available for measurement is possible only with dynamical systems (observers) which are faster than the plant and even the closed loop accelerated by pole placement. 23 Laboratory 2. Exercise 8. A transient caused by a non-dominant (stable, in closed loop) pole decays before the time of the first peak determined by the dominant pair of poles if its absolute value is approximately three times the absolute value of the real part of the dominant pole. Review questions 1. Give the system models used for identification! 2. Why identification is necessary? 3. Define the conception of state feedback! 4. Give the characteristic equation of the closed loop in case of state feedback! 5. List the major problems corresponding to simple state feedback u = − K x in typical control systems! 6. Give the definition of the dominant pair of poles! 7. Give the connection of the damping and undamped natural frequency of the prototype second-order term with the values of its poles! 8. Give the conception of allowing setpoint control in systems with state feedback. 9. Why is it necessary to use a state observer? 10. Give the connection between the nomination “load” and the disturbance signal! 11. Give the concept of disturbance compensation! 12. Define the discrete-time actual observer and specify its advantages! 13. Why is it practical to place an integrator into the control loop? 14. How a continuous-time pole is mapped into the discrete-time domain? 15. What do the eigenvalues of the observer cause in the transfer function of the closed loop? Homework Write all six Matlab routines for controller design (see Additional laboratory tasks 3.1-3.3). During the exercise, the teacher will assign one (or more) routines of these which have to be included in the Consol Matlab application for simulation studies. 24 8. mérés Rendszer-identifikáció és szabályozás The Consol Matlab application The Consol application, running in Matlab environment, is responsible for coordination of the identification, controller design, simulation and evaluation routines. The program can be started from Matlab Command Window by the command Consol. The features of the application can be accessed from the Consol_Panel window, shown in Fig. 8-6. Fig. 8-6. Graphical User Interface of the Matlab application The figure shows that control engineering tasks to be carried out in Matlab environment can be divided into four major parts. INPUT GENERATION This part deals with the generation and recording of the input signal necessary for identification. The signal generated is a series of varying-length square pulses which approximates a pseudo-random signal such that the minimal length of the constant periods can be set. If the default signal is not adequate, the parameters of the input signal can be redefined. 25 8. mérés Rendszer-identifikáció és szabályozás Suggested Sampling Time The suggested sampling time passed to the RT_DataAqu_Control application. The user can set here the time between two samplings (in ideal case). However, due to the properties of Windows scheduler, it cannot be assured that the suggested sampling time is respected exactly by the RT_DataAqu_Control application. Real (avarage) sampling time This parameter is the average sampling time which RT_DataAqu_Control was able to achieve in Windows environment. In the followings, controller design is carried out using this sampling time. The generation of the reference signal for RT_DataAqu_Control is carried out using the Suggested Sampling Time, which will realize a sampling time approximately identical to Real (avarage) sampling time. Amp Magnitude of the excitation square signal. The signal is symmetric, i.e. it varies between +Amp and –Amp. Min. Pulse length Defines the minimal pulse length in multiple of sampling periods i.e. gives at least how many sampling instances elapse between two amplitude changes. Change Probability of the change of the input signal at a given time instance; a real number between 0 and 1. This probability is overridden (masked) if the number of samplings between the actual sampling instance and the last amplitude change is smaller than Min. Pulse length, since the input signal cannot change in that case. Samples Defines the length of the series of input signal in sampling instances. ADbits Defines the number of bits of the AD converter on the data acquisition board. It has significance only in case of simulation, where the plant is also simulated. It allows to cut out quantization (choosing high number of bits) or to check the effect of quantization on the properties of control. This parameter has no effect during the measurements since the data acquisition card has a 12 bit ADC. DAbits Used for the study of quantization effects during the simulation. During the data acquisition for identification or during the control, the number of bits of the DAC on the data acquisition board has to be given here. Based on it, the Matlab software passes a signal to RT_DataAqu_Control with a magnitude not exactly Amp but its adequately quantized value. After setting the aforementioned parameters, the input signal can be generated by clicking on the Generate input button. The signal will be displayed in the window Figure No.1. If the signal does not fulfill the planned requirements, a new input signal can be generated by applying new parameter settings and clicking again on the Generate input button. IDENTIFICATION This part deals with the parameter settings for identification and the execution of the identification procedure. 26 8. mérés Rendszer-identifikáció és szabályozás Load measured output By clicking on the Load measured output button, the measurements of the output signal recorded by RT_DataAqu_Control are loaded into Matlab workspace. After that the input signal and the response of the plant are displayed in the window Figure No. 1. The value of Real (avarage) sampling time is determined simultaneously. Identification mode This allows the selection of the used identification model/method from the set LS, ARX, IV4 and ARMAX. Start identification The identification of the model, based on the input signal used during data acquisition and the measured output signal, can be initiated by clicking on the Start identification button. Results are displayed at the IDENTIFICATION RESULTS block of the Results window (see Fig. 8-7). Fig. 8-7. Window displaying the parameters of the identified model and the controller The identified parameters are contained by the vector theta. The variables zpid and spid contain the poles of the identified model in z and in s domains, respectively. The A3 parameter gives the DC gain of the continuous model corresponding to the identified discrete-time one. T2 and ksi represent the time constant (reciprocal of the undamped natural frequency) and the damping of the second-order term of the model, respectively. T3 is the time constant of the first-order term of the model. Consol_Panel (and also the Results window) displays whether there exists a continuous-time model corresponding to the identified one (identification is carried out in discrete time). If not, the T3 time constant is corrected, which is indicated in the Results window. After the 27 8. mérés Rendszer-identifikáció és szabályozás execution of identification, the identification error, which is the difference of the output signals of the real plant and that of the identified model, is displayed in the Figure No. 2. 2 window. Then the input signal, the measured output signal and the output signal of the identified model are plotted in the window Figure No. 3. CONTROLLER DESIGN This block designs a discrete-time controller using state-space based techniques for the identified model, according to the prescribed specifications. Controller mode Defines whether the controller contains normal state feedback (normal), state feedback with integrating control (integral) or state feedback with load estimation (load). Poles calculator (optional, to be used as a help) The undamped natural frequency (ω ) and damping (ξ ) of the dominant pair of poles can be given in a vector according to the conventions of Matlab. The software computes the pole itself (one of the pair of poles and its complex conjugate) based on these parameters. This function is useful for the specification of poles (scnew, sobs vectors). scnew(1), scnew(2), scnew(3), scnew(4) The prescribed continuous-time poles (dominant pair and additional poles) of the closed loop can be defined here. In case of integrating control, four poles are necessary. Otherwise, only three poles are needed. If a complex pole is specified, then its conjugate will also appear. After giving the poles (and pressing enter or leaving the edit window), the software calculates the corresponding discrete-time poles and displays in the zcnew textbox. sobs(1), sobs(2), sobs(3), sobs(4) The prescribed continuous-time eigenvalues (dominant pair and additional poles) of the observer can be defined here. In case of load estimation, four eigenvalues are necessary. Otherwise, only three eigenvalues are needed. If a complex pole is specified, then its conjugate will also appear. After giving the eigenvalues (and pressing enter or leaving the edit window), the software calculates the corresponding discrete-time poles and displays in the zobs textbox. The application designs a controller according to the specifications after clicking on the Start controller design button. Parameters of state feedback, reference gains and the observer are saved, displayed at the Results window and the file for passing them to RT_DataAqu_Control is prepared. (In case of deficient specifications, the program warns the user to correct the specification, or to execute the identification if no identified model is present.) Results window displays the designed state feedback K, the state feedback corresponding to the integrator Ki (only in case of integrating control), the reference gains Nx, Nu allowing setpoint control and the matrices F, G, H of the state equation of the discrete-time actual observer. SIMULATION This block executes the simulation of the control loop with the controller designed for the identified model. It also compares simulation results with measurements on the controlled physical plant. 28 8. mérés Rendszer-identifikáció és szabályozás Parameter modification The multiplier of parameter perturbation for the simulation can be defined here. The parameter 1.00 corresponds to the nominal system. The parameters A3, T3, ksi (ξ ) and T2 of the identified model are multiplied by this parameter before the simulation. Disturbance level Gives the magnitude of the step function disturbance appearing on the input of the plant (load). Filtering u and y This is an optional feature which allows the filtering of the input and output signals of the plant during the simulation. The simulation of the closed loop, comprising the previously designed controller and the (optionally perturbed) plant is carried out upon clicking on the Start Simulation button. (The length of the simulation, the shape of the reference signal and the time instance where the input load is switched on are determined automatically). Results are displayed in two windows. The left sub-window of Figure No. 4. shows the output signal, the reference signal and the input load, while the right sub-window shows the control signal (the output of the controller). Figure No. 5. is divided into four sub-windows. The top left one shows the state y = x1 of the identified model, and its estimation ( xˆ1 ) provided by the state observer. The top right sub-window shows the state x 2 of the identified model, and its estimation ( xˆ 2 ) provided by the state observer. The bottom left sub-window shows the state x3 of the identified model, and its estimation ( xˆ 3 ) provided by the state observer. The bottom right sub-window shows the input load (d ) and its estimation ( xˆ d ) provided by the observer (only in case of load estimation). Upon clicking on the Load measurements button, Figure No. 4. is extended by the plot of the measured output while Figure No. 5. is extended by the plots of the states of the physical plant and the estimated states provided by the observer realized by RT_DataAqu_Control (i.e. there will be three plots shown in each sub-window). 29 8. mérés Rendszer-identifikáció és szabályozás The RT_DataAqu_Control application The RT_DataAqu_Control application is running in Windows environment on the Lab PCs, i.e. it is a windows application with MFC (Microsoft Foundation Class) user interface. The program consists of two threads such that the one realizing data acquisition and control has higher priority. Fig. 8-8. User interface of the RT_DataAqu_Control application The program starts with a main dialog window (see Fig. 8-8.), which allows to display three functional dialogs: Set circuit Switches, Data aquisition for Identification, Closed loop Control. There is also a Quit button, which closes the application. Circuit selection The Set circuit Switches dialog allows the teacher to set which circuit will represent the nominal plant (see Fig. 8-9). Moreover, students can choose whether they would like to work with the nominal plant, or one with parameters perturbed to negative or positive direction. The selected settings appear in the windows used during data acquisition and closed loop control. It is recommended to check these parameters before starting the aforementioned functions. If the appropriate password is entered, the Circuit Code window is activated. Then the previously set code can be redefined. The radio buttons in the Parameter Variation frame allow the adjustment of perturbation. 30 8. mérés Rendszer-identifikáció és szabályozás Fig. 8-9. Dialog for parameter settings Data acquisition for identification The Data acquisition for Identification dialog shows the parameter set in the Matlab application: the suggested sampling time and the length of data acquisition (see Fig. 8-10). Fig. 8-10. User interface of the data acquisition After clicking on the Start button, the program waits for a safety period (approx. 50 seconds), in order to let the system pass to its steady state. Then the identification is started, and the application displays its progress in percentages. Except the START, STOP and QUIT buttons, all controls of the dialog box are inactive ones, since data displayed by them are either set in the Matlab program or are measurement data. 31 8. mérés Rendszer-identifikáció és szabályozás Due to the properties of Windows scheduler, the prescribed sampling time cannot be exactly respected, but the difference from it is nearly constant at each sampling period and the deviation of the real sampling time is minimal. The program uses the clock pulse of the CPU for fast and precise time measurement. (For CPUs with automatic clock scaling, e.g. Intel Centrino platforms, the automatic scaling feature has to be switched off by the system administrator.) The application informs the user when the data acquisition is finished. Clicking on the Quit/Save button closes the dialog and saves the measurements to a file. The application uses fixed-name files for communication with the Consol Matlab application, which files are rewritten upon running the data acquisition. It is practical to save these files or the appropriate Matlab variables and plots to your own directory in order to facilitate preparing the Laboratory report. The data acquisition can be interrupted any time by the Stop button. However, in that case only a truncated file is generated, which is not handled by the Consol Matlab application, so interrupting the data acquisition is not suggested. Control The functionalities of the Closed loop Control dialog box are similar to the ones of the Data acquisition for Identification dialog, but it displays also the type of the loaded controller (see Fig. 8-11.). In the control loop the offset of the output signal is automatically compensated by the term u offset := − y offset / Aident added to the output of the control algorithm. Fig. 8-11. Dialog of the closed loop control The latter two dialogs load the files created by Matlab upon clicking on the appropriate button of the main dialog box. In case of corrupted files, the application deactivates all buttons except the Quit/Save one, with which the user can return to the main dialog. 32
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
advertisement