Automatic Control Discrete-time linear systems Prof. Alberto Bemporad University of Trento Academic year 2-2 Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 / 34
Introduction Introduction 3.5 y(t), y(kt s ) 4 u(kt s ) 3 3.5 3 2.5 2.5 2 2.5.5 2 3 4 5 time t Sampling of a continuous signal 2 3 4 5 time t Discrete-time signal Discrete-time models describe relationships between sampled variables x(kt s ), u(kt s ), y(kt s ), k =,,... The value x(kt s ) is kept constant during the sampling interval [kt s, (k + )T s ) A discrete-time signal can either represent the sampling of a continuous-time signal, or be an intrinsically discrete signal Discrete-time signals are at the basis of digital controllers (as well as of digital filters in signal processing) Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 2 / 34
Difference equations Difference equation Consider the first order difference equation (autonomous system) x(k + ) = ax(k) x() = x The solution is x(k) = a k x 3 2.5 a> 2 x(k).5 a=.5 <a< 2 3 4 5 6 7 8 9 k Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 3 / 34
Difference equations Difference equation First-order difference equation with input (non-autonomous system) The solution has the form x(k + ) = ax(k) + bu(k) x() = x x(k) = a k x }{{} natural response a i bu(k i) k + i= } {{ } forced response The natural response depends on the initial condition x(), the forced response on the input signal u(k) Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 4 / 34
Difference equations Example - Wealth of a bank account k: year counter ρ: interest rate x(k): wealth at the beginning of year k u(k): money saved at the end of year k x : initial wealth in bank account Discrete-time model: x k u(k) 5 k ρ % x(k + ) = ( + ρ)x(k) + u(k) x() = x 5 45 4 35 3 Stored amount of money (keur) x(k) 25 2 x(k) = (.) k + (.)k. 5 = 6(.)k 5 5 5.5.5 2 2.5 3 3.5 4 4.5 5 k (years) Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 5 / 34
Difference equations Linear discrete-time system Consider the set of n first-order linear difference equations forced by the input u(k) x (k + ) = a x (k) +... + a n x n (k) +b u(k) x 2 (k + ) = a 2 x (k) +... + a 2n x n (k) +b 2 u(k)... x n (k + ) = a n x (k) +... + a nn x n (k) +b n u(k) x () = x,... x n () = x n In compact matrix form: x(k + ) = Ax(k) + Bu(k) where x = x.. n. x n x() = x Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 6 / 34
Difference equations Linear discrete-time system The solution is x(k) = A k x }{{} natural response If matrix A is diagonalizable, A = TΛT Λ =. λ... λ 2.... A i Bu(k i) k + i=...... A k = T.... λ n } {{ } forced response λ k... λ k 2............. λ k n where T = [v... v n ] collects n independent eigenvectors. T Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 7 / 34
Modal response Modal response Assume input u(k) =, k Assume A is diagonalizable, A = TΛT The state trajectory (natural response) is where x(k) = A k x = TΛ k T x = n α i λ k i v i λ i = eigenvalues of A v i = eigenvectors of A α i = coefficients that depend on the initial condition x() α = i= α.. = T x(), T = [v... v n ] α n The system modes depend on the eigenvalues of A, as in continuous-time Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 8 / 34
Modal response Example Consider the linear discrete-time system x (k + ) = 2 x (k) + 2 x 2(k) x 2 (k + ) = x 2 (k) + u(k) x () = x 2 () = x(k + ) = x() = 2 2 x(k) + u(k) Eigenvalues of A: λ = 2, λ 2 = Solution: x(k) = = = 2 2 k k + 2 i= 2 k 2 k k + i= k k 2 + i= }{{} natural response 2 i u(k i) 2 i u(k i) 2 i u(k i) } {{ } forced response.5.5.5 x (k),x 2 (k).5 2 3 4 5 6 7 8 9 step k simulation for u(k) Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 9 / 34
Linear difference equations n th -order difference equation Consider the n th -order difference equation forced by u a n y(k n) + a n y(k n + ) + + a y(k ) + y(k) = b n u(k n) + + b u(k ) + b u(k) Equivalent linear discrete-time system in canonical state matrix form...... x(k + ) =... x(k) +. u(k)... a n a n a n 2... a y(k) = (b n b a n )... (b b a ) x(k) + b u(k) There are infinitely many state-space realizations MATLAB tf2ss n th -order difference equations are very useful for digital filters, digital controllers, and to reconstruct models from data (system identification) Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 / 34
Discrete-time linear systems Discrete-time linear system x(k + ) = Ax(k) + Bu(k) y(k) = Cx(k) + Du(k) x() = x Given the initial condition x() and the input sequence u(k), k, it is possible to predict the entire sequence of states x(k) and outputs y(k), k The state x() summarizes all the past history of the system The dimension n of the state x(k) n is called the order of the system The system is called proper (or strictly causal) if D = General multivariable case: x(k) n u(k) m y(k) p A n n B n m C p n D p m Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 / 34
Discrete-time linear systems Example - Student dynamics Problem Statement: 3-years undergraduate course percentages of students promoted, repeaters, and dropouts are roughly constant direct enrollment in 2nd and 3rd academic year is not allowed students cannot enrol for more than 3 years Notation: k Year x i (k) Number of students enrolled in year i at year k, i =, 2, 3 u(k) Number of freshmen at year k y(k) Number of graduates at year k α i promotion rate during year i, α i β i failure rate during year i, β i γ i dropout rate during year i, γ i = α i β i 3 rd -order linear discrete-time system: x (k + ) = β x (k) + u(k) x 2 (k + ) = α x (k) + β 2 x 2 (k) x 3 (k + ) = α 2 x 2 (k) + β 3 x 3 (k) y(k) = α 3 x 3 (k) Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 2 / 34
Discrete-time linear systems Example - Student dynamics In matrix form β x(k + ) = α β 2 x(k) + u(k) α 2 β 3 y(k) = α 3 x(k) Simulation 4 y(k) α =.6 β =.2 α 2 =.8 β 2 =.5 α 3 =.9 β 3 =.8 u(k) 5, k = 22,... 2 22 24 26 28 22 5 5 step k u(k) 49 22 24 26 28 22 step k Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 3 / 34
Lecture: Discrete-time linear systems Discrete-time linear systems Example - Supply chain!x(k)!2x2(k) "2x2(k) "x(k) u(k) #3x3(k) P S x(k) y(k) $3x3(k) R x2(k) x3(k) Problem Statement: S purchases the quantity u(k) of raw material at each month k a fraction δ of raw material is discarded, a fraction α is shipped to producer P a fraction α2 of product is sold by P to retailer R, a fraction δ2 is discarded retailer R returns a fraction β3 of defective products every month, and sells a fraction γ3 to customers Mathematical model: x (k + ) x2 (k + ) x3 (k + ) y(k) = = = = ( α δ )x (k) + u(k) α x (k) + ( α2 δ2 )x2 (k) + β3 x3 (k) α2 x2 (k) + ( β3 γ3 )x3 (k) γ3 x3 (k) Prof. Alberto Bemporad (University of Trento) Automatic Control k x (k) x2 (k) x3 (k) y(k) month counter raw material in S products in P products in R products sold to customers Academic year 2-2 4 / 34
Stability of discrete-time linear systems Equilibrium Consider the discrete-time nonlinear system x(k + ) = f(x(k), u(k)) y(k) = g(x(k), u(k)) Definition A state x r n and an input u r m are an equilibrium pair if for initial condition x() = x r and constant input u(k) u r, k, the state remains constant: x(k) x r, k Equivalent definition: (x r, u r ) is an equilibrium pair if f(x r, u r ) = x r x r is called equilibrium state, u r equilibrium input The definition generalizes to time-varying discrete-time nonlinear systems Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 5 / 34
Stability of discrete-time linear systems Stability Consider the nonlinear system x(k + ) = f(x(k), ur ) y(k) = g(x(k), u r ) and let x r an equilibrium state, f(x r, u r ) = x r Definition The equilibrium state x r is stable if for each initial conditions x() close enough to x r, the corresponding trajectory x(k) remains near x r for all k a a Analytic definition: ε > δ > : x() x r < δ x(k) x r < ε, k The equilibrium point x r is called asymptotically stable if it is stable and x(k) x r for k Otherwise, the equilibrium point x r is called unstable Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 6 / 34
Stability of discrete-time linear systems Stability of first-order linear systems Consider the first-order linear system x(k + ) = ax(k) + bu(k) x r =, u r = is an equilibrium pair For u(k), k =,,..., the solution is The origin x r = is x(k) = a k x unstable if a > stable if a asymptotically stable if a < x(k) 3 2.5 2.5 x a> a= <a<.5 x r a= 2 4 6 8 k Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 7 / 34
Stability of discrete-time linear systems Stability of discrete-time linear systems Since the natural response of x(k + ) = Ax(k) + Bu(k) is x(k) = A k x, the stability properties depend only on A. We can therefore talk about system stability of a discrete-time linear system (A, B, C, D) Theorem: Let λ,..., λ m, m n be the eigenvalues of A n n. The system x(k + ) = Ax(k) + Bu(k) is asymptotically stable iff λ i <, i =,..., m (marginally) stable if λ i, i =,..., m, and the eigenvalues with unit modulus have equal algebraic and geometric multiplicity a unstable if i such that λ i > a Algebraic multiplicity of λ i = number of coincident roots λ i of det(λi A). Geometric multiplicity of λ i = number of linearly independent eigenvectors v i, Av i = λ i v i The stability properties of a discrete-time linear system only depend on the modulus of the eigenvalues of matrix A Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 8 / 34
Stability of discrete-time linear systems Stability of discrete-time linear systems Proof: The natural response is x(k) = A k x If matrix A is diagonalizable, A = TΛT, λ... λ 2... Take any eigenvalue λ = ρe jθ : Λ =...... A k = T...... λ n λ k... λ k 2.... λ k = ρ k e jkθ = ρ k......... λ k n T A is always diagonalizable if algebraic multiplicity - geometric multiplicity If A is not diagonalizable, it can be transformed to Jordan form. In this case the natural response x(t) contains modes k j λ k, j =,,..., alg. multiplicity = geom. multiplicity Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 9 / 34
Stability of discrete-time linear systems Example x(k + ) = x(k) 2 x() = x x 2 eigenvalues of A:, 2 solution: x (k) =, k =, 2,... x 2 (k) = k 2 x + k 2 x2, k =, 2,....5.5 x (k) x 2 (k).5 asymptotically stable.5.5 2 4 6 8 k 2 4 6 8 k Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 2 / 34
Stability of discrete-time linear systems Example 2 x(k + ) = x() = x x 2 x(k) eigenvalues of A: {+j, j} solution: x (k) = x cos kπ 2 + x 2 sin kπ 2, k =,,... x 2 (k) = x sin kπ 2 + x 2 cos kπ 2, k =,,...,.8.8.6.6.4.4 x (k).2 x 2 (k).2 marginally stable.2.2.4.4.6.6.8.8 2 4 6 k 2 4 6 k Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 2 / 34
Stability of discrete-time linear systems Example 3 x(k + ) = x(k) x() = x x 2 x (k) = x + x 2 k, k =,,... x 2 (k) = x 2, k =,,... eigenvalues of A: {, } Note: A is not diagonalizable! 7 2 6.5 5 4 3.5 x (k) 2 x 2 (k) unstable.5 2.5 3 2 4 6 k 2 2 3 4 5 k Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 22 / 34
Stability of discrete-time linear systems Example 4 2 x(k + ) = x(k) x() = x x 2 eigenvalues of A: {, 2} solution: x (k) = 2 k x, k =,,... x 2 (k) = 2 k x, k =, 2,... 8 8 6 6 4 4 x (k) 2 x 2 (k) 2 unstable 2 2 4 2 4 6 k 4 2 3 4 5 k Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 23 / 34
Stability of discrete-time linear systems Zero eigenvalues Modes λ i = determine finite-time convergence to zero. This has no continuous-time counterpart, where instead all converging modes tend to zero in infinite time (e λ it ) Example: dynamics of a buffer u(k) x 3(k) x 2(k) x (k) y(k) x (k + ) = x 2 (k) x 2 (k + ) = x 3 (k) x 3 (k + ) = u(k) y(k) = x (k) x(k + ) = x(k) + u(k) y(k) = x(k) Natural response: A 3 x() = for all x() 3 For u(k), the buffer deploys after at most 3 steps! Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 24 / 34
Stability of discrete-time linear systems Summary of stability conditions for linear systems system continuous-time discrete-time asympt. stable i =,..., n R(λ i ) < λ i < unstable i such that R(λ i ) > λ i > stable i,..., n R(λ i ) λ i and λ i such that R(λ i ) = λ i = algebraic = geometric mult. Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 25 / 34
Sampling continuous-time systems Exact sampling Consider the continuos-time system ẋ(t) = Ax(t) + Bu(t) y(t) = Cx(t) + Du(t) x() = x We want to characterize the value of x(t), y(t) at the time instants t =, T s, 2T s,..., kt s,..., under the assumption that the input u(t) is constant during each sampling interval (zero-order hold, ZOH).5 y(t), y(kt s ) 2 u(t), u(kt s ).5 u(t) = ū(k), kt s t < (k + )T s.5.5 x(k) x(kt s ) and ȳ(k) y(kt s ) are the state and the output samples at the k th sampling instant, respectively.5.5.5 2 4 6 8 time t 2 2 4 6 8 time t Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 26 / 34
Sampling continuous-time systems Exact sampling Let us evaluate the response of the continuous-time system between time t = kt s and t = (k + )T s from the initial condition x(t ) = x(kt s ) using Lagrange formula: x(t) = e A(t t ) x(t )+ t t e A(t σ) Bu(σ)dσ = e A((k+)Ts kts) x(kt s )+ (k+)ts kt s e A((k+)Ts σ) Bu(σ)dσ Since the input u(t) is piecewise constant, u(σ) ū(k), kt s σ < (k + )T s. By setting τ = σ kt s we get Ts x((k + )T s ) = e AT s x(kt s ) + e A(T s τ) dτ Bu(kT s ) and hence Ts x(k + ) = e ATs x(k) + e A(T s τ) dτ Bū(k) which is a linear difference relation between x(k) and ū(k)! Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 27 / 34
Sampling continuous-time systems Exact sampling The discrete-time system x(k + ) = Ā x(k) + Bū(k) ȳ(k) = C x(k) + Dū(k) depends on the original continuous-time system through the relations Ā e AT s, B Ts e A(T s τ) dτ B, C C, D D If u(t) is piecewise constant, (Ā, B, C, D) provides the exact evolution of state and output samples at discrete times kt s.4 y(t), y(kt s ).2 MATLAB sys=ss(a,b,c,d); sysd=c2d(sys,ts); [Ab,Bb,Cb,Db]=ssdata(sysd);.2.4 2 3 4 5 6 7 8 9 time t.5 u(t), u(kt s ).5 2 3 4 5 6 7 8 9 time t Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 28 / 34
Sampling continuous-time systems Exact sampling Rule of thumb: T s of the rise time = time to move from % to 9% of the steady-state value, for input u(t), x() =.9 9 % rise time.8 y(t), y(kt s ).8.6.4.7.2 output.6.5.4.5.5 2 2.5 3 3.5 4 4.5 5 2 time t u(t), u(kt s ).3.5.2. % rise time 2 3 4 5 6 7 8 9 time t.5.5.5 2 2.5 3 3.5 4 4.5 5 time t More on the choice of sampling time in the second part of the course... Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 29 / 34
Sampling continuous-time systems Approximate sampling - Euler s method ẋ(kt s ) x((k + )T s) x(kt s ) T s x(t) x((k x((k+)t + )Ts) ) x((k + x((k+)t )Ts) ) x(kt x(kts) ) T Ts x(kts) ) For nonlinear systems ẋ(t) = f(x(t), u(t)): kt kts x(k + ) = x(k) + T s f( x(k), ū(k)) Ts T ẋ(kts) _x(t) (k (k+)t + )Ts t Leonhard Paul Euler (77-783) For linear systems ẋ(t) = Ax(t) + Bu(t): x((k + )T s ) = (I + T s A)x(kT s ) + T s Bu(kT s ) Ā I + AT s, B T s B, C C, D D Note that e T sa = I + T s A +... + Tn s An n! +... Therefore when T s is small Euler s method and exact sampling are similar Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 3 / 34
Sampling continuous-time systems Example - Hydraulic system Continuous time: d dt h(t) = a 2g A h(t) + A u(t) q(t) = a 2g h(t) Discrete time: T h(k + ) = h(k) s a 2g T A h(k) + s A ū(k) q(k) = a 2g h(k) u 7 6 level h(t) (m) 5 4 h q 3 2 continuous time Euler approximation 5 5 2 25 3 time (s) Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 3 / 34
Sampling continuous-time systems Tustin s discretization method Assume u(k) constant within the sampling interval. Given the linear system ẋ = Ax + Bu, apply the trapezoidal rule to approximate the integral and therefore x(k + ) x(k) = (k+)ts kt s ẋ(t)dt = (k+)ts kt s (Ax(t) + Bu(t))dt T s (Ax(k) + Bu(k) + Ax(k + ) + Bu(k)) (trapezoidal rule) 2 (I T s 2 A)x(k + ) = (I + T s 2 )x(k) + T sbu(k) x(k + ) = I T s 2 A I + T s 2 A x(k) + I T s 2 A T s Bu(k) Advantage: simpler to compute than exponential matrix, without too much loss of approximation quality Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 32 / 34
Sampling continuous-time systems N-steps Euler method We can obtain the matrices A, B of the discrete-time linearized model while integrating the nonlinear continuous-time dynamic equations ẋ = f(x, u) N-steps explicit forward Euler method: given x(k), u(k), execute the following steps x = x(k), A = I, B = 2 for n=:n do 3 end A (I + T s N B (I + T s N x x + T s N f x (x, u(k))a f x (x, u(k))b + T s N f(x, u(k)) f u (x, u(k))a 4 return x(k + ) x and matrices A, B such that x(k + ) Ax(k) + Bu(k). Property: the difference between the state x(k + ) and its approximation x computed by the above iterations satisfies x(k + ) x) = O T s N Explicit forward Runge-Kutta 4 method also available Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 33 / 34
Sampling continuous-time systems English-Italian Vocabulary discrete-time linear systems sampling interval difference equation zero-order hold piecewise constant rise time sistemi lineari a tempo discreto tempo (o intervallo) di campionamento equazione alle differenze mantenitore di ordine zero costante a tratti tempo di salita Translation is obvious otherwise. Prof. Alberto Bemporad (University of Trento) Automatic Control Academic year 2-2 34 / 34