<<

Lecture 5 –Sampled Time Control

• Sampled time vs. continuous time: implementation, • Linear sampled systems modeling refresher, DSP • Sampled-time frequency analysis • Sampled-time implementation of the basic controllers – I, PI, PD, PID – 80% (or more) of control loops in industry are digital PID

EE392m - Spring 2005 Control Engineering 5-1 Gorinevsky Sampled Time Models

• Time is often sampled because of the digital computer use – digital (sampled time) control system x(t + d) = f (x,u,t) y = g(x,u,t) • Numerical integration of continuous-time ODE x()t + d ≈ x(t) + d ⋅ f (x,u,t), t = kd • Time can be sampled because this is how a system works • Example: bank account balance x(t +1) = x(t) + u(t) – x(t) - balance in the end of day t – u(t) - total of deposits and withdrawals that day y = x – y(t) - displayed in a daily statement

EE392m - Spring 2005 Control Engineering 5-2 Gorinevsky Sampling: continuous time view

• Sampled and continuous time together • Continuous time physical system + digital controller – ZOH = Zero Order Hold

A/D, Sample Control D/A, ZOH computing

Sensors Physical Actuators system

EE392m - Spring 2005 Control Engineering 5-3 Gorinevsky Signal sampling, aliasing

• Nyquist frequency: ω ω ω π N= ½ S; S= 2 /T ω ω ω • Frequency folding: k S± map to the same frequency • Sampling Theorem: sampling is Ok if there are no frequency ω components above N • Practical approach to anti-aliasing: low pass filter (LPF) • Sampled→continuous: impostoring

Low A/D, Sample Digital D/A, ZOH Low Pass computing Pass Filter Filter

EE392m - Spring 2005 Control Engineering 5-4 Gorinevsky Linear state space model • Generic state space model: x(t +1) = f (x,u,t) = y g(x,u,t) x(t + 1) = Ax(t) + Bu(t) • LTI state space model y(t) = Cx(t) – Physics-based linear system model – Obtained by sampling a continuous time model – Zero-order hold (ZOH) T + = AcT + ⎛ Act ⎞ = + x(t T ) e x(t) ⎜ e Bcdt⎟u(t) x&(t) Ac x(t) Bcu(t) 14243 ⎝ ∫0 ⎠ A 1424 434 y(t) = C x(t) B c = y(t) Cc x(t) • Matlab commands for model conversion: help ltimodels

EE392m - Spring 2005 Control Engineering 5-5 Gorinevsky Disk read-write head example

• Sampled time model for T=0.0001 Read-write head control (use Matlab ss and c2d)

⎡0.998 0⎤ ⎡ 10−3 ⎤ x(k + 1) = ⋅ x(k) + ⋅ u(k) ⎢ −4 ⎥ ⎢ −8 ⎥ ⎣ 10 0⎦ ⎣5⋅10 ⎦ 142 43 142 43 A B y(k) = []0 1 ⋅ x(k) 123 y + by = gu b = 20, g = 10 C && & 10 y = u s(s + 20) x(k + 1) = Ax(k ) + Bu(t) − 20 0 10 dx = ⎡ ⎤ ⋅ + ⎡ ⎤ ⋅ y(k ) = Cx(k ) ⎢ ⎥ x ⎢ ⎥ u dt ⎣ 1 0⎦ ⎣ 0 ⎦ 142 43 A {B y = []0 1 ⋅ x 123 C EE392m - Spring 2005 Control Engineering 5-6 Gorinevsky Sampled-time system stability

+ = = x(k 1) Ax(k ), x(0) x0 Example: % Take A, B, C • Initial condition response % from the R-W head example >> eig(A) = k >> ans = x(k ) A x0 1.0000 0.9980 • Exponential stability condition >> >> K = 10 λ = >> Ak = A - K*B*C; { j } eig( A) >> eig(Ak) λ < >> ans = j 1 0.9990 0.9990 >> 0.04 >> N = 2000;

0.03 >> x(:,1) = [1; 0]; >> for t=2:N, 0.02 >> x(:,t) = Ak*x(:,t-1);

0.01 >> end >> 0 0 200 400 600 800 1000 1200 1400 1600 1800 2000 >> plot(1:N,x(2,:)) EE392m - Spring 2005 Control Engineering 5-7 Gorinevsky Impulse response

• Response to an input impulse

u y δ (⋅) ⎯⎯→P h(⋅) t t

• Sampled time: t = 1, 2, ... • Control history = linear combination of the impulses ⇒ system response = linear combination of the impulse responses ∞ u(t) = ∑δ (t − k)u(k) k=0 ∞ y(t) = ∑h(t − k)u(k) = ()h *u (t) k=0

EE392m - Spring 2005 Control Engineering 5-8 Gorinevsky Convolution representation of a sampled-time system

• Convolution signal t processing y = h * u y(t) = ∑h(t − k)u(k) k=−∞ notation • Impulse response u(t) = δ (t) ⇒ y(t) = h(t)

• Step response: u = 1 for t > 0 t t g(t) = ∑h(t − k) = ∑h( j) h(t) = g(t) − g(t −1) k=0 j=0 Matlab commands: g = cumsum(h); h = diff(g);

EE392m - Spring 2005 Control Engineering 5-9 Gorinevsky z-transform vs.

∞ • Discrete (z-transform) transfer function: H (z) = ∑h(k)z−k = – function of complex variable z Imag z k 0 – z forward shift operator i – analytical outside the circle |z|≥r 1 – all poles are inside the circle Re z – for a stable system r ≤ 1 ∞ • Laplace transform transfer function: H (s) = ∫ h(t)estdt −∞ – function of complex variable s Imag s – s differentiation operator – analytical in a half plane Re s ≤ a Re s – for a stable system a ≤ 1

EE392m - Spring 2005 Control Engineering 5-10 Gorinevsky Sampled time vs. continuous time

• Continuous time analysis (digital implementation of a continuous time controller) 1 – Tustin’s method = trapezoidal rule of integration for H(s) = s ⎛ 2 1− z−1 ⎞ H (s) → H (z) = H ⎜ s = ⋅ ⎟ s ⎜ −1 ⎟ ⎝ T 1+ z ⎠ – Matched Zero Pole: map each zero and a pole in accordance with s = e zT • Sampled time analysis (Sampling of continuous signals and system) • Systems analysis is often performed continuous time - this is where the controlled plant is.

EE392m - Spring 2005 Control Engineering 5-11 Gorinevsky FIR model N h = − = () y(t) ∑hFIR (t k)u(k) hFIR *u (t) k=0 t • FIR = • Cut off the trailing part of the impulse response to obtain FIR • FIR filter state x is the shift register content u(t) y(t) z-1 h0

x1=u(t-1) x(t + 1) = Ax(t) + Bu(t) -1 z h1 y(t) = Cx(t) x2=u(t-2) -1 z h2

x3=u(t-3)

EE392m - Spring 2005 Control Engineeringh3 5-12 Gorinevsky IIR model

na nb = − − + − • IIR model: y(t) ∑ak y(t k) ∑bku(t k) k=1 k=0

• Filter states: y(t-1), …, y(t-na ), u(t-1), …, u(t-nb )

u(t) b y(t) z-1 0 z-1 u(t-1) y(t-1) -a z-1 b1 1 z-1 u(t-2) y(t-2) -1 -a2 -1 z b2 z u(t-3) y(t-3) -a b3 3

EE392m - Spring 2005 Control Engineering 5-13 Gorinevsky IIR model

• Matlab implementation of an IIR model: filter • Transfer function realization: unit delay operator z-1 y(t) = H (z)u(t) B(z) b z N + b z N −1 + ... + b H (z) = = 0 1 N Control convention N + N −1 + + Matlab tf, step etc A(z) z a1 z ... a N + −1 + + −N = b0 b1 z ... bN z convention + −1 + + −N 1 a1 z ... a N z Matlab filter etc ()()1 + a z −1 + ... + a z − N y(t) = b + b z −1 + ... + b z − N u(t) 14241 44 434N44 104241 44 4344N 4 A( z ) B( z ) • FIR model is a special case of an IIR with A(z) =1 (or zN )

EE392m - Spring 2005 Control Engineering 5-14 Gorinevsky IIR approximation example

• Low order IIR approximation of impulse response: (prony in Matlab Signal Processing Toolbox) • Fewer parameters than a FIR model • Example: sideways heat transfer – impulse response h(t)

– approximation with IIR filter a = [a1 a2 ], b=[b0 b1 b2 b3 b4 ] IMPULSE RESPONSE −1 −2 −3 −4 0.06 b + b z + b z + b z + b z H (z) = 0 1 2 3 4 + −1 + −2 1 a1z a2 z 0.04

0.02

0 0 20 40 60 80 100 TIME EE392m - Spring 2005 Control Engineering 5-15 Gorinevsky Linear state space model • LTI state space model x(t + 1) = Ax(t) + Bu(t) y(t) = Cx(t) + Du(t)

• Unit delay operator z-1: z-1 x(t) = x(t-1) • Transfer function of an LTI model – defines an IIR representation

− y = [()Iz − A 1 B + D]⋅ u − H (z) = C()Iz − A 1 B + D

• Stability: the poles are inside the unit circle

EE392m - Spring 2005 Control Engineering 5-16 Gorinevsky Stability analysis

• Transfer function poles tell you everything about stability • Model-based analysis for a simple feedback example: y = H (z)u H(z)K y = y = L(z) y = − − + d d u K( y yd ) 1 H(z)K

• If H(z) is a rational transfer function describing an IIR model • Then L(z) also is a rational transfer function describing an IIR model

EE392m - Spring 2005 Control Engineering 5-17 Gorinevsky State space realization of IIR filter u(t) b4 b3 b2 b1 b0 y(t) = H (z)u(t) −1 −N -1 -1 -1 -1 B(z) b + b z + ... + b z z z z z H (z) = = 0 1 N + −1 + + −N A(z) 1 a1z ... aN z a4 a3 a2 a1 y(t)

+ − − − − ⎡ x1(t 1)⎤ ⎡ a1 a2 a3 a3 ⎤ ⎡ x1(t)⎤ ⎡1⎤ ⎢x (t + 1)⎥ ⎢ 1 0 0 0 ⎥ ⎢x (t)⎥ ⎢0⎥ ⎢ 2 ⎥ = ⎢ ⎥ ⋅ ⎢ 2 ⎥ + ⎢ ⎥u(t) + ⎢x3 (t 1)⎥ ⎢ 0 1 0 0 ⎥ ⎢x3 (t)⎥ ⎢0⎥ ⎢ + ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎣x4 (t 1)⎦ ⎣ 0 0 1 0 ⎦ ⎣x4 (t)⎦ ⎣0⎦

⎡ x1(t)⎤ ⎢x (t)⎥ = []− − − − ⋅ ⎢ 2 ⎥ + y(t) b1 a1b0 b2 a2b0 b3 a3b0 b4 a4b0 b0u(t) ⎢x3 (t)⎥ ⎢ ⎥ ⎣x4 (t)⎦ EE392m - Spring 2005 Control Engineering 5-18 Gorinevsky Poles and Zeros  System Impulse Response 1

•…not quite so! 0.8 • Example: 0.6 0.4

z Amplitude y = H (z)u = 0.2 − z 0.7 0 0 5 10 15 20 25 • FIR model - truncated IIR Ti me (sec) 19 + 18 + 17 + + + = = z 0.7z 0.49z ... 0.001628 z 0.00114 y H FIR (z)u 19 z Impulse Response 1

0.8

0.6

0.4 Amplitude 0.2

0 0 5 10 15 20 25 Ti me (sec) EE392m - Spring 2005 Control Engineering 5-19 Gorinevsky IIR/FIR example - cont’d

• Feedback control: z y = H (z)u = z − 0.7 = − − = − − u K( y yd ) ( y yd )

• Closed loop: Impulse Response 0.8 H(z) y = u = L(z)u 0.6 1+ H(z) 0.4 mplitude A 0.2 = H FIR (z) = y u LFIR (z)u 0 1+ H (z) 0 5 10 15 20 25 FIR Ti me (sec)

EE392m - Spring 2005 Control Engineering 5-20 Gorinevsky IIR/FIR example - cont’d Poles and zeros

• Blue: Loop 0.8 with IIR 0.6 model poles x and zeros o 0.4

0.2

• Red: Loop 0

with FIR -0.2 model poles x and zeros o -0.4

-0.6

-0.8 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8

EE392m - Spring 2005 Control Engineering 5-21 Gorinevsky Frequency domain description

• Sinusoids are eigenfunctions of an LTI system: y = H (z)u

ω LTI ω ω Plant ω zei t = ei (t+1) = ei eiωt z → eiω • Frequency domain analysis  systemω diagonalization ω u = u~ ei kt ⇒ y = H(ei k )u~ ei kt ∑ k ∑ 142 4ω3k ~y ( ) ω Packet i kt ω e Packet i kt iω e u of ~ H(e ) of y uk ~ sinusoids sinusoids yk

EE392m - Spring 2005 Control Engineering 5-22 Gorinevsky Frequency domain description ω Mω( ) = H(ei ) • Bode plots:ω ϕ ω (ω) = arg H(ei ) u = ei t ω Bode Diagram = i iωt 15 y H(e )e 10

• Example: 5 1 0 H(z) = -5 z − 0.7 0 -45

•|H| is often -90 Phase (deg) Magnitude (dB) measured in dB -135

-180 -2 -1 0 10 10 10 EE392m - Spring 2005 Control EngineeringFrequency (rad/sec) 5-23 Gorinevsky Fourierω transform for sampled signals

∞ ~ i t x( ) = ∑ x(t)ωe • Fourier transform of a series t=−∞ [−∞ :1: ∞] → [0,2π ] π 2π ω 1 − x(t) = ~x( )e i tdω • Inverse Fourier transform ∫ ω π → −∞ ∞ 2 0 [0,2 ] [ :1: ]

• If x(t) is a smoothly varying signal, the sum approximates the integral for continuous FT •~x(ω) approximates the continuos FT up to the Nyquist frequency of ω = π • If sampling frequency is other than unity, need to scale

EE392m - Spring 2005 Control Engineering 5-24 Gorinevsky Discrete Fourier Transform = DFT

ωDFT is computed by Matlab FFT ω N 2 ~ = i kt = x( k ) ∑ x(t)e , k k •DFT = ω N t 1 f=FFT(x)π [0 :1: N ] → [0 : (2π / N ) : 2π ] N −1 1 − ω = ~ ω i kt x(t) ∑ x( k )e • Inverse DFT N k=0 x=iFFT(f) [0 : (2π / N ) : 2π ] → [0 :1: N ]

• DFT = FT of a sequence: …, 0, x(1), x(2), …, x(N), 0, 0, ...

• The sum in Inverse DFT approximates the infinite sequence inverse FT up to the ‘Nyquist time’ of N/2

EE392m - Spring 2005 Control Engineering 5-25 Gorinevsky Sampled-time LTI models - recap

• Linear system can be described by impulse response • Linear system can be described by frequency response = Fourier transform of the impulse response • FIR, IIR, State-space models can be used to obtain close approximations of sampled-time linear system • A pattern of poles and zeros can be very different for a small change in an input-output model. • Impulse response, step response, and frequency response do not change much for small model changes

EE392m - Spring 2005 Control Engineering 5-26 Gorinevsky Sampled time I control

• Step to step update: sampled time y(t) = g ⋅u(t) + d(t) integrator u(t) = u(t −1) + v(t −1) = []− v(t) kI y(t) yd

• Closed-loop dynamics y = g ⋅u + d gk z −1 y = I y + d k z −1+ gk d z −1+ gk u = I []y − y I I z −1 d = = −1 + ()− −1 • Deadbeat control: gkI 1 y z yd 1 z d

EE392m - Spring 2005 Control Engineering 5-27 Gorinevsky Run-to-run (R2R) control

• Main APC (Advanced Process Control) approach in semiconductor processes • Modification of a product recipe between tool "runs"

• Processes: y(t) = g ⋅ u(t) + d(t) – vapor phase epitaxy = − − []− Run-to-run control u(t) u(t 1) k I y(t) yd – lithography Cell controller – chemical mechanical planarization (CMP) Tunable Runtime – plasma etch controller Metrology recipe system Process parameters Tool EE392m - Spring 2005 Control Engineering 5-28 Gorinevsky PI control

• P Control + Integrator for Cascade loop interpretation: cancelling steady state error

= − Inner loop e y yd v(t + 1) = v(t) + e(t) ∑ ki kP = − − u(t) u(t) k I v(t) kPe(t) e(t) y - Plant yd • Velocity form of the controller = ⋅ kI ki kP = − − − []− − u(t) u(t 1) kI e(t) kP e(t) e(t 1)

EE392m - Spring 2005 Control Engineering 5-29 Gorinevsky QoS Control Example

• QoS control for video server • QoS = Quality of Service • Need to maintain constant delay – for audio synchronization etc

• Control codec quality (processing rate) Assume • Regulate buffer queue Rate r(t + 1) = u(t) T = 1 • Model: Buffer b(t + 1) = b(t) − Tr(t) + w(t) 0 0 −1 0 + = ⎡ ⎤ ⋅ + ⎡ ⎤ ⋅ + ⎡ ⎤ ⋅ x(k 1) ⎢ ⎥ x(k) ⎢ ⎥ u(k) ⎢ ⎥ w(k) ⎣−1 1⎦ ⎣ 0 ⎦ ⎣1⎦ 14243 A {B {F y(k) = []0 1 ⋅ x(k) 123 EE392m - Spring 2005 C Control Engineering 5-30 Gorinevsky QoS Control Example, cont’d

• Dominant integrator dynamics, use P control + = + + = − ()− x(k 1) Ax(k) Bu(k) Fw(k) u(k) kP y(k) yd y(k) = Cx(k)

disturbance w auxillary output z Plant output y - Control Step Response to Disturbance

4 Matlab command: 3 S=feedback(P,C,iI,iO); 2 = kP 0.25

1 Use tf to convert model Amplitude

0 0 5 10 15 20 25 Time (sec) EE392m - Spring 2005 Control Engineering 5-31 Gorinevsky QoS Control Example, cont’d

• P control provides poor disturbance rejection • Use PI control = − e(k) y(k) yd = − − − − − u(k) u(k 1) kI e(k) kP [e(k) e(k 1)] • PI has better disturbance rejection Step Response to Disturbance 3

⎡ k z ⎤ 2 k = 0.25 u = − k + I ⋅ e P ⎢ P ⎥ z −1 1 = ⎣ ⎦ kI 0.1 0 Amplitude

-1 0 5 10 15 20 25 30 35 40 Time (sec)

EE392m - Spring 2005 Control Engineering 5-32 Gorinevsky PID Control

= − • PID: three-term control e y yd u = −k e − k e ⋅ dt − k e P I ∫ D & 1 − u = −k e − k e − k ()1 − z 1 ⋅ e • Sampled-time PID P I 1 − z −1 D present past future

∆ = − ∆2 − ∆ − • PID controller in velocity form u kD e kP e kI e – bumpless transfer between ∆ = 1− z−1 manual and automatic = − − − [][− − − − − + − ] u(t) u(t 1) k I e(t) kP e(t) e(t 1) kD e(t) 2e(t 1) e(t 2)

EE392m - Spring 2005 Control Engineering 5-33 Gorinevsky PID Controller Tuning

• Tune continuous-time PID controller, e.g. by Ziegler-Nichols rule, and set up the sampled time PID to approximate the continuous-time PID • Cascaded loop design (continuous time structure) –Design P – Cascade I, retune P – Add D, retune PI • Optimize the performance parameters by repeated simulation runs – search through the {P, I, D} space • Loopshaping – Lectures 7-8 • Advanced control design – formal specs, other courses

EE392m - Spring 2005 Control Engineering 5-34 Gorinevsky Industrial PID Controller

• A box, not an algorithm • Auto-tuning functionality: – pre-tune –self-tune • Manual/cascade mode switch • Bumpless transfer between different modes, setpoint ramp • Loop alarms • Networked or serial port connection

EE392m - Spring 2005 Control Engineering 5-35 Gorinevsky Plant Type

• Constant gain - I control • Integrator - P control • First order system - PI control • Double integrator or second order system - PD control • Generic response with delay - PID control

EE392m - Spring 2005 Control Engineering 5-36 Gorinevsky