A. Hably 1 1 Gipsa-lab, Grenoble-INP ahmad.hably@grenoble-inp.fr Commande d un robot mobile (Gipsa-lab (DA)) ASI 1 / 25
Outline 1 2 (Gipsa-lab (DA)) ASI 2 / 25
of controllers Signals must be sampled and quantized A digital computer calculate the proper control signal value Limits on the speed or the bandwidth of the digital controller. One way to design a computer-controlled control system is to make a continuous-time design and then make a discrete-time approximation of this controller (Analog Design Digital Implementation). The computer-controlled system should now behave as the continuous-time system. (Gipsa-lab (DA)) ASI 3 / 25
Definitions Analog-to-digital converter (A/D) : A device that samples a physical variable y(t) (in V for example) to y(kt ) with T the sample period (1/T sample rate in Hertz) and converts it to a binary number (bits). Digital-to-analog converter (D/A) : Converter changes the binary number to analog voltage (Gipsa-lab (DA)) ASI 4 / 25
Mathematical definition The output of the ideal sampler, x (t), is a series of impulses with values x(kt e ), we have : x (t) = x(kt e )δ(t kt e ) k=0 Using the Laplace transform, L[x (t)] = x(kt e )e kste k=0 Noting z = e ste, one can derive the so called X (z) = Z[x(k)] = x(k)z k k=0 (Gipsa-lab (DA)) ASI 5 / 25
Properties Properties X (z) = Z[x(k)] = x(k)z k k=0 Z[αx(k) + βy(k)] = αx (z) + βy (z) Z[x(k n)] = z n Z[x(k)] Z[kx(k)] = z d dz Z[x(k)] Z[x(k) y(k)] = X (z).y (z) lim k x(k) = lim 1)X (z) 1 z 1(z The z 1 can be interpreted as a pure delay operator (Gipsa-lab (DA)) ASI 6 / 25
Exercise Determine the of the step function and of the ramp function x step (k) = 1 if k 0 x ramp (k) = k if k 0 = 0 if k < 0 = 0 if k < 0 (Gipsa-lab (DA)) ASI 7 / 25
Exercise Determine the of the step function and of the ramp function x step (k) = 1 if k 0 x ramp (k) = k if k 0 = 0 if k < 0 = 0 if k < 0 Solution 1) Step X step (z) = 1 + z 1 + z 2 + = 2) Ramp (note that x ramp (k) = kx step (k)) 1 1 z 1 = z z 1 X ramp (z) = z d ( z ) dz z 1 z = (z 1) 2 (Gipsa-lab (DA)) ASI 7 / 25
Some useful transformations x(t) X (s) X (z) δ(t) 1 1 δ(t kt e ) e kste z k u(t) 1 s t 1 s 2 e at 1 s+a 1 e at 1 sin(ωt) cos(ωt) z z 1 zt e (z 1) 2 z z e ate z(1 e ate ) s(s+a) (z 1)(z e ate ) ω zsin(ωt e) s 2 +ω 2 z 2 2zcos(ωT e)+1 s z(z cos(ωt e)) s 2 +ω 2 z 2 2zcos(ωT e)+1 (Gipsa-lab (DA)) ASI 8 / 25
Sampler - Zero-order-hold () Sampler : a switch that close every T e seconds Zero-order-hold () : Maintains the signal x throughout the sample period to get h as : Exercise : h(t + kt e ) = x(kt e ), 0 t < T e (Gipsa-lab (DA)) ASI 9 / 25
Zero-order-hold Model of the Zero-order-hold The transfer function of the zero-order-hold is given by : G (s) = 1 s e ste s = 1 e ste s (Gipsa-lab (DA)) ASI 10 / 25
Exercise Discretize (sampling time T e ) the system described by the Laplace function (using a Zero-order-hold) : H(s) = Y (s) U(s) = 1 s(s + 1) (Gipsa-lab (DA)) ASI 11 / 25
Exercise Discretize (sampling time T e ) the system described by the Laplace function (using a Zero-order-hold) : H(s) = Y (s) U(s) = 1 s(s + 1) Adding the Zero order hold leads to : G (s)h(s) = 1 e ste s 1 s(s + 1) hence = 1 e ste s 2 (s + 1) = (1 e ste ) ( 1 s 2 1 s + 1 ) s + 1 Z[G (s)h(s)] = (1 z 1 )Z [ 1 s 2 1 s + 1 ] s + 1 (Gipsa-lab (DA)) ASI 11 / 25
Exercise (cont d) Z[G (s)h(s)] = (1 z 1 )Z [ 1 s 2 1 s + 1 ] s + 1 if T e = 1, we have = (1 z 1 ) [ zt e (z 1) 2 z z 1 + z ] z e Te = (ze Te z + zt e ) + (1 e Te T e e Te ) (z 1)(z e Te ) Z[G (s)h(s)] = (ze Te z + zt e ) + (1 e Te T e e Te ) (z 1)(z e Te ) = ze 1 + 1 2e 1 (z 1)(z e 1 ) b 1 z + b 0 = z 2 + a 1 z + a 0 (Gipsa-lab (DA)) ASI 12 / 25
Exercise (cont d) Let us return back to sampled-time domain Y (z) U(z) = b 1z+b 0 z 2 +a 1z+a 0 b 1z+b 0 z 2 +a 1z+a 0 U(z) Y (z) = Y (z)(z 2 + a 1 z + a 0 ) = (b 1 z + b 0 )U(z) y(n + 2) + a 1 y(n + 1) + a 0 y(n) = b 1 u(n + 1) + b 0 u(n) With an unit feedback, the closed loop function is given by : F cl (z) = G(z) 1 + G(z) Similar to the continuous systems. The stability boundary is the unit circle instead of the imaginary axis. (Gipsa-lab (DA)) ASI 13 / 25
Representation of the discrete linear systems The discrete output of a system can be expressed as : y(k) = h(k n)u(n) n=0 hence, applying the Z-transform leads to Y (z) = Z[h(k)]U(z) = H(z)U(z) H(z) = b 0 + b 1 z + + b m z m a 0 + a 1 z + + a n z n = Y U where n ( m) is the order of the system The corresponding difference equation : y(k) = 1 a n [ b0 u(k n) + b 1 u(k n + 1) + + b m u(k n + m) a 0 y(k n) a 2 y(k n + 1) a n 1 y(k 1) ] (Gipsa-lab (DA)) ASI 14 / 25
{p} {z} Equivalence {p} {z} The equivalence between the Laplace domain and the Z domain is obtained by the following transformation : z = e pte Two poles with a imaginary part which differs of 2π/T e give the same pole in Z. Stability domain (Gipsa-lab (DA)) ASI 15 / 25
Forward difference (Rectangle inferior) p = z 1 T e Backward difference (Rectangle superior) p = z 1 zt e (Gipsa-lab (DA)) ASI 16 / 25
(cont d) Trapezoidal difference (Tustin) p = 2 T e z 1 z + 1 (Gipsa-lab (DA)) ASI 17 / 25
Stability Remarks Forward-difference approximation : it is possible that a stable continuous-time system is mapped into an unstable discrete-time system. Backward approximation : a stable continuous-time system will always give a stable discrete-time system. Tustin s approximation : has the advantage that the left half s-plane is transformed into the unit disc in the z-plane. (Gipsa-lab (DA)) ASI 18 / 25
Definition A discrete-time state space system is as follows : { x((k + 1)h) = Ad x(kh) + B d u(kh), x(0) = x 0 y(kh) = C d x(kh) + D d u(kh) where h is the sampling period. Matlab : ss(a d,b d,c d,d d,h) creates a SS object SYS representing a discrete-time state-space model (Gipsa-lab (DA)) ASI 19 / 25
Relation with transfer function For discrete-time systems, { x((k + 1)h) = Ad x(kh) + B d u(kh), x(0) = x 0 y(kh) = C d x(kh) + D d u(kh) the discrete transfer function is given by G(z) = C d (zi n A d ) 1 B d + D d where z is the shift operator, i.e. zx(kh) = x((k + 1)h) (Gipsa-lab (DA)) ASI 20 / 25
Recall Laplace & Z-transform From Transfer Function to State Space H(s) to state space X U = den(s) Y X = num(s) H(z) to state space X U = den(z) Y X = num(z) Ẋ = AX + BU Y = CX + DU X k+1 = A d X k + B d U k Y k = CX k + DU k Y (s) = [ C[sI A] 1 B + D ] U(s) Y (z) = [ C d [zi A d ] 1 ] B d + D d U(z) }{{}}{{} H(s) H(z) (Gipsa-lab (DA)) ASI 21 / 25
Solution of state space equations The state x k, solution of system x k+1 = A d x k with initial condition x 0, is given by x 1 = A d x 0 x 2 = A 2 d x 0 x n = A n d x 0 The state x k, solution of system x k+1 = A d x k + B d u k, is given by x 1 = A d x 0 + B d u 0 x 2 = A 2 d x 0 + A d B d u 0 + B d u 1 n 1 x n = A n d x 0 + Ad n 1 i B d u i i=0 (Gipsa-lab (DA)) ASI 22 / 25
State space analysis (discrete-time systems) Stability A system (state space representation) is stable iff all the eigenvalues of the matrix A d are inside the unit circle. Controllability definition Given two states x 0 and x 1, the system x k+1 = A d x k + B d u k is controllable if there exist K 1 > 0 and a sequence of control samples u 0, u 1,..., u K1, such that x k takes the values x 0 for k = 0 and x 1 for k = K 1. The system is controllable iff C (Ad,B d ) = rg[b d A d B d... Ad n 1 B d ] = n (Gipsa-lab (DA)) ASI 23 / 25
State space analysis (2) Observability definition The system x k+1 = A d x k + B d u k is said to be completely observable if every initial state x(0) can be determined from the observation of y(k) over a finite number of sampling periods. The system is observable iff O (Ad,C d ) = rg[c d C d A d... C d Ad n 1 ] T = n Duality Observability of (C d, A d ) Controllability of (A T d, C T d ). (proof...) Controllability of (A d, B d ) Observability of (B T d, AT d ). (proof...) (Gipsa-lab (DA)) ASI 24 / 25
Sampling period : to LEGO robots Sampling period and Anti-aliasing filter Compute the continuous-time transfer function of the open loop F BO (s) Estimate the crossover frequency w c of F BO (s) using the function margin in matlab. Choose sampling period T s according to the rule : w c T is between 0.05 and 0.14. Anti-aliasing filter : Fing the function of the filter for g n = 0.1 and ξ f = 0.707. Propose and tune the controller PID (hint use Matlab function pidtune. Discretize the controllers using one of the approximation methods and the chosen sampling period. (Gipsa-lab (DA)) ASI 25 / 25