EE/ME 574: Intermediate Controls EE/ME 574: Intermediate Controls Review-By-Example of some of the Basic Concepts and Methods of Control System Analysis and Design 3 Calculating steady-state errors (Franklin et al. sec. 4.2 (6th Ed.)) 3.1 Contents 1 Differential Eqns, Transfer Functions & Modeling 4 1.1 Example 1, Golden Nugget Airlines . . . . . . . . . . . . . . . . 4 1.2 Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.3 Laplace Transforms and Transfer Functions . . . . . . . . . . . . 6 1.3.1 Laplace transform . . . . . . . . . . . . . . . . . . . . . 6 1.3.2 Some basic Laplace transform Pairs . . . . . . . . . . . . 7 1.3.3 Transfer Functions are Rational Polynomials . . . . . . . 10 1.3.4 A transfer function has poles and zeros . . . . . . . . . . 11 1.3.5 Properties of transfer functions . . . . . . . . . . . . . . . 13 1.3.6 Forms for a transfer function . . . . . . . . . . . . . . . . 14 1.3.7 Proper and strictly proper transfer functions: . . . . . . . 15 Determining steady-state error using Bode standard form . 34 3.2 Table of steady-state errors . . . . . . . . . . . . . . . . . . . . . 35 3.3 Steady-state error example . . . . . . . . . . . . . . . . . . . . . 36 3.4 Summary for steady-state error 36 . . . . . . . . . . . . . . . . . . 4 Characteristics of the Step Response 37 4.1 Rise Time, tr . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 4.2 Peak Time, t p . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 4.3 Settling Time, ts . . . . . . . . . . . . . . . . . . . . . . . . . . 38 4.4 Percent Overshoot, PO . . . . . . . . . . . . . . . . . . . . . . . 38 5 Working 5.1 with the pole-zero constellation 39 Basics of pole-zero maps, 1st order, p1 = −α . . . . . . . . . . . 39 5.1.1 40 Real Pole location and response characteristics . . . . . . 2nd order, p1,2 = −α ± j ω Notation for a complex pole pair . . . . . . . . . . . . . . 42 21 5.2.2 Complex pole location and response characteristics . . . 43 22 5.2.3 The damping factor: ρ . . . . . . . . . . . . . . . . . . . 47 5.3 Higher order systems: dominant mode . . . . . . . . . . . . . . . 48 5.4 Which mode is the dominant mode ? . . . . . . . . . . . . . . . . 49 5.5 Summary: Pole location and response characteristics . . . . . . . 51 1.3.9 Phasors and the transfer function as complex gain . . . . . 16 1.3.10 The DC gain of a transfer function . . . . . . . . . . . . . 1.3.11 The impulse response of a system . . . . . . . . . . . . . 23 2.1 Analyzing a closed-loop system . . . . . . . . . . . . . . . . . . 27 2.2 Common controller structures: . . . . . . . . . . . . . . . . . . . 28 2.3 Analyzing other loops 29 (Revised: Jan 16, 2013) 3.1.1 5.2.1 16 . . . . . . . . . . . . . . . . . . . . . . . 33 41 System type . . . . . . . . . . . . . . . . . . . . . . . . . Part 1: Controls Review-By-Example System type and Bode standard form for the loop gain . . . . . . . . . . . . . . 1.3.8 2 Closing the loop, feedback control 32 Page 1 5.2 Basis of pole-zero maps, Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 2 EE/ME 574: Intermediate Controls EE/ME 574: Intermediate Controls 6 Design 52 1 Differential Eqns, Transfer Functions & Modeling 1.1 Example 1, Golden Nugget Airlines 6.1 Design methods . . . . . . . . . . . . . . . . . . . . . . . . . . 53 6.2 Root Locus Design . . . . . . . . . . . . . . . . . . . . . . . . . 53 7 Summary 54 8 Glossary of Acronyms Section 1.1.0 55 • Dynamic systems are governed by differential equations (or difference equations, if they are discrete-time) • Example (adapted from Franklin et al. 4thed., problem 5.41, figure 5.79) GNA Ω(t), θ(t) Mp(t) Me(t) Figure 1: Golden Nugget Airlines Aircraft. Me (t) is the elevator-moment (the control input), M p (t) is the moment due to passenger movements (a disturbance input), and θ (t) is the aircraft pitch angle, Ω (t) = θ̇ (t) . • For example, the aircraft dynamics give: 1 d Ω (t) d Mt (t) d 2 Ω (t) +4 + 5 Ω (t) = 1 + 3 Mt (t) dt 2 dt dt Mt (t) = Me (t) + M p (t) ; 1 Ω (t) = (1) d θ (t) dt (2) d Me (t) + 10 Me (t) = 7 v(t) dt (3) Where Mt (t) is the total applied moment. Eqn (1) has to do with the velocity of the aircraft response to Mt (t). Eqn (2) expresses that the pitch-rate is the derivative of the pitch angle. And Eqn (3) describes the response of the elevator to an input command from the auto-pilot. Main Fact: The Differential Equations come from the physics of the system. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 3 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 4 EE/ME 574: Intermediate Controls Section 1.2.0 1.2 Block diagram • Eqns (1)-(3) can be laid out graphically, as in figure 2. Mp(t) Elevator servo 7 s + 10 Section 1.3.1 1.3 Laplace Transforms and Transfer Functions • A block diagram is a graphical representation of modeling equations and their interconnection. v(t) EE/ME 574: Intermediate Controls Aircraft Dynamics + Me(t) + Mt(t) 1.3.1 Laplace transform Integrator Ω(t) s+3 • To introduce the Transfer Function (TF), we need to review the Laplace transform. s2 + 4 s + 5 θ(t) 1 s • The Laplace transform (LT) maps a signal (a function of time) to a function of the Laplace variable s . F(s) f(t) L-1{F(s)} • The Inverse Laplace transform maps F (s) to f (t). Figure 2: Block diagram of the aircraft dynamics and signals. Signal Symbol Signal Name / Description Units v (t) Voltage applied to the elevator drive [volts] Me (t) Moment resulting from the elevator surface [N − m] M p (t) Moment resulting from movement of the passengers Ω (t) [N − m] Pitch Rate (angular velocity) [rad/sec] θ (t) Aircraft pitch angle [radians] Space of all functions of time "Time Domain" Answers: U(s) u(t) • When analyzing a problem from basic principals, we would also have a list of parameters. Parameter Symbol Signal Name / Description Value Units b0 Motion parameter of the elevator [N-m/volt] ... ... ... Table 2: List of parameters for the aircraft block diagram. (Revised: Jan 16, 2013) Page 5 Space of all functions of s "Frequency Domain" • Why pay attention to Laplace transforms ? Table 1: List of signals for the aircraft block diagram. Part 1: Controls Review-By-Example L{f(t)} 1. Differential equations in time domain correspond to algebraic equations in s domain. Solve Algebraic Eqn. Solve Diff Eq. Y(s) y(t) 2. The LT makes possible the transfer function. 3. Time domain: find y (t) for one u (t). Space of all functions of time Space of all functions of s 4. Frequency domain: find Guy (s) for all U (s). Figure 3: Solve differential equation in time domain or solve an algebraic equation in s domain. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 6 EE/ME 574: Intermediate Controls Section 1.3.2 EE/ME 574: Intermediate Controls Section 1.3.2 • Two theorems of the Laplace transform permit us to build transfer functions: 1.3.2 Some basic Laplace transform Pairs 1. The Laplace transform obeys superposition and scaling Time Domain Signal Laplace transform Unit Impulse: Scaled Impulse: f (t) = δ (t) F (s) = 1 f (t) = b δ (t) F (s) = b f (t) = 1+ (t) = 1.0, t ≥ 0 F (s) = 1 s Unit ramp: f (t) = t, t ≥ 0 F (s) = Higher Powers of t: (t) = t n , t 1 s2 n! Unit step: f Decaying Exponential: ≥0 F (s) = f (t) = b e−αt F (s) = f (t) = sin (wt) Sinusoid: f (t) = Bc cos (ωt) + Bs sin (ωt) Sinusoidal oscillation: f (t) = e−αt (Bc cos (ωt) + Bs sin (ωt)) Oscillatory Exp. Decay: sn+1 b s+α ω s2 +ω2 c s+Bs ω F (s) = sB2 +0 s+ω2 Bc s+(Bc α+Bs ω) F (s) = s2 +2 α s+ω2 n F (s) = ωn = √ α2 + ω2 Given: z (t) = x (t) + y (t) then Z (s) = X (s) +Y (s) z (t) = 2.0 x (t) then Z (s) = 2.0 X (s) Given: 2. The Laplace transform of the derivative of a signal x (t) is s times the LT of x (t): Given: X (s) = L {x (t)} , • Putting these rules together lets us find the transfer function of a system from its governing differential equation. Area = 1.0 ∆ a2 + 1 (t) 1+ (t), unit step e L a2 t=0 Decaying expon. Part 1: Controls Review-By-Example Oscil. decay exp. (Revised: Jan 16, 2013) u(t) = s X (s) System y(t) Gp(s) d 2 y (t) d y (t) d u (t) + a1 + a0 y (t) = b1 + b0 u (t) dt 2 dt dt d 2 y (t) d y (t) + a1 + a0 y (t) dt 2 dt (4) d u (t) = L b1 + b0 u (t) (5) dt a2 s2 Y (s) + a1 sY (s) + a0 Y (s) = b1 sU (s) + b0 U (s) a2 s2 + a1 s + a0 Y (s) = (b1 s + b0) U (s) t=0 A Sinusoid d x (t) dt • Whatever signals y (t) and u (t) are, they have Laplace transforms. Eqn (4) gives: Unit ramp -αt t=0 (Notice the standard form: output (unknown) on the left, input on the right.) t=0 t=0 t=0 δ (t) , impulse function L • Consider a system that takes in the signal u (t) and gives y (t), governed by the Diff Eq: Table 3: Basic Laplace-transform pairs. 1/∆ then Page 7 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) (6) (7) Page 8 EE/ME 574: Intermediate Controls Section 1.3.2 EE/ME 574: Intermediate Controls • Eqns (5)-(7) tell us something about the ratio of the LT of the output to the LT of the input: a2 s2 + a1 s + a0 Y (s) = (b1 s + b0) U (s) Given Y (s) = G p (s) U (s) GNA (8) Ω(t), θ(t) Mp(t) Me(t) • A Transfer Function (TF) is a ratio of the input and output LT’s (b1 s + b0) , G p (s) = (a2 s2 + a1 s + a0) 1.3.3 Transfer Functions are Rational Polynomials (7, repeated) (b1 s + b0) Output LT Y (s) = = = G p (s) U (s) (a2 s2 + a1 s + a0) Input LT (9) Where G p (s) is the TF of the plant. Figure 5: Golden Nugget Airlines Aircraft. Ω (t) [radians/second] is the pitch-rate of the aircraft, and Mt (t) is the moment (torque) applied by the elevator surface. • Consider the differential equation of the Aircraft pitch angle: • Important fact: 1 – The transfer function is like the gain of the system, it is the ratio of the output LT to the input LT. • Basic and Intermediate Control System Theory are present transfer function-based design. • By engineering the characteristics of the TF, we engineer the system to achieve performance goals. + e(t) Controller u(t) ys(t) Plant y(t) s2 + 4 s + 5 Ω (s) = (s + 3) Mt (s) Ω (s) s+3 = 2 Mt (s) s +4s +5 (11) • Note: – We can write down the TF directly from the coefficients of the differential equation. – We can write down the differential equation directly from the coefficients of the TF. s+3 numerator polymonial Ω (s) = : Mt (s) s2 + 4 s + 5 denominator polynomial Sensor Dynamics Hy(s) • We call a TF such as (11) a rational polynomial. Figure 4: Block diagram of typical closed-loop control. Part 1: Controls Review-By-Example (10) • Transfer functions, such as Eqn (11), are ratios of two polynomials: Gp(s) KcGc(s) d 2 Ω (t) d Ω (t) d Mt (t) +4 + 5 Ω (t) = 1 + 3 Mt (t) dt 2 dt dt • From (10) we get the TF, take LT of both sides, and rearrange: – However, the TF depends only on the parameters of the system (coefficients a2..a0 and b0..b1 in the example), and not on the actual values of U (s) or Y (s) (or u (t) and y (t)). r(t) Section 1.3.3 (Revised: Jan 16, 2013) Page 9 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 10 EE/ME 574: Intermediate Controls Section 1.3.4 • We can use the poles and zeros to write the TF in factored form: • A TF has a numerator and denominator polynomial, for example 2 s2 + 8 s + 6 N (s) = 3 D (s) s + s s2 + 4 s + 0 (12) • The roots of the numerator are called the zeros of the TF, and the roots of the denominator are called the poles of the TF. For example: >> num = [2 8 6] >> den = [1 2 4 0 ] num = 2 8 6 den = 1 2 4 >> zeros = roots(num) zeros = -3 -1 >> poles = roots(den) poles = 0 -1.0000 + 1.7321i -1.0000 - 1.7321i 0 • We can also use Matlab’s system tool to find the poles and zeros >> zero(Gps), b2 (s − z1) (s − z2) 2 s2 + 8 s + 6 = s3 + 2 s2 + 4 s (s − p1) (s − p2) (s − p3) 2 (s + 3) (s + 1) = (s − 0) (s + 1 − 1.732 j) (s + 1 + 1.732 j) G (s) = • With a complex pole pair we can do two things, 1. Use a shorthand G (s) = 2 (s + 3) (s + 1) s (s + 1 ± 1.732 j) (Because poles always come in complex conjugate pairs.) (a) Write the complex pole pair as a quadratic, rather than 1st order terms G (s) = 2 (s + 3) (s + 1) s (s2 + 2 s + 4) • The zeros are values of s at which the transfer function goes to zero • The poles are values of s at which the transfer function goes to infinity %% Build the system object 2 s^2 + 8 s + 6 ----------------s^3 + 2 s^2 + 4 s • We can plot a pole-zero map: PZ Map 2 >> Gps=tf([2 8 6], [1 2 4 0]) >> pzmap(Gps) imaginary >> Gps = tf(num, den) Transfer function: Section 1.3.4 Interpreting the poles (p1, p2, ..., pn) and zeros (z1, ..., zm) 1.3.4 A transfer function has poles and zeros G p (s) = EE/ME 574: Intermediate Controls ans = -3 -1 1 0 −1 >> pole(Gps), ans = 0 -1.0000 + 1.7321i -1.0000 - 1.7321i Part 1: Controls Review-By-Example −2 −4 −2 real 0 Figure 6: Pole-Zero constellation of aircraft transfer function. (Revised: Jan 16, 2013) Page 11 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 12 EE/ME 574: Intermediate Controls Section 1.3.5 EE/ME 574: Intermediate Controls Section 1.3.6 1.3.5 Properties of transfer functions 1.3.6 Forms for a transfer function Just as a differential equation can be scaled by multiplying the left and right sides by a constant, a TF can be scaled by multiplying the numerator and denominator by a constant. 1. Rational polynomial form bm sm + bm−1 sm−1 · · · + b1 s + b0 G (s) = ansn + an−1 sn−1 + · · · + a1 s + a0 Monic: A TF is said to be monic if an =1. We can always scale a TF to be monic. If G1 (s) is scaled to be monic, then b′0 (13) G1 (s) = s + a′1 with b′0 = b0/an and a′1 = a1 /an . Rational Polynomial Form: A TF is in rational polynomial form when the numerator and denominator are each polynomials. For example Example: G (s) = (16) 3s +8 2 s3 + 16 s2 + 30 s (17) 2. Factored form (s − z1) ... (s − zm) (zi and pi are zeros and poles) (s − p1) ... (s − pn) s + 38 3 = (note: zi and pi are commonly negative values) 2 s (s + 3) (s + 5) G (s) = Krlg 3. Bode form 1. Bring out any poles or zeros at the origin, 2 s2 + 8 s + 6 G p (s) = 3 s + s s2 + 4 s + 0 (14) Example: An example of a TF not in rational polynomial form is: G3 (s) = ′ 2 (s + 3)/ (s) (s2 + 2 s + 4)/ (s + 1) (15) (s) (s + 1) 2 s2 + 8 s + 6 2 (s + 3)(s + 1) 2 (s + 3)/ (s) = = (s2 + 2 s + 4)/ (s + 1) (s) (s + 1) (s2 + 2 s + 4)(s) s3 + 2 s2 + 4 s (Revised: Jan 16, 2013) (18) KBode = 1. Bring out a factor, so that the numerator and denominator polynomials are monic. ′ G (s) = Krlg ′ ′ sm + bm−1 sm−1 + ... + b1 s + b0 ′ ′ ′ sn + an−1 sn−1 + ... + a1 s + a0 s + 83 3 3 K = = rlg 2 s3 + 8 s2 + 15 s 2 Page 13 8 9 4. Root locus form Example: Note the middle form above, which can be called factored form. Part 1: Controls Review-By-Example ′ b sm + ... + b1 s + 1 1 KBode ′ m n−n ′ n o s an−no s o + ... + a1 s + 1 3 1 8 8 s+1 = 1 no = 1 , 2 2 s 30 30 s + 16 30 s + 1 G (s) = By clearing the fractions within the fraction, T3 (s) can be expressed in rational polynomial form G3 (s) = 2. Bring out a constant, so that the least significant coefficients of the polynomials are 1.0 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) (19) Page 14 EE/ME 574: Intermediate Controls Section 1.3.7 1.3.7 Proper and strictly proper transfer functions: System Type: A property of transfer functions that comes up often is the system type. The type of a system is the number of poles at the origin. – A TF with m ≤ n is said to be proper. • So, for example, the aircraft transfer function from elevator input to pitch rate gives a type 0 system: – When m < n the TF is said to be strictly proper • Example of a TF that is not proper: G4 (s) = s+1 G p1 (s) = note: m = 2, n=1 G4 (s) = s+1 = Ω (s) s+3 = Me (s) s2 + 4 s + 5 poles : s = −2 ± 1 j , type : 0 • But the TF from the elevator to the pitch angle gives a type I system: such a TF can always be factored by long division: 2s2 + 5 s + 4 Section 1.3.9 1.3.8 System type • m = number of zeros, n = number poles 2s2 + 5 s + 4 EE/ME 574: Intermediate Controls 2 s (s + 1) 3 s + 4 3s +4 1 + = 2 s+ = (2s + 3)+ (s + 1) s+1 s+1 s+1 • A non-proper TF such as G4 (s) has a problem: As s = j ω → j ∞, the gain goes to infinity ! • Since physical systems never have infinite gain at infinite frequency, physical systems must have proper transfer functions. G p2 (s) = s+3 θ (s) = Me (s) s (s2 + 4 s + 5) poles : s = 0, −2 ± 1 j , type : I • If we put a PID controller in the loop, which adds a pole at the origin, the system will be type II. 1.3.9 Phasors and the transfer function as complex gain • To consider the complex gain, we need to represent sinusoidal signals as phasors. A phasor is a complex number that represents a sinusoidal waveform. A time domain signal, such as v (t) = Av cos (ωt + θv ) (20) is represented by the complex number ~V = Av ∠θv = a + j b . Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 15 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) (21) Page 16 EE/ME 574: Intermediate Controls Section 1.3.9 • For example, the time-domain waveform EE/ME 574: Intermediate Controls Section 1.3.9 • In the example of figure 7, v (t) = 3.0 cos (ωt + 40o) u(t)=Au cos(ωt+θu) Gp (s) y(t)=Ay cos(ωt+θy) is represented by ~V = 3.0 ∠400 = 2.30 + 1.93 j . Figure 7: An element with sinusoid in and sinusoid out. • For a phasor to represent a sinusoidal signal, the frequency, ω [rad/sec] must be given. • Phasors in polar and rectangular coordinates Polar ~V = Av ∠θv p Av = a2 + b2 , θv = atan2 (b, a) • The TF evaluated with s = j ω gives the complex gain of the system element Output Phasor = G p (s = jω) Input Phasor Ay ∠θy = G p ( j ω) Rectangular ~V = a + j b (26) Au ∠θu (22) a = Av cos (θv ) , b = Av sin (θv ) (23) • Sinusoidal signals in polar and rectangular coordinates v (t) = Av cos (ωt + θv ) v (t) = a cos (ωt) − b sin (ωt) (24) With a and b as given in Eqn (23). • Notice the difference of ’-’ sign between the phasor in rectangular coordinates and the time-domain function in rectangular coordinates. This extra ’-’ comes from the trig identity: cos (α ± θ) = cos (α) cos (θ) ∓ sin (α) sin (θ) Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) (25) Page 17 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 18 EE/ME 574: Intermediate Controls Section 1.3.9 Example Question: If v (t) = 1.5 cos (2.0t + 0o) , what is the response of the aircraft, Ω (t) ? EE/ME 574: Intermediate Controls Section 1.3.9 • The complex gain is a function of frequency. Evaluating G p (s) = Solution: Looking back at the transfer functions s+3 7 Ω (s) = V (s) s + 10 s2 + 4 s + 5 Ω (s) V (s) s= j ω as a function of ω gives the Bode plot. Bode plot of Gp(s) • Evaluating at s = j ω = j 2 gives the complex gain (27) = 0.1512 − 2.2672 j = 0.307∠ − 60.5o −20 −40 −60 −80 −100 0 • The complex gain determines the output phasor: ~Ω = (0.307∠ − 60.5o) × (1.5∠0o ) = 0.461∠ − 60.5 Magnitude (dB) Magnitude at w=2.0 (28) • So the output, in the time domain, is: Phase (deg) 7 21 + 14 j Ω (s) 3+2 j = = V (s) s=2 j 10 + 2 j (2 j)2 + 4 (2 j) + 5 −6 + 82 j 0 −45 Phase at w=2.0 −90 −135 −180 −1 10 0 10 1 2 10 10 3 10 Frequency (rad/s) Ω (t) = 0.461 cos (2.0t − 60.5o) Figure 8: Bode plot of G p (s). • Summary, section 1.3.9: 1. The dynamics of the aircraft itself gave us a differential equation 2. For linear differential equations, we can get the transfer function directly from the Diff Eq. (a) And for non-linear differential equations, there is no transfer function. 3. With the TF we can determine the complex gain, and find the output for any sinusoidal input. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 19 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 20 EE/ME 574: Intermediate Controls Section 1.3.10 1.3.10 The DC gain of a transfer function EE/ME 574: Intermediate Controls Section 2.0.0 1.3.11 The impulse response of a system • Following up on the idea that the TF gives the complex gain of a system block and recalling the Laplace variable s = jω • When we have a system such as in figure 9, the Laplace transform of the output (a signal) is given by (29) Y (s) = G p (s) U (s) (31) the DC gain is given with s = j0, or simply DC Gain : B (s) = G (s) A (s) s=0 s=0 (30) 0 0 • In some cases T (s = j 0) may evaluate to (undefined). In such cases apply l’Hopital’s rule: DC Gain : lim G (s) • A unit impulse input is a very short pulse with an area under the curve of the pulse of 1.0. • Since the Laplace transform of a unit-impulse is 1, then the Laplace transform of the impulse response is the transfer function Yimp (s) = G p (s) Uimp (s) = G p (s) 1 = G p (s) s→0 • The example TF’s give these values of DC gain s+3 3 Ω (s) = V (s) s + 10 s2 + 4 s + 5 u(t) y(t) t θ (s) s+3 1 3 = V (s) s + 10 s2 + 4 s + 5 s u(t): impulse U(s)=1 • Evaluating the DC Gain t System Gp(s) y(t): impulse response Y(s)=Gp(s) Figure 9: The transfer function is the Laplace transform of the impulse response. Ω (s) 3 3 9 = = V (s) s=0 10 5 50 • The connection between the impulse response and TF can be used to determine the TF θ (s) 3 31 =∞ = V (s) s=0 10 5 0 (Many systems have a DC gain of infinity, it is a common property of control systems.) – Apply an impulse and measure the output, y (t). Take the LT and use G p (s) = Y (s). • The connection between the impulse response and TF helps to understand the mathematical connection between an LT and a TF Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 21 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 22 EE/ME 574: Intermediate Controls Section 2.0.0 2 Closing the loop, feedback control u(t) Gp(s) y(t) r(t) + u(t) - EE/ME 574: Intermediate Controls Section 2.0.0 • Example, wrapping a simple feedback loop around the aircraft dynamics r(t) y(t) Mt(t) + Gp(s) s+3 1 s +4s+5 s 2 - θ(t) sensor Open Loop Closed Loop Figure 11: Simple feedback of aircraft pitch angle. Figure 10: A plant with TF G p (s) in open and closed loop. Closed loop requires a sensor. s+3 G p (s) Ω (s) s (s2 +4 s+5) = = R (s) 1 + G p (s) 1 + 2 s+3 s (s +4 s+5) • Feedback is the basic magic of controls. A feedback controller can (34) – Make an unstable system stable . . . . . . . . . . . . . . . . . . Helicopter autopilot – Make a stable system unstable . . . . . . . . . . . . . . . . Early fly-ball governors – Make a slow system fast . . . . . . . . . . . Motor drive, industrial automation – Make a fast system slow . . . . . . . . F16 controls, approach / landing mode • Eqn (34) is not in rational polynomial form, so s+3 θ (s) s (s2 +4 s+5) = R (s) 1 + 2 s+3 s (s +4 s+5) s s2 + 4 s + 5 s+3 = (35) s (s2 + 4 s + 5) s (s2 + 4 s + 5) + (s + 3) – Make an inaccurate system accurate . . . . . . . . . . . . . . . . . . . . machine tools • The closed-loop TF is still not quite in Rat Poly form, here is the final step: • The magic comes because closing the loop changes the TF Open loop: θ (s) s+3 = R (s) s3 + 4 s2 + 6 s + 3 Y (s) = G p (s) U (s) (36) For the Closed loop use U (s) = R (s) −Y (s), dropping the (s) arguments: Y = G p (R −Y ) = G p R − G p Y r(t) Y (1 + G p) = G p R Gp Y (s) = R (s) 1 + Gp Θ(s) θ(t) R(s) (32) Forward Path Gain Y (s) (33) = = Try (s) R (s) 1 + Loop Gain Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 23 Figure 12: Block with r (t) as input and θ (t) as output. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 24 EE/ME 574: Intermediate Controls Section 2.0.0 EE/ME 574: Intermediate Controls • Analyzing the response Gps = tf([1 3], [1 4 5 0]) %% LTI models Try = tf([1 3], [1 4 6 3]) figure(1), clf [Y_open, Top] = step(Gps, 6); [Y_closed, Tcl] = step(Try, 6); plot(Top, Y_open, Tcl, Y_closed) xlabel(’t [seconds]’); ylabel(’\Omega, pitch-rate’) title(’Open- and closed-loop’) text(3, 1.6, ’Open-loop’, ’rotation’, 45) text(4, 0.8, ’Closed-loop’) SetLabels(14) print(’-deps2c’, ’OpenClosedResponse1’) Section 2.0.0 • Introduce a proportional controller gain e(t) r(t) Kc + Mt(t) - s+3 1 s2 + 4 s + 5 s θ(t) Figure 14: Feedback for aircraft pitch control, with P-type gain Kc . • Look at Kc = 1.0, 3.0, 10, 0 Kc = 1; Try1 = tf(Kc*[1 Kc = 3; Try2 = tf(Kc*[1 Kc = 10; Try3 = tf(Kc*[1 figure(1), clf ... plot(Top, Y_open, Tcl, ... Open− and closed−loop response, aircraft 3.5 3], [1 4 5 0]+Kc*[0 0 1 3]) 3], [1 4 5 0]+Kc*[0 0 1 3]) 3], [1 4 5 0]+Kc*[0 0 1 3]) Y_closed1, Tcl, Y_closed2, Tcl, Y_closed3) Open− and closed−loop response, aircraft 3.5 3 • The response completely changes ! • System gets less stable as Kc increases 1.5 1 Closed−loop op lo 2 1.5 Kc =10 Kc =3 1 Closed−loop, Kc =1 0.5 0 0 2.5 pe n− O pe n− lo 2 O op • System gets much faster as Kc increases Ω, pitch−rate • The closed-loop system is type 0 Ω, pitch−rate • The open-loop system is type I 3 2.5 0.5 1 2 3 t [seconds] 4 5 6 0 0 1 2 3 t [seconds] 4 5 Figure 13: Open and Closed loop response of the aircraft, the two responses have very different characteristics. Figure 15: Open and Closed loop response of the aircraft, with Kc = 1.0, Kc = 3.0, and Kc =10.0 . Part 1: Controls Review-By-Example Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 25 (Revised: Jan 16, 2013) 6 Page 26 EE/ME 574: Intermediate Controls Section 2.1.0 2.1 Analyzing a closed-loop system EE/ME 574: Intermediate Controls 2.2 Common controller structures: • A typical, basic loop (such as velocity PI control of a motor drive) has 3 components: PD PI PID Proportional-Derivative Prop.-Integral Prop.-Int.-Deriv. 1. Plant (thing being controlled) 2. Controller or compensator (usually a computer, a often PLC for motor drives) 3. A sensor r(t) + Section 2.2.0 Gc (s) = kd s + k p Gc (s) = k p s +ki s Gc (s) = kd s2 +k p s +ki s Lead-Lag (s+z ) (s+z ) Gc = Kc (s+p11 ) (s+p22 ) • Common Applications PI: Velocity control of motor drives, temperature control (good speed and accuracy, acceptable stability) e(t) Controller KcGc(s) = - Nc(s) Kc D (s) c u(t) Plant Gp(s) = y(t) Np(s) Dp(s) PID: Many many places, Astrom has estimated that 80% of controllers are PID (good, speed accuracy, stability) Sensor Dynamics Ny(s) Hy(s) = D (s) y ys(t) PD: Position control where high accuracy is not required (good speed and stability, so-so accuracy) Lead-Lag: Used where a pole at the origin is unacceptable, can be as good as PID (notice, 5 parameters rather than 3) Figure 16: Basic loop with a plant, compensator and sensor. • The TF is given as Try (s) = Kc Gc G p Y (s) Forward Path Gain = = R (s) 1 + Loop Gain 1 + Kc Gc G p Hy • Often, for the controls engineer the plant, G p (s), is set (e.g., the designer of a cruise-control does not get to change the engine size). • As a controls engineer, we get to pick Gc (s) and maybe influence Hy (s) (e.g., by convincing the project manager to spring $$$ for a better sensor). Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 27 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 28 EE/ME 574: Intermediate Controls Section 2.3.0 EE/ME 574: Intermediate Controls 2.3 Analyzing other loops 2.3 Analyzing other loops (continued) • As a final example, let’s consider the output arising with sensor noise d(t) Disturbance Filter Nd Gd(s) = D d r(t) Input Shaping Hr(s) + e(t) - Controller N KcGc(s) = Kc Dc c ys(t) Section 2.3.0 uc(t) + + up(t) Tvy (s) = Plant Gp(s) = y(t) Np Dp Vs(t) + Figure 17: Basic loop with a disturbance input, d (t) , and sensor noise, Vs (t) added. (39) • The example transfer functions, Eqns (37), (38) and (39) show some interesting properties. The TFs are repeated here (omitting the many (s)’s) + Sensor Dynamics Ny Hy(s) = D y Y (s) Hy (s) (−1) Kc Gc (s) G p (s) = Vs (s) 1 + Kc Gc (s) G p (s) Hy (s) Try (s) = Hr Kc Gc G p 1 + Kc Gc G p Hy , Tru (s) = Hr Kc Gc 1 + Kc Gc G p Hy Ted (s) = Gd G p Hy (−1) 1 + Kc Gc G p Hy , Tvy (s) = Hy (−1) Kc Gc G p 1 + Kc Gc G p Hy • In some cases we may want to consider additional inputs and outputs. – Many systems have a disturbance signal that acts on the plant, think of wind gusts and a helicopter autopilot. – The poles are the same for any input/output signal pair – All systems have sensor noise. • Any signal in a system can be considered an output. For example, if we want to consider the controller effort, uc (t), arising due to the reference input Uc (s) Forward Path Gain Hr (s) Kc Gc (s) Tru (s) = = = R (s) 1 + Loop Gain 1 + Kc Gc (s) G p (s) Hy (s) (Revised: Jan 16, 2013) – The stability and damping (both determined by the poles) are the same for any signal pair • The numerators are different (37) • If we wanted to consider the error arising with a disturbance, we would have Gd (s) G p (s) Hy (s) (−1) E (s) = (38) Tde (s) = D (s) 1 + Kc Gc (s) G p (s) Hy (s) Part 1: Controls Review-By-Example • The denominators are all the same Page 29 – The zeros are in general different for each input/output signal pair – Since the numerator help determine if the signal is small or large, signals may have very different amplitudes and phase angles Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 30 EE/ME 574: Intermediate Controls Section 2.3.0 • If we consider what happens as Kc → ∞, we can see what happens for very high gain. For this, assume that Hr (s) = 1.0 and Gd (s) = 1.0, since these two terms merely pre-filter inputs. When Kc → ∞ , 1 + Kc Gc G p Hy ≈ Kc Gc G p Hy , so Try (s) ≈ Kc Gc G p 1 = Kc Gc G p Hy Hy Tde (s) ≈ Gd G p Hy (−1) −Gd v = Kc Gc G p Hy Kc Gc , Tru (s) ≈ , Kc Gc 1 = Kc Gc G p Hy G p Hy Tvy (s) ≈ Hy (−1) Kc Gc G p = −1 Kc Gc G p Hy EE/ME 574: Intermediate Controls Section 3.0.0 3 Calculating steady-state errors (Franklin et al. sec. 4.2 (6th Ed.)) • Steady-state errors are computed from the transfer function r (t) → e (t), and the final value theorem: Final value theorem: For a stable system with transfer function Tre (s) = E (s) /R (s), ess = lim e (t) = lim s E (s) t→∞ (40) s→0 • Try (s) ≈ 1/Hy (s) shows that the TF of the plant can be compensated, it disappears from the closed-loop TF as Kc → ∞. In Eqn (40) E (s) (a Laplace transform) is given by Tre (s) (a transfer function) times R (s) (a Laplace transform): • Try (s) ≈ 1/Hy (s) also shows that the TF of the sensor can not be compensated. If the characteristics of Hy (s) are bad (e.g., a cheap sensor) there is nothing feedback control can do about it ! E (s) = Tre (s) R (s) (41) ess = lim e (t) = lim s Tre (s) R (s) (42) • Tde (s) ≈ −1/Kc Gc shows that disturbances can be compensated, as Kc → ∞, errors due to disturbances go to zero ;) • Tru (s) ≈ 1/G p Hy shows that U1 (s) does not go up with Kc , and also, if the plant has a small gain (G p (s) is small for some s = j ω) then a large control effort will be required for a given input. • Tvy (s) ≈ −1 shows that there is no compensation for sensor noise. If there is sensor noise, it is going to show up in the output ! ——– ∼ ——– • Summary: – Feedback control can solve problems arising with characteristics of the plant, G p (s), and disturbances, d (t). – Feedback control can not solve problems with the sensor, Hy (s), or sensor noise, vs (t) . Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 31 which gives t→∞ s→0 – To compute the final value of the error, we have to specify the input r (t). Signals typically used to compute steady-state error are seen in table 4. The step, ramp and acceleration input signals and the Laplace Transforms can be written: 1 1 R (s) = k+1 . r (t) = t k 1+ (t) , (43) k! s For k = 1, 2, 3 the signals and Laplace transforms are given in table 4. k Test input signal, r (t) Step input 0 Ramp input 1 Accelerating input 2 r (t) = 1+ (t) r (t) = t 1+ (t) r (t) = 12 t 2 1+ (t) R (s) R (s) = 1s R (s) = s12 R (s) = s13 Table 4: Typical inputs to consider for determining steady-state error. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 32 EE/ME 574: Intermediate Controls Section 3.1.0 3.1 System type and Bode standard form for the loop gain r(t) + Controller Nc(s) Dc(s) Plant Gc(s) = ys(t) y(t) Np(s) Dp(s) Gp(s) = EE/ME 574: Intermediate Controls Section 3.1.1 3.1.1 Determining steady-state error using Bode standard form • Defining the loop gain as product of gains around the loop. For the standard loop (figure 18): GL (s) = Gc (s) G p (s) Hy (s) (44) • Writing the loop gain in Bode standard form: Sensor Dynamics Ny(s) Hy(s) = D (s) y GL (s) = Gc (s) G p (s) Hy (s) = Figure 18: Standard feedback loop, with numerator and denominators called out. • Considering figure 18, the error transfer function is given as: Ter (s) = 1 1 = 1 + Kc Gc G p Hy 1 + Kc Nc Dc N p Ny D p Dy = • Using Eqn (45), a general solution for the steady-state error can be found: Dc D p Dy Dc D p Dy + Kc Nc N p Ny • The poles of the loop gain are the zeros of the error transfer function ! – Therefore, if the loop gain has a pole at the origin, the error transfer function has a zero at the origin (which means its DC gain is zero) – If Tre (s) has zeros at the origin, these cancel out R (s) in the final value theorem. 1 s terms coming from • The number of poles at the origin in the loop gain is a sufficiently basic property of feedback systems that it is given a special name: the System Type. • The system type is given as Type 0: GL (s) has no pole at the origin, no = 0 Type I: GL (s) has one pole at the origin, no = 1 Type II: GL (s) has two poles at the origin, no = 2 etc. 1 bm sm + bm−1 am−1... + b1s + 1 KBode n o s an sn + an−1 sn−1... a1 s + 1 (45) ess = lim s Tre (s) R (s) s→0 = lim s s→0 1 1 + s1no m +b m−1 ...b s+1 m−1 s 1 KBode abmssn +a n−1 +... a s+1 n n−1 s 1 R (s) But in the limit, all of the terms bm sm + bm−1sm−1 + .. + b1s and am sm + am−1sm−1 + .. + a1s drop out, giving ess = lim s s→0 = lim s (46) 1 R (s) 1 + s1no KBode sno s→0 sno + KBode R (s) (47) • Eqn (47) has a particularly simple form, and is valid for step, ramp or acceleration inputs, and any system type. where no is the number of open-loop poles at the origin. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 33 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 34 EE/ME 574: Intermediate Controls Section 3.2.0 3.2 Table of steady-state errors s→0 • Considering the closed loop example of figure 14, with sno R (s) sno + KBode Gc (s) = (48) • Inserting R (s) from Eqn (43), above, into the equation for steady-state error gives ess s+3 , s 1 , s2 + 4 s + 5 r (t) 0 1+ (t) R (s) = 1 s 1 1+KBode 0 0 Ramp 1 t 1+ (t) R (s) = ∞ 1 KBode 0 Accel 2 1 2 + 2 t 1 (t) R (s) = 1 s2 1 s3 ∞ ∞ 1 KBode 1 3 1 3s + 1 1 1 5 s 5 s2 + 45 s + 1 which shows a system type of I, and KBode = find ess (step) = 0 , k Hy (s) = 1 (50) we have the loop gain in Bode standard form: (49) where no is the system type, and k is the order of the input signal. Using Eqn (49), steady-state errors for system types 0, I and II are seen in table 5. Step G p (s) = GL (s) = Gc G p Hy = sno 1 = lim s n s→0 s o + KBode sk+1 R (s) Section 3.4.0 3.3 Steady-state error example • Eqn (47) leads to a general form for the steady-state error. Recall ess = lim s EE/ME 574: Intermediate Controls ess (ramp) = 3 5 (51) . Considering table 5, we 1 5 = , KBode 3 ess (accel) = ∞ . Type 0 System Type I System Type II System 3.4 Summary for steady-state error • The standard way to compute steady-state error is through table 5. – Table 5 shows that steady-state error depends on 1. The system type, Table 5: Connection between system type and steady-state error. 2. KBode , • Types 0 and I are the most common system types in practical systems. Type II is also seen. Type III and above is quite rare. 3. The order of the input (step, ramp or acceleration). • We often use the controller to make a Type 0 system into Type I, specifically to make the steady-state error go to zero for step inputs. – Controllers that increase the system type by one: ∗ PI ∗ PID • KBode is the product of the DC gains around the loop. By increasing the controller gain we increase KBode and reduce steady-state errors. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 35 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 36 EE/ME 574: Intermediate Controls Section 4.1.0 EE/ME 574: Intermediate Controls 4 Characteristics of the Step Response 4.2 Peak Time, t p Time between application of a step input and the first peak of the output. Undefined if the output does not have a peak, but taken to be satisfied in this case if all other speed-related requirements are met. • We’ve seen that steady-state error is a characteristic of the step (ramp) response. But SSE we usually calculate from the TF. • These performance measures are defined from the step response. Generally speaking, we can’t compute them exactly from the TF, but we’ll see approximate calculations based on the dominant mode in the next section. • Rise time tp ≃ • Settling time Step response of complex pole pair 2.5 2 2% e ss 0.5 0 | | T : 10−90% → 2 4 |← 6 8 Ts: 98% Settling Time Time [sec] (53) ss 1.5 p y90 As seen in figure 19, the step response of a linear system lies within an exponentially decaying envelop. Settling time, ts , is the time required to assure that the response does not pass again out of a narrow band around yss . Typically used: 4 time constants, e−4 = 1.83%. So The 4 time constant settling time is the time between application of a step input and the last time that the signal exits a band 1.83% wide around yss . p M y (1) | t p ts = max{abs( 1 t 0.5 r (0) → y10 ss r Rise Time y r (1) ss Output y(t) Output y(t) Overshoot 1 π ω 4.3 Settling Time, ts • Peak time • Overshoot • When we consider the step response, it is always the closed-loop step response. Step response of complex pole pair 1.5 Section 4.4.0 y (0) → 0 ss r 10 | 1 t 90 2 Time [sec] (54) where −αd is the real part dominant pole location. T : 10−90% Rise Time 0 | t y(t) − yss 4 ) > e−4 } ≃ yss αd 3 4.4 Percent Overshoot, PO Figure 19: Quantity definitions in a CL step response. Difference between peak response and yss , the steady-state response, expressed as a fraction of yss : 4.1 Rise Time, tr The 10% - 90% rise time. For the step response, it is the time between crossing 0.10 yss and 0.90 yss . 1.8 (52) tr ≃ ωn Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 37 PO = 100 × max (y(t)) − yss , yss − √πρ ≃e 1−ρ2 (55) where ρ [·] is the damping factor. If y(t) never goes above yss , PO = 0. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 38 EE/ME 574: Intermediate Controls Section 5.1.0 EE/ME 574: Intermediate Controls Section 5.1.1 5 Working with the pole-zero constellation 5.1.1 Real Pole location and response characteristics 5.1 Basics of pole-zero maps, 1st order, p1 = −α Example 1: Shifting poles to the left accelerates transient decay • Two example first-order responses are shown. • You have seen that: – Each real pole is associated with a mode of the system response. – A real pole gives the terms of Eqn (57), as seen in figure 20. C1 3 = s+α s+2 y (t) = C1 e−αt = 3 e−2t ⇐⇒ Pole−Zero Map Amplitude τ = 1/16 [sec] (56) PZ map showing two systems −α ⇐ Faster 2 h(t) = e−α t = e−t/τ = e−2 t C1 / e 1 5 0 ⇐ Faster Decay −5 −20 −15 −10 −5 0 −1 Real Axis [sec ] 5 Figure 21: A change in pole location changes the decay rate and damping. S−plane −2 −1 0 Real Axis [sec−1] 1 0 0 | τ 1 2 Time (secs) 3 Figure 20: First order pole and impulse response. • A real pole has these characteristics: – y (t) ∼ e−t/τ ’∆’ System step response 1.5 τ = 0.06 [sec] ’X’ System step response 1.5 τ = 0.25 [sec] Amplitude −2 −3 Amplitude Imaginary Axis [sec−1] ’∆’ Case: 3 1 −1 τ = 1/4 [sec] α = 16 [sec−1] Impulse response 2 0 α = 4 [sec−1] Imaginary Axis [sec−1] Y (s) = ’X’ Case: 1 0.5 1 0.5 where τ [sec] = 1/α is the time constant. – Further to the left indicates a faster response (smaller τ). 0 0 – The pole-zero constellation does not show either the KDC or the Krlg of the TF or the amplitude of the impulse response. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 39 0.5 Time (secs) 1 0 0 0.5 Time (secs) 1 Figure 22: A change in α changes the time constant. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 40 Section 5.2.0 EE/ME 574: Intermediate Controls 5.2 Basis of pole-zero maps, 2nd order, p1,2 = −α ± j ω Impulse response Pole−Zero Map – Each complex pole pair gives a mode of the system response. – A complex pole pair gives the terms of Eqn (57), as seen in figure 23. – Using the Laplace transform pair Bc s + (Bc α + Bs ω) ←→ f (t) = eαt (Bc cos (ωt) + Bs sin (ωt)) s2 + s α s + ω2n one finds 3 ω S−plane −1 Imaginary Axis [sec ] 5 • And we have seen for second order: F (s) = Section 5.2.1 2 −αt 0 Amplitude EE/ME 574: Intermediate Controls −α e ← 1 −6 −4 −2 0 Real Axis [sec−1] ← 3.40 cos(4t − 54.0o) −2 0 2 −1.5t =e 0 −1 −5 −8 −t/τ =e 2 4 Time (secs) Figure 23: Second order pole and impulse response. 5.2.1 Notation for a complex pole pair ⇐⇒ y (t) = (57) • A complex pole pair can be expressed in polar or rectangular coordinates: * P−Z Map, p1, p1 =−1.5 ± j 4 A e−αt cos (ωt + φ) = 3.4 e−1.5t cos (4t − 53.97o) (58) with si = −α ± j ω , ωn = √ α2 + ω2 , ρ: damping factor, ρ = α ωn 6 θ1 p −1 = Imaginary Axis [sec ] Y (s) b1 s + b0 2 s + 14 = s2 + 2 α s + (α2 + ω2) s2 + 3 s + 18.25 1 4 jω ωn 2 0 −α −2 −4 S−plane p* 1 −6 −3 −2 −1 0 Real Axis [sec−1] 1 2 Figure 24: Complex pole pair with ωn and φ defined. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 41 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 42 Given by Units Decay Rate Damped Nat. Freq. Natural Freq. Pole Angle Damping Factor p1 = −α + j ω p1 = −α + j ω ω2n = α2 + ω2 θ = atan2 (α, ω) ρ = α/ωn [sec−1] [rad/sec] [rad/sec] [deg] Dim’less, [·] 6 4 2 ⇐ Faster Decay 0 −2 −4 −6 −8 Polar 5.2.2 Complex pole location and response characteristics Example 1: Shifting poles to the left accelerates transient decay ω ωn ρ PO ’X’ Case: 1 [sec−1] 4 [rad/sec] 4.12 [rad/sec] 0.25 [Dim′ less] 44% ’∆’ Case: 4 [sec−1] 4 [rad/sec] 5.66 [rad/sec] 0.71 [Dim′ less] Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) 4% Page 43 −6 −4 −2 0 2 Real Axis [sec−1] 4 0.7 0.5 0.3 4 0.9 2 0 7 5 3 1 −2 −4 0.9 0.7 0.5 0.3 −6 −4 −2 0 2 −1 Real Axis [sec ] −6 −8 4 Figure 25: A change in α changes the decay rate and damping. ’∆’ System step response ’X’ System step response 1.5 Amplitude p1 = −α + j ω p1 = ωn ∠ (90 + θ) α = ρ ωn ρ = sin (θ) p ω = 1 − ρ2 ωn ρ = α / ωn p ω ωn 1 − ρ2 H (s) = H (s) = s2 + 2 ρ ωn s + ω2n (s + α)2 + ω2 Table 7: The terms of table 6 relate to rectangular or polar form for the poles. α PZ map with sgrid (indicates ρ and ωn) PZ map showing two systems 6 Table 6: Factors derived from the location of a complex pole. (Note: Franklin et al. often use σ, ωd and ζ.) Rectangular Section 5.2.2 Imaginary Axis [sec−1] α or σ ω or ωd ωn θ ρ or ζ Description EE/ME 574: Intermediate Controls ρ = 0.24 46 % Overshoot 1 0.5 0 0 1.5 Amplitude Term Section 5.2.2 Imaginary Axis [sec−1] EE/ME 574: Intermediate Controls 2 4 Time (secs) ρ = 0.71 4 % Overshoot 1 0.5 0 0 2 4 Time (secs) Figure 26: Step response: a change in α, ω is unchanged. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 44 Section 5.2.2 Example 2: Shifting poles out vertically increases oscillation frequency ’X’ Case: 4 [sec−1] ωn 4 [rad/sec] ρ 4% ’∆’ Case: 4 [sec−1] 16 [rad/sec] 16.49 [rad/sec] 0.24 [Dim′ less] 44% 0 −10 −20 20 12 −1 4 −10 0.9 −20 −30 0.5 0.3 0.9 28 −20 −10 0 10 Real Axis [sec−1] −30 1 0.5 0 0 1 Time (secs) 2 4% 16 [rad/sec] 22.63 [rad/sec] 0.71 [Dim′ less] 4% 5.66 [rad/sec] 10 0 −10 −20 0.7 0.50.3 20 0.9 10 0 28 20 12 ρ = 0.24 46 % Overshoot 0.5 0.9 −20 0.7 0.50.3 −30 −20 −10 0 10 −1 Real Axis [sec ] ’∆’ System step response 1.5 ρ = 0.71 4 % Overshoot 1 0.5 0 0 2 1 Time (secs) ρ = 0.71 4 % Overshoot 1 0.5 τ = 0.25 [sec] 1 Time (secs) 4 −10 ’X’ System step response 1 0 0 0.71 4 [rad/sec] 20 1.5 Amplitude 1.5 ρ = 0.71 4 % Overshoot PO Figure 29: A radial change in pole location changes the decay rate and oscillation frequency, but not the damping. ’∆’ System step response Amplitude Amplitude 1.5 ρ [Dim′ less] −30 −20 −10 0 10 −1 Real Axis [sec ] 0.7 0.5 0.3 −20 −10 0 10 Real Axis [sec−1] Figure 27: A change in ω changes the oscillation frequency and damping. ’X’ System step response [sec−1] ωn PZ map showing two systems PZ map with sgrid (indicates ρ and ωn) 10 0 4 ω [sec−1] ’∆’ Case: 16 Imaginary Axis [sec ] 0.7 20 Imaginary Axis [sec−1] Imaginary Axis [sec−1] 20 ⇑ Faster Oscillation ’X’ Case: PZ map with sgrid (indicates ρ and ωn) PZ map showing two systems 10 α PO 0.71 [Dim′ less] 5.66 [rad/sec] Example 3: Shifting poles out radially rescales time −1 ω Section 5.2.2 Imaginary Axis [sec ] α EE/ME 574: Intermediate Controls Amplitude EE/ME 574: Intermediate Controls τ = 0.06 [sec] 2 0 0 0.2 0.4 Time (secs) Figure 30: Maintaining ρ, time is rescaled. Figure 28: Step response: a change in ω. Note: The S-plane has units of [sec−1 ]. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 45 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 46 EE/ME 574: Intermediate Controls Section 5.2.3 5.2.3 The damping factor: ρ • The response of a higher order system is the superposition of the responses of the modes: b0 b0 = s2 + a1 s + a0 s2 + 2 ρ ωn s + ω2n a1 a1 = √ ρ= 2 ωn 2 a0 (59) (60) – 1st order modes; – 2nd order modes. • Typically (not quite always) one mode will dominate. In the example of figure 32, the slower second-order mode dominates. Step response Pole−Zero Map q P.O. = 100 e−π ρ/ 1 − ρ2 (61) 0 −5 −10 1.5 Amplitude 100 1.5 5 Amplitude • As illustrated in figure 28, above, on the range 0.0 < ρ < 1.0, the damping factor relates to percent overshoot. For a system with two poles and no zeros, the percent overshoot is given by Eqn (61) and plotted in figure 31 10 Dom. Mode → Fast second−order mode ← Step response ← Dom. mode 1 0.5 0 0 −15 −10 −5 0 −1 Real Axis [sec ] 2 Time (secs) 4 First−order mode 1.5 Amplitude • ρ is defined by Eqn (60) for either real poles: (ρ ≥ 1.0), or a complex pole pair: (0.0 < ρ < 1.0). Imaginary Axis [sec−1] giving: Section 5.3.0 5.3 Higher order systems: dominant mode • Plugging ρ = α/ωn back into the 2nd order form gives: H (s) = EE/ME 574: Intermediate Controls 1 0.5 1 0.5 90 0 0 80 Percent Overshoot 70 60 2 Time (secs) 4 0 0 2 Time (secs) 4 Figure 32: Example high-order system showing dominant mode in step response. 50 40 • Recall: the goal of studying the S-plane is to tie controller specifications to pole locations. 30 20 10 0 0 – The dominant mode dominates the response. 0.1 0.2 0.3 0.4 0.5 0.6 Damping factor [.] 0.7 0.8 0.9 1 Figure 31: Percent overshoot versus damping fact. Exact for a system with two complex poles and no zeros, and approximate for other systems. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 47 – The root-locus design method operates by placing the dominant poles in the desired region of the S-plane (Other poles can be anywhere in stable region). Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 48 EE/ME 574: Intermediate Controls Section 5.4.0 Section 5.4.0 5.3 Dominant mode (continued) • For high-order systems (n ≥ 3), design control by: • A second example is presented in figure 33. • Which mode is dominant in figure 33 ? Imaginary Axis [sec−1] 2. Fine tune controller based on actual (high order) response ⇒ Iterative process of design and analysis. Step response 10 5 0 −5 −15 −10 −5 0 −1 Real Axis [sec ] Amplitude • The dominant mode is: – Large residue. • On the S-plane this means that the dominant mode is (almost always): 1 0.5 Slow second−order mode 5 Time (secs) 10 Step response Dominant mode 5 0.5 0 0 1 0 0 −10 5.4 Which mode is the dominant mode ? – A slow mode, with a Student Exercise Pole−Zero Map 1. Use dominant mode concept and approximation for initial design; then Amplitude • As the figure 32 “Step response” plot shows, the dominant mode is only an approximation to the true step response. Amplitude Dominant mode (continued) EE/ME 574: Intermediate Controls 1 5 Time (secs) 10 Fast second−order mode 0.5 0 0 5 Time (secs) 10 Figure 33: Second example showing dominant mode in step response. – The slowest mode (other modes die out faster). • Exceptionally, one must also consider the size of the residue, the dominant mode should be: – Near to other poles; for example, s = 0 pole from step input (Graphical method: being near other poles gives a large residue). – Far from zeros (Graphical method: being far from zeros gives a large residue). Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 49 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 50 EE/ME 574: Intermediate Controls Section 5.5.0 5.5 Summary: Pole location and response characteristics EE/ME 574: Intermediate Controls Section 6.0.0 6 Design • In some sense, Design is the opposite of Analysis Faster Oscillation Better Damping Faster Decay Analysis p1 X p1* X Stable Region (LHP) Completed Controller Design Performance Specifications S-plane Unstable Region (RHP) Marginally Stable Region (the jω axis) Design Figure 34: Decay rate, oscillation freq. and damping depend upon pole location. Figure 36: Design = Analysis−1 • In Analysis, we use mathematical methods to determine performance specifications from a completed controller design (all structure and parameters specified). • In Design, we use whatever method works ! – Mathematical – Gut feeling – Trial and error – Calling a colleague with experience Figure 35: S-plane and responses. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) to determine a controller structure and parameters to meet performance goals. Page 51 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 52 EE/ME 574: Intermediate Controls Section 6.2.0 The major design methods are: • Dynamic systems are governed by differential equations • Root locus • Every input or output signal of the system has a unique Laplace transform • For linear systems, – Speed, Stability: determine by determining pole locations – Accuracy: increase the system type, check the SSE – The ratio of Laplace transforms, however, does not depend on the signals. (∗) – Speed: Bandwidth and Cross-over frequency directly from bode plot – The ratio depends only on properties of the system. We call it the transfer function. For example: – Stability: Phase margin, Gain margin directly from bode plot Guy (s) = – Accuracy: tracking accy., disturbance rejection directly from bode plot • State Space methods Section 7.0.0 7 Summary 6.1 Design methods • Frequency response EE/ME 574: Intermediate Controls (62) • Transfer function gives us many results (∗) – Design using state-space design methods, check speed, stability and accuracy from the step response 6.2 Root Locus Design – The pole locations tells us the stability and damping ratio – We can get approximate values for rise time, settling time and other performance measures • Control system analysis is the process of determining performance from a system model and controller design • Devised by Walter R. Evans, 1948 (1920 1999) – We have various tools for evaluating performance, including W.R. Evans, “Control system synthesis by root locus method,” Trans. AIEE, vol. 69, pp. 66–69, 1950. * Pole locations • Control system (Amer. Institute of Elec. Engs became IEEE in 1963) * Steady-state error * Step response * Bode plot Design =Analysis−1 it is the process of determining a controller design given a system model and performance goals. • Evans was teaching a course in controls, and a student (now anonymous) asked a question about an approximation. Part 1: Controls Review-By-Example b1 s + b0 s 2 + a1 s + a0 – The root locus method is one method for controller design. (Revised: Jan 16, 2013) Page 53 Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 54 EE/ME 574: Intermediate Controls Section 8.0.0 8 Glossary of Acronyms LT: Laplace Transform TF: Transfer Function FPG: Forward path gain LG: Loop Gain, (also Gl (s)) RHP: Right-half of the S plane (unstable region) LHP: Left-half of the S plane (stable region) SSE: Steady-state error PO: Percent Overshoot LF: Low frequency (as in “LF gain”). frequency. Frequencies below the cross-over HF: High frequency (as in “HF gain”). frequency. Frequencies above the cross-over CL: Closed loop OL: Open loop P, PD, PI, PID: Proportional-Integral-Derivative control, basic and very common controller structures. Part 1: Controls Review-By-Example (Revised: Jan 16, 2013) Page 55 EE/ME 574: Intermediate Controls EE/ME 574: Intermediate Controls New notes in section 2.4, not finished !!! 2.3.5 Frequency-Response Based Analysis . . . . . . . . . . . 36 2.4 Steps for sketching the Bode plot (New for 2014, not yet finished) 38 2.5 Examples: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Contents 1 Introduction 1.1 5 1.1.1 Complex Conjugate: . . . . . . . . . . . . . . . . . . . . 6 1.1.2 Complex Arithmetic: 7 . . . . . . . . . . . . . . . . . . . 2 Frequency Response and the Bode plot 2.1 2.5.1 Example 1: Sketch the bode plot for K G (s) . . . . . . . 39 2.5.2 Example 2: Sketch the bode plot for a system with a complex pole pair . . . . . . . . . . . . . . . . . . . . . . 42 3 Review of complex numbers and arithmetic . . . . . . . . . . . . Sketching a Bode plot by hand 10 . . . . . . . . . . . . . . . . . . 12 2.1.1 Why make a Bode plot by hand . . . . . . . . . . . . . . 12 2.1.2 Sketching individual elements . . . . . . . . . . . . . . . 13 2.1.3 Example 1, One pole no zeros . . . . . . . . . . . . . . . 14 2.1.4 Details of the break point . . . . . . . . . . . . . . . . . 15 2.1.5 Example 2, Two poles one zero . . . . . . . . . . . . . . 16 2.1.6 Example 3, A pole at the origin . . . . . . . . . . . . . . 17 2.2 The Bode plot of the loop gain . . . . . . . . . . . . . . . . . . . 19 2.3 Bode standard form for the loop gain . . . . . . . . . . . . . . . . 24 −no 2.3.1 Plotting terms of the form KBode ( j ω) A . . . . . . . . 26 2.3.2 Contrasting KBode with Krlg . . . . . . . . . . . . . . . . 27 2.3.3 Plotting terms of the form ( j ω τ + 1) (a real pole or zero) 28 2.3.4 Plotting a complex pole or zero pair . . . . . . . . . . . . 32 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 1 2.6 Steady state errors . . . . . . . . . . . . . . . . . . . . . . . . . 45 Determining KBode and SSE using the Matlab bode() command . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Summary of Frequency Response and the Bode plot . . . . . . . . 51 2.6.1 2.7 Summary of Bode plot plotting rules 3 Stability Considerations, Phase and Gain Margins 52 3.1 Marginal Stability . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.2 Definitions for phase and gain margin . . . . . . . . . . . . . . . 53 3.3 Examples, stability, marginal stability and instability . . . . . . . 54 3.3.1 A challenge with applying gain and phase margin . . . . . 58 3.3.2 Example with the pattern of figure 38(a) . . . . . . . . . . 60 Interpreting Phase and Gain Margin . . . . . . . . . . . . . . . . 62 3.4 4 Summary: Analysis by Frequency Response Part 2: Frequency Response Analysis 63 (Revised: Feb 24, 2014) Page 2 EE/ME 574: Intermediate Controls Section 1.0.0 1 Introduction EE/ME 574: Intermediate Controls Section 1.1.0 • We can determine the steady-state output sinusoid from the input and the transfer function • For a linear system a sinusoidal input produces a sinusoidal output, (after all transients have died out) • Figure 1 shows the response of the system G (s) = – Representing the input as a phasor Phasor − A Complex Number Waveform : u(t) 1 s + 10 y(t) 1 G(s)= s+10 for the input u (t) = Au cos (ωt + θu) ←→ ~U = Au ∠θu – Looking at the system u (t) = sin (10t) Output Phasor ~Y 1 = = Complex Gain = G (s) = ~U Input Phasor j ω + 10 s= j ω • Once the startup transient dies out, an input with ω = 10 gives and output with ω = 10. • For example, with u (t) = sin (10t) and G (s) = 1/ (s + 10), then y (t) is determined from: Zero−state Response of G(s) to sin(10 t) 0.2 ~Y 1 1 = √ ∠ − 45o = G (s) = ~U j 10 + 10 10 2 s= j 10 0.15 System Output 0.1 • The input as a phasor is give by 0.05 u (t) = sin (10t) = cos (10t − 90o) 0 ~U = 1.0∠−90o (withω = 10[rad/sec]) • The output phasor is given by: −0.05 −0.1 0 ←→ 1 2 3 4 5 6 Time [seconds] 7 8 9 ~Y = (Input Phasor) (Complex Gain) = (1.0∠ − 90o) 10 Figure 1: A sinusoidal input to a linear system results in a sinusoidal output. ~Y = 1 √ ∠ − 135o 10 2 ←→ y (t) = 1 √ ∠ − 45o 10 2 1 √ cos (10t − 135o) 10 2 (This is the waveform in figure 1) Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 3 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 4 EE/ME 574: Intermediate Controls Section 1.1.0 1.1 Review of complex numbers and arithmetic (See Franklin et al., Appendix B) EE/ME 574: Intermediate Controls Section 1.1.1 • Complex numbers correspond to a point on the plane Imag • Certain polynomials have no solutions which are real numbers, x2 + 1 = 0 or x2 = −1 A • Italian mathematicians of the 1500’s began considering polynomials and √ discussing solutions involving −1 <θ V a+b j Real V* • In 1637 René Descartes coins the term ’imaginary number’ to suggest that work on the subject was an illusion. Complex Plain • It turns out that imaginary numbers solve a wide range of problems in signal processing, medical image reconstruction, impedance analysis, etc. Figure 2: A complex number = A point on the complex plain. • Any complex number is made up of a real and imaginary part • A complex number (point on the complex plain) can be represented in polar or rectangular coordinates A = α+ jω real (A) = α imag (A) = ω • j (or i for mathematicians) is the complex number j2 = −1 (1) Rectangular V = Av ∠θv p a2 + b2 V = a+ jb (2) a = A cos (θv ) (3) b = A sin (θv ) (4) Av = θv = atan2 (b, a) • Higher powers of j are given from: etc. Polar • What the complex plane reveals is that the real and imaginary parts are orthogonal. j3 = j2 j = −1 j j4 = j2 j2 = −1 − 1 = 1 j5 = j2 j2 j = j 1.1.1 Complex Conjugate: The complex conjugate of a number V is written V∗ . With V = Av ∠θv = a + j b , then V∗ = Av ∠ − θv = a − j b V + V∗ gives a real number, V + V∗ = 2 a + j 0 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 5 V V∗ also gives a real number, (a + j b) (a − j b) = a2 + b2 + j (a b − a b) = a2 + b2 + j0 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 6 EE/ME 574: Intermediate Controls Section 1.1.2 1.1.2 Complex Arithmetic: EE/ME 574: Intermediate Controls Section 1.1.2 Euler’s Formula: • The operations of complex arithmetic are given as: Polar • Recall the transcendental functions: Rectangular ex = 1 + x + V = A∠θ , W = B∠φ V = a + j b , W = c + j d Addition : (none) V + W = (a + c) + j (b + d) (5) Subtraction : (none) V − W = (a − c) + j (b − d) (6) V ∗ W = A B∠θ + φ V ∗ W = (a + j b) ∗ (c + j d) (7) Multiplication : = (a c − b d) + j (ad + bc) Division : V W = A /B∠θ − φ (ac + bd) + j (bc − ad) V (8) = W c2 + d 2 x2 x3 x4 + + + ··· 2! 3! 4! cos x = 1 − x2 x4 + + ··· 2! 4! sin x = x − x3 x5 + + ··· 3! 5! • Euler’s formula gives meaning to the complex exponential. e jθ = 1 + j θ + j2 θ2 j3 θ3 j4 θ4 j5 θ5 + + + + ··· 2! 3! 4! 5! (9) Using the fact that j2 = −1 , j4 = 1, etc. • Where the equation for division in rectangular coordinates comes from writing: V V W∗ = W W W∗ and multiplying out the terms. θ2 j θ3 θ4 j θ5 − + + + ··· 2! 3! 4! 5! θ2 θ4 θ3 θ5 = 1 − + + ··· + j θ − + + ··· 2! 4! 3! 5! e jθ = 1 + j θ − e j θ = cos θ + j sin θ (10) • From Eqns (2) and (10) we find that A∠θ = A e j θ = A cos (θ) + j A sin (θ) = a + j b Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 7 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) (11) Page 8 EE/ME 574: Intermediate Controls Section 1.1.2 EE/ME 574: Intermediate Controls Section 2.0.0 2 Frequency Response and the Bode plot • If we write the phasor ~V = A∠θ (12) • Considering the steady state, a sinusoidal input gives a sinusoidal output then • The relationship between the input and output is given by the complex gain v (t) = A cos (ωt + θ) = A real e j(ωt+θ) = A real e jωt e jθ – Which is given by the transfer function evaluated at s = j ω • In general, the G (s = j ω) a function of frequency • We can imagine a complex signal ν (t) = e j(ωt+θ) as a vector on the complex plane. The real signal is the projection of the vector onto the real axis. – In polar coordinates, a complex number has a magnitude and phase – The magnitude and phase are a function of frequency Imag Real v (t) = e j (ωt+θ) = e jωt e j θ High−Pass Filter 10 50 0 40 −20dB/decade −10 −20 G(s)=3/(s+3) −30 20 0 −50 −1 10 0 1 10 10 2 10 3 10 −10 −1 10 0 1 10 2 10 10 −30 Lagging phase −60 −90 Leading phase 60 30 0 −1 0 10 10 Figure 3: Phasor rotating on the complex plane. 1 10 Frequency [radians/second] 2 10 Low Pass Filter • Rotation by an angle φ (either phase shift or by ωt) is just multiplication by e j φ . G (s) = 3 s+3 3 10 −1 10 0 10 1 10 Frequency [radians/second] 2 10 High Pass Filter G (s) = s + 10 10 Figure 4: Bode plot: First-order response characteristic. 1st order low-pass: Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 9 3 10 90 Phase [deg] 0 Phase [deg] +20dB/decade 10 −40 Complex Plain G(s)=(s+10)/10 30 Gain dB A ej(ωt+θ) Gain dB Low−Pass Filter rotation ωt 1st order high-pass: −20dB / decade roll-off +20dB / decade −90o +90o phase at high freq. phase at high freq. Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 10 3 10 EE/ME 574: Intermediate Controls • 2nd order Section 2.0.0 (13) 2.1.1 Why make a Bode plot by hand • Given a structure for Gc (s) and approximate values, computers can be pretty good at fine tuning the parameters (adaptive control) 20 0 Gain dB Gain dB • Given Gc (s) G p (s) computers are great for making the exact Bode plot 2nd order mode, ρ=0.056 20 −40dB/decade −20 −40 −60 −1 10 0 10 0 −40dB/decade −20 −40 G(s)=10/(s2 + 1.0 s + 10) 1 10 10 0 −30 Phase [deg] 0 −30 −60 −90 −120 −150 −180 G(s)=10/(s2 + 0.2 s + 10) −60 −1 10 2 0 1 10 10 2 10 0 1 10 10 Frequency [radians/second] 2nd order, moderate damping G (s) = 2 10 −90 −120 −150 −1 0 10 1 10 10 Frequency [radians/second] 2nd order, light damping 10 s2 + 1.0 s + 10 G (s) = 2 10 • The Bode plot is a tool on which Engineering judgement and intuition can be based. • Some key ideas of the bode plot are: 10 s2 + 0.2 s + 10 Figure 5: Bode plot: Second-order response characteristic. The smaller the damping, the higher the resonant peak. – The axes: ∗ Frequency axis is logarithmic ∗ Magnitude is plotted in decibels (dB) ∗ Phase is plotted in degrees – Decibels: a logarithmic scale 2nd order response: |G (s)|dB = 20 log10 (|G (s)|) −40 dB / decade roll-off ∗ Multiplying the loop gain by a factor corresponds to adding decibels −180o phase at high frequency |40|dB = 32 dB , |50|dB = 34 dB , Sharpness of the transition depends on the damping: ∗ Multiplicative factors: 2× ≃ +6 dB , Moderate to high damping: shallow peak, smooth phase transition 0.5× ≃ −6 dB , Low damping: sharp peak, abrupt phase transition Part 2: Frequency Response Analysis • Computers are no good at all at determining a good structure for Gc (s), or finding the correct ball park for parameters • An approximate sketch of the Frequency Response is a very powerful way to understand the over-all characteristics of a system. −60 −180 −1 10 Section 2.1.1 2.1 Sketching a Bode plot by hand ω2n G (s) = 2 s + 2ρ ωn s + ω2n 2nd order mode, ρ=0.28 Phase [deg] EE/ME 574: Intermediate Controls (Revised: Feb 24, 2014) Page 11 Part 2: Frequency Response Analysis |40 × 50|dB = 32 + 34 dB 10× = +20 dB , 0.1× = −20 dB , 20× ≃ +26 dB 0.05× ≃ −26 dB (Revised: Feb 24, 2014) Page 12 EE/ME 574: Intermediate Controls Section 2.1.2 • Advantage of working in dB: u(t) – Gains of blocks in series multiply, 2.1.3 Example 1, One pole no zeros G (s) = One pole no zeros y(t) 10 G1 G2 = A1 A2 ∠θ1 + θ2 = A12 ∠θ12 −10 Low−Freq Asymptote • Low Freq Asymp: −20dB/decade −20 −30 G ( j 2) ≃ −40 −50 −1 10 – But Bode plot terms in series add 0 10 1 2 10 10 ≃ 2.0 dB∠0o 20 log10 (A1 A2 ) = 20 log10 (A1) + 20 log10 (A2 ) Phase [deg] Phase : 10 0 j+8 3 10 • High Freq Asymp: (|2 j ω| >> 8) 0 Magnitude : 10 2s +8 • Break Point: ω = 4 [rad/sec] ← High−Freq Asymptote 0 Gain dB , G2 Section 2.1.3 ← G1 = A1 ∠θ1 , G2 = A2 ∠θ2 G1 EE/ME 574: Intermediate Controls θ12 = θ1 + θ2 −30 −60 G ( j ω) ≃ 10/(2 j ω) gives −90o 10 2 jω+0 −90 −1 2.1.2 Sketching individual elements 10 • Low frequency asymptote given as (14) lim G ( j ω) (15) • Poles and zeros make contributions as a function of ω – A pole adds a slope of −1 and 2 3 10 10 ≃ 10 ∠ − 90o 2ω • Break points: – Freq’s at which poles (or zeros) introduce transitions into the Bode plot. ω→∞ 90o 1 10 Frequency [radians/second] Figure 6: One pole, no zero. lim G ( j ω) ω→0 • High frequency asymptote given as 0 10 – Also, the break-point frequency is the frequency at which the real and imaginary parts of the pole (or zero) are equal. – Examples: s+5 s + 10 Break point frequency of zero: ω = 5 [rad/sec]. G p (s) = of phase lag – A pole pair adds a slope of −2 and 180o of phase lag Break point frequency of pole: ω = 10 [rad/sec]. – A zero adds a slope of +1 and 90o of phase lead G p (s) = – A zero pair adds a slope of +2 and 180o of phase lead 3s +1 0.02 ∗ s + 1 Break point frequency of zero: ω = 1/3 [rad/sec]. Break point frequency of pole: ω = 50 [rad/sec]. Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 13 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 14 EE/ME 574: Intermediate Controls Section 2.1.4 2.1.4 Details of the break point EE/ME 574: Intermediate Controls 2.1.5 Example 2, Two poles one zero Example: Break Point 10 −10 s2 + 21 s + 20 = 1 40 (s + 4) 1 4 s+1 =8 0 1 (s + 1)(s + 20) s (s + 1) 20 s+1 (16) One pole no zeros −20 30 −30 −40 −50 −1 10 0 10 1 2 10 10 3 10 • The break point is at ω = 4.0 [rad/sec] 20 0 Phase [deg] 40 s + 160 G (s) = Gain dB Gain dB 10 G (s) = 2s +8 Gain reduce by 1/sqrt(2) 0 Section 2.1.5 10 0 −10 −20 −30 −1 10 • At the break point, the real and imaginary parts are equal. −30 o Phase shift of 45 −60 0 1 10 2 10 10 3 10 0 −1 10 0 10 1 10 Frequency [radians/second] 2 10 Phase [deg] −90 3 10 Figure 7: The break point is at ω = 4.0 [rad/sec]. −30 −60 −90 −1 – The break point marks the transition from where the real term dominates to where the imaginary part dominates 0 10 • The break point is the frequency at which the real and imaginary parts of the term (pole or zero) are equal 10 1 10 Frequency [radians/second] 2 10 3 10 Figure 8: Two poles, one zero. • The two asymptotes are very simple – Low Freq Asymptote: • Consider 1 G (s) = s+1 The break point is ω = 1.0 [rad/sec] lim G ( j ω) = lim s→ j 0 s→ j 0 40 s + 160 s2 + 21 s + 20 = 160 = 18.1 dB∠0o 20 – High Freq Asymptote: G (s = 1.0 j) = 1 1 = √ ∠ − 45o jω+1 2 lim G ( j ω) = lim s→ j ∞ s→ j ∞ 40 s + 160 s2 + 21 s + 20 – Three break points: ω = 1 (down), Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 15 Part 2: Frequency Response Analysis = 40 40 40 s 40 = = = ∠ − 90o s2 s jω ω ω = 4 (up), ω = 20 (2x down) (Revised: Feb 24, 2014) Page 16 EE/ME 574: Intermediate Controls Section 2.1.6 2.1.6 Example 3, A pole at the origin G (s) = EE/ME 574: Intermediate Controls – Two break points: 1 4 s+1 1 20 s + 1 1 40 s + 160 40 (s + 4) = =8 1 s2 + 20 s s (s + 20) s ω = 4 (up), Section 2.1.6 ω = 20 (down) (17) One pole no zeros ← Mag=40 (32dB) 20 → Gain dB 40 Mag=8 (16 dB) 0 −20 −1 10 0 1 10 2 10 10 3 10 Phase [deg] 0 −30 −60 −90 −1 10 0 10 1 10 Frequency [radians/second] 2 10 3 10 Figure 9: A Type I system element. • Asymptotes, think about the points where the asymptotes hit ω = 1.0. – Low Freq Asymptote: lim G ( j ω) = lim 8 s→ j 0 s→ j 0 1 s1 1 4 s+1 1 20 s + 1 = lim 8 ω→0 1 8 = ∠ − 90o jω ω – High Freq Asymptote (same as example 2): lim G ( j ω) = lim 8 s→ j ∞ s→ j ∞ 1 s1 Part 2: Frequency Response Analysis 1 4 s+1 1 20 s + 1 1 40 40 = 40 = = ∠ − 90o s jω ω (Revised: Feb 24, 2014) Page 17 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 18 EE/ME 574: Intermediate Controls Section 2.2.0 EE/ME 574: Intermediate Controls 2.2 The Bode plot of the loop gain Section 2.2.0 H (s)=20/(s+20) G (s)=1/s y p 10 20 0 Gain dB Gain dB 0 • The Bode plot of elements in series is given by adding the plots of the individual elements −20 −40 0 + 2 10 −40 −1 10 3 10 10 Phase [deg] Phase [deg] −40 −60 −80 u(t) Kc Gc(s) 1 2 10 3 10 10 −30 −60 −90 −100 −1 10 0 10 1 10 Frequency [radians/second] G p (s) = e(t) 0 10 0 −20 Example 5, A basic loop r(t) 1 10 0 • It will turn out that we can establish the stability, disturbance rejection, noise rejection and other properties from the loop gain, without ever solving for the closed-loop poles. −20 −30 −60 −1 10 • The loop gain is open loop. −10 y(t) 2 −1 3 10 10 10 1 s 0 10 1 10 Frequency [radians/second] Hy (s) = 2 3 10 10 20 s + 20 Figure 11: Components of the loop gain, the plant and sensor. Gp(s) ys(t) • Put together the Bode plots of G p (s) and Hy (s) 2 Gc(s) Hy(s)=20/(s +20s) Hy(s) 20 0 Gain dB Figure 10: A basic control loop. With: −20 G (s) = −40 −60 −80 −100 −1 10 0 10 1 10 2 10 3 10 G p (s) = 1 s Hy (s) = 20 s + 20 Phase [deg] Kc Gc (s) = 2 (s + 5) K GL = Kc Gc G p Hy = Part 2: Frequency Response Analysis • Low Freq Asymp: G ( j ω) = 20/20 s = ω1 ∠ − 90o • High Freq Asymp: G ( j ω) = 20/s2 = ω202 ∠ − 180o −60 −90 −120 −150 −180 −1 10 The loop gain is given as: 20 20 = s2 + 20 s s (s + 20) 0 10 1 10 Frequency [radians/second] 2 10 3 10 • Break Point: ω = 20 [rad/sec] Figure 12: Components of the loop gain, combining the plant and sensor. 40 (s + 5) s (s + 20) (Revised: Feb 24, 2014) (18) Page 19 • Note that at high freq. this system has a roll-off of -40 dB per decade (slope Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 20 EE/ME 574: Intermediate Controls Section 2.2.0 EE/ME 574: Intermediate Controls of -2), and has 180o degree of phase lag. Section 2.2.0 K G (s)=2s+10 G (s) H (s)=20/(s2+20s) c c y 100 Gain dB 0 Gain dB −20 −40 −60 80 60 40 20 −80 0 1 10 10 2 10 0 −1 10 3 10 Phase [deg] −100 −1 10 Phase [deg] c 120 20 −60 −90 −120 −150 −180 0 10 1 10 2 3 10 10 90 60 Break point 30 0 −1 10 0 10 1 10 Frequency [radians/second] 2 10 −1 3 10 10 1 20 s s + 20 G p (s) Hy (s) = 0 10 1 10 Frequency [radians/second] 2 3 10 10 Kc Gc (s) = 2 (s + 5) = 2 s + 10 Figure 13: Components of the loop gain, the plant and sensor. • Some things to notice: Loop Gain Kc Gc(s) Gp(s) Hy(s) • The phase angle corresponds to the slope. 60 Gain dB 40 20 -20 dB per decade gives -90 [deg] 0 −20 −40 −1 10 0 10 1 10 2 10 3 10 Phase [deg] 0 • The zero comes at ω = 5 [rad/sec], while the sensor pole comes at ω = 20 [rad/sec] −20 – So the +90o of Gc (s) wins out for a range of ω −40 −60 −80 −100 −1 10 0 10 1 10 Frequency [radians/second] 2 10 3 10 Figure 14: Components of the loop gain, combining the plant and sensor. Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 21 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 22 EE/ME 574: Intermediate Controls Section 2.2.0 20 120 0 100 −20 80 Gain dB Gain dB • What the Bode plot would look like if the sensor pole came first (had lower frequency) than the PD compensator zero −40 −60 EE/ME 574: Intermediate Controls 2.3 Bode standard form for the loop gain • The loop gain of a linear system can be written in a standard form, called Bode form: 60 K GL (s) = KBode 40 20 −80 −100 −1 10 0 1 10 2 10 0 −1 10 3 10 10 0 10 1 10 2 3 10 10 Phase [deg] Phase [deg] = KBode −60 −90 −120 −150 Section 2.3.0 90 1 ′ G (s) sno L (τ1 s + 1) (τ2 s + 1) · · · 1 (19) sno (τa s + 1) (τb s + 1)· · · (s2/ω2n + 2 ρ s /ωn + 1) where 60 30 −180 0 −1 10 0 10 G p (s) Hy (s) = 1 10 Frequency [radians/second] 2 −1 3 10 10 10 1 20 s 2 s + 20 0 10 1 10 Frequency [radians/second] 2 3 10 10 Kc Gc (s) = 2 (0.25 s + 5) = 0.5 s+10 Figure 15: Components of the loop gain, faster compensator, slower sensor. K GL (s) is the loop gain KBode is the DC gain of the loop, after poles or zeros at the orgin are pulled out using the 1/sno term sno , no is the number of poles at the origin; no is the system type ′ • Some things to notice: Loop Gain K G (s) G (s) H (s) c c p y 40 • The Bode plots of the components look quite similar, Gain dB 20 0 −20 −40 −60 −1 10 0 10 1 10 2 10 3 10 Phase [deg] −40 −60 – The relative speed of poles and zeros matters −80 −100 0 10 1 10 Frequency [radians/second] 2 10 3 10 Figure 16: Components of the loop gain, combining the plant and sensor. Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) τ1 , τ2 , ...[seconds] are time constants of the (real) zeros τa , τb , ...[seconds] are time constants of the (real) poles ωn [radians/second] and ρ [·] are the frequency and damping of a complex pole pair • Eqn (19) is composed of three classes of terms: • Conclusion: −20 −120 −1 10 • The bode plot of the loop gain is quite different (especially the phase) GL (s) is the transfer function of poles and zeros not at the origin, ′ scaled so that the DC gain of GL (s) is 1.0. Page 23 1. KBode ( j ω)−no , a constant term and poles or zeros at the origin ±1 2. ( j ω τ + 1) , first order terms ±1 2 jω jω + 1 + 2ρ , second order terms. 3. ωn ωn • We will see how each of these terms contributes to a Bode plot. Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 24 EE/ME 574: Intermediate Controls Section 2.3.0 EE/ME 574: Intermediate Controls Section 2.3.1 2.3.1 Plotting terms of the form KBode ( j ω)−no A • Example, • This term combines the DC gain with poles or zeros at the origin. 1 20 1 20 (s + 5) =2 s s + 20 s s + 20 (20) • The magnitude curve is a straight line, with a slope of −no × 20 dB / decade • The phase curve is a flat line, at an angle of −90 no degrees • Examples of KBode ( j ω)−no : 1. Pull out any singularities, poles or zeros, at the origin so no = 1 Gain dB 1 20 (s + 5) K GL (s) = 2 , s s + 20 60 40 40 20 Gain dB K GL (s) = Kc Gc (s) G p (s) Hy (s) = 2 (s + 5) 20 0 −40 −20 no = 1 indicates there is a pole at the origin. −40 −1 10 0 10 1 2 10 −60 −1 10 3 10 10 1 b (s) 5 ∗ 20 1 = K GL (s) = KBode n s o a (s) 20 s 1 5s + 1 1 20 s + 1 1 = 5.0 s 2 10 3 10 Phase [deg] −40 −60 −100 −1 10 60 40 20 0 0 10 1 10 Frequency [radians/second] 2 −1 3 10 0 10 10 KBode ( j ω)−no = 12 s−1 , no = +1 10 1 10 Frequency [radians/second] 2 10 3 10 KBode ( j ω)−no = 0.05 s+1, no = −1 40 30 Gain dB 3. Identify the time constants 1 (τ1 s + 1) 1 = 5.0 sno (τa s + 1) s 1 5 s+1 1 20 s + 1 20 10 0 −10 −1 10 (21) 0 1 10 10 2 3 10 10 50 1 [seconds] , KBode = 5.0 and no = 1 which gives τ1 = 15 [seconds], τa = 20 Phase [deg] K GL (s) = KBode 1 10 80 −20 −80 1 5 s+1 1 20 s + 1 0 10 100 0 Phase [deg] 2. Scale the polynomical terms of GL (s) to have constant coefficients of 1.0, putting the loop gain in Bode standard form: 0 −20 0 −50 • Eqn (21) is the loop gain example (20), expressed in Bode standard form. −1 10 0 10 1 10 Frequency [radians/second] KBode ( j ω) −no 2 3 10 10 = 4 , no = 0 Figure 17: First term of the loop gain • The most common cases are: Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 25 Part 2: Frequency Response Analysis no = 0 (Type 0 system) no = 1 (Type I system) (Revised: Feb 24, 2014) Page 26 EE/ME 574: Intermediate Controls Section 2.3.2 Section 2.3.3 2.3.3 Plotting terms of the form ( j ω τ + 1) (a real pole or zero) 2.3.2 Contrasting KBode with Krlg • Given an example TF EE/ME 574: Intermediate Controls 2 s + 10 4s2 + 3 s + 8 we can write the TF in two standard forms: GL (s) = (22) • First-order terms are understood by their asymptotes and the break point 10 Gain dB 0 Bode Form: Break Point −10 −20 K GL (s) = KBode (τ1 s + 1) (τ2 s + 1) · · · 1 sno (τa s + 1) (τb s + 1)· · · (s2/ω2n + 2 ρ s /ωn + 1) −30 −1 10 (19, repeated) 0 1 10 10 1 ′ 10 1 GL (s) = KBode n GL (s) = so 8 s0 1 s+1 5 3 1 2 2 s + 8 s+1 (23) Phase [deg] 0 For example: −30 Break Point −60 −90 −1 0 10 10 Frequency [radians/second] Root Locus Form: 1 10 Figure 18: First-order asymptotes, τa = 0.5 [seconds]. Krlg (s − z1) (s − z2) · · · (s − pa) (s − pb) · · · (s2 + 2 ρ ωn s + ω2n) The first-order term is G1 (s) = where z1 = −1/τ1 , z2 = −1/τ2, pa = −1/τa, pb = −1/τb, etc. For example: ′′ GL (s) = Krlg GL (s) = 2 s+5 4 s2 + 34 s + 2 (24) • Low-frequency asymptote, | j ω τa | << 1 G1 (s) = • For making bode plots, we use Bode form and determine KBode 1 1 = τa s + 1 j ω τa + 1 1 1 1 ≈ = = 1∠0o j ω τa + 1 0 j + 1 1 (25) • For determining K from a root-locus plot we use root-locus form and determine Krlg . Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 27 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 28 EE/ME 574: Intermediate Controls Section 2.3.3 First-order term (continued) EE/ME 574: Intermediate Controls Characteristics of the first-order break point 10 10 0 Gain dB Gain dB 0 Break Point −10 −20 Break Point −10 −20 −30 −1 10 0 −30 −1 10 1 10 10 0 0 1 10 10 0 Phase [deg] Phase [deg] Section 2.3.3 −30 Break Point −60 −90 −30 Break Point −60 −90 −1 0 10 10 Frequency [radians/second] 1 −1 10 Figure 19: First-order term, τa = 0.5 [seconds]. 10 Frequency [radians/second] 1 10 Figure 20: First-order term, τa = 0.5 [seconds]. • The break point is at ωbp τa = 1, or ωbp = 1/τa • High -frequency asymptote, | j ω τa | >> 1 G1 (s) = 0 10 1 1 1 = ∠ − 90o ≈ τa s + 1 j ωτa ω τa (26) • At the break point: G1 (s) = • The high-frequency asymptote has 1 1 1 = = √ ∠ − 45o j ω τa + 1 j1+1 2 (27) • The slope of the phase curve at ω = ωbp gives the phase transition on the range ω = 0.2 ωbp ... 5 ωbp – A slope of −1 , – A phase of −90o – Intercepts ω = 1 at 20 log10 (1/τa ) (shown at triangle) (a 25 : 1 range of frequency !) • On the magnitude curve, the break point is down (or up, for a zero) √ by 1/ 2 or -3 dB Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 29 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 30 EE/ME 574: Intermediate Controls Section 2.3.3 A zero has the same characteristics as a pole, but with the opposite sense. 60 Section 2.3.4 2.3.4 Plotting a complex pole or zero pair • Second-order terms are also understood by their asymptotes and break point 40 20 0 Break Point −40 −60 Intercept 20 −20 Gain dB Gain dB EE/ME 574: Intermediate Controls Intercept 0 1 10 2 10 10 3 10 0 −20 −40 0 1 10 2 10 10 60 0 Break Point 30 0 0 1 10 2 10 10 Frequency [radians/second] 3 10 −60 −90 Break Point −120 −150 −180o degrees −180 Figure 21: First-order asymptotes, τ1 = 0.02 [seconds]. 0 1 10 The first-order term for a zero is: 2 10 Frequency [radians/second] 10 Figure 22: Second-order asymptotes, ωn = 4.0 [radians/second], ρ = 0.2 [·] . G1 (s) = (s τ1 + 1) (28) • ( j ω τ1 + 1) has a low-frequency asymptote of 1∠0o The second-order term is G (s) = • ( j ω τ1 + 1) has a high-frequency asymptote of ω τ1 ∠ + 90o 1 jω ωn 2 + 2ρ jω ωn 1 = +1 − 2 ω ωn + 2ρ j ω ωn +1 • Low-frequency asymptote, | j ω/ωn | << 1: – The high-frequency asymptote has a slope of +1 – The intercept of the high-frequency asymptote is |τ1 |dB at ω = 1.0 • The break point is at 0o degrees −30 Phase [deg] Phase [deg] 90 ωbp τ1 = 1 [·] G (s) ≈ 1 1 = = 1∠0o 0 j2 + 0 j + 1 1 (29) – The phase angle at the break point is +450 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 31 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 32 EE/ME 574: Intermediate Controls Section 2.3.4 Complex pole pair (continued) EE/ME 574: Intermediate Controls Characteristics of the second-order break point Intercept 20 Section 2.3.4 20 Break Point, 20 log10(1/2ρ) Gain dB Gain dB Break Point 0 −20 0 1 10 0 10 10 0 0o degrees −30 Phase [deg] Phase [deg] 1 2 10 −30 −60 −90 Break Point −120 −150 −180o degrees −180 0 10 Frequency [radians/second] 1 ω ωn + 2ρ j ω ωn Break Point 1 2 10 Frequency [radians/second] Figure 24: Second-order break point, detail. ωn = 4.0 [radians/second], ρ = 0.2 [·] . • High-frequency asymptote | j ω/ωn | >> 1: −90 −120 −150 10 Figure 23: Second-order asymptotes, ωn = 4.0 [radians/second], ρ = 0.2 [·] . 2 −60 −180 1 10 − −20 −40 −40 G (s) = 0 +1 ≈ − • The break point is at ωbp/ωn = 1, or ωbp = ωn ω 2 1 n ∠ − 180o 2 = ω ω (30) ωn • The high-frequency asymptote has • At the break point: G (s) = = – A slope of -2, 1 jω ωn 2 + 2ρ jω ωn = +1 1 −1 + 2ρ j + 1 1 1 = ∠ − 90o 2ρ j 2ρ – The amplitude at the break point is (this is the resonant peak) – A phase of −180o – Intercepts ω = 1 at 20 log10 ω2n (shown at triangle) Mr = 1 2ρ – The phase is −90o Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 33 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 34 EE/ME 574: Intermediate Controls Section 2.3.4 Second order break versus damping factor ρ 1. Put the TF in Bode Form rho=0.02 20 Gain dB Section 2.3.5 2.3.5 Summary of Bode plot plotting rules rho: 0.02, 0.10, 0.20, 0.40, 0.60, 0.80, 1.00, (a) Determine the number of singularities at the origin 0 rho=1.0 (b) Order the poles and zeros in order of ascending frequency −20 −40 −1 10 0 2. Select a frequency range 1 10 10 • Cover the poles and zeros of the system 0 rho=0.02 −30 Phase [deg] EE/ME 574: Intermediate Controls −60 • Consider the frequency range of the inputs and outputs of interest rho=1.0 −90 3. Determine the KBode ( j ω)−no term −120 −150 −180 −1 10 0 10 Frequency [radians/second] 4. Plot the magnitude curve 1 10 (a) Plot the low-frequency asymptote, which passes through KBode at ω = 1 . Figure 25: Second-order break point, detail. ωn = 1.0 [radians/second], ρ = {0.2 } [·] . • Low-frequency asymptote slope: −no (×20 dB / decade) – Often no = 0 or no = 1 • As damping decreases – The transition region gets narrower (b) Plot the high-frequency asymptote, which passes through Krlg at ω = 1 . – The peak gets higher (c) Complete the Magnitude Asymptotes • Go from low frequency to high frequency, putting in break points • What value of ρ corresponds to Mr = 1.0 ?\SetScrunchOne • Extend the low-frequency asymptote to the next break point • Change the slope by ±20dB / decade or ±40 dB / decade • Continue through all break points (d) Sketch the approximate magnitude curve Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 35 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 36 EE/ME 574: Intermediate Controls Section 2.3.5 EE/ME 574: Intermediate Controls Section 2.4.0 2.4 Steps for sketching the Bode plot (New for 2014, not yet 5. Plot the phase curve finished) (a) Plot the low-frequency phase, φ = −no 90o for ω τ << 1 (b) Plot the high-frequency asymptote, which occurs above the highest frequency singularity (c) As a guide, put in ±90o or ±180o steps in phase at the break points (starting with the lowest frequency break point) Steps for one method of sketching the Bode plot. 1. Put the loop gain in Bode standard form 2. Determine the Low-Frequency Asymptote (LFA), and break points. (a) Choose the range of the frequency axis, to cover the break points φ (ω) ≃ −90 (n − m) (31) 3. Sketch the Bode plot, where n is the number of poles to the left of ω, and m is the number of zeros to the left of ω . (a) Sketch the low-frequency asymptote, (b) Add construction lines for each break point: (d) Setup the width of the phase transitions • First order, transition width: 15 ωbp ... 5 ωbp • Second Order: transition width depends on damping for 2nd order (wide for heavy damping, narrow for light damping) i. Slope decrements by one, and phase decrements by 90 degrees, at each pole break point. Slope increments by one, and phase increments by 90 degrees, at each zero break point. (c) Sketch in the smooth Bode-plot curve. (e) Draw the phase curve 4. Use the High-Frequency Asymptote to validate the Bode-plot sketch. ——– ∼ ——– Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 37 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 38 EE/ME 574: Intermediate Controls Section 2.5.1 2.5 Examples: EE/ME 574: Intermediate Controls 4. Plot the magnitude curve, 2.5.1 Example 1: Sketch the bode plot for K G (s) K G (s) = (a) Put in the low-frequency asymptote 2000 (s + 0.5) s (s + 10) (s + 50) K G ( j ω) = KBode lim 2.0 (32) s→ j 0 1 ′ ( j ω 2 + 1) 1 G (s) = 2.0 sno L j ω ( j ω 0.1 + 1) ( j ω 0.02 + 1) (b) Put in the high-frequency asymptote lim 2.0 s→ j ∞ (a) Poles at origin: no = 1 (b) Poles/zeros in order of ascending ωbp : zeros: τ1 = 2.0 [seconds], (ωbp = 0.5 [rad/sec]) poles: τa = 0.1 [seconds], τb = 0.02 [seconds], ωbp = 10, 50 [rad/sec] 2. Select the frequency range ( j ω 2 + 1) ( j ω 2) 1 1 1 ≃ 2.0 = 2000 j ω ( j ω 0.1 + 1) ( j ω 0.02 + 1) j ω ( j ω 0.1) ( j ω 0.02) ( j ω)2 • Gives slope of -2, phase: −180o, and an intercept (ω = 1) of 2000 = 66 dB. (c) Put in the break points (d) Proceed from low frequency to high frequency (a) Poles and zeros: • slowest: τ1 → 1 ( j ω 2 + 1) 1 = 2.0 j ω ( j ω 0.1 + 1) ( j ω 0.02 + 1) jω • Gives a slope of -1, phase of −90o, and an intercept (ω = 1) of |2.0|dB 1. Put the TF in Bode form: • fastest: Section 2.5.1 (e) Sketch the magnitude curve (1) ωbp (b) τb → ωbp = 0.5 [radians/second] 5. Plot the phase curve = 50 [radians/second] (1) (a) Put in φ = −90o at low frequency (below 1/5 ωbp ) (b) Choose ω = [0.01 ... 1000][radians/second] 3. Determine the KBode ( j ω) −no (b) (b) Put in φ = −180o at high frequency (above 5 ωbp ) term KBode ( j ω)−no = 2.0 1 jω (c) Put in ±90o or ±180o steps , no = 1 (d) Setup the width of the phase transitions (e) Draw the phase curve Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 39 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 40 EE/ME 574: Intermediate Controls Section 2.5.2 EE/ME 574: Intermediate Controls Section 2.5.2 2.5.2 Example 2: Sketch the bode plot for a system with a complex pole pair Gain dB 50 0 K G (s) = −50 1. Put the TF in Bode Form: −100 −2 10 −1 0 10 10 1 10 2 3 10 10 0 Phase [deg] 10 s (s2 + 0.4 s + 4) K G ( j ω) = KBode 10 1 1 1 ′ G (s) = sno L 4 j ω ( j ω)2 /4 + 0.1 j ω + 1 (a) Poles at origin: no = 1 −30 (a) (b) Poles/zeros in ascending order: poles: ωn = 2 [radians/second] −60 −90 Note: standard forms for a quadratic form: −120 −150 Monic : −180 −2 −1 10 10 0 1 10 10 Frequency [radians/second] 2 3 10 10 Bode : Figure 26: Bode plotting example 1. ( j ω 2 + 1) 1 2000 (s + 0.5) = 2.0 K G (s) = s (s + 10) (s + 50) j ω ( j ω 0.1 + 1) ( j ω 0.02 + 1) • Break points: (1) ωbp = 1/τ1 = 0.5 , (a) (b) ωbp = 1/τa = 10 , ωbp = 1/τb = 50 , [rad/sec], 0 -1 Poles at : 1 s2/ω2n + 2 ρ s/ωn + 1 b1 + b0 s2 + 2 α s + (α2 + ω2 ) s1,2 = −α ± j ω 2. Select the frequency range • The only singularity is at ωn = 2 [radians/second], choose ω = [0.1..100] [radians/second] • Slopes: -1 Rectangular : b1 + b0 s2 + 2 ρ ωn + ω2n -2 • Phase angles: −90o 0o −90o −180o \SetScrunchOne Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 41 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 42 EE/ME 574: Intermediate Controls Section 2.5.2 EE/ME 574: Intermediate Controls 1 3. Determine the KBode ( j ω) no term 1 1 = 2.5 ( j ω)no jω 20 0 Gain dB KBode Section 2.5.2 no = 1 , 4. Plot the magnitude curve, −20 −40 −60 −80 −1 10 (a) Low-frequency asymptote: • Slope of −1, Phase of −90o, intercept (ω = 1) of |2.5|dB 0 10 1 10 2 10 0 lim = s→ j∞ Phase [deg] (b) High-frequency asymptote: 1 10 1 1 = 10 4 j ω ( j ω)2 /4 ( j ω)3 • Slope of −3, Phase of −270o, intercept (ω = 1) of |10.0|dB −90 −180 −270 (c) Put in the break points (ωn = 2.0) −1 0 10 1 10 10 Frequency [radians/second] (d) Sketch the magnitude curve 2 10 Figure 27: Bode plotting example 2. 5. Plot the phase curve • Break points: (a) Put in φ = −90o at low frequency (below ωn ) (a) ωn = 2.0 [rad/sec], (b) Put in φ = −270o at high frequency (above ωn ) • Slopes: (c) Put in −180o steps at the break point -1 (d) Setup the width of the phase transitions • Phase angles: (e) Draw the phase curve K G (s) = -3 −90o −270o 2000 (s + 0.5) ( j ω 2 + 1) 1 = 2.0 s (s + 10) (s + 50) j ω ( j ω 0.1 + 1) ( j ω 0.02 + 1) Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 43 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 44 EE/ME 574: Intermediate Controls Section 2.6.0 2.6 Steady state errors EE/ME 574: Intermediate Controls • If no = 0, (Type 0 system): • When the Loop Gain is in Bode Form, there is a straight-forward way to determine the steady-state error for step, ramp or constant acceleration signal. ess (step) = lim s Tre (s) R (s) = lim s s→0 ess (step) = • Starting with the basic block diagram of figure 28 d(t) r(t) + - Section 2.6.0 e(t) Kc Gc(s) u(t) + 1 1 + KBode Gp(s) ess (step) = lim s s→0 v(t) + Hy(s) ess (ramp) = lim s s→0 Figure 28: Block Diagram of a Basic Loop. ess (ramp) = • The input-error TF is given as: 1 = Tre (s) = 1 + Loop Gain 1 + KBode (τ1 s+1) (τ2 s+1) ··· 1 sno (τa s+1) (τb s+1)···(s2 /ω2n +2 ρ s /ωn +1) (33) • When we consider the SSE, we take the limit as s → 0 ess (step) = lim s s→0 s→0 ess (accel) = lim s s→0 s→0 • And in the limit, all the terms except KBode s1no go to 1/1 Part 2: Frequency Response Analysis s→0 1 1 + KBode s1no 1 s 1 1 1 1 = lim s = lim = 1 + KBode s−1 s2 s→0 s + KBode s2 s→0 s + KBode KBode 1 KBode ess (ramp) = lim s ess = lim s Tre (s) R (s) s→0 1 s 1 1 s =0 = lim s = lim 1 + KBode s−1 s s→0 s + KBode s s→0 s + KBode • If no = 2, (Type II system): 1 ess = lim s Tre (s) R (s) = lim s 1 1 1 = lim 1 + KBode s0 s s→0 1 + KBode 1 • If no = 1, (Type I system): y(t) ys(t) s→0 ess (accel) = 1 1 1 1 + KBode s−2 s2 1 1 s2 =0 = lim s 2 = lim 2 s s→0 s + KBode s s→0 s + KBode 1 1 1 s s2 = lim s = lim =0 1 + KBode s−2 s2 s→0 s2 + KBode s2 s→0 s2 + KBode 1 1 + KBode 1 s−2 s3 = lim s s→0 s2 1 s2 + KBode s3 = lim 1 s→0 s2 + KBode 1 KBode R (s) (Revised: Feb 24, 2014) Page 45 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 46 2 EE/ME 574: Intermediate Controls Section 2.6.1 • We come back to the basic SSE table Ramp >> KBode = bode(Kc*Gc*Gp*Hy, 0) KBode = 3.0000 r (t) = 1, t > 0; R (s) = 1 s 1 1+KBode 0 0 – The steady-state error is given by: r (t) = t, t > 0; R (s) = 1 s2 ∞ 1 KBode 0 ∞ ∞ >> SSEstep = 1/(1+KBode) SSEstep = 0.25 Accel r (t) = 1 2 2t ,t > 0; R (s) = 1 s3 1 KBode Table 1: Connection between system type and steady state error. • If the system is type I, the situation is a little more complex, the loop gain goes to infinity as s → 0 . Considering • In each case, the SSE is determined by KBode . • In all cases, KBode determines where the low-frequency asymptote hits ω = 1.0 . 2.6.1 Determining KBode and SSE using the Matlab bode() command • If we setup the transfer function in Matlab, we can directly determine KBode • Type 0 system: KBode is given by bode(Kc*GL, 0). Kc Gc = 800 >> Gc = tf([0.1 1], [1 0]); 0.1s + 1 s (34) Kc = 800 – We see that the loop gain is infinity for s = 0. >> KDC = bode(Kc*Gc*Gp*Hy, 0) KDC = Inf – Looking to the Bode form – For example, considering the block diagram of figure 28 with Kc Gc (s) = 3000 Section 2.6.1 – Now KBode is given by: Type 0 System Type I System Type II System Step EE/ME 574: Intermediate Controls ′ K GL (s) = Kc Gc (s) G p (s) Hy (s) = KBode s−no GL (s) 0.1s + 1 s + 0.5 1 , Gp = 2 , Hy (s) = 0.01 s + 1 s + 60 s + 500 0.01 s + 1 with no = 1. The Matlab code is set up with: >> >> >> >> Gp Hy Gc Kc = = = = tf([1 0.5], [1 60 500]) tf(1, [0.01 1]) tf([0.1 1], [.01 1]) 3000 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 47 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 48 EE/ME 574: Intermediate Controls Section 2.6.1 – If we cancel the pole at the origin, the bode() command will give KBode . EE/ME 574: Intermediate Controls • If the system is type II, then the Bode form is: >> KBode = bode( tf([1 0], 1), Kc*Gc*Gp*Hy, eps) KBode = 0.8 K GL (s) = KBode Note that the bode() command is evaluating = s 800 s Kc Gc s=ε 0.1s + 1 s + 0.5 1 s s2 + 60 s + 500 0.01 s + 1 1 ′ G (s) s2 L – We can determine KBode by canceling two poles at the origin. For example, considering (35) Kc Gc (s) = 800 where the s in the numerator cancels the s in the denominator. The bode() command does not make the cancelation, so we evaluate with ω = ε. – For the Type I system 0.1s + 3 s + 0.5 1 , Hy (s) = , Gp = s 0.01 s + 1 s (s2 + 60 s + 500) – The system is now type II, so we cancel two poles at the origin in the bode() command >> KBode = bode(tf([1 0 0 ], 1) * Kc*Gc*Gp*Hy, eps) KBode = 2.4000 >> SSEaccel = 1/KBode SSEaccel = 0.4167 >> SSEramp = 1/KBode SSEramp = 1.2500 Part 2: Frequency Response Analysis Section 2.6.1 (Revised: Feb 24, 2014) Page 49 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 50 EE/ME 574: Intermediate Controls Section 2.7.0 • The loop gain is the product of transfer functions of blocks around the loop • The Bode form is a standard way to algebraically arrange the loop gain into the form 1 ′ (36) K GL (s) = KBode n GL (s) so where no determines the system type. • We have seen how to sketch the bode plot based on the break points of the zeros and poles – First order terms introduce a +1 or -1 slope and ±90o of phase shift – Second order terms introduce a +2 or -2 slope, and of phase shift • Two measures of stability that are useful for analysis and design are: – Phase Margin – Gain Margin • These stability measures can be read directly from the Bode plot, and also engineered to desired values by shaping the frequency response curve. • Engineering the phase and gain margins to desired values is a topic of controller design, the subject of the next Part. • Here we look at the determination of phase and gain margin from a Bode plot, and determination of stability. • Consider a general closed-loop TF for a block diagram like figure 29(a). • Computers can accurately draw a Bode plot graph – The importance of sketching lies in the understanding of how changes to the controller design effect system response. • In the next section we will see how system stability and transient characteristics can be determined from the Bode plot. • Hendrik Wade Bode, born 1905 in Madison, Wisconsin, died 1982. H. Bode made several including – Bode plots, 1938 Try ( j ω) = Forward Path Gain 1 + K GL ( j ω) (37) • Figure 29(b) presents a simplified loop, which will have the same stability as that of figure 29(a). r(t) + e(t) u(t) Kc Gc(s) y(t) r(t) + Gp(s) - e(t) ys(t) K GL(s) ys(t) Hy(s) – 1944, became director of the Mathematical Research Group at Bell Laboratories – In 1948, President Harry S. Truman awarded Bode the President’s Certificate of Merit, in recognition of his remarkable scientific contributions Part 2: Frequency Response Analysis Section 3.0.0 3 Stability Considerations, Phase and Gain Margins 2.7 Summary of Frequency Response and the Bode plot ±180o EE/ME 574: Intermediate Controls (Revised: Feb 24, 2014) Page 51 (a) Control loop (b) Simplified control loop with loop gain Figure 29: Control loop with compensator, plant and sensor. • Using the phase and gain margins (and one additional test), we can determine the stability of control loop such as figure 29 (a) or (b). Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 52 EE/ME 574: Intermediate Controls Section 3.2.0 3.1 Marginal Stability EE/ME 574: Intermediate Controls Section 3.3.0 3.3 Examples, stability, marginal stability and instability • A system is marginally stable when poles lie on the s = j ω axis. • Consider the example system of figure 30, with GL (s) as given. • Considering Eqn (37), marginal stability occurs when one or more values of ω give: (38) 1 + K GL ( j ω) = 0 r(t) + - e(t) u(t) K ys(t) GL (s) = GL(s) s+4 (42) s (s2 + 3 s + 2) • The marginal stability condition, Eqn (38) can be re-written: K GL ( j ω) = 1.0∠ − 180o Figure 30: Control loop with controller gain Kc and loop gain GL . (39) Step Response Step Response Amplitude |K GL ( j ω)| = 1.0 (0 dB) ∠K GL ( j ω) = −180o (±n 360o) Amplitude 1.5 1 0 0 5 Time (sec) 10 (a) K = 0.25 3.2 Definitions for phase and gain margin 1.5 50 1 Cases: (a) K = 0.25 : stable (b) K = 6.00 : marginally stable (c) K = 144 : unstable 0 0.5 −50 0 −100 0 5 Time (sec) 10 (b) K = 6.00 0 5 Time (sec) 10 (c) K = 144 Figure 31: Step response of system for three values of K. • Cross-over frequency, ωc : Frequency (-ies) at which the magnitude curve crosses the 0 dB line. • Phase cross-over frequency, ωcp : Frequency (-ies) at which the phase curve crosses over the −180o line • Phase Margin [degrees]: Degree by which the phase curve misses −180o at ω = ωc PM = φ (ωc ) − (−180o) = φ (ωc ) + 180o (40) • Gain Margin [dB]: Degree by which the magnitude curve misses 0 dB at ω = ωcp GM = −20 log10 (K GL ( j ωcp )) dB (41) (Revised: Feb 24, 2014) 100 0.5 • If a value of ω exists satisfying Eqn (39), the system is marginally stable. Part 2: Frequency Response Analysis Step Response 2 Amplitude Which gives: Page 53 • Depending on the value of K, the system can be stable, marginally stable or unstable. • Clearly it is very desirable to know the critical value of K , K = Kcrit , at which the system transitions from stability to instability. • Knowing that K GL (s) = 1∠ − 180o when K = Kcrit is the basis for determining stability from the Bode plot. • The gain margin and phase margin are simply the distance (in gain and phase) by which the K GL (s) curve misses the critical point. Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 54 EE/ME 574: Intermediate Controls Section 3.3.0 • Looking at the Bode plot for the example, with K = 0.25 (stable). Critical Point, |G|=0dB ω =2.83 [r/s] c Gm = 27.6 dB (at 2.83 rad/sec) , Pm = 59.6 deg (at 0.448 rad/sec) %% Build the model, GL (s) >> GL = tf([1 4], [1 3 2 0]) −50 −100 −1 10 0 1 10 10 %% Plot the margins >> margin(0.25*GL) 2 10 50 Magnitude (dB) Mag K G_{L1} Section 3.3.0 • Matlab’s margin() command draws the bode plot and marks the gain and phase margins. Bode Diagram 50 0 EE/ME 574: Intermediate Controls 0 −50 0 −90 −120 Critical Point, <G=−180, ω =0.45 [rad/sec] −150 cp −180 −1 10 0 1 10 10 Frequency [radians/second] 2 10 −100 −90 −135 −180 −225 −2 10 Figure 32: Bode plot of GL (s), corresponding to K = 1.0 . −1 10 0 1 10 Frequency (rad/sec) 2 10 10 Figure 33: Output of the margin command, showing gain and phase margins. • Figure 32 shows two special values of ω, ωc : Cross-over frequency, where the magnitude |GL ( j ωc )| = 1.0 . ωcp : Phase cross-over frequency, where ∠GL ( j ωcp ) = −180o • With K = 0.25, ωc < ωcp , and K GL (s) does not hit the critical value of K GL (s) = 1∠ − 180o. • Evaluating K GL (s) at the cross-over and phase cross-over frequencies: • Now consider all three levels of gain. magnitude curve, as seen in figure 34. Increasing K moves only the 100 Changed: ωc and gain and phase margins Kc= 0.25 Kc= 6.00 50 Mag K GL1 Phase [deg] −60 Phase (deg) Results: ωc = 0.448 [rad/sec] ωcp = 2.83 [rad/sec] PM = 59.6 deg GM = 27.6 dB −30 Kc=144.00 0 wc −50 Unchanged: ωcp (where the gain margin is measured) −100 −1 10 0 1 10 2 10 10 0 K GL (s = j ωc ) = 1.0∠ − 120.4o Phase [deg] −30 K GL (s = j ωcp ) = 0.0417∠ − 180o −60 −90 −120 −150 – At ωc , the phase lag is not sufficient for marginal stability. −1 10 – At ωcp , the gain is not sufficient for marginal stability. (Revised: Feb 24, 2014) 0 1 2 10 10 Frequency [radians/second] 10 Figure 34: Bode plot for three levels of gain. −→ This system is not marginally stable. Part 2: Frequency Response Analysis wcp −180 Page 55 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 56 EE/ME 574: Intermediate Controls Section 3.3.0 EE/ME 574: Intermediate Controls Section 3.3.1 3.3.1 A challenge with applying gain and phase margin Bode Diagram Gm = 0.000207 dB (at 2.83 rad/sec) , Pm = 0.000681 deg (at 2.83 rad/sec) 100 Results: ωc = 2.83 [rad/sec] ωcp = 2.83 [rad/sec] PM = 0 deg GM = 0 dB Magnitude (dB) System is marginally stable. • The GM and PM critera give us an exact definition of marginal stability, but do not indicate whether the system is stable for increasing or decreasing gain. 50 0 −50 • Define the level of gain that sets cross-over where φ = −180o (or, equivalently choose K to give ωc = ωcp , and GM=0 dB, PM=0o ) −100 −90 Phase (deg) %% Plot the margins >> margin(6.00*GL) – This critical value of K can be called Kcrit −135 • Most control loops are low pass filters, with Bode plots that look similar to figures 32-36, above. −180 −225 −2 10 −1 10 0 10 Frequency (rad/sec) 1 10 2 10 – But not all. Figure 35: Output of the margin command, K = 6.00 • For typical systems, the system is stable when K < Kcrit , giving the pattern of figure 37. Bode Diagram Gm = −27.6 dB (at 2.83 rad/sec) , Pm = −4.15 deg (at 12.2 rad/sec) 100 Results: ωc = 12.2 [rad/sec] ωcp = 2.83 [rad/sec] PM = -4.15 deg GM = -27.6 dB Magnitude (dB) System is unstable. stable unstable 50 K=0 0 −135 K increasing • In cases with the pattern of figure 37, the system is stable when ∠K GL ( j ωc ) > −180o and K GL ( j ωcp ) < 0 dB . −180 −225 −2 10 Kcrit Figure 37: Stability and instability versus K. Marginal stability when K = Kcrit −50 −90 Phase (deg) %% Plot the margins >> margin(144*GL) −1 10 0 10 Frequency (rad/sec) 1 10 2 10 – Giving the standard definitions of phase and gain margin: GM = − K GL ( j ωcp )dB Figure 36: Output of the margin command, K = 144. PM = 180 + φ (ωc ) Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 57 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 58 EE/ME 574: Intermediate Controls Section 3.3.1 • However, other patterns are possible, as seen in figure 38. unstable EE/ME 574: Intermediate Controls Section 3.3.2 3.3.2 Example with the pattern of figure 38(a) • Consider a system described by: stable GL (s) = K=0 Kcrit (a) K increasing Step Response Step Response 50 Kcrit1 (43) Step Response 1.5 1.5 Kcrit2 K increasing 0 Amplitude unstable Amplitude K=0 (b) stable Amplitude unstable s2 + 8 s + 16 s3 1 0.5 Figure 38: Stability and instability versus K, alternative possible patterns. −50 0 5 Time (sec) 10 (a) K = 1.00 • When using the Bode stability criterion, we need to check that the resulting closed-loop system is stable. We can check stability by examining: 0 Cases: (a) K = 1.00 : unstable (b) K = 10.0 : stable (c) K = 100 : stable 1 0.5 0 1 Time (sec) 2 (b) K = 10.0 0 0 0.2 0.4 Time (sec) (c) K = 100 Figure 39: Step response of system for three values of K. Bode Diagram Gm = 6.02 dB (at 4 rad/sec) , Pm = −18.1 deg (at 2.9 rad/sec) 2. The step response %% Plot the margins >> margin(1.00*GL) 3. A root-locus plot • When the regions of stability follow an atypical pattern, the Nyquist stability criterion can be used. Results: ωc = 2.90 [rad/sec] ωcp = 4.00 [rad/sec] PM = -18.1 deg GM = 6.02 dB 100 Magnitude (dB) %% Build the model, GL (s) >> GL = tf([1 8 16], [1 0 0 0]) 50 0 −50 −90 Phase (deg) 1. The closed-loop poles −180 −270 −1 10 0 1 10 2 10 10 Frequency (rad/sec) Figure 40: Output of the margin command, showing gain and phase margins, system of Eqn (43). Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 59 Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 60 Section 3.3.2 EE/ME 574: Intermediate Controls Section 3.4.0 3.4 Interpreting Phase and Gain Margin 3.3.2 Example with the pattern of figure 38(a) (continued) • The example above shows a case where the phase and gain margins are difficult to interpret. • For typical systems, a positive PM and GM indicate a stable system. • For example, for the TF given we find the bode plot and margins of fig. 41. Bode Diagram Gm = −4.27 dB (at 1.43 rad/sec) , Pm = −8.28 deg (at 1.64 rad/sec) • Cases where the open-loop system is unstable (right-half-plane poles) or non-minimum phase (right-half-plane zeros) often give rise to complex frequency response patterns. • The Nyquist stability criterion (Franklin et al., section 6.3) is a frequency domain tool capable of handling with complex Bode plots. 20 10 GL (s) = s+3 s3 + 1.4 s2 + 1.44 s + 1.04 Magnitude (dB) EE/ME 574: Intermediate Controls 0 −10 −20 −30 −40 0 • We will not be studying the Nyquist stability criterion in detail. Phase (deg) −45 – It is complex – With modern computer tools such as Matlab, stability questions can be answered other ways, the Nyquist stability criterion is seldom used. – The Nyquist stability criterion is important for robust control, such as H∞ control. Students who take an advanced course in robust control will encounter the Nyquist stability criterion. • Bode phase and gain margin remain valuable tools −90 −135 −180 −225 −1 10 0 1 10 Frequency (rad/sec) 10 Figure 41: Bode plot and margins for GL (s). • Interpretations that can be made from the Bode plot and margins are: – The overall shape of the magnitude and phase curves indicate the qualitative properties of the system. – They apply in a straight forward way to most systems – The gain margin indicates change in gain required before the system becomes stable/unstable (an aspect of robustness). – Phase and gain margin give insight into how to engineer controllers to achieve performance goals – The phase margin indicates – Bode stability results should be validated by an alternative method: 1. Determine the poles 2. Examine the step response of the final system, or as a function of K , as illustrated in figures 31 and 39 3. Examine the root locus Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 61 ∗ The damping, we’ll see how to determine the approximate overshoot from from the PM ∗ The amount of additional phase lag the control loop can tolerate before becoming unstable (an aspect of robustness). – In the next part, we will learn a number of additional control system performance measures that can be determined from the Bode plot. Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 62 EE/ME 574: Intermediate Controls Section 4.0.0 4 Summary: Analysis by Frequency Response • For linear systems, a sinusoid input gives an sinusoid output. – The transfer function can be interpreted as a complex-valued gain: ~Y = T (s = j ω) U ~ ~ is the input phasor and T (s = j ω). where ~Y is the output phasor, U • By evaluating the transfer function as a function of ω, we can make the Bode plot. • The Bode plot can also be sketched by hand, by putting together the break points for each pole and zero. • The bode plot indicates overall characteristics of the system, as well as specific features that indicate the stability of the system. – Cross-over frequency, ωc – Phase cross-over frequency, ωcp – Phase margin, PM – Gain margin, GM • Since the standard interpretation of PM and GM does not apply to all systems, we need to validate results by checking the poles, step response or root locus of the system. • Bode analysis is a valuable tool, used in conjunction with analysis of the poles, root locus and other tools. Part 2: Frequency Response Analysis (Revised: Feb 24, 2014) Page 63 EE/ME 574: Intermediate Controls EE/ME 574: Intermediate Controls Designing Control by Frequency-Response 2.2.2 2.2.3 Contents 2.3 1 Performance measures 1.1 1.2 1.3 1.4 1.5 3 Phase-lead design example . . . . . . . . . . . . . . . . . 37 PI compensator . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Basics of PI design . . . . . . . . . . . . . . . . . . . . . 42 Phase-Lag compensator . . . . . . . . . . . . . . . . . . . . . . . 43 2.3.1 4 1.1.1 Bandwidth (ωb) . . . . . . . . . . . . . . . . . . . . . . 5 2.4.1 Basics of phase-lag design . . . . . . . . . . . . . . . . . 45 1.1.2 Cross-over frequency (ωc ) . . . . . . . . . . . . . . . . . 7 2.4.2 Stability related performance measures . . . . . . . . . . . . . . . 8 Phase-lag compensation design procedure (see Franklin, section 6.7.4) . . . . . . . . . . . . . . . . . . . . . . . . 46 1.2.1 Gain Margin, GM and Phase Margin, PM . . . . . . . . . 8 Phase-lag design example #1 . . . . . . . . . . . . . . . 47 Accuracy related performance measures . . . . . . . . . . . . . . 11 PID compensation . . . . . . . . . . . . . . . . . . . . . . . . . . 59 1.3.1 Steady State Error . . . . . . . . . . . . . . . . . . . . . 11 2.5.1 Basics of PID design . . . . . . . . . . . . . . . . . . . . 60 1.3.2 Disturbance rejection, magnitude Edist at frequency ωd . . 12 2.5.2 Design procedure . . . . . . . . . . . . . . . . . . . . . . 60 1.3.3 Tracking Error, Etrack at frequency ωt . . . . . . . . . . . 17 2.5.3 1.3.4 Noise Rejection, Ngain at frequency ωs . . . . . . . . . . . 20 Ziegler-Nichols Method 1: Quarter-Cycle Damping Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Connection between ωc , ωb and tr . . . . . . . . . . . . . . . . . 22 2.5.4 Ziegler-Nichols Method 2: Ultimate Sensitivity Method . 64 1.4.1 23 2.5.5 Tyreus-Luyben Tuning Chart (“TLC” tuning rules) . . . . 67 2.5.6 PID design by frequency response . . . . . . . . . . . . . 68 2.5.7 Realizable form for PD and PID controllers . . . . . . . . 71 Lead-Lag compensation . . . . . . . . . . . . . . . . . . . . . . 73 2.6.1 74 Table of approximate dominant-mode relationships . . . . Summary of performance measures and interpretation on the Bode plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4 2.4.3 2.5 24 2.6 PD compensator 30 . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Basics of PD design . . . . . . . . . . . . . . . . . . . . 31 Phase-lead compensator . . . . . . . . . . . . . . . . . . . . . . 32 2.2.1 33 2.1.1 2.2 35 Speed related performance measures . . . . . . . . . . . . . . . . 2 Design of frequency compensation 2.1 Phase-lead compensation design procedure (Franklin, section 6.7.2) . . . . . . . . . . . . . . . . . . . . . . . . Basics of phase-lead design . . . . . . . . . . . . . . . . Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 1 Basics of Lead-Lag compensation . . . . . . . . . . . . . 3 Summary of frequency-response based compensator design Part 3: Frequency Response Design 75 (Revised: Mar 26, 2013) Page 2 EE/ME 574: Intermediate Controls Section 1.0.0 1 Performance measures • Several performance measures are best understood based on the frequency response. • The complete list of performance measures of interest is repeated in table 1. • The items based on frequency analysis are highlighted, and will be defined with the aid of examples. From table 1, there are seven performance measures typically evaluated from the bode plot. We will look at the seven using an example. • The example system is our basic control loop, including a reference input, disturbance and sensor noise. disturbance r(t) Symbol Domain Evaluated From Rise Time tr Time Step Response or Dominant Mode Peak Time tp Time Step Response or Dominant Mode Settling Time ts Time Step Response or Dominant Mode Pole Locations pi Freq Transfer Function, S-plane Bandwidth ωb Freq Closed-loop Freq. Resp. Cross-over Frequency ωc Freq Frequency Response TF Transfer Function Overshoot Mp Time Step Response or Dominant Mode Damping Factor ρ Freq Dominant Mode Pole Locations pi Freq Transfer Function, S-plane Phase Margin PM Freq Frequency Response Gain Margin GM Freq Frequency Response + e(t) Controller u1(t) KcGc(s) - Speed: + d(t) + Plant u2(t) y(t) Gp(s) + Sensor Dynamics ys(t) Hy(s) sensor noise vs(t) + Figure 1: Basic control loop. • The example transfer function is: Degree of Stability: Stable / Unstable Section 1.1.0 1.1 Speed related performance measures • Frequency response gives us a distinct way to understand system behavior Performance Measure EE/ME 574: Intermediate Controls G p1 (s) in Bode form: Accuracy: Steady State Error SSE Time Step/Ramp Response or Trans. Fun. Integrated Squared Error ISE Time Step Response Integrated Absolute Error IAE Time Step Response Disturbance Rejection Edist , ωd Freq Freq Resp, or closed-loop Freq Resp Tracking Error Etrack , ωt Freq Freq Resp, or closed-loop Freq Resp Noise Rejection Ngain , ωs Freq Freq Resp, or closed-loop Freq Resp s + 10 s + 10 = s (s2 + 5 s + 4) s (s + 1) (s + 4) 1 10 −1 10 s + 1 s G p1 (s) = 4 (s + 1) 14 s + 1 • For our examples will use Hy (s) = 1.0 (1) (2) (3) which is included for completeness. Table 1: A list of standard performance measures and how they are evaluated. Highlighted performance measures are based on frequency analysis. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 3 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 4 EE/ME 574: Intermediate Controls Section 1.1.1 EE/ME 574: Intermediate Controls • The Bode plot of G p1 (s) is seen in figure 2. Section 1.1.2 – Example of bandwidth, taking Kc Gc (s) = 1.0 20 40 0 Gain dB Gain dB 20 0 −20 −40 −40 −60 −60 −80 −1 10 −80 −1 10 0 1 10 Try (s) = Determines Bandwidth −20 0 10 ωb 1 10 2 10 2 10 10 −30 −30 −60 Phase [deg] Phase [deg] 0 0 −60 −90 −150 −150 −180 −1 −180 10 −1 0 10 1 2 10 10 Frequency [radians/second] 10 >> Gp = tf([1 10], [1 5 4]); >> Gc = tf(1, 1); Hy = tf(1,1) >> Try = ... feedback(Gc*Gp*Hy, 1); >> bode(Try); >> Wb = bandwidth(Try); ωb = 2.12 [rad/sec] −90 −120 −120 Kc Gc G p 1 + Kc Gc G p Hy (5) 0 1 10 10 Frequency [radians/second] 2 10 Figure 3: Frequency-response plot of Try (s) (closed loop). Figure 2: Bode plot of G p1 (s) (open loop). – Notice the difference between the frequency-response plot of figures 2 and 3. 1.1.1 Bandwidth (ωb ) • The first performance measure is actually measured from the closed-loop frequency-response plot. 1. At low frequency, the loop gain, G p1 (s), is large with ∠ − 90o , but the closed-loop TF, Try (s), is about 1.0 with ∠0o 2. At high frequencies the two curves are very comparable ωb is the lowest frequency at which the magnitude of the closed-loop transfer function equals ( √1 ) Try (s = j 0), where Try (s = j 0) is the 2 DC gain of the closed-loop system . Try ( j ωb ) = 1 √ 2 Try (0) (4) Equivalently: the bandwidth is the frequency at which the magnitude of the closed-loop frequency-response plot as dropped of by 3 dB. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 5 – These two statements reveal basic facts about feedback control: ∗ Within the bandwidth of the closed-loop system, feedback gives the system very nice behavior (Try (s) ≃ 1.0∠0o) ∗ Outside the bandwidth, feedback does not significantly change the response • Bandwidth, ωb , is commonly used to specify the speed of a system. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 6 EE/ME 574: Intermediate Controls Section 1.1.2 EE/ME 574: Intermediate Controls Section 1.2.1 1.1.2 Cross-over frequency (ωc ) 1.2 Stability related performance measures We have already seen cross-over frequency when considering the phase margin. 1.2.1 Gain Margin, GM and Phase Margin, PM • ωc is the frequency at which the Bode magnitude curve first crosses 0 dB. We have already seen phase and gain margin. These are determined on the Bode plot, which is to say the frequency-response plot of the loop gain (open loop). – If the magnitude curve crosses 0 dB several times, ∗ For phase margin, they must all be considered Gain dB 20 ωc 0 −40 20 −60 −80 −1 10 0 Cross−over ωc = 1.39 [rad/sec] Gain Margin 12.0 dB −20 40 0 1 10 10 2 10 −20 −40 0 ωc = 1.39 [rad/sec] −60 −80 −1 10 0 10 1 10 2 10 0 −30 −60 ωcp = 2.83 [rad/sec] −90 −120 Phase Margin 24.4 deg −150 −30 Phase [deg] 40 Phase [deg] Gain dB ∗ For performance specification, the lowest frequency of crossing is taken as ωc ω −180 −60 −1 10 −90 cp 0 1 10 10 Frequency [radians/second] 2 10 −120 Figure 5: Bode plot of G p1 (s) (open loop). −150 −180 −1 10 0 1 10 10 Frequency [radians/second] 2 10 Note: Generally (but not always) ωc < ωcp for a stable system. Figure 4: Bode plot of G p1 (s) (open loop). Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 7 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 8 EE/ME 574: Intermediate Controls Section 1.2.1 • The phase margin is also connected to closed-loop damping. Consider the 2nd order system (see Franklin 5th ed. Eqn (6.31) and figures 6.34-6.36) ω2n s (s + 2 ρ ωn) ω2n 2 s + 2 ρ ωn s + ω2n 2ρ 1 + 4 ρ4 − 2ρ (8) • By evaluating the derivative of Eqn (8) an the approximate relation between PM and damping is seen to be: PM (9) ρ≈ 100 1 0.9 (10) where 100 × M p is the percent overshoot. (7) For this particular case, the phase margin can be solved explicitly and comes out to be: PM = tan−1 qp Mp = e 100 90 p Try (s) = − √ πρ (1−ρ2 ) (6) • When we set up G p2 (s) with the feedback Hy (s) = 1.0, Kc Gc (s) = 1.0 , we get the closed-loop transfer function Section 1.2.1 • Another view that shows the relationship between phase margin and damping is given by evaluating Percent Overshoot, 100*M G p2 (s) = EE/ME 574: Intermediate Controls 80 70 60 50 40 30 20 10 0 0 10 20 30 40 50 60 Phase Margin [deg] 70 80 90 Figure 7: Phase margin vs percent overshoot, for a system with 2 poles and no zeros. ρ vs PM Approximation 0.8 • Note that Eqns (8) - (10) and figures 6 and 7 are all based on the 2-pole no-zero system. Damping ratio, ρ 0.7 0.6 0.5 • These approximations show that damping and overshoot are strongly linked to phase margin 0.4 0.3 0.2 – PM and damping factor are both approximate indicators of overshoot, 0.1 0 0 10 20 30 40 50 Phase Margin [deg] 60 70 – We must check the actual step response to assure that an overshoot specification is met. 80 Figure 6: Damping ratio vs. phase margin, for a system with 2 poles and no zeros. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 9 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 10 EE/ME 574: Intermediate Controls Section 1.3.1 EE/ME 574: Intermediate Controls Section 1.3.2 1.3 Accuracy related performance measures 1.3.2 Disturbance rejection, magnitude Edist at frequency ωd 1.3.1 Steady State Error Many closed-loop systems operate with disturbances. For these systems, it is often necessary to specify the maximum influence the disturbance can have on the output. Defining the disturbance transfer function as The steady state error is determined by the system type and KBode . We can read both directly off the Bode plot, as illustrated in fig 8. • We see a slope of -1 in low-frequency range, so the system is type I • The DC gain is 8.0 dB (2.5) Therefore, the steady state error is: (11) The magnitude of the disturbance transfer function Tdy (s) will not be greater than Edist at any frequency at or below ωd . Or, mathematically SSE (step) = 0 1 = 0.4 2.5 SSE(ramp) = G p (s) Y (s) = D (s) 1 + Kc Gc (s) GP (s) Hy (s) A disturbance rejection specification of Edist at frequency ωd specifies: – KBode is where the low freq. asymptote hits ω = 1.0 [rad/sec] Tdy ( j ω) ≤ Edist ∀ ω ≤ ωd (12) For example, if we combine PID control with G p1 (s), 40 20 Gain dB Tdy (s) = DC Gain Low−fre q asym 0 Kc Gc (s) = ptote kd s2 + k p s + kI s2 + 2.4 s + 2.44 = 1.5 s s (13) −20 −40 −1 10 0 The transfer function is given as 1 10 10 0 Try (s) = Phase [deg] −30 −60 Kc Gc G p 1.5 s3 + 18.6 s2 + 39.66 s + 36.6 = 1 + Kc Gc GP Hy s4 + 6.5 s3 + 22.6 s2 + 39.66 s + 36.6 −90 And the disturbance transfer function is given as: −120 −150 −180 −1 10 0 10 Frequency [radians/second] 1 Tdy (s) = 10 Gp s2 + 10 s = 4 3 1 + Kc Gc GP Hy s + 6.5 s + 22.6 s2 + 39.66 s + 36.6 (14) Figure 8: Bode plot of G p1 (s) , showing low-frequency asymptote and DC gain. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 11 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 12 EE/ME 574: Intermediate Controls Section 1.3.2 1.3.2 Disturbance rejection, magnitude Edist at frequency ωd (continued) EE/ME 574: Intermediate Controls • Figure 10 shows that the system also meets a specification of • For example, Tdy (s) is plotted in figure 9. The frequency-response plot shows that the closed-loop system meets a requirement of: Edist = −20 dB , Section 1.3.2 Edist = −25 dB , ωd = 0.2 [rad/sec] – Note that only the magnitude curve is needed to evaluate disturbance response. ωd = 0.3 [rad/sec] >> Tdy = feedback(Gp, -Hy*Kc*Gc) >> bode(Tdy) 0 Gain dB −20 0 Dist. Rej. Gain dB −20 −40 −60 −80 −1 10 −40 0 1 10 10 Frequency [radians/second] 2 10 −60 −80 −1 10 Figure 10: Disturbance transfer function, Tdy (s) 0 10 1 10 2 10 • Figure 11 shows that the system does not meet a specification of Phase [deg] 90 0 Edist = −25 dB , −90 ωd = 0.3 [rad/sec] −180 0 1 10 10 Frequency [radians/second] 0 2 10 −20 Gain dB −1 10 Figure 9: Disturbance transfer function, Tdy (s) −40 −60 −80 −1 10 0 1 10 10 Frequency [radians/second] 2 10 Figure 11: Disturbance transfer function, Tdy (s) Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 13 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 14 EE/ME 574: Intermediate Controls Section 1.3.2 • Considering the two transfer functions: Disturbance : Gp = 1 + Kc Gc GP Hy Tdy (s) = 1 Try (s) Kc Gc (s) and Try (s) ≃ 1.0∠0o ω << ωb – Additionally, ωd << ωb , since, very reasonably, the closed loop can only compensate for disturbances at frequencies well below the closedloop bandwidth. we see that the disturbance transfer function is given as 1 Try (s) Kc Gc (s) (15) – And finally, in most cases, the controller has relatively high gain at low frequencies (this improves accuracy). The Bode plot of Kc Gc (s) is seen in figure 13. 40 • Eqn (15) can be understood by considering the general characteristics of closed-loop systems. 30 Gain dB Input − Output : Tdy (s) = Section 1.3.2 – Since Kc Gc G p Try (s) = 1 + Kc Gc G p Hy Tdy(s) EE/ME 574: Intermediate Controls 20 10 – In most cases Try (s) ≃ 1.0 ∠0o for ω << ωb . For example, Try (s) for the plant of figure 3 and controller of Eqn (13) is seen in figure 12 0 −1 10 20 0 1 10 10 90 Phase [deg] Gain dB 60 0 −20 30 0 −30 −60 −90 −40 −1 10 0 10 1 10 −1 10 2 10 1 10 Figure 13: Gain of the controller Kc Gc (s) , Eqn (13), for a PID controller. 0 Phase [deg] 0 10 Frequency [radians/second] −30 • Putting these facts together, we find: −60 −90 −120 −150 −1 10 0 1 10 10 Frequency [radians/second] Tdy (s) ≃ 2 10 Figure 12: Closed-loop transfer function, Try (s) , plant with controller (13). Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 15 1 Kc Gc (s) s= j ω , ω<ωb (16) • For good disturbance rejection, we want a large controller gain ! Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 16 EE/ME 574: Intermediate Controls Section 1.3.3 1.3.3 Tracking Error, Etrack at frequency ωt • A tracking error specification refers to accurately tracking input signals of any frequency up to a specified frequency. 0 ≤ ω ≤ ωt , for Section 1.3.3 • The example system (figure 14) meets the requirement (note: 1% = -40 dB) Etrack = 1%, ωt = 0.3 [radians/second] This means that for any input signal r (t) = A cos (ωt + φ) 100 × |Tre ( j ω)| ≤ Etrack % the output will track the input with an error of less than 1%, for ω < ωt . • For the basic system of figure 1, the error response transfer function is: Tre (s) = EE/ME 574: Intermediate Controls 1 E ( j ω) = R ( j ω) 1 + Kc Gc G p Hy • Accurate tracking requires (17) Tre (s) = • We can plot the frequency-response of Tre (s). For example, 1 << 1 1 + Kc Gc G p Hy so – The example system (Eqns (1) and (13)) gives the tracking error frequency response of figure 14. Kc Gc G p Hy = K GL (s) >> 1 for ω ≤ ωt • When |K GL (s)| >> 1 , tracking error can be approximated by: Gain dB 0 Meets: Etrack ≤ 1% , ωt = 0.3 [r/s] −20 −40 0 10 1 10 2 10 1 K GL (s) (19) • For example, 0 Phase [deg] Tre (s) ≈ so even though tracking is a closed-loop property, we can read the approximate tracking error directly off the Bode plot. −60 −80 −1 10 (18) −90 – For a tracking error ≤ 2%, −180 – We require |K GL ( j ωt )|≥ 50. And 50x = 34 dB −270 −360 −1 10 0 1 10 10 Frequency [radians/second] – To track a signal with less than 2% error, the loop gain must be greater than 34 dB at ω ≤ ωt 2 10 Figure 14: Error response transfer function for the example system (closed-loop). Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 17 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 18 EE/ME 574: Intermediate Controls Section 1.3.3 • The bode plot for the example system with PID controller (Eqns (1) and (13)) is shown in figure 16. – The system can meet tracking requirement up to ωt = 0.4 [rad/sec] EE/ME 574: Intermediate Controls Section 1.3.4 1.3.4 Noise Rejection, Ngain at frequency ωs • Consider the noise response transfer function: Tvy (s) = Bode plot, Gp1, with PID control −Kc Gc G p Hy −K GL (s) = 1 + Kc Gc G p Hy 1 + K GL (s) (20) 60 20 0 −20 −40 −1 10 • We would like the noise contribution to the output to be small ωc Tracking Error Gain dB 40 ωt 0 10 • At low frequency, ω < ωb , where |K GL (s)| >> 1 1 10 Tvy ≃ 1.0∠ − 180o 2 10 (21) 0 there is nothing we can do (except buy a better sensor) Phase [deg] −30 −60 • At high frequency, ω >> ωb , we can have low sensor-noise sensitivity by having |K GL (s)| << 1 for ω >> ωb −90 −120 −150 −180 −1 10 0 1 10 10 Frequency [radians/second] 2 10 which gives Tvy (s) ≃ −K GL (s) Figure 15: Loop gain (Bode plot) for the example system, Eqn (1) with example PID control, Eqn (13). • Some sensors (e.g., a tachometer) may have considerable noise at frequencies higher than the closed-loop bandwidth of the system – So noise rejection in the control loop is important • A noise-gain specification requires that the closed-loop gain of the system be below some level Ngain for all frequencies above a specified frequency ωs . for Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 19 ω ≥ ωs , Part 3: Frequency Response Design Tvy ( j ω) ≤ Ngain (22) (Revised: Mar 26, 2013) Page 20 EE/ME 574: Intermediate Controls Section 1.3.4 • We can form the closed-loop TF Tvy (s) and plot the frequency response. • For design, it is more useful to consider the Bode plot. 2. Bandwidth, ωb 3. Rise time, tr – For ω >> ωb , the noise gain is approximately the loop gain. • For design, it will be useful to consider the connection, so we can see how to adjust one in order to achieve performance goals in another 60 • The cross-over frequency is defined by a property of the loop gain Noise Rejection Gain dB 40 ωc 0 1.4 Connection between ωc , ωb and tr 1. Cross-over frequency, ωc −K GL (s) −K GL (s) ≃ = −K GL (s) 1 + K GL (s) 1 20 Section 1.4.0 • These speed characteristics are closely linked: – Since |K GL (s)| << 1 in the region of interest Tvy (s) = EE/ME 574: Intermediate Controls −20 ωc : |K GL ( j ωc )| = 1.0 (24) Tnoise −40 −1 10 0 ω 1 10 s 10 2 10 • The bandwidth is defined by a property of the closed-loop transfer function 0 Kc Gc ( j ω) G p ( j ω) 1 + K GL ( j ω) (25) √ • Eqn (25) holds at a frequency where K GL ( j ω) ≈ 1/ 2 (not exactly, because of the complex values in the denominator) Phase [deg] −30 1 ωb : Try ( j ωb ) = √ Try ( j 0) , with 2 −60 −90 −120 −150 −180 −1 10 0 1 2 10 10 Frequency [radians/second] 10 Figure 16: Loop gain for the example system, Eqn (1) with example PID control, Eqn (13). Noise rejection plotted. • We meet the sensor noise specification if: ∀ ω ≥ ωs Part 3: Frequency Response Design Try ( j ω) = • Since the magnitude curve typically trends downward in the region of crossover, with a slope between -1 and -1.5 , we find that – The bandwidth will always be somewhat greater than the cross-over frequency Tvy (s) ≤ Ngain (Revised: Mar 26, 2013) (23) Page 21 – We can often use the approximation √ ωb ≈ 2 ωc Part 3: Frequency Response Design (26) (Revised: Mar 26, 2013) Page 22 EE/ME 574: Intermediate Controls Section 1.4.1 EE/ME 574: Intermediate Controls Section 1.5.0 1.5 Summary of performance measures and interpretation on • Similarly, we can approximate the 10%-90% rise time as: the Bode plot √ 1.8 2 2 ≃ ≃ tr ≃ ωn ωb ωc (27) • The Bode plot of the loop gain shows us 3 regions: – Region I: low-frequency, the magnitude curve shape in this region will determine the accuracy: • The main point is that if we increase the speed in one measure (such as ωc , for frequency-domain design), then the speed in all measures (such as ωb or tr ) will increase. * SSE , * Tracking accuracy , * Disturbance rejection – Region II: cross-over, ∗ the cross-over frequency, ωc determines the speed of the system, 1.4.1 Table of approximate dominant-mode relationships PM←→ ρ − √ πρ 1−ρ2 P.O.=100 × e ρ ≃ PM 100 ωc ←→ ωb ωb ≃ ωc ←→ ωn √ PM 2 100 ωn ≃ ωb ωn ←→ tr ≃ ω2b ≃ ωc2 p ω = ωn 1 − ρ2 ≃ ωc PM, ωc ←→ ω ωc , PM → ts ts = 4 α = √ 4 ρ ωn π ωc ≃ From dominant mode, b , numerical study GL (s) = s(s+a) Close with ρ = 0.7, else approx. (Franklin et al. sect. 6.1) 1.8 ωn t p = ωπ ≃ ω ←→ t p – Region III: high frequency, there is little useful performance in this region, ∗ The roll-off of the gain limits noise sensitivity From dominant mode, and b GL (s) = s(s+a) ωb ←→ ωn tr ≃ From dominant mode From dominant mode, and b GL (s) = s(s+a) 2 ωc ωn ≃ ωc 1 + ∗ phase curve in this region determines the phase margin and the stability of the system Notes 4 PM ωc ( 100 ) 50 Gain dB P.O ↔ ρ Expression 0 Region III (Roll−off) Region I (Accuracy) Region II (Speed/Damping) −50 −2 10 −1 10 0 10 1 10 G p (s) = 1 s2 + s + 0.1 Hy (s) = 1 s + 50 2 10 From dominant mode 0 Connecting approximations From dominant mode Phase [deg] Approx. −90 −180 Connecting approximations −2 10 Table 2: Table of approximations linking PM and ωc to ρ, P.O., ωb , ωn , tr and ts . −1 10 0 10 Frequency [radians/second] 1 10 2 10 Figure 17: Three regions for consideration of design specifications Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 23 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 24 EE/ME 574: Intermediate Controls Section 1.5.0 • Often in controller design we have three big goals and one minor goal EE/ME 574: Intermediate Controls Section 1.5.0 • Example 1: Boost the gain in Region I, to improve accuracy – Put in a compensator with high gain at low frequencies – Big goals: – Extra slope on the the gain curve increases phase lag at low frequencies 1. Achieve sufficient accuracy. ∗ That is, get good low-frequency gain. – If the frequency range of added gain is well below ωc , the damage to phase margin is not too bad. (Region I) 2. Achieve sufficient speed. 20 ∗ That is, get sufficient ωc . (Region II) Gain dB 3. Achieve sufficient damping. ∗ That is, get good phase margin. Phase lag: 10 0 (Region II) −20 −2 10 – Minor goal: Kc Gc (s) = Kc Region I (Accuracy) −10 −1 0 10 1 10 10 2 10 1. Achieve sufficient roll-off at high frequency. Don’t amplify noise, if present. ∗ That is, get good roll-off for ω > ωc . (Region III) Phase [deg] 0 τs + 1 ατs + 1 α > 1 Example: α = 10 −20 −40 Kc Gc (s) = 10 −60 10 s + 1 100 s + 1 Added Phase Lag −80 −2 −1 10 0 10 10 Frequency [radians/second] 1 10 2 10 Figure 18: Bode plot of compensator with high gain in Region I (phase-lag) Gain dB 50 - -: Original system 0 Region I (Accuracy) −50 −2 10 −1 10 0 10 1 10 2 —: With phase-lag compensation 10 Phase [deg] 0 −90 Added Phase Lag −180 −2 10 −1 10 0 10 Frequency [radians/second] 1 10 2 10 Figure 19: Improve performance by boosting low-frequency gain. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 25 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 26 EE/ME 574: Intermediate Controls Section 1.5.0 • Example 2: Add positive phase (phase lead) in the region of cross-over EE/ME 574: Intermediate Controls • Example 3: Add phase lead to push out the cross-over frequency – Put in a compensator with phase lead around ωc – Put in a compensator to support the phase angle at the new ωc – Adjust Kc to move up ωc – This example set up to leave speed unchanged 60 Gain dB – Big boost in phase lead (recall ρ ≃ PM/100 ) Boosts HF gain 30 Phase lead: Gain dB 20 40 Kc Gc (s) = 30 20 0.3 s + 1 0.03 s + 1 Boosts HF gain 10 0 Kc Gc (s) = Kc −20 −2 10 −1 0 10 10 1 10 2 10 100 τs + 1 ατs + 1 α < 1 Example: α = 0.1 80 −2 10 −1 0 10 1 10 2 10 10 100 Phase [deg] 0 −10 Phase [deg] Section 1.5.0 80 60 Added Phase Lead At new crossover 40 20 60 4s +1 Kc Gc (s) = 0.316 0.4 s + 1 Added Phase Lead At crossover 40 20 0 −2 10 −1 10 0 10 Frequency [radians/second] 1 10 0 −2 10 −1 10 0 10 Frequency [radians/second] 1 2 10 10 Figure 22: Bode plot of compensator with phase lead in Region II (phase-lead) 2 10 Figure 20: Bode plot of compensator with phase lead in Region II (phase-lead) 50 Gain dB - -: Original system 0 Region II (Speed/Damping) −50 −2 −1 0 10 10 1 10 2 Region II (Speed/Damping) −2 10 —: With phase-lead compensation −90 −2 −1 10 0 10 Frequency [radians/second] 1 10 1 10 2 10 Added Phase Lead −90 −180 −2 10 0 10 0 10 Added Phase Lead −180 −1 10 10 0 Phase [deg] 0 −50 Phase [deg] 10 Gain dB Increase speed 50 2 −1 10 0 10 Frequency [radians/second] 1 10 2 10 Figure 23: Improve performance by boosting low-frequency gain. 10 Figure 21: Improve performance by boosting low-frequency gain. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 27 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 28 EE/ME 574: Intermediate Controls Section 1.5.0 EE/ME 574: Intermediate Controls Section 2.0.0 2 Design of frequency compensation • Basis of controller design: – Compensators re-shape the loop gain To approach compensator design we will • Some compensators boost gain (improve accuracy) 1. Review standard compensators and their properties – These compensators will add phase lag 2. Consider examples of compensator design – Generally the frequency range has to be low enough that the phase lag does not damage stability • Some compensators boost phase angle (improve damping) Standard compensators • There are four basic standard compensators – These compensators can be used for 1. Proportional-Derivative (PD) 1. Improve phase margin at the existing cross-over 2. Phase-lead ∗ No change to gain 3. Proportional-Integral (PI) 2. Increase the frequency of cross-over 4. Phase-lag ∗ Increased gain • Trade-offs can be made by adjusting the frequency or gain of compensation • These can be combined into larger units. Common examples are 1. Proportional-Integral-Derivative (PID) The most common type of controller, K. Aström estimates that 80% of series compensators are PID 2. Lag-lead compensation 3. Double phase lead 4. Double phase lag Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 29 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 30 EE/ME 574: Intermediate Controls Section 2.1.1 EE/ME 574: Intermediate Controls 2.1 PD compensator Section 2.2.0 2.2 Phase-lead compensator u (t) = kd ė (t) + k p e (t) (28) Kc Gc (s) = kd s + k p = Kc (τD s + 1) Kc Gc (s) = Kc (29) Kc = k p , τD = kd / k p so: (τ s + 1) (α τ s + 1) , α < 1, τ : [seconds] , α : [·] (30) 30 Root Locus 0.3 40 30 Gain dB 0 −10 −2 10 −1/τD −1 0 10 1 10 10 2 10 0 −2 10 0.1 −1/(ατ) −1/τ 0 90 Phase [deg] −0.05 −0.1 −0.15 −0.2 60 Phase Lead 30 −0.3 0 −0.4 −6 −2 −3.5 −3 −2.5 −2 −1.5 −1 −0.5 0 0.5 −1 10 10 Real Axis 0 10 Frequency [radians/second] 1 10 1 10 30 Zero −5 −4 −3 −2 −1 0 1 0 −2 10 −1 10 Pole 0 10 Frequency [radians/second] 1 10 2 10 Figure 25: Phase Lead Compensator Figure 24: PD Compensator • The phase lead compensator puts a zero and a pole in the transfer function. • The PD compensator puts a zero in the transfer function. • At the frequency of the zero, the PD compensator introduces phase lead 2.1.1 Basics of PD design • Use the phase lead to improve stability and/or increase the speed of the closed loop • Cross-over should occur where the compensator gives a reasonable amount of phase lead (at or above 3 [rad/sec] in the figure) • The increasing gain with increasing frequency is not helpful Part 3: Frequency Response Design (Revised: Mar 26, 2013) zero: s = −1/τ , pole: s = −1/α τ , α<1 • The phase is concentrated at the center frequency between the zero and pole. • The phase-lead compensator is basically a PD compensator with a pole above the cross-over frequency to limit the high-frequency gain – Since high-frequency gain is rarely desirable, phase-lead is nearly always more desirable than PD – Phase lead has 1 more parameter, and the designer has to take care to place ωc in the center of the phase-lead region ∗ This makes phase-lead a bit trickier than PD, and perhaps less robust than PD. (increased gain in Region III does no good at all) Page 31 2 10 60 Real Axis −0.2 −4 0 10 90 Phase [deg] real −1 10 real −0.1 0 10 0.2 10 0.1 0.05 20 20 Imaginary Axis imag 0.15 Gain dB 50 Root Locus 0.2 Imaginary Axis imag 0.4 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 32 2 10 EE/ME 574: Intermediate Controls Section 2.2.1 EE/ME 574: Intermediate Controls Section 2.2.1 • Eqn (32) is plotted in figure 27. 2.2.1 Basics of phase-lead design • First we have to understand the role of the parameters α and τ . Gain dB Maximum phase lead 30 α=0.05 Kc Gc (s) = Kc −1 10 0 10 10 For these √ plots, τ = 1/ α Phase [deg] α=0.05 60 α=0.2 10 −1 10 0 10 Frequency [radians/second] 1 2 10 0.1 0.01 • α = 0.1 is a typical value, giving 55o of phase lead. • One thing that must be carefully considered in phase-lead design is to be sure that cross-over occurs at or near the frequency of maximum phase lead, that is (33) ωc ≃ ωmax 2 10 10 Figure 26: Phase Lead Compensator, α determines the amount of phase lead. • We need to determine the relationship between α and the phase lead • Otherwise, the benefit of the phase lead is lost. • And we need to know the frequency of the peak phase lead (and set Kc so that this is the cross-over frequency) • Looking at figure 26, and considering symmetry, ωmax is 1/2 way between the zero and pole frequencies, on a logarithmic scale. Giving • These are derived in Franklin et al. , 1−α sin φmax = 1+α which gives 1 10 1/α ωmax , the frequency of maximum phase lead α=0.5 0 −2 10 30 Figure 27: Maximum phase increase for lead compensation (adapted from Franklin et al., 5th Ed.) 2 90 30 40 α: 1 α<1 1 10 50 0 0 10 α=0.5 0 −2 10 60 20 (τ s + 1) (α τ s + 1) α=0.2 10 80 70 • α determines the separation between the zero and pole. 20 90 1 − sin φmax α= 1 + sin φmax Part 3: Frequency Response Design (Revised: Mar 26, 2013) 1 ωmax = √ τ α (34) (31) Or if we write: (32) Page 33 Kc Gc (s) = Kc s+z s+ p Part 3: Frequency Response Design then ωmax = p |z| |p| (Revised: Mar 26, 2013) Page 34 EE/ME 574: Intermediate Controls Section 2.2.2 2.2.2 Phase-lead compensation design procedure (Franklin, section 6.7.2) • Need to find Kc (step 1) , α (step 4) and τ (step 5) Kc Gc (s) = Kc τs + 1 ατs + 1 Step 2: Evaluate the phase margin (PM) of G p (s = j ωc ) using ωc and Kc 2. Verify that ωmax ≃ ωc , since any mismatch will result in phase lead that is not utilized 3. Plot the step response of the system, verify overshoot, rise and settling time, etc., depending on requirements Step 7: Iterate on the design, make adjustments as needed. • If more speed is required, increase ωc (and ωmax ) • If more damping is required, reduce α and to increase the phase margin Step 3: Allow an extra margin (about 10o ), and determine the needed phase lead to meet the stability requirement. Step 4: Determine α from Eqn (32) or figure 27 – Add a second phase-lead filter (double-lead compensation) if necessary • If more accuracy is required, consider phase-lag compensation to increase low-frequency gain. Step 5: Set ωmax = ωc , find τ √ ωmax α 2.2.2 Phase-lead compensation design procedure (continued) 1. Draw the bode plot for the compensated system, verify the phase margin, tracking accuracy, etc., as needed. 1. Determine Kc to meet an accuracy requirement. Shifting the magnitude curve according to Kc determines ωc √ 2. A speed requirement determines ωc (such as ωc ≃1/ 2 ωb). Shifting the magnitude curve to set ωc determines Kc 1 Section 2.2.2 Step 6: Verify the design Step 1: Determine where the cross-over frequency, ωc , will fall, and the gain Kc . Typically τ= EE/ME 574: Intermediate Controls Analysis (exact) [seconds] (35) • This completes the design Specifications Complete Design Details Design (approximate, iterative, intuitive) Figure 28: The design cycle: an asymmetric loop. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 35 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 36 EE/ME 574: Intermediate Controls Section 2.2.3 Kc will be driven by the SSE requirement. To achieve SSE (step) ≤ 0.01 we need a LF gain of 100. The current LF gain is about 10, so we need Kc = 10. • Consider the plant of figure 17 (repeated here) Step 2: Kc = 10 gives the dashed magnitude of figure 31. And we find Gm = 34.1 dB (at 7.08 rad/sec), Pm = 54.2 deg (at 0.82 rad/sec) 50 Gain dB Section 2.2.3 Step 1: Determine Kc and ωc 2.2.3 Phase-lead design example 1 G p (s) = 2 s + s + 0.1 (1) ωc = 3.1 [rad/sec] , PM (1) = 14.5o 0 (1) 1 Hy (s) = 0.02 s + 1 −50 −2 10 −1 0 10 10 1 where ωc and PM (1) are the first measurements of ωc and PM. 50 2 10 10 Gain dB 0 −90 0 −50 −2 −180 10 −2 10 −1 10 0 10 Frequency [radians/second] 1 10 Figure 29: A third order plant • The design specifications are: 0 1 10 10 2 10 −90 −180 −2 10 1. SSE (step) ≤ 0.01 −1 10 0 10 Frequency [radians/second] 1 10 2 10 Figure 30: G p (s) with adequate gain 2. PO ≤ 20% • The steady-state error requirement tells us that we need a low-frequency gain of at least 99 (100, rounding off) • For a PO of 20% we should have a damping ratio of at least ρ = 0.46 , which suggests PM ≥ 46o Part 3: Frequency Response Design −1 10 0 2 10 Phase [deg] Phase [deg] EE/ME 574: Intermediate Controls (Revised: Mar 26, 2013) Page 37 Step 3: The additional phase lead needed is δPM = 46 − 14.5 + 10 ≃ 42o where +10o have been added to have a little extra margin. Step 4: Reading off of figure 27, for a phase-boost of 42o, we find α ≃ 0.16 . Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 38 EE/ME 574: Intermediate Controls Section 2.2.3 (1) Step 5: ωc was found from the Bode plot to be ωc = 3.1(1) . To get the greatest benefit from the phase-lead compensation, we need ωmax ≃ ωc . With √ ωmax = 1/τ α, solving for τ: 1 1 √ = √ = 0.806 [seconds] ωc α 3.1 0.16 τ= Section 2.2.3 Step 7: Iterating on the design, making adjustments as needed • In this case we want to adjust τ to center the phase lead on the cross-over frequency (cf. figure 25) (36) >> wmax = 6.27 >> tau = 1/(wmax*sqrt(alpha)) tau = 0.3987 >> Gc = tf( [tau, 1], [alpha*tau, 1]) Step 6: Verify the design >> >> >> >> >> >> EE/ME 574: Intermediate Controls Gps = tf(1, [1 1 0.1]); Hys = tf(1, [0.02, 1]); Gp1a = series(Gps, Hys); Kc = 10; alpha = 0.16; tau = 0.806; Gc = tf( [tau, 1], [alpha*tau, 1]) figure(1), clf margin(Kc*Gc*Gp1a) Bode Diagram Gm = 23.1 dB (at 26.2 rad/sec) , Pm = 52.6 deg (at 4.33 rad/sec) 50 Magnitude (dB) 0 Bode Diagram Gm = 16.8 dB (at 19.3 rad/sec) , Pm = 41.8 deg (at 6.27 rad/sec) 50 −50 −100 Magnitude (dB) 0 −150 0 −50 Phase (deg) −100 Phase (deg) −150 0 −90 −180 −270 −3 10 −180 −270 −3 10 −90 −2 10 −1 10 0 10 Frequency (rad/sec) 1 10 2 10 3 10 Figure 32: Kc Gc (s) G p (s) for verification II. −2 10 −1 10 0 10 Frequency (rad/sec) 1 10 2 10 3 10 • The phase margin comes out right at the target of 52o Figure 31: Kc Gc (s) G p (s) for verification. • The phase margin came out a little short. On examination, it is because the cross-over frequency is not 3.1 [rad/sec] as we planned, but 6.27 [rad/sec]. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 39 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 40 Section 2.2.3 EE/ME 574: Intermediate Controls 2.3 PI compensator Verify that requirements are met • The original specification had a steady state error and PO specifications, Z t e (τ) dτ (37) 0 (τI s + 1) k p s + ki = s s Kc = ki ; τI = k p / kI so: (38) 50 Root Locus High LF Gain 40 0.06 imag 0.04 30 20 10 0 0.02 −10 −2 10 0 −1 0 10 1 10 10 2 10 real 0 Phase [deg] Imaginary Axis – Tre (s) has a DC gain of 0.1/10.1, so the steady state error u (t) = k p e (t) + kI Kc Gc (s) = Kc – Checking the error transfer function Tre (s) = E (s) /R (s) >> Tre = feedback(1, Kc*Gc*Gp1a) Transfer function: 0.001276 s^4 + 0.08507 s^3 + 1.084 s^2 + 1.008 s + 0.1 ------------------------------------------------------0.001276 s^4 + 0.08507 s^3 + 1.084 s^2 + 4.996 s + 10.1 Section 2.3.1 Gain dB EE/ME 574: Intermediate Controls −0.02 SSE (step) = 0.0099 −0.04 −30 −60 −90 – Checking the step response, we just meet the 20% overshoot requirement −0.06 −1.2 −2 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 −1 10 10 Real Axis (It is a good thing we put the extra ρ = 0.46 is for a 2nd order system) 10o of phase margin, recall that 1.4 Figure 34: PD Compensator • Below the frequency of the zero, the PI compensator increases gain, for improved accuracy 1.2 • The PI compensator introduces phase lag. 1 Amplitude 1 10 • The PI compensator puts a pole at the origin, and zero determined by τI Step Response – We avoid damaging the phase margin by putting the PI controller well below ω = ωc 0.8 0.6 – Contrast this with the Phase-Lead compensator, were we deliberately (and carefully !) setup the dynamics to have effect right at ω = ωc . 0.4 0.2 0 0 0 10 Frequency [radians/second] 2.3.1 Basics of PI design 0.5 1 1.5 2 • Use the increased gain to improve accuracy at low frequencies Time (sec) • Cross-over should occur above the range of significant phase lag. Figure 33: Step response, for verification. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 41 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 42 2 10 EE/ME 574: Intermediate Controls Section 2.4.0 EE/ME 574: Intermediate Controls 2.4 Phase-Lag compensator Kc Gc (s) = Kc α • The phase-lag compensator is basically a PI compensator with a finite pole, and thus finite DC gain (τ s + 1) (α τ s + 1) , α > 1, Root Locus (39) 40 ∗ Phase-lag compensation can be used Gain dB imag 30 0.3 0.2 Imaginary Axis τ : [seconds] , α : [·] – Certain systems (e.g, with static friction) don’t work well with an integrator in the control loop (that is, a pole at the origin) 0.4 20 10 – In many cases, a finite gain boost is sufficient 0 −10 −2 10 0.1 0 real −1 0 10 1 10 10 2 10 0 Phase [deg] −0.1 −0.2 −0.3 Pole −5 −4 −3 −60 −2 −1 0 1 −2 −1 10 10 Real Axis – The phase lag has one more parameter that PI control (the speed of the pole) Zero −30 −90 −0.4 −6 Section 2.4.0 0 10 Frequency [radians/second] 1 10 Figure 35: Phase Lag Compensator 2 10 ∗ Phase-lag design is basically no trickier than PI design, in both cases we must assure that the zero is well below ωc , to avoid damaging the phase margin. ∗ The desired gain boost determines the location of the pole. • The phase lag compensator puts a pole and a zero in the transfer function. pole: s = −1/α τ , zero: s = −1/τ , α>1 • The phase-lag compensator boosts the low-frequency gain. – The gain boost occurs over the region between the pole and zero – The magnitude of the gain boost is α (α > 1 , for phase lag) • In the region between the pole and zero, the phase lag compensator introduces phase lag, we’ve got to place the phase-lag away from ωc Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 43 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 44 EE/ME 574: Intermediate Controls Section 2.4.1 2.4.1 Basics of phase-lag design Step 1: Determine ωc and the open-loop gain Kc that will meet the phase-margin requirement without compensation • α determines the separation between the zero and pole. Step 2: Draw the Bode plot of the uncompensated system with ωc and Kc from step 1 Gain dB 30 α=20 Kc Gc (s) = Kc α α=2 α>1 0 −2 10 −1 0 10 1 10 10 2 10 For these √ plots, τ = 1/ α 0 Phase [deg] (τ s + 1) (α τ s + 1) α=5 10 α=2 −30 Step 3: Choose α to meet the low-frequency gain requirement (determined from an accuracy requirement) Step 4: Choose the corner frequency ω = 1/τ, (the zero frequency of the lag compensator) to be one octave (2×) to one decade (10×) below the crossover frequency, ωc . That is: 1 1 1 1 < ωc ... < ωc τ 2 τ 10 α=5 −60 α=20 10 −1 10 0 10 Frequency [radians/second] 1 10 2 10 Step 6: Verify the design Figure 36: Phase Lag Compensator, α determines the amount of gain boost and phase lag. 1. Draw the bode plot for the compensated system, verify the phase margin, tracking accuracy, etc., as needed. 2. Plot the step response of the system, verify overshoot, rise and settling time, etc., depending on requirements • Aspects to consider: – The relationship between α and the LF gain boost: Gain boost = α – Phase-lag 1 1 < ωc τ 5 (40) (Recall: the zero frequency is α× above the pole frequency.) (Revised: Mar 26, 2013) Step 7: Iterate on the design, make adjustments as needed. • If more speed is required, increase ωc (may require phase-lead compensation) ∗ The phase lag is substantial up to about 5×the zero frequency, so Part 3: Frequency Response Design (41) Step 5: The second corner frequency (the pole location) is then at ω = 1/ατ. −90 −2 Section 2.4.2 2.4.2 Phase-lag compensation design procedure (see Franklin, section 6.7.4) • First we have to understand the role of the parameters α and τ . 20 EE/ME 574: Intermediate Controls • If more damping is required, increase the phase margin, either by reducing the zero frequency (ωz = 1/τ) or by added a phase-lead compensator. • If more accuracy is required, increase α Page 45 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 46 EE/ME 574: Intermediate Controls Section 2.4.3 2.4.3 Phase-lag design example #1 • Consider the plant of figure 37 Motor and load time constants: 0 τm = 1.0, τe = 0.05 [sec] −20 −40 • The PO suggests a damping factor of ρ ≥ 0.6, which suggests a phase margin of at least PM ≥ 60o. • A blow-up of the Bode plot of G p is seen in figure 38 • The essential concepts for PI or phase-lag compensation are: 1. The phase margin of the plant should be good enough 2. The compensator boosts the LF gain −60 −80 −1 10 0 1 10 10 2 10 3 G p (s) = 10 Km /b (τm s + 1) (τe s + 1) 0 −30 G p (s) = −60 −90 2 (s + 1)(0.05 s + 1) 10 Gain dB Gain dB Section 2.4.3 Phase-lag design example #1 (continued), Design: Velocity control of a motor is a common application of PI or phase-lag compensation. −120 −150 −180 −1 10 0 10 1 10 Frequency [radians/second] 2 10 3 10 Figure 37: A motor with velocity control. • With the design goals – ωb ≥ 10 [radians/sec] 0 −10 −20 0 10 1 Hy (s) = 0.02 s + 1 Phase [deg] Phase [deg] EE/ME 574: Intermediate Controls 1 10 −60 −70 −80 −90 −100 −110 −120 −130 −140 −150 0 10 ωc=7.2 [rad/sec] 1 10 Frequency [radians/second] Figure 38: Blow-up of Bode plot of motor velocity response. – PO ≤ 10% – Tracking accuracy, Etrack ≤ 2%, ωt = 0.1 [rad/sec] • Figure 38 shows we can achieve a phase margin of 70o at ωc = 7.2 [rad/sec]. – Upeak ≤ 5.0 [Amps] – A phase margin of 70o gives us a little extra PM – ωc = 7.2 [rad/sec] should give a closed-loop bandwidth of ωb ≈ 10 [rad/sec], which gives us a little extra speed Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 47 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 48 EE/ME 574: Intermediate Controls Section 2.4.3 Step 1: Determine ωc and Kc to meet PM requirement For ωc = 7.2 [rad/sec], Section 2.4.3 Step 4: Choose the zero location Kc = +12 dB = 4.0 Step 2: Draw the Bode plot of the uncompensated system with ωc and Kc from step 1. • We don’t want to add very much phase lag at ω = ωc , set the compensator zero a full decade below ωc – Choose wz = 0.72 [rad/sec] , which gives: τ = 1/0.72 = 1.39 [sec] Step 5: The pole is located at ω p = 1/ατ = 1/ (8 ∗ 1.39) = 0.090 [rad/sec] PM = 69.16 at wcp= 7.36 [rad/sec] 40 EE/ME 574: Intermediate Controls Step 6: Verify the design, recall the requirements Accuracy Requirement Gain dB 20 • ωb ≥ 10 [radians/sec] 0 • PO ≤ 10% −20 −40 −2 10 −1 0 10 1 10 10 • Tracking accuracy, Etrack ≤ 2%, ωt = 0.1 [rad/sec] 2 10 • Upeak ≤ 5.0 [Amps] Phase [deg] 0 −90 −180 −270 −2 10 −1 10 0 10 Frequency [radians/second] 1 10 2 10 Figure 39: Motor velocity control, K = 4.0 . Step 3: Choose α to meet the LF gain requirement. • For a tracking error less than 2%, we need a gain at ωt = 0.1 [rad/sec] of at least 50. – The current gain is 18 dB or 8.0, %% Plant Model >> Gp1a = tf(2, poly([-1 -20 -50])/1000) %% Compensator >> Tau = 1.39; Alpha = 8; Kc = 4; >> Gc1a = tf(Alpha*[Tau 1], [Alpha*Tau, 1]) %% Closed Loop TF >> Try = feedback( Kc*Gc1a*Gp1a, 1) Transfer function: 88.9 s + 64 --------------------------------------------------0.0111 s^4 + 0.790 s^3 + 12.0 s^2 + 101.1 s + 65 >> Bandwidth = bandwidth(Try) Bandwidth = 12.7847 (CHECK) – So we need to increase the gain by 50/8=6.25 • Choose α = 8 (a little extra) Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 49 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 50 EE/ME 574: Intermediate Controls Section 2.4.3 EE/ME 574: Intermediate Controls Section 2.4.3 • Examine the tracking-error Bode plot, Phase-lag design example #1 (continued) • Examining the step response >> >> >> >> >> figure(2), clf >> step(Try) >> y = step(Try); >> PO = 100* (max(y)-y(end))/y(end) PO = 4.2410 % Tre = feedback( 1, Kc*Gc1a*Gp1a); figure(1), clf bode(Tre) Wt = 0.1; MagE1 = bode(Tre, Wt) MagE1 = 0.0229 %% R->E TF 10 Step Response 0 Gain dB 1.4 1.2 Amplitude −20 −30 1 −40 −2 10 0.8 0.6 −1 0 10 1 10 10 2 10 Phase [deg] 90 0.4 0.2 0 0 −10 1 2 3 4 60 30 0 −30 5 Time (sec) −2 10 Figure 40: Motor velocity control, closed-loop step response • The step response shows about 4.2% overshoot (CHECK) −1 10 0 10 Frequency [radians/second] 1 10 2 10 Figure 41: Motor velocity control, frequency response plot of Tre (s), the error response. • Requirement: Etrack ≤ 2% at ωt = 0.1 [rad/sec] • Actual performance: Tre (s = j ωt ) = 0.0229 • The requirement is not met ! Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 51 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 52 EE/ME 574: Intermediate Controls Section 2.4.3 EE/ME 574: Intermediate Controls Section 2.4.3 Phase-lag design example #1 (continued), 2nd iteration • Check the Upeak >> Tru = feedback( Kc*Gc1a, Gp1a); >> figure(2), >> step(Tru) 4.5 >> Upeak = ... 4 max(step(Tru)) • We can increase the LF gain by increasing α %% R->U TF • But the frequency of the pole is already below ωt = 0.1 [rad/sec] Step Response ω pole = 1 = 0.090 [rad/sec] ατ 3.5 • Additional gain below ω = 0.1 [rad/sec] does not help us. Amplitude 3 2.5 • Figure 43 shows the bode plot of the compensator, 2 – We are introducing a little additional phase lag at ωc 1.5 1 – Strategy: increase α by a small amount, holding α τ constant 0.5 0 0 0.1 0.2 0.3 0.4 Time (sec) 0.5 0.6 0.7 0.8 (hold the pole location constant, move up the zero). ∗ We will loose some phase margin, but pick up some low-freq gain Figure 42: Motor velocity control, closed-loop step response PM = 64.01 at wcp= 7.39 [rad/sec] • Considering all of the performance requirements ωb ≥ 10 [rad/sec] ωb = 12.78 [rad/s] P.O. ≤ 10% P.O. = 4.2% √ Etrack ≤ 2.29% Upeak ≤ 5.0 [Amps] Upeak = 4.03 20 10 −2 10 √ zero −1 0 10 1 10 10 2 10 0 Step 7: Iterate on the design, make adjustments as needed. −20 −40 −60 −2 10 • We have plenty of headroom on ωb , P.O. and Upeak . We need to improve Etrack by a small amount. (Revised: Mar 26, 2013) pole 25 15 Table 3: Performance requirements of the motor velocity control example. Part 3: Frequency Response Design Gain dB 2nd iteration 3rd iteration √ Etrack ≤ 2%, ωt = 0.1 [rad/s] 30 Phase [deg] 1st iteration Requirement 35 Page 53 −1 10 0 10 Frequency [radians/second] 1 10 2 10 Figure 43: Motor velocity control, Bode plot of compensator. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 54 EE/ME 574: Intermediate Controls Section 2.4.3 Phase-lag design example #1 (continued), 2nd iteration >> >> >> >> >> >> %% Compensator 2, move up zero by 10% Tau = 1.38/1.1; Alpha = 8*1.1 Gc1b = tf(Alpha*[Tau 1], [Alpha*Tau, 1]); Try = feedback(Kc*Gc1b*Gp1a, 1); Tre = feedback(1, Kc*Gc1b*Gp1a); Tru = feedback(Kc*Gc1b, Gp1a); Bandwidth2 = bandwidth(Try) Bandwidth2 = 12.8159 >> y = step(Try); PO2 = 5.4665 EE/ME 574: Intermediate Controls Section 2.4.3 Phase-lag design example #1 (continued), 3rd iteration %% R->Y TF %% R->E TF %% R->U TF PO2 = 100*(max(y)-y(end)) / y(end) >> >> >> >> >> >> %% Compensator 3, move up zero by 20% Tau = 1.35/1.2; Alpha = 8*1.2 Gc1b = tf(Alpha*[Tau 1], [Alpha*Tau, 1]); Try = feedback(Kc*Gc1b*Gp1a, 1); Tre = feedback(1, Kc*Gc1b*Gp1a); Tru = feedback(Kc*Gc1b, Gp1a); Bandwidth3 = bandwidth(Try) Bandwidth3 = 12.8495 >> y = step(Try); PO3 = 5.6338 PO3 = 100*(max(y)-y(end)) / y(end) >> u = step(Tru); Upeak2 = max(u) Upeak2 = 4.0272 >> u = step(Tru); Upeak3 = max(u) Upeak3 = 4.0311 >> [MagE2, PhaseE] = bode(Tre, Wt) MagE2 = 0.0209 >> [MagE3, PhaseE] = bode(Tre, Wt) MagE3 = 0.0192 Requirement 1st iteration 2nd iteration 3rd iteration ωb ≥ 10 [rad/sec] ωb = 12.78 [rad/s] √ ωb = 12.82 [rad/s] √ P.O. ≤ 10% P.O. = 4.2% √ P.O. = 5.5% √ Etrack ≤ 2%, ωt = 0.1 [rad/s] Etrack ≤ 2.29% - Etrack ≤ 2.09% - Upeak ≤ 5.0 [Amps] Upeak = 4.03 √ Upeak = 4.03 √ 1st iteration Requirement 2nd iteration 3rd iteration ωb ≥ 10 [rad/sec] ωb = 12.78 [rad/s] √ ωb = 12.82 √ ωb = 12.85 √ P.O. ≤ 10% P.O. = 4.2% √ P.O. = 5.5% √ P.O. = 5.6% √ Etrack ≤ 2%, ωt = 0.1 [rad/s] Etrack ≤ 2.29% - Etrack ≤ 2.09% - Etrack ≤ 1.92% Upeak ≤ 5.0 [Amps] Upeak = 4.03 √ Upeak = 4.03 √ Upeak = 4.03 Table 4: Performance requirements of the motor velocity control example. Table 5: Performance requirements of the motor velocity control example. • Close, but not quite there. We lost a little on the PO, but we still have room to make additional adjustment. • Success ! Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 55 √ √ >> Alpha, Alpha = 9.6000 >> Tau, Tau = 1.1583 >> Gc1b/Alpha Transfer function: (1.158 s + 1) / (11.12 s + 1) Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 56 EE/ME 574: Intermediate Controls Section 2.4.3 EE/ME 574: Intermediate Controls Section 2.4.3 • Design process tips: Summary, phase-lag design example #1 • What suggested phase lag, as opposed to phase lead, or some other compensator ? – Carrying the design through step 2, and – Notice the code to evaluate each of the performance criteria – Setup the compensator %% Compensator 3 >> Tau = 1.39/1.2; Alpha = 8*1.2 >> Gc1c = tf(Alpha*[Tau 1], [Alpha*Tau, 1]) ∗ Seeing that the speed and damping were adequate,and that ∗ The challenging requirement is tracking accuracy – Setup the transfer functions that will be needed – Trying a phase-lead compensation, and seeing problems (Phase-lead would not be good for this application, try it and see !) – Knowing that motor velocity servos are often PI controllers • Why did it take 3 iterations >> Try = feedback(Kc*Gc1c*Gp1a, 1); >> Tre = feedback(1, Kc*Gc1c*Gp1a); >> Tru = feedback(Kc*Gc1c, Gp1a); – bandwidth() is a routine I wrote (write needed routines) – There is a 73x frequency spread between ωc and ωt , but it was still a little difficult to get the needed low-frequency gain boost. >> Bandwidth3 = bandwidth(Try) – Directly evaluate the percent overshoot and Upeak ∗ Boost needed at ωt >> >> >> >> ∗ Can’t tolerate very much added phase lag at ωc ∗ Examine the phase lag put in by the compensator >> [temp, PhaseGc1c] = bode(Kc*Gc1c, wc2) PhaseGc1b = -5.9657 Gc (s) has −6.0o of phase at ωc (a bit of damage to the phase margin) • If needed, we could have gotten more low-frequency gain by putting in a double-lag compensator, Double lag compensation: 2 lag compensators, with the pole repeated and the zero repeated. y = step(Try); PO3 = 100*(max(y)-y(end)) / y(end) u = step(Tru); Upeak3 = max(u) – Directly evaluate the error magnitude >> [MagE3, PhaseE] = bode(Tre, Wt) – Pay careful attention to validation, it is the most important step ! – If you’re not sure how an adjustment will impact the design, try it ! – 2x as much low-frequency boost – 2x as much damage to the phase margin, may need to increase τ Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 57 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 58 EE/ME 574: Intermediate Controls Section 2.5.0 EE/ME 574: Intermediate Controls 2.5 PID compensation Section 2.5.2 2.5.1 Basics of PID design • Determine desired cross-over frequency, ωc • Proportion-Integral-Derivative compensation combines the elements of PI and PD control – For example, from a speed requirement • It is very widely used for motion controllers, in the process industry and in other applications u (t) = kd ė (t) + k p e (t) + kI Z t – Often, the zeros will be set to the same speed: e (τ) dτ (42) 0 τD =≃ τI kd s2 + k p s + ki 1 Kc Gc (s) = Kc (τD s + 1) 1 + = s τI s – Define ωz = 1/τD = 1/τI as the speed of the PID zeros, then the phase lead is given for several ratios ωc /ωz 40 Gain dB imag 0.15 0.1 ωc /ωz ∠ PID High LF Gain 30 20 0.5 10 0 1.0 −10 −2 10 0.05 0 real −0.1 −0.15 −1 10 0 1 10 10 Phase Lead 0 −90 −0.2 −3.5 −2 −3 −2.5 −2 −1.5 −1 −0.5 0 0.5 −1 10 10 Real Axis 0 10 Frequency [radians/second] 1 10 −37o 00 2 10 90 Phase [deg] −0.05 (44) (43) 50 Root Locus 0.2 Imaginary Axis • Set the zeros to give good phase lead at ωc 2 10 2.5 45o 3.8 ∞ 60o 90o 2.5.2 Design procedure 1. Determine the desired value of cross-over, ωc Figure 44: PID Compensator 2. Set ωz , determine τD , τI • The PID compensator puts 3. Determine Kc to achieve cross-over at ωc – A pole at the origin, for high LF gain (and to increase the system type) 4. Validate – Two zeros, at 1/τI and 1/τD , for phase lead (and improved damping) Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 59 5. Iterate Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 60 EE/ME 574: Intermediate Controls Section 2.5.3 EE/ME 574: Intermediate Controls Section 2.5.3 • The form for Gc (s) for Ziegler and Nichols tuning is: 2.5.3 Ziegler-Nichols Method 1: Quarter-Cycle Damping Method • Proposed in 1942 by J.G. Ziegler and N. B. Nichols 1 τD s2 + s + 1/τI Gc (s) = k p 1 + + τD s = k p τI s s • Provides a systematic approach when no transfer function is available • Widely used in the process industry (cf. Franklin et al. (5th Ed.) sec. 4.4.2). • Also called the “Process Reaction Curve Method” • With a series of trials on an analog computer, Ziegler and Nichols determined the following recommended gain values of table 6. • The first Ziegler-Nichols method is based on the open-loop step response of the system. Recommended Gains τI kp – This method is suitable for over-damped systems, especially with time delay (examples: mayonnaise processing, heat or flow in an oil refinery) P-Control PI-Control – A typical curve is seen in figure 46. The curve defines three values: Amplitude of response L: Time Delay [seconds] τ: Time constant [seconds] R = A/τ 0.9/RL L/0.3 Process Reaction Curve 2L 0.5 L Example, Quarter-Cycle Damping method Step Response G p (s) = A e−s L τs + 1 Reaction Rate: G p2 (s) = 2 A = 2 1 L = 0.3 [seconds] R = A/τ τ = 2.2 [seconds] 0.5 L=td τ t 0 Figure 45: Typical process reaction curve. Part 3: Frequency Response Design (Revised: Mar 26, 2013) 2 (s + 1) (0.5 s + 1) (0.2 s + 1) 1.5 Amplitude A Recall, Reaction Rate: Table 6: Ziegler-Nichols tuning for PID controller, for quarter-cycle damping. Approximate transfer function: y(t) τD 1/RL PID-Control 1.2/RL A: (45) 0 1 2 3 4 5 Time (sec) 6 7 8 9 Figure 46: Process reaction curve for G p2 (s) Page 61 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 62 EE/ME 574: Intermediate Controls Section 2.5.4 • The calculation gives: >> >> >> >> >> EE/ME 574: Intermediate Controls Section 2.5.4 2.5.4 Ziegler-Nichols Method 2: Ultimate Sensitivity Method A=2; L=0.3; tau = 2.2; R = A/tau„ kp = 1.2/(R*L)„ tauI = 2*L„ tauD = 0.5*L„ R kp tauI tauD = = = = • The ultimate sensitivity method is based on performing a test in which the closed-loop system is driven to marginal stability. 0.9091 4.4000 0.6000 0.1500 – Wrap a loop around the process, with proportional gain, as shown in figure 48. >> Gc2 = tf(kp*[tauD, 1, 1/tauI], [1 0]) Transfer function: (0.66 s^2 + 4.4 s + 7.333) / s – Increase the gain until marginal stability is reached (figure 49), this determines two values Ku : Ultimate Gain Pu : Ultimate Period Step Response 1.8 P 1 1.6 r(t) 1.4 2 1.2 Amplitude y(t) e(t) K For Quarter-Cycle Damping: P (P2 − 1) = 1 1 (P1 − 1) 4 Process (46) 0.8 Figure 48: Feedback for the ultimate sensitivity method. Kc is the proprotional feedback gain. 0.6 0.4 0.2 1 0 0 2 4 6 8 10 12 Pu 0.8 14 Time (sec) 0.6 Figure 47: Closed-loop step response for system tuned by the Quarter-Cycle Damping method. 0.4 y(t) 0.2 • The objective is “Quarter-Cycle Damping,” which means that each successive peak is reduced to 1/4th the amplitude of the previous peak. 0 −0.2 −0.4 −0.6 −0.8 • In this example, we don’t quite get quarter-cycle damping, −1 0 5 – But the parameters give a starting point for final tuning. 10 time [seconds] 15 20 Figure 49: Output of the system at marginal stability. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 63 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 64 EE/ME 574: Intermediate Controls Section 2.5.4 τD >> Ku = 6; 1 8 Pu Table 7: Ziegler-Nichols tuning for PID controller, for ultimate sensitivity method. Example, Ultimate Sensitivity Method • Example plant TF: G p (s) = Section 2.5.4 • Applying the Ultimate Sensitivity method Recommended Gains kp τI P-Control 0.5 Ku PI-Control 0.45 Ku Pu /1.2 1 PID-Control 0.6 Ku 2 Pu EE/ME 574: Intermediate Controls 2 s2 + 2 s + 5 >> >> >> >> Pu = 4.6/3; %% Raw measurements kp = 0.6*Ku %% Determine compensator tauI = Pu/2 tauD = Pu/8 Gc = kp * tf( [tauD, 1, 1/tauI], [1 0] ) Transfer function: 0.69 s^2 + 4.5 s + 4.696 kd s^2 + kp s + ki -----------------------= ------------------s s • Test values of gain until marginal sensitivity is reached >> figure(2), clf %% Plot CL step response >> step( Gc*Gp2a) ; grid on Kc = 1.0000 Kc = 2.0000 0.8 1.4 0.7 1.2 0.5 0.4 0.4 0.2 0.2 2 4 6 8 0 0 10 4 6 Time (sec) Kc = 6.0000 1.6 1.4 1.4 1.2 1.2 Amplitude 1.6 1 0.8 10 Ku = 6 0.6 0.4 SSE(step): 0.00 SSE(ramp): 0.5 0.11 Pu = 1.533 [s] 0.8 0.4 0.2 8 1 0.6 0 0 1 2 Time (sec) Kc = 5.0000 Amplitude 0.1 Amplitude 0.8 0.6 0.3 0 0 Step response of system, by Ziegler−Nichols UC tuning 1.5 1 Amplitude Amplitude 0.6 0.2 2 4 6 8 10 0 0 Time (sec) 2 4 6 8 10 0 0 Time (sec) 2 4 6 8 10 12 Time (sec) Figure 50: Step response for K = 1, 2, 5, 6 Figure 51: Controller tuned by the Ultimate Sensitivity method. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 65 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 66 EE/ME 574: Intermediate Controls Section 2.5.5 2.5.5 Tyreus-Luyben Tuning Chart (“TLC” tuning rules) EE/ME 574: Intermediate Controls Section 2.5.6 2.5.6 PID design by frequency response • An alternate set of rules due to B.D. Tyreus and W.L. Luyben gives: • The Bode plot for a PID controller with τI = τD is seen in figure 53. Recommended Gains 60 kp τI τD PI-Control Ku/3.2 2.2 Pu PID-Control Ku/2.2 2.2 Pu Pu /6.3 Gain dB 50 40 30 High gain for accuracy in this region 20 Table 8: Tyreus-Luyben alternate tuning for PID controller. Ku and Pu determined as for the ultimate sensitivity method. 10 −2 10 • Relative to the ultimate sensitivity method, TLC tuning gives: −1 0 10 1 10 10 2 10 Phase [deg] 90 – Slightly lower gain – Slightly longer τ′ s 60 Crossover in this region 30 0 −30 −60 – Will give a slightly slower, more damped response −90 −2 10 −1 10 0 10 Frequency [radians/second] 1 10 2 10 Step response of system, by frequency response design Figure 53: PID controller tuned by frequency response. 1 0.9 • Frequency response design of PID control comprises two main ideas: 0.8 Amplitude 0.7 1. Determine cross-over, to get adequate speed and stability 0.6 SSE(step): 0.00 0.5 SSE(ramp): 0.47 0.4 Bandwidth: 6.81 – Boosting the phase margin with phase lead, if necessary 2. Boost the low frequency gain, as needed, to meet accuracy requirements 0.3 0.2 0.1 0 0 2 4 6 8 10 12 Time (sec) Figure 52: Controller tuned by TLC tuning rules. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 67 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 68 EE/ME 574: Intermediate Controls Section 2.5.6 2.5.6 PID design by frequency response (continued) • Consider the uncompensated plant, G p2 (s) EE/ME 574: Intermediate Controls 2.5.6 PID design by frequency response (continued) 2 G p2 (s) = (s + 1) (0.5 s + 1) (0.2 s + 1) • Let’s set ωc = 4.1 [rad/sec] (this determines k p) • To get good phase margin Gain dB 50 – Both compensator zeros at ωz = ωc /5 [rad/sec] = 0.8 [rad/sec] 0 τD = τI = 1/ωz −50 −100 −2 10 −1 0 10 1 10 10 (47) 2 10 • Including Gc (s) in the bode plot, k p for ωc = 4.1[rad/sec] comes out to 1.3 0 Phase [deg] Section 2.5.6 • Writing the compensator transfer function as: −90 Gc (s) = k p −180 −270 −2 10 −1 10 0 10 Frequency [radians/second] 1 10 = kp 2 10 Figure 54: The uncompensated plant, G p2 (s). • We find – ZN tuning gives about 25o of phase lead around 4 [rad/sec], Gm = NaN dB (at Gain dB 0.9 0.8 (Revised: Mar 26, 2013) SSE(step): 0.00 SSE(ramp): 0.6 SSE(step): 0.5 SSE(ramp): −50 −2 10 0.00 0.47 −1 10 0 10 1 2 10 10 0.47 0 Bandwidth: 6.81 Phase [deg] −30 0.1 0 0 −60 −90 −120 −150 −180 2 4 6 8 10 Time (sec) 12 −2 10 −1 10 0 10 Frequency [radians/second] 1 2 10 10 Figure 55: Step response (closed-loop) and Bode plot (open-loop), Gc3 G p2 . Steady state error for a ramp input is 47%. – Z-N is a coarse tuning, a starting point for fine tuning ! Part 3: Frequency Response Design NaN rad/sec), Pm = 65.0 deg (at 4.38 rad/sec) 0 0.7 0.2 ∗ This is why the Z-N tuned controller looks lightly damped (50) 50 0.3 ∗ 90o of phase lead would be the maximum possible (49) 1.22 s2 + 2 s + 0.82 s Step response of system, by frequency response design 0.4 ∗ Certainly not as much as possible 1 Amplitude • For comparison, the compensation given by Ziegler-Nichols Quarter-Cycle Damping type tuning is seen figure 47. (48) τD s2 + (1 + τD/τI ) s + 1/τI s Gc3 (s) = 1.3 • Phase cross-over (φ = −180o) occurs at 4.1 [rad/sec] • With effective phase boost (the phase-lead portion of the PID) we can get 60o of phase margin at ωc = 4.0 [rad/sec] (τD s + 1) (s + 1/τI ) s Page 69 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 70 EE/ME 574: Intermediate Controls Section 2.5.7 2.5.6 PID design by frequency response (continued) • Study questions, for the previous example EE/ME 574: Intermediate Controls Section 2.5.7 Solution: • To make Gc3 (s) proper, we can add one or several poles at frequencies well above ωc Gc3 (s) ≃ 1.3 1.22 s2 + 2 s + 0.82 1.22 s2 + 2 s + 0.82 ≃ 1.3 (53) s (0.01s + 1) s (0.01s + 1) (0.01s + 1) ... – What would we change to increase the bandwidth of the system ? Gc (s) = 3 s + 7 ≃ ∗ What would be the side effects ? 3s +7 3s +7 ≃ ... (0.01 s + 1) (0.01 s + 1) (0.01 s + 1) (54) – What would we change to increase the accuracy of the system ? 50 ∗ What would be the other consequences ? Gain dB 40 – What would we change to increase the damping of the system ? ∗ What would be the other consequences ? 30 ωc 20 10 0 −2 10 −1 0 10 1 10 10 2 10 2.5.7 Realizable form for PD and PID controllers 90 Gc3 (s) = 1.3 1.22 s2 + 2 s + 0.82 s Phase [deg] • The transfer function for the PID controller of the last example is (51) 60 30 0 −30 −60 −90 −2 10 • A PD controller might have a TF of the form Gc (s) = 3 s + 7 (52) −1 10 0 10 Frequency [radians/second] 1 10 2 10 Figure 56: An additional pole at s = −100 has little influence near ωc . • Additional poles should be at frequencies well above cross-over • Neither of these transfer functions is implementable (infinite gain at infinite frequency) • They should be put in so that their low-frequency gain is 1, that is: Not >> step(Gc3) ??? Error using ==> ltipack.ltidata.utCheckComputability at 13 Not supported for models with more zeros than poles. 1/ (0.01 s + 1) 1/ (s + 100) • These poles are physical, actual controller devices have finite bandwidth ! • That is, Gc3 (s) is not proper. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 71 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 72 EE/ME 574: Intermediate Controls Section 2.6.0 EE/ME 574: Intermediate Controls 2.6 Lead-Lag compensation Section 2.6.1 2.6.1 Basics of Lead-Lag compensation • The structure of the lead-lag compensator is illustrated in figure 58. • Lead-lag compensation is like PID compensation, except that: – The low-frequency pole is at finite frequency, not the origin ωc somewhere in here – There is an additional high-frequency pole. frequency, ω x oo Gc (s) = Kc α1 (τ1 s + 1) (τ2 s + 1) (α1 τ1 s + 1) (α2 τ2 s + 1) with lag section: α1 > 1, lead section: α2 < 1. x S-plane Lead Part Lag Part Figure 58: Structure of the poles and zeros in a Lead-Lag compensator • Design ideas: Root Locus 40 – Use the lag part to boost the low-frequency gain 1.5 Gain dB imag 30 1 0 −0.5 High gain for 10 accuracy in this region 0 −2 −1 10 10 – The lag zero should be well below the cross-over frequency 0 1 10 10 2 10 – The lead pole should be well above the cross-over frequency real 90 Phase Lead Portion Phase [deg] Imaginary Axis 0.5 – Use the lead part to boost the phase margin 20 Phase Lag Portion −1 60 – Choose Kc so that cross-over occurs in the desired region. 30 0 Crossover in this region −30 −60 −90 −1.5 −25 −20 −15 −10 −5 0 5 −2 −1 10 10 Real Axis 0 10 Frequency [radians/second] 1 10 2 Figure 57: Phase Lag Compensator Part 3: Frequency Response Design (Revised: Mar 26, 2013) – The DC gain is finite ∗ The infinite DC gain of the PID compensator may not be advantageous, if, for example, we have a disturbance rejection requirement, at ωd . %% Example Lead-Lag Compensation >> Alpha1 = 20„ Tau1 = 2 %% Lag portion >> Alpha2 = 0.1„ Tau2 = 0.5 %% Lead portion >> Kc = 2 >> GcLeadLag = Kc* series( ... tf( Alpha1 * [Tau1 1], [(Alpha1*Tau1) 1]), ... tf( [Tau2 1], [(Alpha2*Tau2) 1]) ) • Comparing with the PID compensator 10 – The Lead-Lag compensator has a 2nd pole, above the cut off frequency of the controller. ∗ We’ve seen that PID controllers (and everything really) actually have additional high-frequency poles. %% Lag Part %% Lead Part Page 73 ∗ The explicit HF pole of Lead-Lag compensation may be good for controlling noise sensitivity. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 74 EE/ME 574: Intermediate Controls Section 3.0.0 EE/ME 574: Intermediate Controls Section 3.0.0 • Look at the phase-margin at ωc 3 Summary of frequency-response based compensator design – If the speed and phase margin are adequate, ∗ PI or Phase-Lag control may be suitable • Broadly speaking, controller design comprises 4 steps: – If the speed or phase margin needs boosting 1. Determining specifications ∗ PD, Phase-Lead control may be suitable 2. Modeling the system to be controlled 3. Choosing a controller structure • Look at the accuracy requirement 4. Tuning the controller parameters – If the accuracy is adequate • We’ve seen a number of different controller structures, these are listed in table 9, with indications of their virtues. ∗ PD or Phase-lead control may be suitable – If the accuracy needs improving Compensator Type: Speed Damping Accuracy Number of Parameters: P-type + - + 1 PD ++ ++ 0 2 Phase-Lead ++ ++ 0 3 PI 0 - ++ 2 Phase-Lag 0 - ++ 3 lag-lead ++ ++ ++ 5 PID ++ ++ ++ 3 State Space ++ ++ ++ n Notation ∗ PI or Phase-Lag control may be suitable • If both (speed or phase margin) and accuracy need a boost – PID or Lead-Lag control may be suitable ’+’: improves, ’-’: makes worse, ’0’: unchanged. Table 9: Controller Structures • The most important step of any frequency-domain design is to determine the cross-over frequency. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 75 Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 76 EE/ME 574: Intermediate Controls Section 3.0.0 • It is permitted to use multiple compensators. – For example, to get a phase boost of more than about 60o we can use a double-lead compensator Gc (s) = Kc τs + 1 τs + 1 , ατs + 1 ατs + 1 α<1 (55) – A double-lag compensator would give greater boost of the low-frequency gain – A Lag-Lead-Lead compensator would give some accuracy improvement with considerable phase support – Et cetera for other combinations • Poles at ω p >> ωc (frequency significantly above ωc ) have little influence on the closed-loop response of the system. – They can be added to the compensator to make it realizable – They can be added as needed to reduce sensitivity to high-frequency noise. ——– ∼ ——– • The Bode plot reveals many features of the requirements and performance of feedback control systems, including – The concepts of cross-over frequency, phase and gain margin, – Tools for assessing the speed, stability and accuracy of feedback control, – Aspects to examine, to help select a controller structure, and – Design techniques to realize controllers of many different types. Part 3: Frequency Response Design (Revised: Mar 26, 2013) Page 77 EE/ME 574: Intermediate Controls EE/ME 574: Intermediate Controls State-Variable Modeling for Controller Analysis and Design Contents 1 Introduction to state-variable models 1.1 Voice-coil motor: an example contrasting classical and statevariable modeling . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.1 Developing a classical model . . . . . . . . . . . . . . . . 1.1.2 Some observations on developing the classical model . . . 1.1.3 Writing the model in state-variable form . . . . . . . . . 1.1.4 Form for the state-variable model . . . . . . . . . . . . . 1.1.5 Steps of building a state-variable model, with the voicecoil motor example . . . . . . . . . . . . . . . . . . . . . 1.1.6 Matlab code to set up the voice-coil motor example . . . . 1.1.7 Some observations on developing the state-variable model 1.2 State-variable modeling, conclusions . . . . . . . . . . . . . . . . 12 21 24 26 2 Review of basics of linear algebra 2.1 Scalars, matrices and vectors . . . . . . . . . . . . . . . . . 2.2 Transpose . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Basic arithmetic: +, - and * are well defined . . . . . . . . . 2.3.1 Multiplication . . . . . . . . . . . . . . . . . . . . . 2.4 Commutative, associative, distributive and identity properties 2.4.1 Commutative property . . . . . . . . . . . . . . . . 2.4.2 Associative property . . . . . . . . . . . . . . . . . 2.4.3 Distributive property . . . . . . . . . . . . . . . . . 2.4.4 Identity Matrix . . . . . . . . . . . . . . . . . . . . 2.4.5 Doing algebra with vectors and matrices . . . . . . 2.5 Linear independence and the determinant . . . . . . . . . . 2.5.1 Computing the determinant . . . . . . . . . . . . . 27 27 27 28 29 31 31 31 32 32 33 34 35 Part 4: State-Space Control . . . . . . . . 36 37 38 39 41 44 46 47 3 Working with state-variable models 3.1 Deriving the transfer function from the state-variable model . . . . 3.1.1 Interpreting J p . . . . . . . . . . . . . . . . . . . . . . . 3.2 Getting a state-space model from a transfer function . . . . . . . . 3.2.1 Example, state-space model from a transfer function . . . 3.2.2 One more complication . . . . . . . . . . . . . . . . . . 3.3 Coordinate transformation of a state-variable model . . . . . . . . 3.3.1 Derivation of the state model transformation . . . . . . . 3.3.2 Example: transforming a system model into modal coordinates . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.3 Summary of coordinate transformation . . . . . . . . . . 49 49 51 52 56 57 58 59 4 Introducing state-feedback control 4.1 Determination of a new model with state feedback 4.2 Determining N f . . . . . . . . . . . . . . . . . . . 4.2.1 Note on N f and SSE(step) = 0 . . . . . . . 4.3 Example system with state feedback . . . . . . . . . . . . 63 64 66 67 67 . . . . 69 70 71 73 75 2.6 2.7 2.8 . . . . . . . . . . . . (Revised: Jan 27, 2016) . . . . . . . . . . . . . . . . . . . . . . . . 5 5 7 8 10 11 Page 1 2.5.2 Some relations involving determinants . . . . . . . . Rank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The norm of a vector . . . . . . . . . . . . . . . . . . . . . . A quick review of eigenvalue and eigenvectors . . . . . . . . 2.8.1 Some properties of Eigenvectors and Eigenvalues . . 2.8.2 A few more notes on Eigenvectors and Eigenvalues . 2.8.3 Positive definite and positive semi-definite matrices . 2.8.4 One final fact about the eigensystem: V diagonalizes A . . . . . . . . . . . . . . . . . . . . 5 State-space controller design, determine K and N f 5.1 State-Space Controller Design Method #1: Pole Placement 5.1.1 Pole placement example . . . . . . . . . . . . . . . 5.1.2 Try pole-placement control design, twice as fast . . . 5.1.3 Taking a look at the control effort and tracking error Part 4: State-Space Control . . . . . . . . (Revised: Jan 27, 2016) . . . . . . . . . . . . . . . . 60 62 Page 2 EE/ME 574: Intermediate Controls 5.2 EE/ME 574: Intermediate Controls State-Space Controller Design Method #2: The Linear Quadratic Regulator, an optimal control method . . . . . . . . . . . . . . . 5.2.1 The LQR cost function . . . . . . . . . . . . . . . . . . . 5.2.2 Designing an LQR controller . . . . . . . . . . . . . . . 5.2.3 Tuning an LQR controller . . . . . . . . . . . . . . . . . 5.2.4 Procedure for tuning Q and R . . . . . . . . . . . . . . . 5.2.5 Further notes on choosing Q and R . . . . . . . . . . . . . 5.2.6 Connection between LQR and the Symmetric Root Locus 6 State-variable models with various inputs and outputs 6.1 Considering various inputs . . . . . . . . . . . . . . . . . . 6.1.1 Considering a disturbance input . . . . . . . . . . . 6.2 Considering various outputs . . . . . . . . . . . . . . . . . 6.3 Determining the Steady-State error for a state-variable model 6.3.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Summary, state-variable modeling and control 121 78 79 82 84 86 87 88 89 . 89 . 93 . 95 . 97 . 100 7 Integral control: augmenting the model with an integral control state 103 7.1 Augment the state vector with controller states . . . . . . . . . . . 103 7.2 Block diagram of state-variable controller with controller states . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 7.3 Example, integral control for the voice-coil motor . . . . . . . . . 108 7.3.1 Now, set N f . . . . . . . . . . . . . . . . . . . . . . . . 111 7.4 Summary of integral control . . . . . . . . . . . . . . . . . . . . 113 8 Controllability and observability 8.1 Main facts about uncontrollable or unobservable modes: . . 8.2 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.3 Mathematical tests: . . . . . . . . . . . . . . . . . . . . . . 8.3.1 Test for controllability . . . . . . . . . . . . . . . . 8.3.2 Test for observability . . . . . . . . . . . . . . . . . 8.4 Summary Controllability and Observability . . . . . . . . . 8.4.1 Uncontrollable and unobservable modes and rocketry Part 4: State-Space Control . . . . . . . (Revised: Jan 27, 2016) . . . . . . . . . . . . . . 115 116 116 117 117 118 119 120 Page 3 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 4 EE/ME 574: Intermediate Controls Section 1.1.0 EE/ME 574: Intermediate Controls Section 1.1.0 1 Introduction to state-variable models • To introduce the the subject and advantages of state-variable modeling, we will consider an example. • We will compare and contrast state-variable modeling with “classical modeling” Figure 1: Voice-coil motor schematic (Example 2.10, Figure 2.19 in Franklin et al. 5th Ed.). – Classical modeling: ∗ Algebraic simplification of equations to 1 nth order differential equation in 1 variable. • Figure 1 shows a schematic diagram. The a voice-coil motor combines – An electrical side – State-variable modeling: – A mechanical side ∗ Little algebraic simplification of differential equations required • The model equations are: ∗ Represent the model as n first order differential equations 1.1 Voice-coil motor: an example contrasting classical and cone : coil current : state-variable modeling back emf M z̈ (t) = −bż (t) + ks ia (t) d La ia (t) = −Ra ia (t) − ecoil (t) + va (t) dt ecoil (t) = ks ż (t) (1) (2) (3) • The model for voice-coil motor will be used as an example to develop the ideas of state variable modeling and control. • Eqn (1) comes from the mechanics of the voice coil • Voice-coil motors are linear motors used in high speed applications, such as the hummingbird robot developed by IBM research laboratories (cf. Zai et al., 1992). • Eqn (2) comes from the circuit and the inductor • Eqn (3) reflects the back EMF of the coil • A model for a voice-coil motor is developed in chapter 2 of Franklin et al. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 5 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 6 EE/ME 574: Intermediate Controls Section 1.1.1 EE/ME 574: Intermediate Controls • Signals and parameters are listed in table 1 Section 1.1.2 – Now the ia (t) term on the right has to be eliminated, use Eqn (1) to write: Signal Description Units Parameter Description z (t) Cone position [m] M Cone mass ia (t) Coil current [A] b Cone damping va (t) Applied voltage [V] ks Coil motor constant Ra Coil resistance La Coil inductance Table 1: Signals and parameters of the voice coil model. Units i h N [kg] = m/s 2 h i N A N m/s = h V m/s ia (t) = (6) – Plugging (6) back into 5 gives i V [Ω] = A [H]= V A−s 1 (M z̈ (t) + b ż (t)) ks M ˙z˙˙(t) = −b z̈ (t) + ks 1 1 (M z̈ (t) + b ż (t)) − ks ż (t) + va (t) −Ra La ks – After a certain amount of algebra, one finds: 1.1.1 Developing a classical model L M ˙z˙˙(t) + La b z̈ (t) + Ra M z̈ (t) + Ra b ż (t) + ks2ż (t) = ks va (t) • A classical model is developed first, to show the contrast with state-variable modeling. • We can see from Eqns (1)-(3) that the system will have a 3rd order model. • If the system input is va (t) and the output is z (t), we should eliminate ecoil (t) (easy) and i (t) (harder) from the equations (7) – Which gives the transfer function: Z (s) ks = Va (s) La M s3 + (La b + Ra M) s2 + (Ra b + ks2) s (8) 1.1.2 Some observations on developing the classical model • It requires many algebra steps – Taking the derivative of Eqn (1) will introduce d ia (t) /dt : Actually, the algebra steps required goes up rapidly in the system order M ˙z˙˙(t) = −b z̈ (t) + ks i˙a (t) (4) – 3rd is 4 − 5×more algebra than 2nd order ∗ 4th order is 10 − 20×more algebra than 2nd order – The d ia (t) /dt term can be eliminated with Eqn (2) : M ˙z˙˙(t) = −b z̈ (t) + ks Part 4: State-Space Control 1 (−Ra ia (t) − ks ż (t) + va (t)) La (Revised: Jan 27, 2016) ∗ Imagine deriving a 6th order model ! (5) Page 7 ∗ Imagine deriving a 200th order model ! Part 4: State-Space Control (Revised: Jan 27, 2016) Page 8 EE/ME 574: Intermediate Controls Section 1.1.2 • By eliminating the intermediate variables we throw away information – Suppose we have an ammeter in the circuit and measure ia (t), how do we relate that to Eqn (5) ? EE/ME 574: Intermediate Controls Section 1.1.3 1.1.3 Writing the model in state-variable form • A State Variable (SV) model addresses all of the above concerns about classical models • To construct a n SV model, we need n, 1st order differential equations • To solve Eqn (5) we need the initial conditions z (t0 ), ż (t0 ), z̈ (t0) • The form for a state-variable model is – What is the physical significance of z̈ (t0 )? ẋ (t) = Fp x (t) + G p u (t) (9) y (t) = H p x (t) + J p u (t) (10) • What are the mathematical properties of Eqn (5) ? u(t) – Is it the simplest form ? Fp, Gp, Hp, Jp y(t) x(t) – Can we determine the states from measurements of z (t)? ∗ Or from ia (t) ? (ia (t) is even in the model !) Figure 2: Basic block diagram of a state-variable model. Fp , G p , H p , J p are model matrices. x (t) is the state vector. • Paying attention to details, there are five steps in writing a state variable model: – By choosing va (t) can we control z (t) ? • What other forms for the model are possible, 1. Write the relevant relations for the system 2. Identify the differential equations – For example, we could have developed the model Ia (s) /Va (s) 3. Write the differential equations in state-variable form – Can we describe all possible alternative model forms ? 4. Write the equation of the output signal (or signals) using the states and inputs 5. Verify correctness, by verifying the individual rows of the state variable model, and check units in the state and output equation. ——– ∼ ——– • Let’s look at each step and break it out into sub-steps, and see an example. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 9 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 10 EE/ME 574: Intermediate Controls Section 1.1.4 1.1.4 Form for the state-variable model EE/ME 574: Intermediate Controls Section 1.1.5 1.1.5 Steps of building a state-variable model, with the voice-coil motor example • The form for a state-variable model is 1. Write the relevant relations for the system ẋ (t) = Fp x (t) + G p u (t) (11) y (t) = H p x (t) + J p u (t) (12) (a) Define symbols for the signals and parameters (b) Write the equations u(t) Fp, Gp, Hp, Jp i. Constituent relations (for elements) y(t) ii. Continuity constraints (for how elements are linked into a system) x(t) (c) Record the units, verify that units balance in the equations Figure 2 (repeated). Basic block diagram of a state-variable model. Signal x (t) u (t) y (t) name description Parameter State vector n-element vector Input vector m-element vector Output vector p-element vector name • The equations express laws of physics, the units must balance System matrix n × n matrix Input matrix n × m matrix Output matrix p × n matrix DT term p × m matrix Fp Gp Hp Jp ——– ∼ ——– description • For the VCM: – Going back to the basic modeling equations, and dividing through by any leading constant Table 2: Signals and parameters of the state-variable model. cone : • For a linear model with constant coefficients , Fp , G p , H p , J p are constant coil current : – Matrices Fp , G p , H p , J p represent the system back emf ks b ż (t) + ia (t) (15) M M Ra 1 1 d ia (t) = − ia (t) − ecoil (t) + va (t) (16) dt La La La ecoil (t) = ks ż (t) (17) z̈ (t) = − • Signals x (t), u (t) and y (t) are signals – Re-write Eqn (15) as two first order equations, define v (t) = ż (t) , so v̇ (t) = z̈ (t): • 2nd order example (to see what the model looks like): x (t) = z (t) ż (t) , Part 4: State-Space Control ẋ (t) = −1 3 x (t) + 2 −2 0 h i y (t) = 3 4 x (t) + [0] u (t) 1 u (t) (Revised: Jan 27, 2016) cone : (13) b ks v (t) + ia (t) M M ż (t) = v (t) v̇ (t) = − (18) (19) (14) – Table of parameters with units is given in table 1. Page 11 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 12 EE/ME 574: Intermediate Controls Section 1.1.5 2. Identify the differential equations (a) Put derivatives in the left-hand side, these must be the state derivatives • The number of independent “storage” elements • The system order will almost always be sum of the orders of the contributing differential equations • Rarely, differential equations may be inter-dependent in a way that reduces the order (b) Select the state variables (b) All signals on the right-hand side must be expressed in terms of the states and inputs (c) Higher order differential equations are written as a chain of first-order equations (d) Put the model in state-variable form nth order system ——– ∼ ——– • State variables must be independent, no state variable can be a linear combination of other state variables (a) From Eqns (15)-(19) we can write: • The highest derivatives in the differential equations are not state variables, they go on the left-hand side of ẋ (t) = A x (t) + Bu (t) ks b v (t) + ia (t) M M ż (t) = v (t) Ra 1 1 i˙a (t) = − ecoil (t) − ia (t) + va (t) La La La v̇ (t) = z̈ (t) = − • The choice of state variables is not unique • Often the “storage” variables are a good choice • For the VCM: ——– ∼ ——– (a) Eqns (16) (18) and (19) are 3 first-order differential equations, system order: n = 3. (b) Select the variables of the state vector for Eqn (18) v (t) x (t) = for Eqn (19) z (t) for Eqn (16) ia (t) (Revised: Jan 27, 2016) v̇ (t) = − Page 13 (21) (22) (23) (b) Looking at the right-hand side, all signals must be states or inputs. Signals v (t) , ia (t) are states, va (t) is the input, however ecoil (t) is not a state or input. Use the algebraic modeling equations to rewrite ecoil (t) in terms of states+inputs: ecoil (t) = ks ż (t) Giving – Now, for writing ẋ (t) = Fp x (t) + G p u (t) we need ẋ (t), which is v̇ (t) ∗ These are precisely the derivatives ẋ (t) = of Eqns (16) (18), and (19) ż (t) (20) i˙a (t) Part 4: State-Space Control Section 1.1.5 3. Write the differential equations in state-variable form (a) Determine the system order • n state variables for an EE/ME 574: Intermediate Controls ks b v (t) + 0 z (t) + ia (t) + 0 va (t) M M ż (t) = 1 v (t) + 0 z (t) + 0 ia (t) + 0 va (t) Ra 1 ks i˙a (t) = − v (t) + 0 z (t) − ia (t) + va (t) La La La Part 4: State-Space Control (Revised: Jan 27, 2016) (24) (25) (26) Page 14 EE/ME 574: Intermediate Controls Section 1.1.5 (c) Starting with EE/ME 574: Intermediate Controls Section 1.1.5 With matrices b ks z̈ (t) = − ż (t) + ia (t) M M (27) Introduce v (t) = ż (t) v̇ (t) = z̈ (t) (28) Using Eqn (28) in (27) gives a chain of two first-order differential equations, capturing the second order relationship of Eqn (27) : ks b v (t) + ia (t) M M ż (t) = v (t) v̇ (t) = − − Mb ks M 0 Fp = 1 0 0 − Lksa 0 − RLaa and 0 Gp = 0 1 La (29) (30) (d) Eqns (24)-(26) is written in state-variable form with: • ks b v (t) − M 0 M ẋ (t) = z (t) = 1 0 0 − Lksa 0 − RLaa ia (t) v (t) 0 z (t) + 0 [va (t)] (31) 1 ia (t) La • Which is the state equation: ẋ (t) = Fp x (t) + G p u (t) Part 4: State-Space Control (Revised: Jan 27, 2016) Page 15 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 16 EE/ME 574: Intermediate Controls Section 1.1.5 4. Write the equation of the output signal (or signals) using the states and inputs ——– ∼ ——– • For the VCM, the output is the position, z (t) y (t) = [z (t)] = v (t) 0 1 0 z (t) ia (t) EE/ME 574: Intermediate Controls Section 1.1.5 • Keeping in mind the units of the state vector: m s x (t) = [m] [A] • Checking units in the state equation, ẋ (t) = Fp x (t) + G p u (t) + [0] [va (t)] m s2 m sec h i Amp sec • Which is the output equation: "h N 2 i# [·] hm/sN i m/s = 1 [·] "h i# V m/s [·] [ VA−s ] "h kg−m/s2 A kg [·] [ VA ] [ V −s A ] i# m s [m] [A] [·] + [·] A V −s [volts] • Simplifying the units expression: y (t) = H p x (t) + J p u (t) With Hp = 0 1 0 and m s2 m sec h i J p = [0] Amp sec 5. Verify correctness, by verifying the individual rows of the state variable model, and check units in the state and output equation. ——– ∼ ——– • For the VCM, we can examine the individual rows, and assure that the correspond to the original modeling equations (from page 6). h 2i m/s [·] s−1 A −1 = 1 s [·] −1 A [·] s m m s [m] [A] [·] + [·] A V −s [volts] • Looking at the output equation m h i s [m] = [·] 1 [·] [m] [A] + [·] [volts] – The output signal is one of the states, so H p and J p are pretty simple in this example. – In some cases there is more going on in the output equation. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 17 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 18 EE/ME 574: Intermediate Controls Section 1.1.5 • Some things to notice about the example state variable model EE/ME 574: Intermediate Controls Section 1.1.5 • Further remarks on state-variable models – All of the information about the system is in the Fp , G p , H p , J p matrices. (any parameter that doesn’t show up in the matrices, doesn’t influence the system). – The middle row of the state equation, Eqn (31), is – The state variable model is a very general form. – In fact, any linear, time-invariant constant coefficient system model can be written as a state variable model. ż (t) = 1 v (t) + 0 z (t) + 0 ia (t) + 0 va (t) ẋ (t) = Fp x (t) + G p u (t) y (t) = H p x (t) + J p u (t) ∗ Or simply ż (t) = 1 v (t) ∗ This derivative equation might seem trivial, since we defined v (t) = ż (t). However, it is needed. ∗ The derivative equation is needed for each state variable, no matter how simple. – The state variable model can directly handle multi-input, multi-output systems (like a helicopter) ∗ For a system with m inputs and p outputs: • Some essential things to keep in mind for state-variable modeling: – Always distinguish between signals and parameters ∗ Signals are functions of time and change when the input (signals) change. x (t) ∈ Rn×1 Fp ∈ Rn×n u (t) ∈ Rm×1 G p ∈ Rn×m y (t) ∈ R p×1 H p ∈ R p×n J p ∈ R p×m ∗ Parameters are generally constant (or slowly varying) and are properties of the system. ∗ Both have physical units – Pay special attention to the states ∗ Systems have many signals, only n signals are states ∗ States correspond to the needed initial condition needed to determine the output of the system ∗ With experience, it is often quite straight-forward to determine the states for a state-variable model. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 19 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 20 EE/ME 574: Intermediate Controls Section 1.1.6 1.1.6 Matlab code to set up the voice-coil motor example %% Setup the parameters as constants ks = 0.63; b = 0.03; M = 0.2; R = 0.3; L = 0.02; >> Fp = [ -(b/M) 0 (ks/M); 1 0 0 ; -(ks/L) 0 -(R/L) ] >> Gp = [0; 0; (1/L)] >> Hp = [ 1 0 0 ]; Jp = 0; Fp = -0.1500 1.0000 -31.5000 0 0 0 %% Define the state equations %% using the constants %% (not numbers) EE/ME 574: Intermediate Controls Section 1.1.6 >> OLPoles = pole(Ga_ss) OLPoles = 0 -7.5750 + 6.6404i -7.5750 - 6.6404i >> OLZeros = zero(Ga_ss) OLZeros = Empty matrix >> figure(1), clf %% Examine the system response >> step(Ga_ss) >> title(’Open Loop Step Response’); grid >> print(’-deps2c’, ’FEStepOL’) 3.1500 0 -15.0000 Gp = 0 0 50 Open Loop Step Response, position 3 2.5 0 1 Jp = 0 0 2 Amplitude Hp = %% Build Matlab Sys model, examine poles and zeros >> Ga_ss = ss(Fp, Gp, Hp, Jp); 1.5 1 0.5 Matlab prints a = b = 0 0 0.5 1 1.5 2 Time (sec) x1 x2 x3 x1 -0.15 1 -31.5 x2 0 0 0 c = x3 3.15 0 -15 x1 x2 x3 u1 0 0 50 Figure 3: Open-Loop system step response, note: system is type I. d = y1 x1 0 x2 1 x3 0 Part 4: State-Space Control y1 u1 0 (Revised: Jan 27, 2016) Page 21 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 22 EE/ME 574: Intermediate Controls Section 1.1.6 EE/ME 574: Intermediate Controls • By changing the H p and J p matrices, we can consider the velocity or the current as the output of the system >> >> >> >> Section 1.1.7 1.1.7 Some observations on developing the state-variable model (Compare with section 1.1.2) • Classical modelling: requires many steps of algebra Hp_v = [1 0 0]; Jp_v = [0]; %% Cone Velocity as output Hp_i = [0 0 1]; Jp_i = [0]; %% Coil current as output figure(1), clf, step(ss(Fp, Gp, Hp_v, Jp_v), 2) figure(2), clf, step(ss(Fp, Gp, Hp_i, Jp_i), 2) – Writing the state variable model required almost no algebra – For a large model, this would be a significant advantage Open Loop Step Response, velocity Open Loop Step Response, current 1.6 2.5 • Classical modeling: eliminates intermediate variables 1.4 2 1.2 – State variables are not thrown out ! Amplitude Amplitude 1 0.8 1.5 – Information about the evolution of the states is explicitly available in the model 1 0.6 0.4 0.5 0.2 • Classical modeling: What is the significance of the initial conditions ? 0 0 0.5 1 1.5 2 0 0 0.5 Time (sec) 1 1.5 2 Time (sec) Figure 4: Velocity response and current response. – The initial conditions, x (t = 0) are the states at t = 0 ! – The physical significance of the initial conditions, as well as how to accurately determine them, is readily apparent. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 23 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 24 EE/ME 574: Intermediate Controls Section 1.1.7 • Classical modeling: transfer function provides limited mathematical insight into the system – State-variable modeling brings a wealth of insight into the details of the physical system EE/ME 574: Intermediate Controls Section 1.2.0 1.2 State-variable modeling, conclusions • An overview of basic system modeling (TF and SS) is found chapter 2 of Franklin et al. • State variable modeling in 5 steps: ∗ The modes of response ∗ Geometric interpretation of the model and system response (EE/ME 701) 1. Write the relevant relations for the system 2. Identify the differential equations ∗ Rigorous definitions of controllability and observability · Very difficult with transfer functions, and a key original motivation for state-space development – Optimal control design methods 3. Write the differential equations in state-variable form 4. Write the equation of the output signal (or signals) using the states and inputs 5. Verify correctness, by verifying the individual rows of the state variable model, and check units in the state and output equation. • Classical modeling: what other forms for the model are possible ? – Model transformation shows the set of all possible state-variable models for a system. • Matlab manipulates state variable-models as a type of LTI model • State variable models carry information (the states) that TF models throw away. • And we can get the TF from the SS model ! • New control design methods for state-variable models (coming up!) Part 4: State-Space Control (Revised: Jan 27, 2016) Page 25 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 26 EE/ME 574: Intermediate Controls Section 2.2.0 2 Review of basics of linear algebra EE/ME 574: Intermediate Controls Section 2.3.0 2.3 Basic arithmetic: +, - and * are well defined Define: 2.1 Scalars, matrices and vectors 1 2 A= ; 3 4 • Matrices are rectangular sets of numbers or functions, examples: • Matrices have zero or more rows and columns: v (t) 1 0 7 x (t) = w (t) , x (t) ∈ R3×1 A= 4 5 0 z (t) 2 3 6 , 3×3 A∈R • Vectors are special cases of Matrices, with only one row or column, – x is a column vector, h i – w = 3 4 ∈ R1×2 is a row vector • Scalar values (numbers or functions with one output variable) can also be treated as matrices or vectors: 3 = [3] ∈ R1×1 • ’Array’ is a synonym for Matrix −1 1 B= ; 2 3 2 x = ; 3 w= 3 1 C = 4 −1 5 2 3 4 • Operations +, - and * are well defined. The dimensions of the operands must be compatible. • For addition and subtraction, the operation is element-wise, and the operands must be the same size: 0 3 A+B = 5 7 2 1 A−B = 1 1 – If not the same size, there is no defined result (the operation is impossible) A + C = undefined 2.2 Transpose Transposing an array rearranges each column to a row: 3 1 C = 4 −1 5 2 CT = 3 4 5 1 −1 2 We say that A and C are incommensurate for addition. • C ∈ R3×2 , CT ∈ R2×3 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 27 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 28 EE/ME 574: Intermediate Controls Section 2.3.1 EE/ME 574: Intermediate Controls Section 2.3.1 • Examples: 2.3.1 Multiplication • For multiplication, the operation is by row on the left and column on the right. – To produce one element of the result, go across each row on the left and multiply with elements of the column on the right. With 1 2 −1 1 A= , B= 3 4 2 3 (1 ∗ (−1) + 2 ∗ 2) A ∗ B = AB = (3 ∗ (−1) + 4 ∗ 2) 3 1 1 2 AC = 4 −1 = undefined 3 4 5 2 With n = 3 , m = 2 , j = 2 , k = 2 : then m = j : We get With n = 2 , m = 2 , j = 3 , k = 2 , then m 6= j : (1 ∗ 1 + 2 ∗ 3) 3 7 = 5 15 (3 ∗ 1 + 4 ∗ 3) 3 1 6 10 1 2 C A = 4 −1 = 1 4 3 4 5 2 11 18 – A and B don’t have to be the same size to multiply 1 2 2 (1 ∗ 2 + 2 ∗ 3) 8 Ax = = = 3 4 3 (3 ∗ 2 + 4 ∗ 3) 18 – For A B = C , given A ∈ Rn×m and B ∈ R j×k ∗ The number of columns in A must match the number of rows in B that is, m = j ∗ The size of the result matrix is determined by the number of rows in A and columns in B ∗ To multiply A and B, we must have m = j , then C ∈ Rn×k Part 4: State-Space Control (Revised: Jan 27, 2016) Page 29 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 30 EE/ME 574: Intermediate Controls 2.4 Commutative, associative, Section 2.4.2 distributive and identity properties EE/ME 574: Intermediate Controls Section 2.4.4 2.4.3 Distributive property • Like scalar algebra, * distributes over + and - : 2.4.1 Commutative property (A + B) C = A C + B C • Like scalar algebra, addition commutes: A + B = B + A • Like scalar algebra, subtraction commutes with a ’-’ sign: A − B = − (B − A) C (A − B) = C ∗ A − C ∗ B • Unlike scalar algebra, multiplication does not generally commute: A B 6= B A Note: left-to-right order of multiplications in second example. 2.4.4 Identity Matrix – Example: 3 7 AB = ; 5 15 2 2 BA = 11 16 • Like scalar algebra, linear algebra has a multiplicative identity: IL C = C IR = C – ’Generally’: There are many properties of linear algebra that are ’generally’ true, but may not be true for some special cases. – Examples: 2.4.2 Associative property • Like scalar algebra, +, - and * have the associative property: (A + B) + C = A + (B + C) 1 3 1 = 4 −1 −1 2 5 2 3 1 0 = 4 −1 1 5 2 – If A is square, then IL = IR , and we just call it I, the identity matrix: (A + B) − C = A + (B − C) 1 0 1 2 1 2 1 0 1 2 = = 0 1 3 4 3 4 0 1 3 4 (A ∗ B) ∗ C = A ∗ (B ∗ C) (Revised: Jan 27, 2016) 1 0 0 3 0 1 0 4 0 0 1 5 3 1 1 4 −1 0 5 2 – ’Does not generally commute’ means that most matrices do not commute, but that perhaps special matrices can be found that do commute. Part 4: State-Space Control Page 31 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 32 EE/ME 574: Intermediate Controls Section 2.4.5 EE/ME 574: Intermediate Controls Section 2.5.0 2.5 Linear independence and the determinant 2.4.5 Doing algebra with vectors and matrices • Starting with an equation, • The columns (or rows) of a matrix are linearly independent if there are no coefficients a1, a2, ... such that – We can add, subtract or multiply on the left or right by any allowed term and get a new equation. – Examples, given: a1 c1 + a2 c2 + ... + an−1 cn−1 = cn (32) Or, equivalently, there is no vector x such that C x = 0, where C = [c1 , c2 , ...] is the array of vectors ci , and 0 is the null vector (vector of zeros). A+B = C • The determinant is a scalar measure of the ’size’ of a square matrix. Then det (A) = |A| ∈ R1 (33) (A + B) + D = C + D – The determinant is not defined for a non-square matrix. • The determinant of a matrix will be non-zero if and only if the rows (or, equivalently, columns) of a matrix are linearly independent. Examples: E (A + B) = E A + E B = E C (A + B) F = C F (a) – Where A, B, C, D, E and F are compatible sizes. • Matrices that are the appropriate size for an operation are called commensurate . 1 2 3 4 5 6 =0 10 14 18 (b) 1 2 3 4 5 6 7 8 −9 = 54 (34) – In case (a), the third column is given by 2xCol2 - 1xCol1. In case (b), the three columns are independent. – Notice that in case (a), the third row is given by 2xRow1 + 2xRow2. ∗ Always for a square matrix, if the columns are dependent, the rows will be dependent. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 33 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 34 EE/ME 574: Intermediate Controls Section 2.5.1 2.5.1 Computing the determinant Section 2.5.2 2.5.2 Some relations involving determinants The determinant of a square matrix (the only kind !) is defined by Laplace’s expansion (following Franklin et al.): 1. det (I) = 1, where I is the identity matrix 2. det (A B) = det (A) det (B) n det A = EE/ME 574: Intermediate Controls ∑ ai j γi j for any i = 1, 2, ..., n (35) j=1 3. Given M, an invertible matrix, where ai j is the element from the ith row and jth column of A; and γi j is called the cofactor, given by: (36) γi j = (−1)i+ j det Mi j where Mi j is called a minor. Mi j is the same matrix as A, with the ith row and jth column removed. (a) det M −1 = 1/ det (M) (b) det M A M −1 = det (M) det (A) 1/ det (M) = det (A) • For example, with i = 1, j=1 j=2 j=3 a b c e f d f d e det d e f = a det − b det + c det h i g i g h g h i • Closed-form expressions for 2x2 and 3x3 matrices are sometimes handy. They are: a b = ad − bc det c d a b c det d e f = a e i − a h f − b d i + b g f + c d g − c g e g h i Part 4: State-Space Control (Revised: Jan 27, 2016) Page 35 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 36 EE/ME 574: Intermediate Controls Section 2.6.0 2.6 Rank EE/ME 574: Intermediate Controls 2.7 The norm of a vector • The rank of a matrix is the number of independent rows and columns r = rank (A) • The norm of a vector, written ||x|| is a measure of the size of the vector. (37) • The number of independent rows is always equal to the number of independent columns • In mathematics many “measures of size” are defined for special purposes. • The most common measure by far is the "2-norm", (a.k.a. the Euclidean norm) s n • Example: ||x||2 = 1 2 3 4 A = 5 6 7 8 6 8 10 12 rank (A) = 2 3rd ∑ x2i (38) i=1 example: – The third row is the sum of the first two. – Notice that the Section 2.7.0 ||x||2 = column is 2 x Col2 - Col1 – And the 4th column is 3 x Col2 - 2 x Col1 r 2 x = −3 −4 (39) 22 + (−3)2 + (−4)2 = 5.39 (40) • The rank of a matrix can not be greater than the number of rows or columns rank (A) ≤ min (n , m) • A matrix is said to be full rank if rank (A) takes its maximum value, that is rank (A) = min (n , m) • Otherwise the matrix is said to be rank deficient. • A square matrix is invertible if and only if it is full rank. • The determinant of a square matrix is zero if the matrix is rank deficient. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 37 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 38 EE/ME 574: Intermediate Controls Section 2.8.0 EE/ME 574: Intermediate Controls 2.8 A quick review of eigenvalue and eigenvectors A quick review of eigenvalue and eigenvectors (continued) These are the main properties of eigenvectors and eigenvalues, which are typically covered more thoroughly and rigorously in a first course in linear algebra. • For any square matrix A, certain vectors have the property that the matrix changes magnitude only, not direction. – For A, such vectors are: • A vector has both a direction and a magnitude. Consider Section 2.8.0 1 −1.5 1.58 v1 = , v2 = , v3 = 2 −3.0 1.58 1.5 1.5 = 2.0 −0.5 1.0 0.5 1 1 ; 1 2 = 2.0 −0.5 1.0 0.5 1 2 • These special vectors are called the eigenvectors – v1 has the same direction as v2 , but has a different magnitude. • An eigenvector is scaled by the matrix – v3 has the same magnitude as v1 , but has a different direction. x2 v1 • In general, multiplying a vector v by a matrix v3 x1 y4 = A v4 1.5 2.0 −0.5 1 1 1 = = 1.5 , so v1 = , λ1 = 1.5 1 1.5 1.0 0.5 1 1 2.0 −0.5 1 1 1 1 = = 1.0 , so v2 = , λ2 = 1.0 1.0 0.5 2 2 2 2 • We can write: introduces both a change of magnitude and a change of direction v2 1 2.5 2.0 −0.5 y4 = A v4 = = −1 0.5 1.0 0.5 λ i vi = A vi , x2 for example 1.5 1 1 = A 1 1 (41) where the λi are the eigenvalues and the vi are the eigenvectors. y4 x1 v4 • Notice that in general a x 6= A x, because multiplication by matrix A will rotate a general vector x (Choosing vectors x at random, what is the probability of selecting an eigenvector ?) Part 4: State-Space Control (Revised: Jan 27, 2016) Page 39 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 40 Student Exercise EE/ME 574: Intermediate Controls Section 2.8.1 EE/ME 574: Intermediate Controls Section 2.8.1 4. A complete set of eigenvectors exists when an n × n matrix has n distinct eigenvectors (so V, the matrix of eigenvectors, is invertible). 2.8.1 Some properties of Eigenvectors and Eigenvalues 1. Only square matrices have an eigensystem • For the example matrix 2. The eigenvalues are the solutions to the equation det (A − λ I) = 0 . • Example, using (42) 2.0 −0.5 A= 1.0 0.5 with >> [V, U] = eig(A); • The matrix of eigenvectors is a b det = ad − bc c d This leads to a polynomial equation in λ 2.0 − λ −0.5 2.0 −0.5 1 0 det −λ = det 1.0 0.5 − λ 1.0 0.5 0 1 (a) A 3x3 matrix gives an equation in λ3, a 4x4 gives an equation in λ4 , etc. (b) Abel’s theorem states: there is no closed-form solution for the roots of a polynomial of 5th order and above, therefore there is no closed-form solution for the eigenvalues a 5x5 matrix or larger. 1 1 V= 1 2 and the matrix of eigenvalues is 1.5 0 U= 0 1 = (2.0 − λ)(0.5 − λ) − 1.0 (−0.5) = λ2 − 2.5λ + 1.5 = 0 3. The polynomial equation given by Eqn (42) is called the characteristic equation of the matrix A 5. A matrix that lacks a complete set of eigenvectors is said to be defective, but this name is meaningful only from a mathematical perspective. For many control systems, some combinations of parameter values will give a ’defective’ system matrix. • This case corresponds to the case of repeated roots in the study of ordinary differential equations, where solutions of the form y (t) = t e−λt arise. • A defective matrix can only arise when there are repeated eigenvalues. • In this case, a special tool called the Jordan Form is required to solve the equation ẋ (t) = A x (x). Part 4: State-Space Control (Revised: Jan 27, 2016) Page 41 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 42 EE/ME 574: Intermediate Controls Section 2.8.1 6. The eigensystem is computed in Matlab with the eig() command, • V is the matrix of eigenvectors, U is a matrix with the corresponding eigenvalues on the main diagonal. [ 1 2 -2 4 5 6 >> [v,u] = eig(A) v = 0.5276 0.2873 -0.7994 u = -2.4563 0 0 Section 2.8.2 2.8.2 A few more notes on Eigenvectors and Eigenvalues >> [v,u] = eig(A) >> A = EE/ME 574: Intermediate Controls 3 1 3 ] 1. Don’t use the determinant equation to determine the characteristic equation to find eigenvalues. Don’t solve: det (A − λI) = 0 (44) λn + an−1λn−1 + · · · + a1λ + a0 = 0 (45) to get and then solve Eqn (45) to find the eigenvalues λi 0.5267 - 0.0250i -0.1294 + 0.1030i 0.8335 0.5267 + 0.0250i -0.1294 - 0.1030i 0.8335 0 5.2282 + 0.5919i 0 0 0 5.2282 - 0.5919i • Some reasons to avoid the determinant are: (a) Going from Eqn (44) to Eqn (45) by solving the determinant involves symbolic manipulation of matrix A. It is a lot of work. (b) The determinant does not give the eigenvectors (c) Once you get Eqn (45), how are you going to find the roots of the polynomial ? (Answer on the next page) 7. Notice that eigenvalues can be real or complex. >> Poly = poly(diag(u)) Poly = 1.0000 -8.0000 (d) Working with the determinant does not lead to a numerically stable algorithm. 2.0000 68.0000 The characteristic equation corresponding to 3 × 3 matrix A is λ3 − 8 λ2 + 2 λ + 68 = 0 (43) • As with many things, wikipedia has a very nice article on eigenvectors and eigenvalues: “Everything you wanted to know about the eigensystem of A, in 3 pages. “ Part 4: State-Space Control (Revised: Jan 27, 2016) Page 43 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 44 EE/ME 574: Intermediate Controls Section 2.8.2 EE/ME 574: Intermediate Controls Section 2.8.3 2. Matlab does not create the characteristic equation using det (A − λ I) = 0, and then solving for the polynomial roots. • Relationship: • Matlab actually goes the other way, and solves for the roots of a polynomial by forming a matrix and finding the eigenvalues of that ! The polynomial • For a state-variable model, the poles of the system are the eigenvalues of the F matrix λ3 − 8 λ2 + 2 λ + 68 = 0 Roots of Characteristic Equation ⇔ Eigenvalues of the Companion Matrix – If the F matrix has poles in the right half plane, the system is unstable. is represented in Matlab as the vector • Note: I haven’t told you an algorithm for eig(F). Poly = [ 1, -8, 2, 68] The algorithm is: Use Matlab ! and the command roots() finds the roots: 2.8.3 Positive definite and positive semi-definite matrices >> roots(Poly) ans = [ 5.2282 + 0.5919i 5.2282 - 0.5919i -2.4563 • A matrix is positive definite if – Actually ‘under the hood’ Matlab forms a matrix (called the companion matrix) and applies the eigenvalue routine to that: >> compan(Poly) ans = 8.0000 1.0000 0 -2.0000 0 1.0000 -68.0000 0 0 xT A x > 0 ∀ x ∈ Rn – A symmetric matrix A is positive definite (PD) if all eigenvalues λi > 0 – For diagonal matrices, A is positive definite if each diagonal element is greater than zero. • A matrix is positive semi-definite if >> eig(compan(Poly)) ans = [ 5.2282 + 0.5919i 5.2282 - 0.5919i -2.4563 ] Part 4: State-Space Control λ 3 + a2 λ 2 + a1 λ + a0 = 0 −a2 −a1 −a0 C= 1 0 0 0 1 0 (Revised: Jan 27, 2016) Page 45 xT A x ≥ 0 ∀ x ∈ Rn – A symmetric matrix A is positive semi-definite if all eigenvalues λi ≥ 0 – For diagonal matrices, A is positive definite if each diagonal element is greater than or equal to zero. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 46 EE/ME 574: Intermediate Controls Section 2.8.4 2.8.4 One final fact about the eigensystem: V diagonalizes A EE/ME 574: Intermediate Controls V diagonalizes A (continued) • When a complete set of eigenvectors exists, the matrix of the eigenvectors • A numerical example: – which is an n × n matrix can be used to transform A into a diagonal matrix, by similarity transform • General form for the similarity transform: b = T A T −1 A 1 2 3 A= 4 5 6 7 8 9 [V, Λ] = eig (A) −0.2320 −0.7858 0.4082 V = −0.5253 −0.0868 −0.8165 −0.8187 0.6123 0.4082 (46) • Properties of a similarity transform: 0 0 16.1168 U = 0 −1.1168 0 0 0 0.0000 – T must be invertible – The similarity transform preserves eigenvalues b eig (A) = eig(A) Diagonalizing A : U = V−1 A V (47) Recovering A from [V, U] : A = V U V−1 (48) 0 0 16.1168 −1 V AV = 0 −1.1168 0 0 0 0.0000 −1 • Eqns (47) and (48) are both similarity transforms (Revised: Jan 27, 2016) – We have: • The equations for V diagonalizing A are, with V the array of eigenvectors, and U with the eigenvalues on the diagonal: Part 4: State-Space Control Section 2.8.4 VUV Page 47 Part 4: State-Space Control =U 1 2 3 = 4 5 6 =A 7 8 9 (Revised: Jan 27, 2016) Page 48 EE/ME 574: Intermediate Controls Section 3.1.0 3 Working with state-variable models EE/ME 574: Intermediate Controls Section 3.1.0 • Or we can use Matlab ! 3.1 Deriving the transfer function from the state-variable model >> [Np, Dp] = ss2tf(Fp, Gp, Hp, Jp); %% One method (old fashioned) • Or, using LTI models • It is straight forward to get the transfer function from a state variable model. Starting with the state equation >> SSp >> Gps = ss(Fp, Gp, Hp, Jp); = tf(SSp); %% Create a state variable model object %% Second method (uses tf object) ẋ (t) = Fp x (t) + G p u (t) Transfer function: 157.5 s - 1.553e-29 -------------------------------s^3 + 15.15 s^2 + 101.5 s • Considering the Laplace transform of the state equation: s X (s) = Fp X (s) + G p U (s) (49) Y (s) = H p X (s) + J p U (s) (50) • Eqn (49) leads to: • Returning to Eqn (53) Y (s) = H p (s I − Fp)−1 G p + J p U (s) (s I − Fp) X (s) = G p U (s) (Note round-off error) (53, repeated) or X (s) = (s I − Fp)−1 G p U (s) (51) • With (51), Eqn (50) leads to: • From Eqn (53) we can determine the DC Gain of a state-variable model, KDC = lim s→0 Y (s) = H p (s I − Fp)−1 G p U (s) + J p U (s) Y (s) = lim H p (s I − Fp)−1 G p + J p = H p (−Fp)−1 G p + J p U (s) s→0 (54) (52) – If the system is a Type 0 system, Eqn (54) will give a finite result. • If m = 1 (one input) and p = 1 (one output), then Eqn (52) gives the transfer function: Y (s) (53) = H p (s I − Fp)−1 G p + J p U (s) • Eqn (53) can be solved symbolically by Cramer’s rule, to give the symbolic transfer function. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 49 – If the system is a Type I system, (−Fp )−1 will blow up, giving ∞ gain. ∗ limω→0 G (s = jω) does go to ∞ for a Type 1 system ∗ More on this later . Part 4: State-Space Control (Revised: Jan 27, 2016) Page 50 EE/ME 574: Intermediate Controls Section 3.1.1 • If (−Fp)−1 is undefined, Matlab can still determine the transfer function (by carrying out the calculation of Eqn (53) symbolically, and canceling terms that go to zero). >> Fp Fp = -0.1500 0 3.1500 1.0000 0 0 -31.5000 0 -15.0000 >> inv(-Fp) Warning: Matrix is singular to working precision. ans = Inf Inf Inf Inf Inf Inf %% ss() gives an SS object Inf Inf Inf %% tf() converts to tf object >> Gtf = tf( ss(Fp, Gp, Hp, Jp) ) Transfer function: 157.5 ------------------------s^3 + 15.15 s^2 + 101.5 s EE/ME 574: Intermediate Controls 3.2 Getting a state-space model from a transfer function • The usual way to derive a state-variable model is from the basic modeling equations of the system • But it can be desirable to obtain a state variable model directly from the transfer function. One approach (used by the Matlab tf2ss() command) is to express the model in controllable canonical form. • Given a system with a transfer function u(t) y(t) • It can be considered a poles filter, A (s), and a zeros filter B (s). The two components can be arranged u(t) • If J p ∼=0, then B(s) A(s) 3.1.1 Interpreting J p • A direct transmission term corresponds to a transfer function that is not strictly proper. Section 3.2.0 1 A(s) xn(t) y(t) B(s) Figure 5: Transfer function with zeros in the output path. • If we build the number of zeros equals the number of poles. – A system matrix that produces 1/A (s), and – An output matrix that produces B (s) • In many controls situations, Jp = 0 =⇒ Then we will have a state-variable model corresponding to the transfer function B (s) /A (s). Part 4: State-Space Control (Revised: Jan 27, 2016) Page 51 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 52 EE/ME 574: Intermediate Controls Section 3.2.0 • Consider the strictly proper transfer function T (s) = • For example, T (s) = bm−1sm−1 + · · · + b1s + b0 an sn + an−1sn−1 + · · · + a1s + a0 (55) (56) • Eqn (56) comes from 1/A (s), and can be implemented on an analog computer as shown in figure 6 + . x1 .. . x3(t) x3(t) x. 2 x1 ∫ + -a2 ∫ x3(t) x. 3 x2 -a1 ∫ x3(t) x3 . x1 x. 2 x1 ∫ x. 3 x2 ∫ x3(t) x3(t) x3 ∫ -a1 -a0 (Notation follows Bay) Figure 6 (repeated). 1/A (s) constructed in phase-variable form. A TF denominator of any order can be constructed by chaining n integrators, introducing n states. ẋ1 (t) ẋ (t) = ẋ2 (t) ẋ3 (t) −a2 −a1 −a0 = 1 0 0 1 0 x2 (t) 0 x3 (t) ——– ∼ ——– u(t) 1 A(s) x1 (t) xn(t) 1 + 0 u (t) (57) 0 y(t) B(s) Figure 5 (repeated). xn (t) is generated by Eqn (57). -a0 • Looking back to figure 5, the numerator term corresponds to (Notation follows Bay) Figure 6: Realization of controllable canonical form, incorporates Phase Variable Feedback. iT h • The states in figure 6, x (t) = x1 x2 x3 , are called the “phase variables” because they are successive derivatives of xn (t). B (s) = Y (s) = b2 s 2 + b1 s + b0 Xn (s) (58) for the m = 2 case. Converting the TF, Eqn (58), back to a diff. eq., y (t) = b2 x2 (t) = ẋ3 (t) , . x3(t) • The state equation for the realization of figure 6 may be written: ˙x˙˙3 (t) = −a2 ẍ3 (t) − a1ẋ3 (t) − a0 x3 (t) + u (t) u(t) .. x3(t) x3(t) note : a3 = 1 Which can be written: x3(t) u(t) Section 3.2.0 -a2 b2 s 2 + b1 s + b0 , s 3 + a2 s 2 + a1 s + a0 ˙x˙˙3 (t) + a2 ẍ3 (t) + a1 ẋ3 (t) + a0 x3 (t) = u (t) Signal: ... Signal: • The transfer function denominator corresponds to the differential equation ... EE/ME 574: Intermediate Controls d 2 x3 (t) d 1 x3 (t) + b1 + b0 x3 (t) dt 2 dt (59) x1 (t) = ẋ2 (t) = ẍ3 (t) , and ẋ1 (t) = ẍ2 (t) = ẋ˙˙3 (t) Part 4: State-Space Control (Revised: Jan 27, 2016) Page 53 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 54 EE/ME 574: Intermediate Controls Section 3.2.0 EE/ME 574: Intermediate Controls • The output equation can be built from Eqn (59) 3.2.1 Example, state-space model from a transfer function • If the system is strictly proper, then b3 =0, and • Example y (t) = b2 ẍ3 (t) + b1 ẋ3 (t) + b0 x3 (t) (59, repeated) >> num = [2 3 4] >> den = [1 6 7 8] – But recall the state vector in phase-variable form: x1 (t) ẍ3 (t) x (t) = x2 (t) = ẋ3 (t) x3 (t) x3 (t) %% >> TF = tf(num, den) Transfer function: x1 (t) h = b2 b1 b0 h i h i y (t) = b2 b1 b0 x (t) = b2 b1 b0 x2 (t) x3 (t) – And the state model can be written: 1 −a2 −a1 −a0 x (t) + ẋ (t) = 1 0 u (t) 0 0 0 1 0 0 h i y (t) = b2 b1 b0 x (t) + [0] u (t) T(s) = i ẋ3 (t) x3 (t) b1 u(t) + . x1 ∫ . x2 x1 -a2 ∫ (61) -a1 ∫ %% a0 = 1 Obtain the tf model %% Generate the state-variable model %% in Controllable Canonical Form >> [Fp, Gp, Hp, Jp] = tf2ss(num, den) Hp = -6 1 0 -7 0 1 -8 0 0 Gp = 1 0 0 2 3 4 Jp = 0 • Compare with: x3 y (t) = -a0 (Revised: Jan 27, 2016) −a2 −a1 −a0 ẋ (t) = 1 0 h 0 1 1 0 x (t) + 0 u (t) 0 0 i b2 b1 b0 x (t) + [0] u (t) (62) • The coefficients of A (s) and B (s) are simply plugged into Fp and H p Figure 7: Strictly proper system in controllable canonical form. Part 4: State-Space Control y(t) b0 . x3 x2 (60) s3 + a2 s2 + a1 s + a0 b2 ẍ3 (t) Fp = + b2 s2 + b1 s + b0 Note 2 s^2 + 3 s + 4 --------------------s^3 + 6 s^2 + 7 s + 8 – So Eqn (59) can be written: Section 3.2.1 Page 55 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 56 EE/ME 574: Intermediate Controls Section 3.2.2 EE/ME 574: Intermediate Controls Section 3.3.0 3.3 Coordinate transformation of a state-variable model 3.2.2 One more complication • To reduce sensitivity in certain numerical computations, the ss() routine ‘balances’ the state-space realization when converting from a TF • Question: given a state variable model of a system u(t) Fp, Gp, Hp, Jp • This results in modified numerical values >> TF1 = tf( num, den) >> SS1 = ss( TF1 ) a = x1 x2 x1 -6 -1.75 x2 4 0 x3 0 1 x(t) x3 -2 0 0 b = x1 x2 x3 u1 2 0 0 d = c = y1 x1 1 x2 0.375 y(t) x3 0.5 – Is it possible to find a different realization of the model for the same system ? u(t) Fp, Gp, Hp, Jp y(t) z(t) – Is it possible to find all possible alternative realizations ? y1 u1 0 • Example of two model realizations of a given system: >> SSuy1=ss(Fp, Gp, Hp, Jp) >> SSuy2 = ss(Fp2, Gp2, Hp2, Jp2) Continuous-time model. • Compare with controllable canonical form (given by tf2ss()): – Structurally the same, but with ’balanced’ values • For EE/ME 574, the take home points are: Fp= x1 x2 x1 -4 1 x2 0 -3 Gp= u1 5 0 Fp2= x1 x1 -4 x2 0 x2 0 -3 Gp2= u1 5 5 Hp= y1 x1 0 x2 2 Jp= u1 0 Hp2= x1 y1 2 x2 -2 Jp2= u1 0 1. The state variable model is not unique. >> 2. tf2ss() gives the model in standard controllable canonical form. 3. ss() gives the model in ’balanced’ controllable canonical form. 4. tf2ss() is used in the EE/ME 574 project. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 57 tf(SSuy1) Transfer function: 10 -------------s^2 + 7 s + 12 Part 4: State-Space Control >> tf(SSuy2) Transfer function: 10 -------------s^2 + 7 s + 12 (Revised: Jan 27, 2016) Page 58 EE/ME 574: Intermediate Controls Section 3.3.1 3.3.1 Derivation of the state model transformation EE/ME 574: Intermediate Controls 3.3.2 Example: transforming a system model into modal coordinates • Starting with the voice-coil motor system model (Ra increased to have real poles in the example, method works for real or complex poles). • Starting with the state model based on state vector x (t) ẋ (t) = Fp x (t) + G p u (t) (63) y (t) = H p x (t) + J p u (t) (64) • The new state vector z (t) is related to the original by a transformation matrix T : z (t) = T x (t) (65) • We can derive a new state model based on z (t). From Eqn (65) we can solve for x (t): x (t) = T −1 z (t) (66) ẋ (t) = T −1 ż (t) (67) T −1 ż (t) = Fp T −1z (t) + G p u (t) Fp = -0.1500 1.0000 -31.5000 0 0 0 3.1500 0 -25.0000 Gp = 0 0 50 Hp = 0 1 0 Jp = 0 >> SSuy1 = ss( Fp, Gp, Hp, Jp) >> Guy1 = tf( SSuy1 ) Transfer function: 157.5 ----------------------s^3 + 25.15 s^2 + 103 s • Find the eigensystem of Fp Plugging (65)-(67) into Eqns (63) and (64) gives the state model (68) y (t) = H p T −1 z (t) + J p u (t) >> [V, U] = eig(Fp) V = 0 1.0000 0 U = 0 0 0 • Left-multiplying Eqn (68) by T gives: ż (t) = T Fp T −1 z (t) + T G p u (t) y (t) = H p T which can be rewritten as: −1 Section 3.3.2 (69) z (t) + J p u (t) 0.5303 -0.1030 -0.8415 0 -5.1483 0 -0.1567 0.0078 0.9876 0 0 -20.0017 With: (Recall: Fbp = T Fp T −1 and U = V−1 A V) • Choose cp u (t) ż (t) = Fbp z (t) + G cp z (t) + J p u (t) y (t) = H Part 4: State-Space Control (70) (71) −1 Fbp = T Fp T c Gp = T Gp cp = H p T −1 H J p : unchanged (Revised: Jan 27, 2016) (72) (73) (74) (75) Page 59 >> T = inv(V) T = 0.2428 2.5201 2.1473 Part 4: State-Space Control 1.0000 0 0 0.0306 0.3999 1.3533 (Revised: Jan 27, 2016) Page 60 EE/ME 574: Intermediate Controls Section 3.3.2 • Form the new model matrices: >> Gphat = T*Gp Gphat = 1.5295 19.9945 67.6637 And any invertible matrix T 1.2 1.2 1 1 0.6 0.4 0.4 0.2 0.2 1 cp u (t) ż (t) = Fbp z (t) + G cp z (t) + J p u (t) y (t) = H 1.5 Time (sec) 2 2.5 Fbp = T Fp T −1 cp = T G p G cp = H p T −1 H J p : unchanged 0.8 0.6 0.5 • We can construct a new realization of the system model with Step Response 1.4 Amplitude Amplitude Step Response 1.4 x (t) , Fp , G p , H p , J p ẋ (t) = Fp x (t) + G p u (t) 0.0078 >> SSuy2 = ss( Fphat, Gphat, Hphat, Jp) >> Guy2 = tf( SSuy2 ) Transfer function: 157.5 ----------------------s^3 + 25.15 s^2 + 103 s 0.8 • Given a model y (t) = H p x (t) + J p u (t) >> Hphat = Hp*inv(T) Hphat = 1.0000 -0.1030 0 Section 3.3.3 3.3.3 Summary of coordinate transformation >> Fphat = T*Fp*inv(T) Fphat = 0 -0.0000 0.0000 0 -5.1483 0.0000 0 -0.0000 -20.0017 0 EE/ME 574: Intermediate Controls 0 • The set of all possible forms for the system model is given by the set of all possible invertible matrices T . 0 0.5 1 1.5 o n cp , H cp , J p z (t) , Fbp , G 2 2.5 Time (sec) • Some forms have particular theoretical or practical interest, such as modal coordinates. Figure 8: Step response of two realizations of the voice-coil motor. • The model above and on page 60 are two model realizations for one system. • Look at the Fbp matrix. The states are decoupled. • The elements of the state vector z (t) are called the modes of the system. • The state model in the form using Fbp is called the model in modal coordinates. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 61 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 62 EE/ME 574: Intermediate Controls Section 4.0.0 4 Introducing state-feedback control EE/ME 574: Intermediate Controls 4.1 Determination of a new model with state feedback • Put in State Feedback control • To determine the state-variable model of the system with feedback, start with the open-loop model (figure 9) u (t) = −K x (t) + N f r (t) (76) – The control signal depends on the state vector and a reference input. • Putting in feedback control is illustrated in figures 9, 10 and 11. u(t) Section 4.1.0 Fp, Gp, Hp, Jp y(t) ẋ (t) = Fp x (t) + G p u (t) (11, repeated) y (t) = H p x (t) + J p u (t) (12, repeated) • Plugging the control law x(t) Figure 9: State-variable model of the open-loop system (the plant). This is the plant before feedback control is applied, u (t) as input, and y (t) as output. r’(t) r(t) Nf + u(t) x(t) + (76, repeated) into the state equation, we find ẋ (t) = Fp x (t) + G p −K x (t) + N f r (t) = Fp x (t) − G p K x (t) + G p N f r (t) y(t) Fp, Gp, Hp, Jp u (t) = −K x (t) + N f r (t) x(t) = (Fp − G p K) x (t) + G p N f r (t) -K • So we can write New System Figure 10: State-variable model of the closed-loop system with feed-forward gain in input. The closed-loop system has r (t) as input and y (t) as output. r(t) Fcl, Gcl, Hcl, Jcl New System ẋ (t) = Fcl x (t) + Gcl u (t) (77) Fcl = Fp − G p K (78) Gcl = G p N f (79) with y(t) x(t) Figure 11: State-space model of the closed-loop system, with r (t)as input and y (t) as output. • Feedback control fundamentally transforms the system. Changing the statevariable model from figure 9 to 11. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 63 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 64 EE/ME 574: Intermediate Controls Section 4.1.0 EE/ME 574: Intermediate Controls 4.2 Determining N f • Plugging the control law into the output equation, we find y (t) = H p x (t) + J p −K x (t) + N f r (t) = H p x (t) − J p K x (t) + J p N f r (t) • With state-feedback control, the model is given as: = (H p − J p K) x (t) + J p N f r (t) – So we can write y (t) = Hcl x (t) + Jcl r (t) (80) Hcl = H p − J p K (81) Jcl = J p N f (82) with • Eqns (77)-(82) describe how we determine the state-variable model of the system with feedback control. with (85) y (t) = Hcl x (t) + Jcl r (t) (86) Gcl = G p N f Hcl = H p − J p K , Jcl = J p N f • The transfer function for a state variable model was derived in Eqn (53). Applying Eqn (53) to the closed-loop system gives: Try (s) = Hcl , (s I − Fcl )−1 Gcl + Jcl = Hcl (s I − Fcl )−1 G p N f + J p N f • Evaluating Try (s = 0), the DC gain is given as: → Feedback is based on the state vector Try (s = 0) = Hcl (−Fcl )−1 G p + J p N f → There is no compensator transfer function Gc (s) ∈ Rm×n (87) • We can make the DC gain of Try (s) = 1.0 by choosing m is the number of inputs 1 Nf = Hcl (−Fcl )−1 G p + J p n is the number of states • For the voice-coil motor introduced in section 1.1: u (t) = −K x (t) + N f r (t) K = k1 k2 k3 Part 4: State-Space Control ẋ (t) = Fcl x (t) + Gcl u (t) Fcl = Fp − G p K , • State feedback control is fundamentally different from single-loop, compensated feedback: → The control gains form a vector, K Section 4.2.1 (Revised: Jan 27, 2016) (83) • Eqn (88) looks a bit complicated. But as we will see, it is straight forward to calculate. In the common case that J p = 0, Eqn (88) simplifies to (84) Nf = Page 65 (88) Part 4: State-Space Control 1 H p (−Fcl )−1 G p (Revised: Jan 27, 2016) (89) Page 66 EE/ME 574: Intermediate Controls Section 4.3.0 EE/ME 574: Intermediate Controls Section 4.3.0 4.2.1 Note on N f and SSE(step) = 0 Closed−Loop Step Response, current 1 >> figure(1), clf >> step(ss(Fcl1, Gcl1,... Hcl, Jcl), 2) • When the model knowledge is ideal, the choice for N f will give zero steady state error for step input. 0.9 0.8 Amplitude 0.7 • Practically: if the DC gain is an approximation, N f will be an approximation, and the steady state error will be greater than zero, and depend on the loop gain in the usual way. 0.6 0.5 0.4 0.3 0.2 4.3 Example system with state feedback • For a first experiment, try K = 0.1 0 0 2 5 1 , 0.5 1 1.5 2 Time (sec) Figure 12: Closed-Loop system step response. Which corresponds to u (t) = −2.0 v (t) − 5.0 z (t) − 1.0 i (t) + N f r (t) • Looking at the closed-loop poles >> K1 = [ 2 5 1] %% Determine Fcl and Hcl from K1 >> Fcl1 = Fp - Gp * K1 Fcl1 = -0.1500 1.0000 -131.5000 – First, the eigenvalues of the system matrix >> Hcl = Hp - Jp*K1 0 0 3.1500 0 -250.0000 -65.0000 %% Determine Nf1 >> Nf1 = 1 / (Hcl * inv(-Fcl1) * Gp + Jp), Hcl = 0 1 >> CLPoles = eig(Fcl1) CLPoles = -58.0841 -3.5330 + 1.0374i -3.5330 - 1.0374i Nf1 = %% Poles are eigenvalues %% of the system matrix 5 – Now using the pole command, applied to the CL system model %% Determine the rest of the CL model >> Gcl = Gp * Nf1 >> Jcl = Jp * Nf1 Gcl = 0 Jcl = 0 0 250 Part 4: State-Space Control 0 (Revised: Jan 27, 2016) >> SSry1 = ss(Fcl1, Gcl1, Hcl, Jcl); >> CLPoles = pole(SSry1) %% Poles from state model CLPoles = -58.0841 -3.5330 + 1.0374i -3.5330 - 1.0374i Page 67 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 68 EE/ME 574: Intermediate Controls Section 5.0.0 5 State-space controller design, determine K and N f • State feedback design is fundamentally different from frequency-response or root-locus design • We will see the two most common methods for state-space controller design: EE/ME 574: Intermediate Controls Section 5.1.0 5.1 State-Space Controller Design Method #1: Pole Placement (See Franklin et al. 5th ed. section 7.5) • Under very general conditions, the poles of the closed-loop system can be arbitrarily placed by proper choice of K – System has n poles (n degrees of freedom) 1. Pole placement – K has n elements (n degrees of freedom) – Design procedure: (a) Choose the desired pole locations – Original system matrix, Fp (b) Calculate K to give the desired closed-loop poles – System matrix with feedback, Fcl = Fp − G p K %% Pd is a vector of desired pole locations >> Pd = [p1, p2, p3] >> K = place(Fp, Gp, Pd); • Design procedure: 1. Choose the desired pole locations, S = (c) Calculate N f for y (t) = r (t) in steady state s1 s2 · · · sn 2. Calculate K to give the desired closed-loop poles 2. Linear Quadratic Regulator (LQR) design, a form of optimal control – Design procedure: >> K = place(Fp, Gp, S) >> K = acker(Fp, Gp, S) %% Kautsky-Nichols algorithm %% Ackerman’s formula – Mathworks recommends the Kautsky-Nichols algorithm, place(), for most cases. (a) Specify a ’cost’ function (b) Calculate the K to minimize the cost function – Ackerman’s formula may succeed for repeated roots where the Kautsky-Nichols algorithm fails. (c) Calculate N f for y (t) = r (t) in steady state • Pole placement and LQR design determine K. N f is given by Eqn (89). 3. Calculate N f for y (t) = r (t) in steady state >> Fcl = Fp - Gp * K %% Form closed-loop Syst. Mat. >> Hcl = Hp - Jp * K %% Form closed-loop Output >> Nf = 1/(Hcl*inv(-Fcl)*Gp+Jp) %% Nf for CL DC Gain = 1.0 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 69 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 70 EE/ME 574: Intermediate Controls Section 5.1.1 EE/ME 574: Intermediate Controls • Examine the closed-loop poles to be sure we got the desired poles. 5.1.1 Pole placement example %% Check the CL Poles >> CLPoles2 = eig(Fcl2) CLPoles2 = -2.0000 + 0.2000i -2.0000 - 0.2000i -2.0000 • Steps: 1. Select the desired pole locations Suggestion: do not choose repeated poles. 2. Compute the needed K using pole placement >> • Example: SSry2 = ss(Fcl2, Gp*Nf2, Hp-Jp*K2, Jp*Nf2) %% The ss command pretty prints the model a = >> DesiredPoles0 = [ -2, -2+0.2*j, -2-0.2*j] >> K2 = place(Fp, Gp, DesiredPoles0) K2 = -0.5591 0.0513 -0.1830 %% Desired poles %% K by K-N algorithm x1 x2 x3 c = >> K3 = acker(Fp, Gp, DesiredPoles0) K3 = -0.5591 0.0513 -0.1830 %% Determine CL Poles • Form a state-variable model of the closed-loop system: 3. Compute the needed N f using Eqn (89) %% K by Ack. formula y1 x1 -0.15 1 -3.544 x2 0 0 -2.565 x1 x2 x3 0 1 0 b = x3 3.15 0 -5.85 u1 0 0 2.565 x1 x2 x3 d = u1 y1 >> figure(4), clf ; >> Fcl2 = Fp - Gp * K2 Fcl2 = -0.1500 0 1.0000 0 -3.5437 -2.5651 Section 5.1.1 0 step(SSry2, 4) %% Form the CL Syst. Mat. Step Response 3.1500 0 -5.8500 1 0.9 0.8 0.7 Part 4: State-Space Control (Revised: Jan 27, 2016) Amplitude %% Determine Nf2 >> KDC0 = Hcl2 * inv(-Fcl2) * Gp + Jp KDC0 = 19.4926 %% Determine Gcl >> Nf2 = 1/KDC0 >> Gcl2 = Gp*Nf2 Nf2 = 0.0513 Gcl2 = 0 0 2.5651 0.6 0.5 0.4 0.3 0.2 0.1 0 0 0.5 1 1.5 2 2.5 3 3.5 4 Time (sec) Figure 13: Closed-Loop system with K = K2 , step response. Page 71 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 72 EE/ME 574: Intermediate Controls Section 5.1.2 5.1.2 Try pole-placement control design, twice as fast Section 5.1.2 Notes: >> DesiredPoles2b = [ -4, -4+0.2*j, -4-0.2*j] >> K2b = place(Fp, Gp, DesiredPoles2b) K2b = -0.3363 0.4074 -0.0630 >> Fcl2b = Fp - Gp * K2b Fcl2b = -0.1500 0 1.0000 0 -14.6865 -20.3683 EE/ME 574: Intermediate Controls • Pole placement will be successful, except for uncontrollable or unobservable systems – Uncontrollable or unobservable systems often require modification of the system hardware, see section 8. 3.1500 0 -11.8500 >> CLPoles2 = eig(Fcl2b) %% CL poles are eigenvalues of CL SS model CLPoles2 = -4.0000 + 0.2000i -4.0000 - 0.2000i -4.0000 >> KDC0 = Hcl * inv( -Fcl2b ) * Gp %% Determine DC gain (with Nf=1) KDC0 = 2.4548 • Pole placement can be sensitive to small variations in parameters • The pole locations relate directly to speed and damping, but not so directly to accuracy. The desired pole locations may not be obvious. >> step( ss(Fcl2b, Gp, Hcl, Jp) ) Step Response 2.5 KDC0 = 2.4548 2 Amplitude 1.5 1 0.5 0 0 0.5 1 1.5 2 Time (sec) 2.5 3 3.5 4 Figure 14: Step response of closed-loop system with K2b , real part of poles increased 2X. Note change in DCgain, N f must be re-computed whenever K is changed. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 73 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 74 EE/ME 574: Intermediate Controls Section 5.1.3 EE/ME 574: Intermediate Controls 5.1.3 Taking a look at the control effort and tracking error Section 5.1.3 >> step(SSry) >> step(SSru) >> step(SSre) • With Matlab and transfer-function modelling, we could easily set up various transfer function models Step Response, y(t) 1 0.9 %% %% %% TF: Input -> Output TF: Input -> Error TF: Input -> Control 0.8 0.7 Amplitude >> Try = feedback( Gc*Gp, Hy) >> Tre = feedback( 1, Gc*Gp*Hy) >> Tru = feedback(Gc, Gp*Hy) • Similarly, we can build state models with various outputs. For each of these models, 0.6 0.5 0.4 0.3 0.2 0.1 – The state equation remains the same 0 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 Time (sec) ẋ (t) = Fcl x (t) + Gcl r (t) Figure 15: Plot of control effort during a step response. – Only the output equation changes. Step Response, e(t) Step Response, u(t) 0.8 ∗ For output y (t) 0.7 1 0.9 −U peak 0.8 0.6 >> SSry = ss(Fcl2b, Gcl2b, Hp-Jp*K2b, Jp*Nf2b) 0.7 Amplitude 0.5 Amplitude y (t) = H p x (t) + J p u (t) = (H p − J p K) x (t) + J p N f r (t) 0.4 0.6 0.5 0.4 0.3 0.3 ∗ For control signal u (t) 0.2 0.2 0.1 u (t) = −K x (t) + N f r (t) 0 0 >> SSru = ss(Fcl2b, Gcl2b, -K2b, Nf2b) 0.1 0.5 1 1.5 2 Time (sec) 2.5 3 3.5 0 0 0.5 1 1.5 2 2.5 3 3.5 Time (sec) Figure 16: Plot of control effort during a step response. ∗ For error signal e (t) e (t) = r (t) − y (t) = r (t) − (Hcl x (t) + Jcl u (t)) = −Hcl x (t) + (1 − Jcl) r (t) >> SSre = ss(Fcl2b, Gcl2b, -Hcl, 1-Jcl) Part 4: State-Space Control (Revised: Jan 27, 2016) Page 75 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 76 4 4.5 EE/ME 574: Intermediate Controls Section 5.1.3 • We can also use the step() command to generate the response data. EE/ME 574: Intermediate Controls Section 5.2.0 5.2 State-Space Controller Design Method #2: The Linear Quadratic Regulator, an optimal control method – Determine Upeak from a state-variable model >> uu = step(SSru); >> Upeak = max(uu) Upeak = 0.7016 %% Determine the u(t) signal %% Determine the max of u(t) – The pole locations or other characteristics determine the control gains and thus the final, closed-loop performance. – Determine yss and P.O. from a state-variable model >> yy = step(SSry); >> Yss = yy(end) Yss = 1.0000 %% Determine the y(t) signal %% Determine the steady-state value >> PO = 100 * (max(yy)-Yss)/Yss PO = 0 • With other control design methods, the controls engineer selects closedloop pole locations (root locus, or pole placement) or other response characteristics (e.g, ωc and PM in frequency domain design). • Designing an LQR controller is completely different, for an LQR design, the controls engineer selects a cost function. %% Determine the PO – Linear Quadratic Regulator (LQR) controller design determines the controller gains which will minimize the cost function. – Determine the steady-state error to a step input from a state-variable model – The cost function determines the control gains and the thus final, closedloop performance. >> >> ee = step(SSre); Ess = ee(end) Ess = 1.1576e-05 %% Determine the e(t) signal %% Determine e(t) at the end %% of the transient – The controls engineer selects the cost function to achieve the design goals (more on this later). • And we can use the bode() command to address questions of frequency response >> bode(SSre) >> Etrack = 100 * bode(SSre, Wt) Part 4: State-Space Control (Revised: Jan 27, 2016) Page 77 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 78 EE/ME 574: Intermediate Controls Section 5.2.1 EE/ME 574: Intermediate Controls • An example is seen in figure 17. 5.2.1 The LQR cost function %% Zero-input response of LQR design >> Q = eye(3); R = eye(1) >> K4 = lqr(Fp, Gp, Q, R) %% LQR Design K4 = [ 0.7711 1.0000 0.7896 ] >> Fcl4 = (Fp - Gp*K4); %% Build CL model >> Sys = ss(Fcl4, [0;0;0], Hp, Jp) • A general quadratic cost function has the form: J (x, u) = Z ∞ 0 shapes : x (t)T xT (t) Q x(t) + uT (t) R u(t) + 2 ∗ xT (t) N u (t) dt Q x (t) (90) h i T + u (t) [ R][ u (t)] + 2 x (t)T N [ u (t)] • lsim() command simulates response of the system with initial cond. x (0). >> tt = 0:0.01:10; X0 = [0;1;0]; >> [y, t, x] = lsim(Sys, zeros(size(tt)), tt, X0); >> u = - K4 * x’; %% Calculate u (t) where: J (x, u) is a ’cost’ function, to be minimized. and u(t) ∈ Rm Rn×n 1 0.8 are the state and input signals. Rm×m Q∈ and R ∈ are square matrices that put weights the state and input signals, determining their contributions to the total cost. y(t) x(t) ∈ Rn Section 5.2.1 0.6 0.4 0.2 0 0 N ∈ Rn×m determines a contribution to the cost from a product of x and u. This term is often zero. 2 4 2 4 6 8 10 6 8 10 0 • First, the “regulator” case is considered, that is u(t) −0.5 −1 u (t) = −K x (t) −1.5 0 with no reference input. t [sec] – In this case, for any stable system the state and output go to zero, – The control signal goes to zero Part 4: State-Space Control (Revised: Jan 27, 2016) Page 79 Figure 17: Response of the voice-coil motor to initial condition h iT x (0) = 0 1 0 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 80 EE/ME 574: Intermediate Controls Section 5.2.1 • It turns out that for the quadratic cost function J (x, u) = Section 5.2.2 5.2.2 Designing an LQR controller xT (t) Q x(t) + uT (t) R u(t) + 2 ∗ xT (t) N u (t) dt Z ∞ 0 EE/ME 574: Intermediate Controls There is a unique value of K that minimizes the cost function for any initial condition. • This is the K given by the LQR method ! – The details of how K is computed is a subject in optimal control • Using Matlab’s lqr() function Example, starting with the voice-coil motor model: 0 Gp = 0 50 −0.15 0 3.15 Fp = 1 0 0 −31.5 0 −15 Hp = – The LQR method gives K, N f can be computed in the usual way 0 1 0 (91) J p = [0] • Choose the state-error cost matrix (the identity matrix is a good place to start): 1 0 0 Q = diag = 0 1 0 1 1 1 0 0 1 • Choose the control-effort cost matrix: R = [1] Part 4: State-Space Control (Revised: Jan 27, 2016) Page 81 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 82 EE/ME 574: Intermediate Controls Section 5.2.2 • In Matlab: >> K4a = lqr(Fp, Gp, Q, R); K4a = [ 0.7711 1.0000 0.7896 ] >> Fcl4a = Fp - Gp*K4a; Hcl4a = Hp - Jp * K4a >> KDC = Hcl4a*inv(-Fcl4a)*Gp + Jp; >> Nf4a = 1/KDC; %% Determine Nf Nf4a = 1.0000 >> Gcl4a = Gp*Nf4a; Jcl4a = Jp*Nf4a; %% Define Gcl and Jcl >> SSry = ss(Fcl4a, Gcl4a, Hcl4a, Jcl4a) %% Define SS object EE/ME 574: Intermediate Controls 5.2.3 Tuning an LQR controller • For the moment, let’s just try a different Q matrix. Lets increase the cost on position error by 100× • So choose: • Recall that the state vector is: 1 0 0 Qb = 0 100 0 , 0 0 1 v (t) Cone velocity x (t) = z (t) Cone position Winding current ia (t) • Verify the response: >> >> >> >> Section 5.2.3 subplot(2,1,1) %% Plot step response of output step(Fcl4a, Gcl4a, Hcl4a, Jcl4a) subplot(2,1,2) %% Plot step response of control effort step(Fcl4a, Gcl4a, -K4a, Nf4a) >> K4b = lqr(Fp, Gp, Qb, R) K4b = [ 2.2962 10.0000 Nf4b = 10.0 R=1 0.8744 ] Step Response 1.5 • Characteristics: Amplitude Step Response 1 (A) • Characteristics: 0.4 0.2 0 (A) 0 0 1 2 – Settling time: ts ≈ 5.0 [sec] 0 1 2 3 4 5 6 7 Time (sec) Step Response 1 3 Time (sec) 4 5 6 7 Step Response – Damping: over damped – ISE =0.85 – Upeak = 1.0 (B) 0.8 Amplitude – Settling time: ts ≈ 0.46 [sec] (much faster) 0.5 0.6 – Damping: slightly under damped (PO ~ 2%, damping reduced) – ISE =0.0022 (much lower ISE) 10 Amplitude Amplitude 0.8 1 5 (B) 0 0.6 0.4 −5 0.2 0 0 1 2 3 4 5 6 7 Time (sec) Figure 18: Step response of the closed-loop system with first LQR controller. (A) Output, (B) Control effort. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 83 0 1 2 3 Time (sec) 4 5 6 7 Figure 19: Step response of the closed-loop system with second LQR controller. (A) Output, (B) Control effort. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 84 EE/ME 574: Intermediate Controls Section 5.2.3 • By increasing the cost on the position variable, we made EE/ME 574: Intermediate Controls Section 5.2.4 5.2.4 Procedure for tuning Q and R – The position error go to zero more quickly 1. Set up the system in state space. – At the expense of a larger velocity transient and greater use of control. 2. Choose initial values for Q and R: • Identity matrices are often a good starting point • LQR design is really pretty simple: (Note: R will be a 1x1 matrix for a single input system) 1. Work with diagonal matrices 3. Adjust cost on elements of Q and R matrices to achieve design goals 2. All values must be non-negative – R matrix must be positive definite • If error is too large, increase the cost on error – Q matrix must be positive semi-definite • If overshoot is too large, increase the cost on velocity (Often some diagonal elements of Q can be zero) • If control use is too large, increase R • General idea of LQR design: ——– ∼ ——– – Increase cost on states or input that should be reduced or converge to steady state quickly • LQR design often gives a desirable controller: – Reduce cost on states or input that can be increased – Well damped (we have seen) – Make large adjustments of Q and R terms, of 10x or 100x (not 20%) – Low to moderate control usage – Examples: – Low to moderate controller gains ∗ If the system is too slow, increase cost on the position element of x. ∗ If the system has too much overshoot, increase cost on the velocity element of x ∗ If Upeak is too high, increase R – Use trial and error (a.k.a. Iterative Design) Part 4: State-Space Control – LQR-designed controllers tend to be quite robust to variations in plant parameters • By switching from tuning compensator poles and zeros and loop gain to tuning Q and R elements, one is trading one set of adjustments for another. – Which is more suitable will depend on the application and on the experience of the controls designer. (Revised: Jan 27, 2016) Page 85 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 86 EE/ME 574: Intermediate Controls Section 5.2.5 5.2.5 Further notes on choosing Q and R EE/ME 574: Intermediate Controls Section 5.2.6 5.2.6 Connection between LQR and the Symmetric Root Locus 1. R ∈ Rm×m will be a scalar if the system is single-input (m is the number of inputs). • In section 7.6 (5thed.) Franklin et al. give a method of LQR based on the symmetric root locus 2. Often choose Q and R to be diagonal matrices with positive values on the main diagonal • The method uses the cost function • Zero is OK for some diagonal elements of Q. JF (x, u) = • It is possible for Q and R to have non-zero off-diagonal elements. The requirements are: Z ∞ 0 ρ y2 (t) + u2(t) dt (92) – Q and R must be symmetric, that is Q = QT , R = RT which is equivalent to the general LQR cost function, Eqn (90), with the special choice: Q = ρ H pT H p , R=1 (93) – All eigenvalues of R must be positive (Student activity: prove this, use J p = [0].) – All eigenvalues of Q must be non-negative • The Symmetric Root Locus (SRL) theoretical result is a neat mathematical result which gives the CL poles when Q is chosen by Eqn (93). 3. The relative values of Q and R matter, not the absolute magnitude • If Q0 and R0 give K0 – LQR K can be found using the SRL by → then Q = 10 Q0 and R = 10 R0 also give K = K0 (no change). 1. Determine the CL poles by the SRL method, 2. Determine K by pole placement. • However, there is no real need to use the SRL, since we can find K directly with the lqr() command 1. Choose Q and R (possibly set Q and R by Eqn (93)) 2. Call K = lqr (Fp , G p, Q, R) Part 4: State-Space Control (Revised: Jan 27, 2016) Page 87 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 88 EE/ME 574: Intermediate Controls Section 6.1.0 EE/ME 574: Intermediate Controls 6 State-variable models with various inputs and Section 6.1.0 • The model matrices are: outputs ks M − Mb 0 Fp = 1 0 0 − Lksa 0 − RLaa • State space models give the controls engineer the freedom to make many changes or examine the model in many different ways. 6.1 Considering various inputs Hp = • We can add an input just be adding either a new column on the G matrix, or adding more G matrices. h 0 1 0 i , Gp = 0 , J p = [0] 0 1 La (position output) • Let’s suppose there are some additional inputs. As an example, we’ll consider fc (t), an external disturbance force acting on the speaker cone; and vn (t), voltage noise pickup in the wiring. Consider the voice-coil motor, the original modeling equations are: M z̈ (t) + b ż (t) = ks ia (t) 1. Determine how the new input signals enter into the original model (as always, be sure units balance). In this case: d i (t) + Ra ia (t) = va (t) − ks ż (t) La dt • fc (t) enters the equation for z̈ (t) , We wrote the SS model as: M z̈ (t) + b ż (t) = ks i (t) + fc (t) (94) ẋ (t) = Fp x (t) + G p u (t) y (t) = H p x (t) + J p u (t) with State vector : Input vector : Output vector : • And vn (t) enters the equation for d ia (t) /dt, v (t) Cone velocity x (t) = z (t) Cone position i (t) Winding current u (t) = [va (t)] [Applied Voltage] (Revised: Jan 27, 2016) Page 89 d i (t) + R i (t) = va (t) − ks ẋ (t) + vn (t) dt (95) 2. Introduce the signals into the state-variable model. Considering Eqns (94) and (95), we can write the model as: z̈ (t) ẋ (t) = ż (t) i˙a (t) y (t) = [z (t)] [Cone position] • In the original model there is a single input and a single output. Part 4: State-Space Control L − Mb 0 ks M = 1 0 0 − Lksa 0 − RLaa Part 4: State-Space Control ż (t) z (t) ia (t) 0 1 M 0 + 0 va (t)+ 0 fc (t)+ 0 vn (t) 1 1 0 La La (96) (Revised: Jan 27, 2016) Page 90 EE/ME 574: Intermediate Controls Section 6.1.0 EE/ME 574: Intermediate Controls • Eqn (96) has the form Now: ẋ (t) = Fp x (t) + Gva va (t) + G fc fc (t) + Gvn vn (t) (97) • The system matrix for feedback control is constructed: Fcl = (Fp − Gva K) – Gva reflects how control input va (t) enters the dynamic model, – G fc reflects how disturbance fc (t) enters the dynamic model, 0 Gva = 0 1 M G fc = 0 0 , 1 La , – Notice the physics of the system determining the modeling. • If we want to consider the response of the closed-loop system to a unit step of the disturbance force fc (t), then y (t) = Hcl x (t) + Jd d (t), so use 0 Gvn = 0 >> SSdy = ss(Fcl, Gfc, Hcl, Jd); 1 La – For the model in standard form, we put all input signals on u (t) and the three Gx vectors in one, 3 × 3 G p matrix. ẋ = Fpx + G pu (t) becomes: ks M − Mb 0 z̈ (t) ż (t) = 1 0 0 − Lksa 0 − RLaa i˙a (t) where 0 Gp = 0 1 La 1 M 0 0 0 , 0 1 La 1 M ż (t) 0 z (t) + 0 0 1 ia (t) La 0 and 0 va (t) fc (t) 0 1 vn (t) La v (t) a u (t) = fc (t) vn (t) (Revised: Jan 27, 2016) step( SSdy ) • If we want to consider the frequency response to voltage noise vn (t), then y (t) = Hcl x (t) + Jvn vn (t), so use >> SSvy = ss(Fcl, Gvn, Hcl, Jvn) ; bode( SSvy ) • If we want the transfer function of the open-loop system for a disturbance force input, setup Gdy = tf( ss(Fp, Gfc, Hp, Jd) ) • If we want the transfer function of the closed-loop system for a voltage noise input and control effort output, then u (t) = −K x (t) + 0 vn (t), so use >> SSvu – The system has n states and m inputs, and G p ∈ Rn×m . Part 4: State-Space Control (98) because the control signal is applied on the va (t) input. – Gvn reflects how noise vn (t) enters the dynamic model, Section 6.1.0 = ss(Fcl, Gvn, -K, 0) ; Tvu = tf( SSvu ) • And many other input/output combinations can be considered. Page 91 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 92 EE/ME 574: Intermediate Controls Section 6.1.1 6.1.1 Considering a disturbance input The most general model for a disturbance input is seen in figure 20, with ẋ (t) = (Fp − G p K) x (t) + G p N f r (t) + Gd d (t) (99) y (t) = Hcl x (t) + Jcl r (t) + Jd d (t) EE/ME 574: Intermediate Controls In the special case that the disturbance is a signal added to the plant input signal, u (t), then the block diagram looks as in figure 21. And for equations (99) to (102) Gd = G p , Jd = J p . (100) where Gd reflects the impact of disturbance d (t) on the state derivative, and will come from considering the basic physical modeling equations of the system, and Jd is the direct-transfer term between the disturbance input and the output. Section 6.1.1 d(t) r(t) r’(t) Nf + + + y(t) Fp, Gp, Hp, Jp u(t) x(t) x(t) d(t) -K r’(t) r(t) Nf + u(t) New System y(t) Fp, Ga, Hp, Jp + x(t) x(t) Figure 21: Control additive disturbance input. -K New System Figure 20: General disturbance input. Considering r (t) and d (t) together, one can write Eqns (99) and (100) in a single, standard state-variable model with: ẋ (t) = Fcl x (t) + Ga u (t) (101) y (t) = Hcl x (t) + Ja u (t) (102) where u (t) = r (t) d (t) , Part 4: State-Space Control | | Ga = G p N f Gd , | | Ja = h Jcl Jd i (Revised: Jan 27, 2016) Page 93 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 94 EE/ME 574: Intermediate Controls Section 6.2.0 6.2 Considering various outputs EE/ME 574: Intermediate Controls Section 6.2.0 6.2 Considering various outputs (continued) To consider various signals the as output, adjust the H and J matrices accordingly. For example: • If we want to consider the cone velocity, then use: Hcv = • u (t) = −K x (t) + N f r (t) so to consider the control effort as output use: Hu = −K; h 1 0 0 i Jcv = [0] • For example, to plot the step response of the cone velocity of the closed-loop voice-coil motor to an input step of an external disturbance force applied to the speaker cone, use: Ju = N f then >> SSru = ss( Fcl, Gcl, -K, Nf ) >> bode( SSru ) %% Frequency response of u(t) to input r(t) >> step( ss(Fcl, Gfc, Hcv, Jcv) ) • Important fact of state-variable modeling: • Given the state vector, if we want to consider the winding current, then use: Hi = 0 0 1 >> SSri = ss( Fcl, Gcl, Hi, Ji ) – Any signal in a linear system can be expressed as a linear combination of states and inputs. Ji = [0] %% Closed-loop system, r(t)->i(t) • For example, to plot the step response of the winding current of the open-loop voice-coil motor to an input step of applied voltage, use: %% Note open loop system matrix. >> SSvi_ol = ss(Fp, Gva, Hi, Ji) ; step( SSvi_ol) ; • To plot the step response of the winding current of the closed-loop voice-coil motor to a unit step disturbance force, use: %% Note disturbance input, Gfc, and current output >> SSfi = ss(Fcl, Gfc, Hi, Ji) ; step( SSfi ) Part 4: State-Space Control (Revised: Jan 27, 2016) Page 95 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 96 EE/ME 574: Intermediate Controls Section 6.3.0 6.3 Determining the Steady-State error for a state-variable model EE/ME 574: Intermediate Controls Section 6.3.0 System Type using Eqn (104) • For the state variable model, there is not a direct analog to the loop gain. • We can determine the system type by one of two methods: • Steady-state error is given by the final value theorem as: ess = lim e (t) = lim s E (s) = lim s t→∞ s→0 s→0 E (s) R (s) R (s) (103) 2. Count the number of zeros of the closed-loop error transfer function at the origin. For ess , what is needed is the Laplace transform of the error signal. • With a state variable model, Fcl , Gcl , Hcl , Jcl reflecting the closed-loop system, we can determine E (s) /R (s). since : e (t) = r (t) − y (t) = r (t) − (Hcl x (t) + Jcl r (t)) >> SSre = ss( Fcl, Gcl, -Hcl, (1-Jcl) ) >> Tre = tf( SSre ) sn + a • For example: – Type 0 system might give the TF Tre (s) = %% Model r(t) -> e(t) %% E(s) / R(s) bm s m + · · · + b2 s 2 + b1 s + b0 n−1 + a n−2 + · · · + a s + a n−1 s n−2 s 1 0 (104) bm s m + · · · + b2 s 2 + b1 s + b0 n−1 + a n−2 + · · · + a s + a n−1 s n−2 s 1 0 (105) sn + a bm s m + · · · + b2 s 2 + b1 s + 0 n−1 + a n−2 + · · · + a s + a n−1 s n−2 s 1 0 (106) – Type II system might give the TF Tre (s) = Then we can plug Eqn (104) into (103) and find ess . sn + a – Type I system might give the TF Tre (s) = • Writing the transfer function E (s) /R (s) as Tre (s) = 1. Count the open loop poles at the origin, that is the number of eigenvalues of Fp that are equal to zero. sn + a bm sm + · · · + b2 s2 + 0s + 0 n−1 + a n−2 + · · · + a s + a n−1 s n−2 s 1 0 (107) • Just by looking at Tre (s), we can determine the system type. • Notice Eqns (105)-(107) have a0 6= 0 – a0 = 0 corresponds to a pole of the closed-loop system at the origin. – Such a system would be marginally stable, and is rarely (if ever) encountered in practice Part 4: State-Space Control (Revised: Jan 27, 2016) Page 97 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 98 EE/ME 574: Intermediate Controls Section 6.3.0 Determining the steady-state error from Tre (s) • Considering the voice-coil motor and controller K4a , developed in section 5.2.2 lim s Tre (s) R (s) = lim s s→0 = lim s s→0 bm s m + · · · + b2 s 2 + b1 s + b0 R (s) sn + an−1 sn−1 + · · · + a1s + a0 ess = b0 a0 (108) This is logical, b0/a0 is the DC gain of Tre (s) ess = lim s s→0 b0 1 =∞ a0 s 2 (109) = lim s s→0 0 0 0 3.1500 0 -15.0000 Gp = 0 0 50 Hp = 0 1 0 Jp = 0 0.7896 ] • The model r (t) − > e (t) is obtained >> Fcl4a = Fp - Gp*K4a; Gcl4a = Gp*Nf4a ; >> Hcl4a = Hp - Jp*K4a; Jcl4a = Jp*Nf4a; %% Consider SSre for K4a >> SSre = ss(Fcl4a, Gcl4a, -Hcl4a, (1-Jcl4a)) • For a Type I system, b0 = 0 , so s→0 -0.1500 1.0000 -31.5000 K4a = [ 0.7711 1.0000 Nf4a = 1.0000 – For a ramp input, R (s) = 1/s2 , so lim s Tre (s) R (s) = lim s Fp = b0 R (s) a0 – For a step input, R (s) = 1/s, so s→0 Section 6.3.1 6.3.1 Example • For a Type 0 system, b0 6= 0 , so s→0 EE/ME 574: Intermediate Controls bm s m + · · · + b2 s 2 + b1 s + 0 R (s) n s + an−1 sn−1 + · · · + a1s + a0 b1 s + 0 b1 s R (s) = lim s R (s) s→0 a0 a0 • Determine Tre (s) – For a step input, R (s) = 1/s, so b1 s 1 =0 ess = lim s s→0 a0 s (110) – For a ramp input, R (s) = 1/s2 , so ess = lim s s→0 Part 4: State-Space Control s b1 1 b1 = a0 s 2 a0 (Revised: Jan 27, 2016) (111) Page 99 >> Tre=tf(SSre) Transfer function: s^3 + 54.63 s^2 + 228.8 s - 1.192e-13 ------------------------------------s^3 + 54.63 s^2 + 228.8 s + 157.5 – 1.192 × 10−13 ≃ 0 , system is type I Part 4: State-Space Control (Revised: Jan 27, 2016) Page 100 EE/ME 574: Intermediate Controls Section 6.3.1 Note the round-off error: Section 6.3.1 Conclusions • The TF is given as • For series compensation, we have a short cut for steady-state error based on the System Type and DC gain. Tre (s) = (−Hcl ) (sI − Fcl )−1 Gcl (112) • But SSE is defined in terms of the final value theorem, based on Tre (s), which is easily determined from the state-variable model. which evaluates to give Tre(s) = EE/ME 574: Intermediate Controls s^3 + 54.63 s^2 + 228.8 s - 1.192e-13 ------------------------------------s^3 + 54.63 s^2 + 228.8 s + 157.5 • For state-space systems, go back to the basics, and use Tre (s) to determine SSE. • With infinite precision arithmetic, the calculation would give Tre(s) = s^3 + 54.63 s^2 + 228.8 s - 0 ------------------------------------s^3 + 54.63 s^2 + 228.8 s + 157.5 • In the calculation of Eqn (112), round-off error produces the b0 = −1.192 × 10−13 term. • b0 = −1.192 × 10−13 is effectively zero. • The system is Type I • SSE (ramp) = 228.8/157.5=145% Part 4: State-Space Control (Revised: Jan 27, 2016) Page 101 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 102 EE/ME 574: Intermediate Controls Section 7.1.0 7 Integral control: augmenting the model with an EE/ME 574: Intermediate Controls • Augmenting the state vector increases the size of the F, G, H and J matrices integral control state • The PID control law is: u(t) = k pe(t) + kd ė(t) + ki Z t e(τ) dτ (113) 0 =⇒ To introduce integral control, we must add a state to the state vector • Define ie (t) = − Z t d ie (t) = y (t) − r (t) dt e(τ) dτ , or 0 (114) If ie (t) were in the state vector, we could put ki in the control vector, and we would have integral control ! • Adding a controller state, such as ie (t), results in an augmented state vector. • x p (t) h . H p .. 0 ẋa (t) = · · · xc (t) y (t) = • Integral control has an internal state (the integral of error) Section 7.1.0 Fp .. . 0 = ··· ··· ··· . Fcp .. Fcc i x p (t) ··· xc (t) Gp + ··· Gcu u (t) + · · · Gcr xa (t) + [J p] u (t) • The control signal can be written u (t) = −K p x p (t) − Kc xc (t) + N f r (t) = −Ka xa (t) + N f r (t) (117) h i where Ka = K p ... Kc is the controller gains designed for the augmented system. • Writing out the individual equations, we find where .. . x p(t) xa (t) = ... ··· xc (t) ẋ p (t) = Fp x p (t) + G p u (t) (unchanged) y (t) = H p x p (t) + J p u (t) (unchanged) • Controller state equation is: (115) ẋc (t) = Fcp x p (t) + Fcc xc (t) + Gcu u (t) + Gcr r (t) (118) Fcp determines how the controller state(s) depend on x p (t) xa (t) is the augmented state vector (the state vector of the complete system) x p (t) are the original plant states, and Fcc determines in internal dynamics of the controller state(s) Gcu is a coupling of u (t) to ẋc (t), internal to the controller Gcr is a coupling of r (t) to ẋc (t), internal to the controller xc (t) is the controller states, such as xc (t) = [ie (t)] Part 4: State-Space Control (Revised: Jan 27, 2016) Page 103 Part 4: State-Space Control r (t) (116) 7.1 Augment the state vector with controller states • We can augment the state vector with controller states, 0 (Revised: Jan 27, 2016) Page 104 EE/ME 574: Intermediate Controls Section 7.1.0 EE/ME 574: Intermediate Controls • Returning to the augmented state model, and defining . 0 Fp .. Fa = · · · · · · · · · is the augmented state transition matrix ; . Fcp .. Fcc 0 Gp Gau = · · · , Grr = · · · are the augmented input matrices; Gcr Gcu Section 7.1.0 • Writing: Gar = Gau N f + Grr = N f Gp ··· Gcu N f + Gcr (122) • Putting together Eqns (121), (120) and (122) gives the closed-loop model: ẋa (t) = Fcl xa (t) + Gar r (t) Ha = [H p , 0] is the augmented output vector (123) y (t) = Hcl xa (t) + Jcl r (t) J p is unchanged where • The augmented state model becomes: ẋa (t) = Fa xa (t) + Gau u (t) + Grr r (t) Fcl = Fa − Gau K (119) (124) Gar = Gau N f + Grr y (t) = Ha xa (t) + J p u (t) Hcl = Ha − J p K Jcl = J p N f • Using the control law: u (t) = −Ka xa (t) + N f r (t) (120) gives the closed-loop model is given as ẋa (t) = (Fa − Gau Ka ) xa (t) + Gau N f + Grr r (t) (121) y (t) = (Ha − J p Ka) xa (t) + J p N f r (t) Notes • All matrices and matrix components are the appropriate size, e.g., Fcp ∈ R1×n p if there is 1 controller state, and n p plant states. • Student exercise: determine the sizes of each element in Fa , Ga , Ha , Ja . Part 4: State-Space Control (Revised: Jan 27, 2016) Page 105 Student Exercise Part 4: State-Space Control (Revised: Jan 27, 2016) Page 106 EE/ME 574: Intermediate Controls Section 7.2.0 7.2 Block diagram of state-variable controller with xc xa (123, repeated) y (t) = Hcl xa (t) + Jcl r (t) Fp , Gp , Hp , Jp + xp ẋa (t) = Fcl xa (t) + Gar r (t) Plant Nf Section 7.3.0 • The complete system of figure 22 is encapsulated as a single state-variable model with input r (t) and output y (t) and governed by: controller states r(t) EE/ME 574: Intermediate Controls u(t) y(t) -Ka xp (t) xp(t) r(t) Plant + Controller Fcl , Gar , Ha , Jp y(t) Controller xa(t) xp xa(t) Fcc , Gx , 0, 0 Figure 23: Block diagram of the complete Plant + Controller system. Gcu xc (t) Gcr xc(t) Figure 22: Block diagram of a state-space model with controller states, such as integral control. • A block diagram for integral control is seen in figure 22. • Everything outside the plant is implemented as equations in the controller (typically a program in an embedded micro processor) x p (t) u (t) = −Ka · · · xc (t) + N f r (t) (Revised: Jan 27, 2016) xc (t) = [ie (t)] = Z t −e (t) dτ = 0 Z t (y (τ) − r (τ)) dτ , 0 nc = 1 • Assuming J p = 0, so that y (t) = H px p (t) , determine the derivative equation for the new controller state x˙c (t) = i˙e (t) = −e (t) • Comparing with Eqn (118) x˙c (t) = Fcp x p (t) + Fcc xc (t) + Gcu u (t) + Gcr r (t) • The controller has internal state xc (t) (values inside the control CPU). These are updated according to Eqn (118) Part 4: State-Space Control • Add the error integrator state (note sign, could be done either way): ẋc (t) = −e (t) = y (t) − r (t) = (H p x p (t) + J p u (t)) − r (t) = (H p − J p K p) x p (t) − J p Kc xc (t) + J p N f r (t) − r (t) = (H p − J p K p ) x p (t) − J p Kc xc (t) + −1 + J p N f r (t) (125) • The control vector Ka processes both x p (t) and xc (t) terms: 7.3 Example, integral control for the voice-coil motor Page 107 we find: Fcp = H p − J p K p , Part 4: State-Space Control Fcc = −J p Kc , Gcu = 0 , (118, repeated) Gcr = (−1 + Jcl ) (Revised: Jan 27, 2016) Page 108 Section 7.3.0 EE/ME 574: Intermediate Controls • Voice-coil motor example . Section 7.3.0 %% Now design Ka (needed to determine Nf) >> Q = diag([ 1 100 1 2]); R = 1; >> K5a = lqr(Fa, Gau, Q, R) K5a = 2.3484 10.4203 0.8772 1.4142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Voice Coil with Integral Control %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% For initial analysis, set Nf to 0 >> Nf0 = 0 >> Gar0 = [Nf0 * Gp; Nf0*Gcu + Gcr] >> SSry0 = ss( (Fa-Gau*K5a), Gar0, Ha, %% Setup Model open-loop model (Ka = [Kp, Kc] = Null) Fcp = Hp; Fcc = 0; %% Controller state terms Gcu = 0; Gcr = (-1 + Jp); %% Augmented model terms >> Fa = [Fp , [0;0;0] ; Fcp, Fcc ] >> >> >> >> Jp) • Build the error model from e (t) = r (t) − y (t) = r (t) − (Ha xa (t) + Ja r (t)) >> SSre0 = ss( (Fa-Gau*K5a), Gar0, -Ha, (1-Jp)) Step SSry0 Bode SSry0 1 Magnitude (dB) 0 >> Gau = [Gp; Gcu] >> Ha = [Hp, 0] 0.9 −50 0.8 −100 0.7 −150 Amplitude EE/ME 574: Intermediate Controls −200 0 0.6 0.5 Phase (deg) 0.4 • The augmented model is −90 0.3 −180 0.2 −270 −360 −3 10 0.1 −2 10 −1 0 10 1 10 2 10 10 0 0 3 10 10 20 Frequency (rad/sec) Ha = 0 0 0 0 1.0000 1 0 3.1500 0 -15.0000 0 0 0 0 0 0 Gau = Jp = 0 0 50 0 30 40 50 40 50 Time (sec) Figure 24: r (t) → y (t) Bode plot and step response, SSry0 Bode SSry0 0 Step SSre0 20 1 0 0.9 0.8 −20 0.7 −40 Amplitude -0.1500 1.0000 -31.5000 0 Magnitude (dB) Fa = −60 90 0.6 0.5 Phase (deg) 0.4 45 0.3 0.2 0 0.1 −45 −3 10 −2 10 −1 10 0 10 Frequency (rad/sec) 1 10 2 10 0 0 10 20 30 Time (sec) Figure 25: r (t) → e (t) Bode plot and step response of error, SSre0 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 109 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 110 Section 7.3.1 EE/ME 574: Intermediate Controls 7.3.1 Now, set N f %% Final Closed loop system >> Gar = [Nf5a * Gp; Nf5a*Gcu+Gcr] >> SSry = ss( (Fa-Gau*K5a), Gar, Ha, Jp) >> SSre = ss( (Fa-Gau*K5a), Gar, -Ha, 1-Jp) • With integral control, the closed-loop DC gain of SSry is 1.0, no matter what the value of N f (including N f = 0!) – One method to choose N f : choose N f so that ie (t) goes to zero Step SSry Magnitude (dB) Bode SSry • Examining the response of ie (t) for N f = 0 >> SSri0 = ss( Section 7.3.1 (Fa-Gau*K5a), Gar0, [0 0 0 1], 0) 50 1.4 0 1.2 −50 1 −100 Amplitude EE/ME 574: Intermediate Controls −150 0 Bode SSri0 0 −1 0 −2 0.4 −180 0.2 0 1 10 2 10 0 0 3 10 10 1 2 3 Frequency (rad/sec) −3 −40 180 4 5 6 7 8 6 7 8 Time (sec) Figure 27: r (t) → y (t) Bode plot and step response, SSry −4 −5 135 Bode SSry −6 Step SSre 50 1.2 0 1 −2 10 −1 10 0 10 Frequency (rad/sec) 1 10 2 10 −8 0 5 10 15 20 25 30 35 40 45 Time (sec) Figure 26: r (t) → ie (t) Bode plot and step response of error, SSre0 • Choose N f to make ie (t) → 0 by canceling the contributions due G p and Gcr , with Hie = 0 0 0 1 %% >> %% >> DC gain from r(t) input to ie(t), through Gcr iss1 = [0 0 0 1] * inv( -Fcl ) * [0*Gp; 0*Gcu+1*Gcr] DC gain from r(t) input to ie(t), through Gp iss2 = [0 0 0 1] * inv( -Fcl ) * [1*Gp; 1*Gcu+0*Gcr] %% Choose Nf so that Nf iss2 + iss1 = 0; >> Nf5a = - iss1/ iss2 Nf5a = 10.2975 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 111 0.8 −50 Amplitude −7 45 −3 10 Magnitude (dB) 90 −100 135 Phase (deg) Phase (deg) 0.6 −90 −270 −1 10 −20 Amplitude Magnitude (dB) 20 Phase (deg) Step SSri0 0.8 0.6 0.4 90 0.2 45 0 0 −45 −3 10 −2 10 −1 10 0 10 1 10 2 10 −0.2 0 Frequency (rad/sec) 1 2 3 4 5 Time (sec) Figure 28: r (t) → e (t) Bode plot and step response of error, SSre • Comparing figures 24 and 27, changing N f from 0 to 10.2975 1. Enormously accelerates the system 2. Introduces some overshoot. • Like any controller parameter, N f can be tuned to meet system requirements. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 112 EE/ME 574: Intermediate Controls Section 7.4.0 7.4 Summary of integral control EE/ME 574: Intermediate Controls Section 7.4.0 2. Select N f for good transient response (as given in example 7.3.1, or by trial and error, or other method) • To use a controller design with internal state(s), we augment the state vector with the controller state(s), using Eqn (119). • Integral control can significantly improve performance, especially accuracy. • Specifically, to put in integral control introduce ie (t) = − Z t e (τ) dτ , which gives 0 d d ie (t) = xc (t) = y (t) − r (t) dt dt by choosing Fcp = H p − J p K p , Fcc = −J p Kc , Gcu = 0 , Gcr = −1 + Jcl which leads to: Fa = Fp .. . 0 ··· ··· ··· Hp − Jp Kp .. . −J p Kc , G p Gau = · · · , 0 where the controller gain vector is partitioned according to Ka = N G f p Gar = · · · −1 + Jcl K p : Kc . • Control can then be designed by: 1. Determine the Ka vector by (a) LQR (b) Pole placement Part 4: State-Space Control (Revised: Jan 27, 2016) Page 113 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 114 EE/ME 574: Intermediate Controls Section 8.0.0 8 Controllability and observability EE/ME 574: Intermediate Controls Section 8.2.0 8.1 Main facts about uncontrollable or unobservable modes: • No discussion of State-Variable models would be complete without a discussion of observability and controllability (R. E. Kalman [1960, 1962]). • Even if a pole and zero cancel, the system still has that mode in its response. Challenge: if a pole and zero cancel, it means that feedback control can do nothing about the mode: • Modes correspond to energy storage elements in the system – When a pole and a zero cancel, the mode remains in the system: • Example: a pole-zero cancellation (fig 29(A)). – If the mode is unstable, feedback control cannot stabilize the system. – If the mode is slow or lightly damped, it will remain slow or lightly damped. – The mode disappears from the transfer function. – The mode - and energy storage element - remains in the system: ∗ Either the signal of the mode does not appear in the output (Unobservable, fig 29(B)); ∗ Or the input signal can’t reach the mode (Uncontrollable, fig 29(C)). – If the mode is fast and well damped: unobservability is often not a problem. uncontrollability or • How do uncontrollable or unobservable modes get excited: – Disturbances (don’t go through zeros of control input path), u(t) B(s) y(t) A(s) y(t) s+3 u(t) (s+3) (s+4) – Initial conditions, (A) System with pole-zero cancellation. – Non-linearities, etc. 1 u(t) 8.2 Definitions y(t) s+3 (s+3) (s+4) Controllable System: The system can be driven from any state, x0, to any state, x1 , by suitable choice of input signal. Equivalently, the input signal reaches each mode. (B) Unobservable system (state hidden from output) u(t) s+3 y(t) 1 Figure 29(C) shows an uncontrollable system. (s+3) (s+4) Observable System: The state x (t = 0) can be determined by observing y (t). Equivalently, the response of each mode reaches the output signal. (C) Uncontrollable system (state untouched by input) Figure 29: A pole-zero cancellation can physically occur in either the input or output path. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 115 Figure 29(B) shows an unobservable system. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 116 EE/ME 574: Intermediate Controls Section 8.3.1 EE/ME 574: Intermediate Controls 8.3 Mathematical tests: Section 8.3.2 8.3.2 Test for observability 8.3.1 Test for controllability Test 1: If the observability matrix is full rank, then the system is observable: Test 1: If the controllability matrix is full rank, then the system is controllable: C = G p Fp G p Fp2 G p · · · (n−1) Fp Gp O = (126) • System is controllable if C is full rank. • Example: −1 0 Fp = , 1 1 C = G p , Fp G p −2 Gp = 1 Hp H p Fp H p Fp2 .. . (n−2) H p Fp (127) • System is observable if O is full rank. • Example: −2 −1 0 −2 −2 2 = , = 1 1 1 1 1 −1 since the rank of C is 1 (not 2), the system is uncontrollable. −1 0 F = 1 1 H= 0 1 0 1 H 0 1 O = = = −1 0 0 1 HF 1 1 1 1 since the rank of O is 2, the system is observable. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 117 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 118 EE/ME 574: Intermediate Controls Section 8.4.0 8.4 Summary Controllability and Observability EE/ME 574: Intermediate Controls Section 8.4.1 8.4.1 Uncontrollable and unobservable modes and rocketry • The order of the system is based on the number of storage elements (or 1st order differential equations). – If a pole and zero cancel, it does not remove an energy storage element from the system: the mode is still in there. • Space launch vehicles are one type of system where controllability and observability problems arise: – Flexible structures – Restricted freedom to place sensors or actuators • Controllability and observability are properties of the system, not the controller. – There is no way to fix a controllability or observability problem by choosing a different controller. • Most often controllability or observability problems are fixed by changing (or adding) an actuator; or changing (or adding) a sensor. – The poles and zeros move around vigorously during launch, as the aerodynamic condition changes and mass changes. • Uncontrollable or unobservable modes must be very carefully considered for rocketry – Open-loop unstable mode (without control, the rocket will fall over) – Lightly damped structural modes: ∗ Can be excited by vibrations during launch ∗ Moderate oscillations can (and did!) exceed structural limits. • Controllability and observability make no sense with transfer functions. State variable models were needed to see what was going on (R.E. Kalman [1960, 1962]) Part 4: State-Space Control (Revised: Jan 27, 2016) Page 119 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 120 EE/ME 574: Intermediate Controls Section 9.0.0 9 Summary, state-variable modeling and control • State space models can be written down directly from system equations. – Often easier than transfer function modeling, since internal variables do not need to be eliminated. – When numerical values are available, the plant TF can be obtained from from the SS model >> SSuy = ss(Fp, Gp, Hp, Jp) >> Guy = tf(SSuy) EE/ME 574: Intermediate Controls Section 9.0.0 • Integral control – Any linear system can be modeled in state-variable form, including a linear plant with PID control. – Control states are appended to the state vector, giving the augmented state vector. – The Fa , Ga and Ha matrices are produced as expected. – Integral control can be designed with standard tools, e.g., the lqr() command. • State-variable modeling • Observability and Controllability – A state-variable model is nothing other than a collection of modeling equations stacked up in matrix-vector form. – State-variable models have units. – We can easily represent a variety of different input or output configurations, by writing the corresponding Gx (for inputs) and Hx and Jx (for outputs). – Unobservable and uncontrollable modes arise when poles and zeros cancel. – The cancellation is mathematical, the energy storage elements remain in the system. – Observability and controllability are intrinsic properties of the system, independent of the way it is modelled. • Controller Design – We have seen two state feedback control design methods: – Observability and controllability are easily determined with a statevariable model. 1. Pole placement 2. The linear quadratic regulator (LQR design) – Pole placement design may result in very high controller gains. – LQR design gives fast, well damped control in many situations. Part 4: State-Space Control (Revised: Jan 27, 2016) Page 121 Part 4: State-Space Control (Revised: Jan 27, 2016) Page 122 EE/ME 574: Intermediate Controls EE/ME 574: Intermediate Controls Discrete-Time Control Systems, the basis of Computer Control 3.2.1 3.2.2 3.2.3 Contents 1 Introduction, big picture of discrete control 1.1 Doing signal processing with sampled signals . . . . . . . . . 1.2 Connecting a controller computer to the continuous-time world 1.2.1 Converting from an analog signal to a sampled signal . 1.2.2 Converting a sampled signal back to an analog signal . 1.3 Building a control system with a discrete-time controller . . . 1.4 Terminology and synonyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 6 10 11 13 14 15 2 Introduction to the Z-transform 2.1 Recall, for continuous-time systems: . . . . . . . . . . . . . . . . 2.2 The Z-transform . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.1 Definition of the Z-transform and table of Z-transform pairs 2.2.2 Z-transform gives transfer function of a difference equation 2.2.3 Essential properties of a Z-domain transfer function . . . . 2.2.4 Discrete final value theorem . . . . . . . . . . . . . . . . 2.2.5 Time shifting, one extra bit of nuisance: . . . . . . . . . . 2.3 Discrete system / Z-transform example . . . . . . . . . . . . . . . 2.3.1 Nyquist frequency . . . . . . . . . . . . . . . . . . . . . 2.3.2 Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4 Conclusions on z-transform . . . . . . . . . . . . . . . . . . . . . 16 16 18 19 20 21 22 23 25 27 27 29 3 Interpretation of pole locations on the Z-plane 3.1 Examining Z-domain poles by example . . . . . . . . . 3.1.1 Real poles . . . . . . . . . . . . . . . . . . . . 3.1.2 Complex pole pairs . . . . . . . . . . . . . . . 3.2 Determining the frequency and damping of Z-plane poles 30 30 30 32 34 Part 5: Z-Transform and discrete control . . . . . . . . . . . . (Revised: Feb 13, 2013) . . . . . . . . Page 1 Matched s-plane and Z-plane poles . . . . . . . . . . . . Pictoral examples of matched pole pairs . . . . . . . . . Example, determining ωn and ρ for Z-plane poles . . . . . 34 35 39 4 Converting between continuous and discrete systems 4.1 Determining G pz (z) , the z-transform of G p (s) . . . . . . . . . . 4.1.1 Discrete control example . . . . . . . . . . . . . . . . . 40 40 42 5 Compensator design by discrete equivalent TF 5.1 Matlab’s c2d() command . . . . . . . . . . . . . . . . . . . . . 5.1.1 Why 6 different design methods . . . . . . . . . . . . . . 5.2 Tustin’s rule to find Gcz (z) that approximates Gcs (s) . . . . . . . 5.2.1 Deriving Tustin’s rule . . . . . . . . . . . . . . . . . . . 5.2.2 Example with Tustin’s rule . . . . . . . . . . . . . . . . 5.2.3 Example controller design by discrete equivalent, done by hand . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4 Example controller design by discrete equivalent, using Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 50 52 53 53 55 6 DC Gain, Steady State Error and Complex Gain 6.1 DC Gain . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2 Steady-State error . . . . . . . . . . . . . . . . . . . . . . . 6.2.1 Determining steady-state error from Trez (z) (or Tre (s)) 6.3 Complex gain from a discrete TF . . . . . . . . . . . . . . . 7 Conclusion Part 5: Z-Transform and discrete control . . . . . . . . 57 60 65 65 67 67 71 72 (Revised: Feb 13, 2013) Page 2 EE/ME 574: Intermediate Controls Section 1.0.0 1 Introduction, big picture of discrete control EE/ME 574: Intermediate Controls Section 1.0.0 • Computer control brings a fundamental change to the nature of signals − Analog control (Op Amps, capacitors, etc). operate on analog signals • A basic control loop is illustrated in figure 1. 1 The controller is represented by Gc (s). So far we haven’t talked about how controllers are actually built. 0.5 Trajectory Generation r(t) + Process under control f(t) Controller 0 e(t) Controller Plant u(t) Gc(s) y(t) Gp(s) - −0.5 0 2 4 6 8 10 t [sec] Sensor Figure 2: An analog signal, f (t) = e−αt sin (ωt). Hy(s) Figure 1: Basic control loop. The Controller comprises the compensator, Gc (s), and may include trajectory generation, generating r (t), and other elements. • How controllers are actually built There are two broad approaches 1. Analog (e.g., Op Amps, capacitors and inductors, or pneumatics) 0 1 k= 2 .. . 0.0000 0.6113 f (k) = 0.7258 .. . 0.0 0.8 = tk = 1.6 .. . 0 τs 1 τs 2 τs .. . • When a sampled system is connected to a continuous system, two special pieces of hardware are needed, 2. Discrete or sampled (by computer) • Today the vast majority of controllers are sampled − An A/D converter, and a D/A converter − Process control, oil refineries, computer controlled in the 1960’s with ’mini’ computers − Machine tools / robotics, computer controlled in the 1970’s Continuous Signal f(t) − Aviation, computer controlled in the 1980’s Sampled Signal f(k) Sampled Signal Continuous Signal g(t) g(k) ZOH tk = k Ts − Today, virtually all control (car engines, building environment, ...) is implemented by computer Part 5: Z-Transform and discrete control − Computers operate on discrete sequences of numbers, or samples, of sampled signals (Revised: Feb 13, 2013) Page 3 (A/D Converter) (D/A Converter) Figure 3: Block diagrams for A/D and D/A converts. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 4 EE/ME 574: Intermediate Controls Section 1.0.0 • A sampled signal can be represented graphically by a stem plot, as seen in figure 4. EE/ME 574: Intermediate Controls 1.1 Doing signal processing with sampled signals Controller Gc(z) e(k) >> >> >> >> Ts = 0.8 td = 0:Ts:10; fd = exp(-alpha*td) .* sin(omega*td); stem(td, fd) 1 0.5 0.5 • A continuous signal is a wave-form, such as u (t). A sampled signal is a sequence of numbers, such as u (k). Examples: 0 −0.5 0 −0.5 2 4 6 8 k [sample] 10 12 14 (a) f (k) 0 0 1 Ts t (k) = 2 Ts .. . s f(k) 0 u(k) Figure 5: Block implementing Gc (z), the compensator in a computer. f(k T ) 1 Section 1.1.0 2 4 6 8 10 t [sec] (b) f (k Ts ) , 0.0000 0.6113 e (k) = 0.7258 .. . , ? u (k) = .. . how can we do signal processing to create a new sampled signal ? • Sampled signals are processed using difference equations. Figure 4: A stem plot showing a sampled signal, (a) versus k (which is what the computer knows), (b) versus tk (which relates to the analog world). • Figure 4 shows something basic about sampled signals: − In a difference equation, the output is given by sums and differences of samples. For example: u (k) = −a1 u (k − 1)− a2 u (k − 2)+b0 e (k) +b1 e (k − 1)+· · · (1) A sampled signal is only defined at the sample instants. • At each sample k, the output is calculated as a combination of − The input, e (k) − Past inputs, e (k − 1) , e (k − 2)... − Past output, u (k − 1) , u (k − 2) ... Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 5 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 6 EE/ME 574: Intermediate Controls Section 1.1.0 EE/ME 574: Intermediate Controls • Difference equation example: • A difference equation is linear. For example, if e (k) is doubled, u (k) is doubled. u (k) = 0.8 u (k − 1) + 0.1 e (k) + 0.1 e (k − 1) (2) u (k) = 0.8 u (k − 1) + 0.1 e (k) + 0.1 e (k − 1) . • Impulse response, an digital impulsive signal has e (0) = 1 , e (1, 2 ...) = 0 . k 1 2 3 4 e(k-1) 0 1 0 0 Section 1.1.0 e(k) 1 0 0 0 u(k-1) 0 0.1 0.180 0.144 u(k) 0.100 0.180 0.144 0.115 k 1 2 e(k-1) 0 2 e(k) 2 0 (2, repeated) u(k-1) 0 0.2 u(k) 0.200 0.360 ... • Since difference equations are linear, a sampled sinusoidal input gives a sampled sinusoidal output. For example, t (k) = k Ts = 0.8 k , e (k) = 1.0 sin (0.75 t (k)) (Ts = 0.8 seconds) u (k) = 0.338 sin (0.75t (k) − 70.2o) 0.2 0.16 0.14 u(k) e(k) 0.12 0.1 0.08 0.06 1 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 −0.2 −0.4 −0.4 −0.6 −0.6 −0.8 −1 0 0.02 5 10 t [seconds] 15 20 (a) Signal e (k) = 1.0 sin (0.75t) 5 10 0 −0.2 −0.8 0.04 0 0 1 0.8 u(k) 0.18 −1 0 5 10 t [seconds] 15 20 (b) u (k): output of Gc1 (z) 15 k Figure 6: Stem plot of the impulse response of difference Eqn (2). Notice the exponential decay. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) • The new magnitude and phase are determined by: >> >> >> >> Page 7 Ts = 0.8; Num = [0.1 0.1]; Den = [1 -0.8]; Gc1z = tf(Num, Den, Ts) [Mag, Phase] = bode(Gc1z, 0.75) Mag = 0.3380 Phase = -70.2421 Part 5: Z-Transform and discrete control %% Setup model %% Calc Mag and Phase %% With bode command (Revised: Feb 13, 2013) Page 8 EE/ME 574: Intermediate Controls Section 1.1.0 − Specifically, since a sinusoidal input gives a sinusoidal output world • We can make a bode plot of Gc1 (z), which plots the magnitude and phase of the output for sinusoidal inputs. 10 • To use digital control, the controller computer has to receive inputs from sensors, and supply outputs to actuators. • A typical configuration is seen in figure 8. 0 Gain dB Section 1.2.0 1.2 Connecting a controller computer to the continuous-time • Since the difference equation is linear −10 − The sensor itself is analog (such as a pressure sensor). The analog sensor signal y (t) is converted to a digital signal y (k) by an A/D converter. (An Analog To Digital converter) −20 −30 −40 −50 −2 10 −1 10 0 10 1 10 0 Phase [deg] EE/ME 574: Intermediate Controls − The computer command, u (k), is converted from a digital signal by a D/A converter. (A Digital To Analog converter) ∗ The D/A converter implements a “Zero-Order Hold” (ZOH), which must be modelled in the control loop (more later). −30 −60 Discrete part, Computer Controller −90 −2 10 −1 0 10 10 Frequency [radians/second] 1 10 r(k) Trajectory Generator + e(k) Figure 7: Bode plot for difference equation (2). Eqn (2) gives a low-pass filter. ys(t) ys(k) Kc Gc(z) u(k) - ZOH (D/A Conv.) u(t) Plant y(t) Gp(s) t=kTs (A/D Conv.) >> Gc1z = tf(Num, Den, Ts) >> bode(Gc1z) Sensor %% %% %% Hy(s) Ts = 0.8 [seconds] Fs = 1.25 [Hz] Fnyquist = Fs/2 = 0.625 [Hz] Analog part Figure 8: Configuration of basic computer control. Sensor signals are prepared for the computer by Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 9 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 10 EE/ME 574: Intermediate Controls Section 1.2.1 EE/ME 574: Intermediate Controls Section 1.2.1 − Voice is sampled at 8 bits, 8,000 samples per second 1.2.1 Converting from an analog signal to a sampled signal • This is the job of the A/D converter. The sampled signal is defined only at the sampling instants. − One voice channel on a telephone trunk line is 64,000 bits per second (uncompressed) 1 0.5 y(k) tk = k Ts f(k Ts) y(t) (A/D Converter) 0 −0.5 0 2 4 6 8 10 t [sec] Figure 9: Sampling, converting from y (t) to y (k). • A/D converters are defined by − A range, such as e (t) = −10..10 [volts] − A resolution, normally in bits, such as 8 bit, 10 bit, 16 bit. − A maximum speed, GSamples/second such as 100k samples/second, up to 1 • Example: telephone − Today essentially all telephone exchanges are digital Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 11 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 12 EE/ME 574: Intermediate Controls Section 1.2.2 EE/ME 574: Intermediate Controls Section 1.3.0 1.3 Building a control system with a discrete-time controller 1.2.2 Converting a sampled signal back to an analog signal • If we are going to control continuous-time equipment, we need to convert u (k) back into u (t) • This is the job of the D/A converter. The output signal is u (t), defined at all instants. 1 • Most control systems comprise a discrete-time part (the controller) and a continuous-time part (the thing being controlled), figure 11. − The computer controller implements Gc (z), a difference equation − The plant is governed by differential equations − The two pieces are joined together by an A/D and a D/A u(k) u(t) Discrete part, Computer Controller 0.5 ZOH Trajectory Generator f(t) (D/A Converter) r(k) + e(k) 0 ys(t) ys(k) Kc Gc(z) u(k) - ZOH (D/A Conv.) u(t) Plant y(t) Gp(s) t=kTs (A/D Conv.) −0.5 0 2 4 6 8 10 t [sec] Sensor Hy(s) Figure 10: Sampling, converting a signal from u (k) to u (t) with zero-order hold. Analog part • The Zero-Order-Hold (ZOH) Figure 11: System with sampled control. − A level u (k) is given at t = tk = k Ts Broad approach to design and analysis: − The ZOH has a hold circuit (Op Amp + capacitor) that holds the signal until u (k + 1) arrives. Z-transform. (Analogous to the Laplace transform) • D/A converters are defined by 2. Convert Ys (s) /U (s) to discrete-time (including the zero-order hold), to analyze the complete discrete-time system. − A range, such as u (k) = −10..10 [volts] − A resolution, normally in bits, such as 8 bit, 10 bit, 16 bit. − A maximum speed, such as 100 kS/sec, up to 1 GS/second 3. Obtain the digital compensator, Gc (z) by: • Example: telephone (a) Discrete Equivalent Design: design Gc (s), convert to discrete-time, − At the phone switch, a D/A converter converts 8,000 8-bit samples per second to an analog signal, which goes out on the local subscriber line. Part 5: Z-Transform and discrete control 1. Develop transform method to analyze discrete-time system, the (Revised: Feb 13, 2013) Page 13 or (b) Direct Digital Design: directly design Gc (z) based on discrete-time analysis. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 14 EE/ME 574: Intermediate Controls Section 1.4.0 EE/ME 574: Intermediate Controls Section 2.1.0 2 Introduction to the Z-transform 1.4 Terminology and synonyms • Discrete-time systems • The Z-transform can be understood by analogy with the Laplace transform for continuous-time systems. − Digital control − Discrete system 2.1 Recall, for continuous-time systems: − Sampled system • Consider a controller with an input e (t) and an output u (t) − z-domain system input e(t) • Sampled signals − Discrete-time signal Controller output u(t) Figure 12: System with input and output. − Discrete signal − Digital signal • Continuous signals are functions of time, such as e (t) and u (t). − z-domain signal • Continuous time systems are governed by differential equations, such as • Continuous-time systems ü (t) + a1 u̇ (t) + a2 u (t) = bo ë (t) + b1 ė (t) + b2 e (t) − Analog system − s-domain system (3) • For continuous equations, the highest derivative of the output is given by: − The lower derivatives of the output, and − The input and derivatives of the input ü (t) = −a1 u̇ (t) − a2u (t) + bo ë (t) + b1 ė (t) + b2 e (t) Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 15 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) (4) Page 16 EE/ME 574: Intermediate Controls Section 2.1.0 2.1 Recall, for continuous-time systems (continued) L =⇒ L {u (t)} = Z ∞ 0− e−st u (t) dt = U (s) (5) if v (t) = 3 y (t) → V (s) = 3Y (s) 2. Superposition • For the controls engineer, the transfer function is the value proposition − As we’ve seen, the control’s engineer rarely forms the Laplace transform of a signal, or inverse Laplace Transform of U (s) − The transfer function enables us to study the properties of systems without solving differential equations. • The essential properties of the Laplace Transform are: 1. Scaling Section 2.2.0 2.1 Recall, for continuous-time systems (continued) • The Laplace transform is a transform between a time-domain signal and a function of s u (t) EE/ME 574: Intermediate Controls if v (t) = y (t) + u (t) → V (s) = Y (s) +U (s) − The transfer function is the reason we use Laplace transforms in the analysis of control systems. 3. It handles derivatives nicely: 2.2 The Z-transform L Given: L y (t) =⇒ Y (s) then ẏ (t) =⇒ sY (s) • The Z-transform is a transformation between a sampled time-domain signal and a function of z : • Properties 1, 2 and 3 enable us to define the transfer function, given y (k) Z → ∞ Z {y (k)} = ∑ u (k) z−k = Y (z) (8) k=0 ü (t) + a1 u̇ (t) + a2 u (t) = bo ë (t) + b1 ė (t) + b2 e (t) • As one would expect, the important properties of the Z-transform are: U (s) s2 + a1 s + a2 = E (s) b0 s2 + b1 s + b2 2. Superposition (6) Forward : s2 + b U (s) b0 1 s + b2 = 2 E (s) s + a1 s + a2 (Revised: Feb 13, 2013) if v (k) = y (k) + u (k) → V (z) = Y (z) +U (z) 3. It handles time shifts: • And obtain the transfer function Part 5: Z-Transform and discrete control if v (k) = 3 y (k) → V (z) = 3Y (z) 1. Scaling • We can form the Laplace transform of the left and right sides (7) and Backward : Page 17 Z {y (k + 1)} = z Z {y (k)} = zY (z) Z {y (k − 1)} = z−1 Z {y (k)} = z−1 Y (z) Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 18 EE/ME 574: Intermediate Controls Section 2.2.1 EE/ME 574: Intermediate Controls 2.2.1 Definition of the Z-transform and table of Z-transform pairs 2.2.2 Z-transform gives transfer function of a difference equation 1. Starting with difference equation (10) • The one-sided Z-transform is defined by: ∞ Z { f (k) } = F (z) = Section 2.2.2 ∑ f (k) z−k u (k) + a1 u (k − 1) + a2 u (k − 2) = (9) (10) k=0 bo e (k) + b1 e (k − 1) + b2 e (k − 2) − Like the Laplace transform integrals, Eqn (9) is not often used directly by the controls engineer. 2. Taking the Z-transform of the each term gives: − What is important is properties (1) - (3) above, because they allow one to define the transfer function of a difference equation. Z {u (k)} + Z {a1 u (k − 1)} + Z {a2 u (k − 2)} = (11) Z {bo e (k)} + Z {b1 e (k − 1)} + Z {b2 e (k − 2)} • Some Z-transform pairs are given in table 1. 3. Now applying the scaling and time-shift properties of the Z-transform: Signal Impulse Z-transform, t (k) = k Ts Laplace transform f (t) = δ (t) F (s) = 1 f (k) = 1 Z {u (k)} + a1 z−1 Z {u (k)} + a2 z−2 Z {u (k)} = F (z) = 1 b0 Z {e (k)} + b1 z−1 Z {e (k)} + b2 z−2 Z {e (k)} 0 , otherwise Step f (t) = 1+ (t) Ramp f (t) = t Exp. Decay f (t) = e−at F (s) = 1 s F (s) = 1 s2 f (k) = k Ts , k ≥ 0 F (z) = Ts z (z−1)2 1 s+a f (k) = e−a k Ts F (z) = z z−e−a Ts F (s) = Sine f (t) = sin (ωt) F (s) = a s2 +a2 Cosine f (t) = cos (ωt) F (s) = s s2 +a2 f (k) = 1 , k ≥ 0 F (z) = f (k) = sin (ω k Ts ) F (z) = z sin(ω Ts ) z2 −2 cos(ω Ts ) z+1 f (k) = cos (ω k Ts ) F (z) = z(z−cos(ω Ts )) z2 −2 cos(ω Ts ) z+1 Table 1: Laplace and Z-transform transform pairs Part 5: Z-Transform and discrete control z z−1 (Revised: Feb 13, 2013) Page 19 (12) which gives: U (z) 1 + a1 z−1 + a2 z−2 = E (z) b0 + b1 z−1 + b2 z−2 (13) and finally: U (z) b0 + b1 z−1 + b2 z−2 bo z2 + b1 z + b2 = = 2 E (z) 1 + a1 z−1 + a2 z−2 z + a1 z + a2 (14) • Eqn (14) is the Transfer Function of Eqn (10) • The steps of forming a discrete transfer function, Eqns (10) to (14), are entirely analogous to the steps of forming a continuous transfer function. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 20 EE/ME 574: Intermediate Controls Section 2.2.3 2.2.3 Essential properties of a Z-domain transfer function EE/ME 574: Intermediate Controls Section 2.2.4 2.2.4 Discrete final value theorem The essential properties of a discrete transfer function are also analogous to the properties of the continuous transfer function. Given: • The final value theorem for the z-transform is: lim x (k) = xss = lim 1 − z−1 X (z) (15) (16) z→1 k→∞ U (z) bo z2 + b1 z + b2 = 2 Gc (z) = E (z) z + a1 z + a2 − Steady-state error applies ! • All information about the system is captured in the transfer function, Gc (z) − Gc (z) is a rational polynomial of constants, − Example, final value of u (k) with Gc1 (z) and e (k) given by a unit step U (z) E (z) lim u (k) = lim 1 − z−1 U (z) = lim 1 − z−1 z→1 z→1 E (z) k→∞ − It is independent of the particular input and output signals. (17) − Since e (k) is a unit step, E (z) = z/ (z − 1) , and so • The Discrete Transfer Function has poles and zeros 0.1 z + 0.1 z lim u (k) = lim 1 − z−1 z→1 k→∞ z − 0.8 z − 1 − They are the roots of the denominator and numerator polynomials − The poles correspond to the modes. − Notice that − We can test the poles for stability − Root locus applies ! (But special interpretation is needed for pole locations on the Z-plane) z−1 1 = 1 − z−1 = 1 − z z (18) (19) Giving lim u (k) = lim k→∞ z→1 z−1 z 0.1 z + 0.1 0.1 z + 0.1 z = lim z − 0.8 z − 1 z→1 z − 0.8 • Example, considering the difference equation (2), − Finally u (k) = 0.8 u (k − 1) + 0.1 e (k) + 0.1 e (k − 1) (2, repeated) lim u (k) = lim k→∞ 0.1 z + 0.1 = 1.0 z − 0.8 The final value of u (k) with e (k) = 1+ (k) is u (k) = 1.0 Then Gc1 (z) = Pole: z = 0.8 , z→1 U (z) 0.1 + 0.1 z−1 0.1 z + 0.1 = = E (z) 1 − 0.8 z−1 z − 0.8 − Notice the analogy between the cancellation in Eqn (19) and the cancellation in: U (s) 1 lim u (t) = lim s t→∞ s→0 E (s) s Zero: z = −1. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 21 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 22 EE/ME 574: Intermediate Controls Section 2.2.5 EE/ME 574: Intermediate Controls 2.2.5 Time shifting, one extra bit of nuisance: Section 2.2.5 Conclusion on time shifting • Consider the difference equation u (k) = +1.6 u (k − 1) − 0.68 u (k − 2) + 0.4 e (k) − 0.28 e (k − 1) + 0.048 e (k − 2) u (k) = +1.6 u (k − 1) − 0.68 u (k − 2) + 0.4 e (k) − 0.28 e (k − 1) + 0.048 e (k − 2) (20) (Eqn 20, repeated) • We can also write the difference equation directly from Eqn (22) • Gives the Z-transform: − Remembering that z2U (z) −1 −2 −1 → u (k + 2) = +1.6 u (k + 1) − 0.68 u (k) + 0.4 e (k + 2) − 0.28 e (k + 1) + 0.048 e (k) (24) • If difference Eqn (20) is true for all k, then difference Eqn (24) is likewise true for all k. U (z) 0.4 − 0.28 z−1 + 0.048 z−2 = = Geuz (z) E (z) 1 − 1.6 z−1 + 0.68 z−2 • This is analogous to saying, • But we work with poles and zeros of the TF written with z, so clear the z−n: Gc (z) = U (z) b0 + b1 z−1 + b2 z−2 = E (z) 1 + a1 z−1 + a2 z−2 bo z 2 + b1 z + b2 z2 = z2 z 2 + a1 z + a2 = u (k + 2), Eqn (22) becomes: −2 U (z) − 1.6 z U (z) + 0.68 z U (z) = 0.4 E (z) − 0.28 z E (z) + 0.048 z E (z) U (z) 1 − 1.6 z−1 + 0.68 z−2 = E (z) 0.4 − 0.28 z−1 + 0.048 z−2 • And so: Z −1 z2 Gc (z) z2 (21) • In a sense, the distinction between Eqns (20) and (24) lies is the definition of k. • So we have to shift back and forth between two forms of the TF: − We normally set up the difference equation to compute u (k), 0.4 z2 − 0.28 z + 0.048 Gc (z) = z2 − 1.6 z + 0.68 Gc (z) = 0.4 − 0.28 z−1 + 0.048 z−2 1 − 1.6 z−1 + 0.68 z−2 For analysis (22) For implementation (23) − In some cases we might compute u (k + 1). For example, if output u (k) depends only on values up to e (k − 1), in this case we might set up the the difference equation ∗ To compute u (k + 1) based on e (k) (pre-computing) ∗ Rather than computing u (k) based on e (k − 1). • Eqns (22) and (23) are the two forms of the same TF. • In general, we can time-shift the difference equation as needed − The TF in the form of Eqn (23) gives the Diff Eqn (20) Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 23 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 24 EE/ME 574: Intermediate Controls Section 2.3.0 EE/ME 574: Intermediate Controls 2.3 Discrete system / Z-transform example Section 2.3.0 Step response from Eqn () 2.4 2.2 • A TF model of the difference equation is setup with the tf() command, including a value for ts . >> figure(1), clf >> step(Guez); >> grid on 2 1.8 1.6 Amplitude • Starting with the difference equation, and Fs = 20 [samples/second] 1.4 1.2 u (k) = +1.6 u (k − 1)−0.68 u (k − 2)+0.4 e (k)−0.28 e (k − 1)+0.048 e (k − 2) 1 0.8 • Setup the TF with the Matlab code: 0.6 0.4 0 0.5 1 1.5 Time (sec) >> Fs = 20; Ts = 1/Fs; >> Num = [0.4 -0.28 0.048] >> Den = [1 -1.6 +0.68] >> Geuz = tf(Num, Den, Ts) %% %% %% %% Figure 13: Discrete step response of first example system. Set the sample rate, often convenient to set Fs Set the Num and Den polynomials Setup the TF • We can also determine the frequency response Bode Diagram 0.4 z^2 - 0.28 z + 0.048 -----------------------z^2 - 1.6 z + 0.68 20 15 Magnitude (dB) Transfer function: >> figure(2), clf >> bode(Geuz) 10 5 Sampling time: 0.05 0 90 45 Phase (deg) • Printing “Sample time” indicates that the TF is discrete-time. 0 −45 −90 −135 −180 −2 10 + −1 10 0 10 Frequency (rad/sec) 1 10 Figure 14: Discrete step response. Note the Nyquist frequency limit at 10 Hz (62.8 [rad/sec]), from Fs = 20 [samples/sec]. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 25 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 26 2 10 EE/ME 574: Intermediate Controls Section 2.3.2 EE/ME 574: Intermediate Controls Section 2.3.2 • Pay attention to get the numerator powers correct, when multiplying by zn/zn to convert between analysis form and implementation form. 2.3.1 Nyquist frequency • In a sampled system, the Nyquist frequency highest frequency sinusoidal signal that can be uniquely determined. It is given by: FNyquist = 1 Fs 2 (25) • Example: CD music format: Fs = 44, 000 [samples/sec] FNyq = 22, 000 [Hz] • Matlab draws the discrete Bode plot up to the Nyquist frequency. 2.3.2 Tips • Notice the ’-’ signs in the denominator − The difference equation u (k) = +1.6 u (k − 1) − 0.68 u (k − 2) +0.4 e (k) − 0.28 e (k − 1) + 0.048 e (k − 2) − Gives the TF Geuz (z) = 0.4 z2 − 0.28 z + 0.048 U (z) = E (z) z2 − 1.6 z + 0.68 • Pay attention to the minus signs in the denominator; the +ai terms in the TF are −ai terms in the implementation equation. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 27 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 28 EE/ME 574: Intermediate Controls Section 2.4.0 EE/ME 574: Intermediate Controls Section 3.1.1 3 Interpretation of pole locations on the Z-plane 2.4 Conclusions on z-transform • Starting with the difference equation • Discrete time systems are implemented as difference equations u (k) = −a1 u (k − 1) − a2 u (k − 2) • The z-transform gives us the z-domain transfer function, such as Gc (z) (26) +bo e (k) + b1 e (k − 1) + b2 e (k − 2) We get the TF − Gc (z) can be obtained directly from the difference equation Geuz (z) = − Gc (z) is a rational polynomial, and has poles and zeros U (z) bo z2 + b1 z + b2 = 2 E (z) z + a1 z + a2 (27) • The poles are the roots of • Commands such as tf(), step(), and bode() operate with discrete as well as continuous transfer functions. z 2 + a1 z + a2 = 0 • It is the feedback of past outputs to the current output that determines stability, that is, the poles of G (z). 3.1 Examining Z-domain poles by example 3.1.1 Real poles u (k) = 0.8 u (k − 1) + e (k) , • Consider 1 Gc (z) = z z − 0.8 1.5 0.9 Unit Circle 1 0.8 0.7 0.5 Imaginary u(k) 0.6 0.5 0.4 0 −0.5 0.3 0.2 −1 0.1 0 0 2 4 6 k [sample] 8 10 12 −1.5 −1.5 −1 −0.5 0 Real 0.5 1 1.5 Figure 15: Impulse response and pole-zero map. − Pole at z1 = +0.8 , yet the system is stable. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 29 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 30 EE/ME 574: Intermediate Controls Section 3.1.1 • Now consider EE/ME 574: Intermediate Controls Section 3.1.2 3.1.2 Complex pole pairs Gc (z) = u (k) = 1.1 u (k − 1) + e (k) , 3.5 z z − 1.1 • Consider a system with a complex pole pair 3 • This system has pole pair at: 0.5 Imaginary u(k) 1.5 z2 z2 − 1.6 z + 0.8 Unit Circle 1 2.5 2 Gc (z) = u (k) = 1.6 u (k − 1) − 0.8 u (k − 2) + e (k) , 1.5 0 z1,2 = 0.8 ± j 0.4 = 0.89∠ ± 26.6o −0.5 1 −1 0 0 2 4 6 k [sample] 8 10 −1.5 −1.5 12 −1 −0.5 0 Real 0.5 1 1.5 u(k) Figure 16: Impulse response and pole-zero map. Pole at z1 = +1.1 , System unstable. • Intuitively, with u (k) = a1 u (k − 1) + b0e (k) − If |a1| < 1.0 , the successive values of u (k) will get smaller. − If a1 = 1.0 , the successive values of u (k) will remain a constant size. − If |a1| > 1.0, the successive values of u (k) will grow larger f (k) = e − Pole at z1 − If α < 0, = eα Ts , z F (z) = z − eα Ts 1 1 0.5 0.5 0 0 −0.5 −0.5 −1 −1 0 2 4 6 k [sample] 8 10 12 Unit Circle −1.5 −1.5 −1 −0.5 0 Real 0.5 1 1.5 • The difference equation with a complex pole pair: (28) . |z1| < 1.0 , 1.5 Figure 17: Impulse response and pole-zero map. The system is stable. • Mathematically, from table 1, we have the Z-transform pair: α k Ts 2 1.5 Imaginary 0.5 − Gives a damped sinusoidal impulse response, − If we write: z1,2 = A ∠ ± θ (stable) − If α = 0, |z1| = 1.0 , (marginally stable) ∗ Then the envelop evolves by a factor of A with each sample, − If α > 0, |z1| > 1.0 , (unstable) ∗ And the sinusoid rotates by an angle θ with each sample. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 31 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) (29) Page 32 EE/ME 574: Intermediate Controls Section 3.1.2 Section 3.2.1 3.2 Determining the frequency and damping of Z-plane poles • Finally, consider another complex pole pair u (k) = 2.0 u (k − 1) − 1.8 u (k − 2) + e (k) , Gc (z) = z2 z2 − 2.0 z + 1.8 z1,2 = 1.0 ± j 0.89 = 1.34∠ ± 41.8o • This system has pole pair at: EE/ME 574: Intermediate Controls − Rotation per sample: 41.8o • There are two ways to think about frequency and damping on the Z-plane 1. Matching Z-plane and s-plane poles, and interpreting the s-plane pole locations 2. Directly considering pole locations on the z-plane. − Magnitude change per sample: 1.34 . 3.2.1 Matched s-plane and Z-plane poles 30 1.5 • The relationship between an s-plane si and a Z-plane pole zi is: 25 Unit Circle 1 20 0.5 Imaginary u(k) 15 10 zi = esi Ts , si = 0 ln (zi ) Ts (30) 5 −0.5 0 • Eqn (30) leads to a couple of useful forms: −1 −5 −10 0 2 4 6 k [sample] 8 10 12 −1.5 −1.5 −1 −0.5 0 Real 0.5 1 1.5 s − plane Figure 18: Impulse response and pole-zero map. The system is unstable. s1,2 = −α ± j ω s1,2 = • The difference equation with a complex pole pair with |zi | > 1.0 − Gives an unstable oscillatory response, as with real (si ) > 0 . θ ln (A) ±j Ts Ts z − plane z1,2 = e−α Ts ∠ ω Ts (31) z1,2 = A ∠ ± θ (32) − In Eqns (31) and (32), the s-plane poles are in rectuangar coordinates, while the z-plane poles are in polar coordinates. Conclusions • Poles that lie within the unit disk give stable modes • A stable complex pole pair gives a damped oscillatory response Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 33 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 34 EE/ME 574: Intermediate Controls Section 3.2.2 3.2.2 Pictoral examples of matched pole pairs EE/ME 574: Intermediate Controls Section 3.2.2 1. Consider contours of constant decay rate on the s and Z-planes • Lines of constant decay rate are circles in the Z-plane. • The smaller the radius, the faster the decay. 5 4 4 3 3 Faster Decay 1 Faster Decay 2 1 1 0 0.6 0.4 imaginary 2 imaginary imaginary 0.8 0 −1 −1 −2 −2 −3 −3 −4 −4 0.2 0 −0.2 −0.4 −0.6 s−plane −0.8 Z−plane −1 s−plane −5 −5 0 real −4 −3 −2 −1 0 1 2 3 −1 −0.5 real 5 Figure 19: s-plane pole locations, ’+’ and ’x’ are stable, ’♦’ is marginally stable, ’∇’ and ’△’ are unstable. 0 real 0.5 1 (a) s-plane (b) Z-plane Figure 21: s and Z-plane, contours of constant decay rate, α = −1 , −2 , −3 , −4 sec−1 , Ts = 0.2 [sec]. 2. Consider contours of constant oscillatory frequency, ω • Angle of pole gives oscillation frequency. • Negative real axis corresponds to the Nyquist frequency. 2 1.5 1 4 1.5 Faster ω 3 1 2 0 0.5 1 imaginary −0.5 −1 Faster ω imaginary imaginary 0.5 0 0 Nyquist Freq −1 −0.5 Z−plane −1.5 −2 s−plane −2 −2 0 real 1 2 −4 −4 −3 −2 −1 0 1 2 3 real Figure 20: Corresponding Z-plane pole locations, ’+’ and ’x’ are stable, ’♦’ is marginally stable, ’∇’ and ’△’ are unstable. Part 5: Z-Transform and discrete control Z−plane −1 −3 −1 (Revised: Feb 13, 2013) Page 35 −1.5 −1.5 −1 −0.5 0 real 0.5 1 1.5 (a) s-plane (b) Z-plane Figure 22: s and Z-plane, contours of constant ω, ω = 1 , 2 , 3 [r/s], Ts = 0.2 [s]. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 36 EE/ME 574: Intermediate Controls Section 3.2.2 3. Consider contours of constant damping, ρ EE/ME 574: Intermediate Controls Section 3.2.2 4. Consider contours of constant natural frequency, ωn • On the s-plane, damping corresponds to angle • On the s-plane, ωn corresponds to radius. • On the Z-plane, contours of constant damping correspond to complex curves • On the Z-plane, contours of constant ωn correspond to complex curves • Generally, the nearer the pole lies to the real axis, the greater the damping • The character of the contours near z = 1.0 match the character of the contours near s = 0 • The character of the contours near z = 1.0 match the character of the contours near s = 0 1.5 4 3 Increasing Wn Increasing Wn 1 2 1.5 4 imaginary imaginary 1 Increasing Damping 2 0 −1 0.5 imaginary 0 0 −0.5 −2 1 imaginary 0.5 1 Increasing Damping 3 s−plane −3 0 Z−plane −1 −4 −1 −0.5 −4 −2 0 2 −1.5 −1.5 −1 −0.5 real −2 s−plane (a) s-plane Z−plane −1 −3 −4 −4 −3 −2 −1 0 1 2 3 −1.5 −1.5 −1 −0.5 real (a) s-plane 0 real 0.5 1 1.5 0 real 0.5 1 1.5 (b) Z-plane Figure 24: s and Z-plane, contours of constant ωn , ωn = 1 , 2 , 3 , 4 [rad/sec], Ts = 0.2 [sec]. (b) Z-plane Figure 23: s and Z-plane, contours of constant ρ, ρ = 0.24 , 0.44 , 0.71 , 0.89 , 0.97 [·], Ts = 0.2 [sec]. • Units of the s-plane: Decay or rotation per second, seconds−1 • Units of the Z-plane: Decay or rotation per sample (dimensionless) Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 37 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 38 EE/ME 574: Intermediate Controls Section 3.2.3 3.2.3 Example, determining ωn and ρ for Z-plane poles Answer: The decay rate, α, and oscillatory frequency, ω, can be found directly from zi . Writing systems • We need to convert between discrete and continuous systems for two reasons: 1. Analysis of the complete system using z-transforms o − The decay rate α is given by the pole radius, we have A = e−α Ts , so α=− Section 4.1.0 4 Converting between continuous and discrete • Given Ts = 0.15 [seconds], and z1,2 = 0.8 ± 0.2 j, find the equivalent s-plane poles, and find α, ω, ωn and ρ for the poles. z1,2 = A∠ ± θ = 0.8246∠ ± 14.03 EE/ME 574: Intermediate Controls ln (A) ln (0.8246) =− = 1.2855 [sec−1] Ts −0.15 2. To implement compensators, Gc (s) design in continuous-time and implemented in discrete-time. 4.1 Determining G pz (z) , the z-transform of G p (s) − The oscillatory frequency is given by the angle of the z-plane pole θ degrees/sample θ degrees ω = = Ts seconds/sample Ts second Discrete part, Computer Controller r(k) Trajectory Generator + e(k) ys(t) ys(k) u(k) Gc(z) ZOH (D/A Conv.) - u(t) Plant y(t) Gp(s) t=kTs (A/D Conv.) ω = 14.03/0.15 = 93.57 [degrees/second] = 1.633 [radians/second] Sensor Hy(s) − We can also directly find the equivalent s-plane pole ln z1,2 s1,2 = −α ± j ω = Ts −0.1928 + j 0.2450 = −1.2855 + j 1.6332 [sec−1] = 0.15 − ωn and ρ can be found from α and ω ωn = p Part 5: Z-Transform and discrete control Analog part, u(t)->y(t) Figure 25: Build a discrete model of the system. • The plant is itself is modelled as a continuous-time system, G p (s) • But if we combined the plant with the D/A and A/D, we have a true discrete system. G pz (z) : u (k) − > ys (k) (33) α2 + ω2 = 2.0784 [radians/second] ρ = α/ωn = 1.2855/2.0784 = 0.6185 Discrete signal path, u(k)->ys(k) [·] (Revised: Feb 13, 2013) Page 39 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 40 EE/ME 574: Intermediate Controls Section 4.1.0 • By converting G p (s) to G pz (z), including the Zero-Order-Hold of the D/A converter, we can form G pz (z) and put together an all-discrete model. EE/ME 574: Intermediate Controls Section 4.1.1 4.1.1 Discrete control example • Consider a system governed by d(k) r(k) + e(k) + u(k) u(k) Kc Gcz(z) - + G p (s) = ys(k) Gpz(z) 0.2 s+1 • Implement a discrete controller according to (more on discrete design in the next section): ys(k) Figure 26: Block of all-discrete model. Ts = 1/20 [sec] • Standard transfer-function analysis applies, using the z-transform. u (k) = 0.9 u (k − 1) + 1.0 e (k) − 0.5 e (k − 1) Kc Gcz G pz 1 + Kc Gcz G pz (34) 1 Trez (z) = 1 + Kc Gcz G pz (35) Tryz (z) = Tdyz (z) = = G pz 1 + Kc Gcz G pz (36) Etc. (38) • Find G pz (z) >> Gps = tf(0.2, [1 1]) >> Fs = 20; Ts = 1/Fs >> Gpz = c2d(Gps, Ts, ’zoh’) Transfer function: 0.009754 ---------z - 0.9512 Sampling time: 0.05 %% Gps from physics of system %% Setup Ts %% Find Gpz • The discrete TF G pz (z) is given by G (s) p G pz (z) = 1 − z−1 Z s • Find Gcz (z) from the controller implementation, Eqn (38), (37) Where Z {F (s)} is the z-transform of the sampled time series whose Laplace transform is F (s) (see Franklin et al., section 6.8). • Practically, G pz (z) is determined using Matlab’s c2d() command. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 41 >> Kc = 10 >> Gcz = tf([1 -0.5], [1 -.9], Ts) Transfer function: z - 0.5 ------z - 0.9 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 42 EE/ME 574: Intermediate Controls Section 4.1.1 • Find the closed-loop transfer function EE/ME 574: Intermediate Controls Section 4.1.1 • Find the equivalent s-plane pole locations 1. By converting the z-plane poles directly >> Tryz = feedback(Kc*Gcz*Gpz, 1) Transfer function: >> CLPolesz = pole(Tryz) CLPolesz = 0.8768 + 0.1962i 0.8768 - 0.1962i >> CLPoless = log(CLPolesz)/Ts CLPoless = -2.1402 + 4.4018i -2.1402 - 4.4018i 0.09754 z - 0.04877 ---------------------z^2 - 1.754 z + 0.8073 Sampling time: 0.05 • Plot step response. The step() command recognizes that Tryz is a z-transform. >> figure(1), clf >> step(Tryz) %% Find z-plane poles %% Convert to s-plane 2. By converting Tryz (z) to Trys (s) >> Trys = d2c(Tryz) %% Convert Tryz to Trys Step Response Transfer function: 1.622 s + 21.78 -------------------s^2 + 4.28 s + 23.96 1.4 1.2 Amplitude 1 0.8 >> pole(Trys) ans = -2.1402 + 4.4018i -2.1402 - 4.4018i 0.6 0.4 0.2 0 0 0.5 1 1.5 Time (sec) 2 2.5 3 3.5 • Find ρ , ω , ωn from s-plane poles Figure 27: Step response of Tryz (z). • Find step-response properties (overshoot, settling time, rise time) from the discrete step response. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 43 >> >> >> >> alpha omegan rho omega = = = = -real(CLPoless(1)) abs(CLPoless(1)) alpha / omegan omegan * sqrt(1-rho^2) Part 5: Z-Transform and discrete control alpha = 2.1402 omegan = 4.8945 rho = 0.4373 omega = 4.4018 (Revised: Feb 13, 2013) Page 44 EE/ME 574: Intermediate Controls Section 4.1.1 • Take a look at the Bode plot for the loop, with margins >> margin(Kc*Gcz*Gpz); EE/ME 574: Intermediate Controls Section 4.1.1 • Take a look at the frequency response of the compensator grid on >> bode(Kc*Gcz); grid on Bode Diagram Gm = 28.1 dB (at 62.8 rad/sec) , Pm = 50.2 deg (at 4.42 rad/sec) Bode Diagram 20 35 30 Magnitude (dB) Magnitude (dB) 10 0 −10 25 −20 20 −30 0 15 0 Phase (deg) Phase (deg) −45 −90 −135 −30 −180 −225 −2 10 −1 10 0 10 Frequency (rad/sec) 1 10 −60 −1 10 2 10 0 1 10 10 2 10 Frequency (rad/sec) Figure 28: Bode response of Trez (z). Figure 29: Frequency response of Gcz (z). • Questions: − What type of controller is implemented by Gcz (z) − What are the approximate frequencies of the pole and zero ? Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 45 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 46 EE/ME 574: Intermediate Controls Section 4.1.1 Section 5.0.0 5 Compensator design by discrete equivalent TF • Take a look at the error response >> Trez = EE/ME 574: Intermediate Controls • One way to design a compensator for computer-based control is by emulating a continuous-time controller. feedback(1, Kc*Gcz*Gpz) Transfer function: z^2 - 1.851 z + 0.8561 ---------------------z^2 - 1.754 z + 0.8073 1. Design − Design a continuous-time, Gcs (s), by any suitable method Sampling time: 0.05 >> bode(Trez); grid on 2. Implementation • System will meet a tracking error requirement of Etrack ≤ 10% with ωt below about 0.3 [rad/sec]. Bode Diagram (a) Select the sample rate Fs [samples/second]. Ts = 1/Fs . (b) Convert Gcs (s) to a discrete-time compensator, Gcz (z) 3. Analysis 10 5 (a) Done in the z-domain Magnitude (dB) 0 − To correctly consider sampling effects. −5 −10 (b) Convert the continuous-time model for the plant, G ps (s) to discrete time, G pz (z) −15 −20 −25 Phase (deg) −30 90 (c) Analyze the complete discrete time system • Many discrete controllers (compute-based controllers) are designed in this fashion, because the tools and understanding of continuous-time can be brought to bear. 45 0 −2 10 −1 10 0 10 Frequency (rad/sec) 1 10 • Synonyms 2 10 − Design by discrete equivalent Figure 30: Bode response of Trez (z). − Design by emulation Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 47 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 48 EE/ME 574: Intermediate Controls Section 5.0.0 • Block diagrams for 3 steps, designing a discrete compensator by emulation 1. Design Controller Trajectory Generation r(t) + Controller e(t) Plant u(t) Section 5.1.0 • Design by discrete equivalent: 1. Design Gcs (s) by standard methods Process under control Gc(s) EE/ME 574: Intermediate Controls 2. Select Ts and convert Gcs (s) to Gcz (z) y(t) Gp(s) - 3. Analyze Kc Gcz (z) G pz (z) Sensor − For step 2, we must use a method to find Gcz (z) that approximates Gcs (s) Hy(s) ——– ∼ ——– Figure 31: Block diagram for design. 5.1 Matlab’s c2d() command 2. Implementation Discrete part, Computer Controller r(k) Trajectory Generator + e(k) ys(t) u(k) Kc Gc(z) ZOH (D/A Conv.) - ys(k) u(t) Plant y(t) Gp(s) t=kTs (A/D Conv.) Sensor Hy(s) Analog part Figure 32: Block diagram for implementation. 3. Analysis Discrete Controller Trajectory Generator r(k) + e(k) - Computer Controller Gc(k) u(k) ZOH + Plant y(k) Gp(z) ys(k) ys(k) Sensor Hy(z) Discrete Model of Plant Figure 33: Block diagram for analysis. Part 5: Z-Transform and discrete control • Matlab’s c2d() command as six possible methods converting a continuoustime TF into a discrete-time TF (Revised: Feb 13, 2013) Page 49 >> help c2d C2D Conversion of continuous-time models to discrete time. SYSD = C2D(SYSC,Ts,METHOD) converts the continuous-time LTI model SYSC to a discrete-time model SYSD with sample time Ts. The string METHOD selects the discretization method among the following: ’zoh’ Zero-order hold on the inputs ’foh’ Linear interpolation of inputs (triangle appx.) ’imp’ Impulse-invariant discretization ’tustin’ Bilinear (Tustin) approximation ’prewarp’ Tustin approximation with frequency prewarping. The critical frequency Wc (in rad/sec) is specified as fourth input by SYSD = C2D(SYSC,Ts,’prewarp’,Wc) ’matched’ Matched pole-zero method (for SISO systems only). The default is ’zoh’ when METHOD is omitted. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 50 EE/ME 574: Intermediate Controls Section 5.1.1 • ZOH EE/ME 574: Intermediate Controls Section 5.1.1 5.1.1 Why 6 different design methods The “Zero-Order Hold” conversion models a zero-order-hold in the input path of the continuous time system. This option exactly models G p (s) in figure 32. • When the physical system incorporates a zero-order hold, we can find a G (z) that exactly matches G (s). − This is the case for converting G ps (s) to G pz (z) • FOH Models a first-order-hold, correct for signal processing applications where a FOH is used. • imp • When we matching transfer functions (no ZOH in the physical system) there is not an exact match − This is the case for converting Gcs (s) to Gcz (z) Matches the impulse response of the transfer function. Note that a continuous-time input is not the same signal as a discrete-time input Impulse type: Height Width − Tustin’s rule gives a good approximation for controller design. Continuous-time Infinite Infinitesimal Discrete-time − The reason the conversion is approximate lies with the difference between the continuous and discrete input signal. When this is modelled exactly (e.g., ZOH) the correspondence is exact. 1 Ts ——– ∼ ——– Ts • Tustin’s method See the next section. • prewarp Used for digital filters design, adjusts the conversion to give a more accurate match in a ’critical’ frequency range. • matched Transforms poles and zeros according to z = es Ts . Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 51 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 52 EE/ME 574: Intermediate Controls Section 5.2.1 5.2 Tustin’s rule to find Gcz (z) that approximates Gcs (s) EE/ME 574: Intermediate Controls Section 5.2.1 • Rearranging to derive the transfer function 5.2.1 Deriving Tustin’s rule Ts Ts e (k) + e (k − 1) 2 2 u (k) − u (k − 1) = • Consider u (t) = Z t e (τ) dτ or Gc (s) = Z k Ts e (τ) dτ o − Then u (k) = u (k − 1) + k Ts −Ts 1 s Ts U (z) 1 − z−1 = E (z) 1 + z−1 2 (39) (40) • From which we get the TF Ts U (z) = Gc (z) = E (z) 2 • Eqns (39) and (40) are exact, but with knowledge of e (t) only at sample instants, there is no exact way to integrate e (t) in Eqn (40). 1 + z−1 1 − z−1 (42) • One approximate method to integrate e (t) is the trapezoidal-rule. • Comparing Gc (z) with Gc (s), one finds an approximation for s: e(t) e(k-1) e(k) 1 Ts ≃ s 2 t R Figure 34: The trapezoidal rule of Tustin’s method approximates e (t). Z k Ts k Ts −Ts e (τ) dτ ≃ ←→ 1 + z−1 1 − z−1 so Gc (z) = s≃ 2 Ts Ts 2 1 + z−1 1 − z−1 1 − z−1 1 + z−1 = 2 Ts z−1 z+1 (43) 1. Replace s in Gs (s) by [e (k − 1) + e (k)] Ts 2 2 Ts Plugging this into Eqn (40) gives: [e (k − 1) + e (k)] Ts 2 Ts = u (k − 1) + [e (k − 1) + e (k)] 2 u (k) = u (k − 1) + Part 5: Z-Transform and discrete control 1 s • Tustin’s rule, to form Gz (z) from Gs (s): • The trapezoidal approximation gives: • Gc (s) = (Revised: Feb 13, 2013) z−1 z+1 2. Simplify Gz (z), and express it in rational polynomial form . (41) Page 53 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 54 EE/ME 574: Intermediate Controls Section 5.2.2 • Example 4s +5 s+2 Gc (z) = (phase − lead compensator) 2 z−1 , Ts z + 1 3.333 − 1.111 z−1 1 − 0.1111 z−1 (44) • Next, form the difference equation Using Ts = 0.8 and s∼ Section 5.2.2 • For implementation, first rearrange into past-sample form: 5.2.2 Example with Tustin’s rule Gc (s) = EE/ME 574: Intermediate Controls Gc (z) = Gives 4 2 0.8 2 0.8 1.0 u (k) − 0.1111 u (k − 1) = 3.333 e (k) − 1.111 e (k − 1) z−1 z+1 + 5 z−1 z+1 + 2 (45) • Which is implemented in the controller as • With some re-arrangement we get: 1.0 u (k) = +0.1111 u (k − 1) + 3.333 e (k) − 1.111 e (k − 1) (46) 15 z − 5 10 (z − 1) + 5 (z + 1) = Gc (z) = 2.5 (z − 1) + 2 (z + 1) 4.5 z − 0.5 • Putting in monic form Gc (z) = 3.333 z − 1.111 z − 0.1111 • With Matlab c2d() command >> Gcs = tf( [4 5], [ 1 2]) >> Ts = 0.8 >> Gcz = c2d(Gcs, Ts, ’tustin’) Transfer function: 3.333 z - 1.111 --------------z - 0.1111 Sampling time: 0.8 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 55 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 56 EE/ME 574: Intermediate Controls Section 5.2.3 EE/ME 574: Intermediate Controls Section 5.2.3 − Thus, if Ts changes, the discrete transfer functions change. 5.2.3 Example controller design by discrete equivalent, done by hand • Consider example 6.17 in Franklin, et al., where G ps (s) = 1 0.5 s + 1 9 (s + 1) 1 2s + 1 , Gcs (s) = 3 5s +1 15 s + 1 (47) • Find Gcz (z), plug in the Tustin’s rule approximation for s: 5 2 z−1 , s∼ Ts z + 1 Gc (z) = 3 h 15 2 Ts h 2 Ts 1−z−1 1+z−1 i 1−z−1 1+z−1 +1 i +1 (48) • Put expression in rational polynomial form: Gc (z) = 3 5 T2s 1 − z−1 + 1 1 + z−1 (49) 15 T2s (1 − z−1) + 1 (1 + z−1) −1 + 1 + 1 − 10 Ts z = 3 30 30 −1 Ts + 1 + 1 − Ts z = c0 = 3 10 Ts c0 + c1 z−1 c0 /d0 + c1/d0 z−1 = −1 d0 + d1 z 1 + d1/d0 z−1 (50) 10 10 30 30 + 1 , c1 = 3 1 − + 1 , d1 = 1 − , d0 = Ts Ts Ts Ts where the last express is to put coefficient a0 = 1 (the standard form). • Notice: that the expressions for terms c0.. d1 depend on Ts Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 57 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 58 EE/ME 574: Intermediate Controls Section 5.2.3 5.2.3 Example controller design using emulation (continued) 10 Ts +1 >> Kc = 3; >> Gc_617_s = tf([5 1], [15 1]) Transfer function: 5 s + 1 -------15 s + 1 = 63 c1 = 3 1 − 10 = −57 Ts 30 Ts + 1 d0 = d1 = 1 − 30 = −59 Ts %% Form the discrete-time TF by Tustin’s rule >> Fs = 2; Ts = 1/Fs; >> Gc_617_z = c2d(Gc_617_s, Ts, ’tustin’) = 61 Transfer function: • And finally: Gc (z) = 63/61 − 57/61 z−1 1.033 − 0.9344 z−1 = 1 − 59/61 z−1 1 − 0.9672 z−1 (51) 0.3443 z - 0.3115 ---------------z - 0.9672 Sampling time: 0.5 • Examine the step response of the system • Which gives the implementation equation u (k) = 0.9672 u (k − 1) + 1.033 e (k) − 0.9344 e (k − 1) (52) • Equations (47) - (51) can be a bit of algebra, especially for higher-order Gc (s), but fortunately there is an easier way to make this calculation. Part 5: Z-Transform and discrete control Section 5.2.4 5.2.4 Example controller design by discrete equivalent, using Matlab • Using Ts = 0.5[seconds], gives c0 = 3 EE/ME 574: Intermediate Controls (Revised: Feb 13, 2013) Page 59 − Write down the continuous-time model of the plant (still from example Franklin et al. 6.17) >> Nps = K = 3 >> Dps = [ 1.0000 3.5000 >> Guy_617_s = tf(Nps, Dps) Transfer function: Gp(s) = Part 5: Z-Transform and discrete control 3.5000 1.0000 ] 3 ------------------------s^3 + 3.5 s^2 + 3.5 s + 1 (Revised: Feb 13, 2013) Page 60 EE/ME 574: Intermediate Controls Section 5.2.4 • Convert the plant to discrete EE/ME 574: Intermediate Controls Section 5.2.4 • Let’s look at the discrete and continuous system responses %% Convert plant to discrete, using zero order hold method >> Fs = 2; Ts = 1/Fs; >> Guy_617_z = c2d(Guy_617_s, Ts, ’zoh’) Transfer function: 0.0409 z^2 + 0.1071 z + 0.01706 ---------------------------------z^3 - 1.753 z^2 + 0.982 z - 0.1738 >> >> [Ycont, Tcont] = step(Try_617_s, TStepfinal); hold on; plot(Tcont, Ycont, ’--’); hold off Step Response 1.4 1.2 • Form the closed-loop TF and plot the step response >> TStepfinal = 20; >> Try_617_z = feedback(Kc*Gc_617_z*Guy_617_z, 1) Transfer function: 0.04224 z^3 + 0.07239 z^2 - 0.08246 z - 0.01594 ----------------------------------------------z^4 - 2.678 z^3 + 2.75 z^2 - 1.206 z + 0.1521 >> figure(3) >> step(Try_617_z, TStepfinal) Amplitude 1 0.8 0.6 0.4 0.2 0 0 2 4 6 8 10 Time (sec) 12 14 16 18 20 Figure 36: Step response of discrete model for example 6.17; with continuous model and control in - - , Ts = 0.5. Step Response 1.4 1.2 • It is seen that the discrete system is a bit slower and with more overshoot. Amplitude 1 • The loss of speed and damping is due delay introduced by the ZOH. 0.8 0.6 − The added delay introduces phase lag, it subtracts from the phase margin 0.4 − The added delay is approximately τd = Ts /2, 0.2 − The lost phase margin depends on the delay and the period of one cycle at the cross-over frequency 0 0 2 4 6 8 10 12 14 16 18 20 Time (sec) Figure 35: Step response of discrete model for example 6.17, Ts = 0.5 [sec]. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 61 φlost ≃ 360 Ts /2 0.25 τd = 360 = 360 = 13o τcycle 2 π/ωc 6.9 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) (53) Page 62 EE/ME 574: Intermediate Controls Section 5.2.4 EE/ME 574: Intermediate Controls − In this case, about 13o of phase margin are lost through discrete implementation. Section 5.2.4 • The lost phase margin can be reduced by increasing the sample rate. • Try accelerated sampling the sample with Fs = 8 [samples/second] Step Response 1.4 • Changed Fs 1.2 Was: Fs = 2 [samples/sec] 1 Amplitude Now: Fs = 8 [samples/sec] 0.8 0.6 0.4 0.2 0 0 2 4 6 8 10 12 14 16 18 20 Time (sec) Figure 37: Step response of discrete model for example 6.17; with continuous model and control in - - , Ts = 0.125 [sec]. • Response is quite a lot better. Check the closed-loop bandwidth, to compare with the sampling rate: %% CL bandwidth, in Hz >> CLWb = (bandwidth(Try_617_z) / (2*pi)) CLWb = 0.2491 [Hz] • The first try, Fs = 1/Ts = 2 [Hertz] was about 8x ωb, pretty slow. • Second try, Fs = 1/Ts = 8 [Hertz] was about 32x ωb, and shows much better performance. • Performance can also be improved by adding phase lead to Gc (s) Notes: Pay attention to distinguish [cycles/sec] and [rad/sec]. The limit for the project is Fs ≤ 50 ωb/2π [samples/sec]. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 63 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 64 EE/ME 574: Intermediate Controls Section 6.1.0 6 DC Gain, Steady State Error and Complex Gain EE/ME 574: Intermediate Controls Section 6.1.0 • If we have numerator and denominator polynomials, with can use − Polynomial evaluation, evaluating with z = 1, or 6.1 DC Gain − The sum of the numerator and denominator • The DC gain of a discrete system is given as KDC = T (z) (54) z→1 >> num = Gcz.num{1} num = 1.0328 -0.9344 • For example, the compensator above had the transfer function Gc (z) = 1.0333z − 0.9344 z − 0.9672 >> den = Gcz.den{1} den = 1.0000 -0.9672 (55) >> KDC = polyval(num, 1) / polyval(den, 1) KDC = 3 So the DC gain of the compensator is: KDC = Gc (z = +1) = 1.0333 − 0.9344 0.0984 = =3 1 − 0.9672 0.0328 (56) >> KDC = sum(num) / sum(den) KDC = 3 • Recall that for the example, the original Gc (s) was • The bode() command also works 5s + 1 Gc (s) = 3 15 s + 1 • Notice in Eqn (56) that it is not easy to examine Gc (z) and determine the DC gain. >> [Mag, Phase] = bode(Gcz, 0) Mag = 3 Phase = 0 %% bode(TF, omega) • Notice that bode() is evaluated with omega, not z Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 65 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 66 EE/ME 574: Intermediate Controls Section 6.2.1 6.2 Steady-State error EE/ME 574: Intermediate Controls Section 6.2.1 • Build two systems • The analysis of discrete-time steady-state error is analogous to the continuous-time case. 1. Type 0 system: with phase-lag control Gc1 (s) = 3 5s +1 15 s + 1 • This can be done from either the open-loop loop gain, or the closed-loop Trez (z) >> Gc_617_PhaseLag_z = c2d(Gc_617_PhaseLag_s, Ts, ’tustin’) Transfer function: 0.3443 z - 0.3115 ----------------z - 0.9672 Sampling time: 0.5 • Methods 1. Apply the final value theorem from theory (see section 2.2.4) 2. Determine the Bode form for the discrete loop-gain transfer function (open-loop), and determine the system type and SSE from the Bode form. − Bode form for discrete TF’s: Kc Gc (z) G p (z) = KBode z−1 Ts no Glz (z) (57) where all poles and zeros at z = +1 are placed in the term (z − 1)no , and Glz (z) has a DC gain of 1.0. >> Trez1 = feedback(1, Kc*Gc_617_PhaseLag_z*Guy_617_z) Transfer function: z^4 - 2.72 z^3 + 2.678 z^2 - 1.124 z + 0.1681 --------------------------------------------z^4 - 2.678 z^3 + 2.75 z^2 - 1.206 z + 0.1521 Sampling time: 0.5 2. Type I system: with PI control Gc2 (s) = 0.1 5s +1 s 6.2.1 Determining steady-state error from Trez (z) (or Tre (s)) • We can determine steady state error for step or ramp inputs from the bode plot of Trez (z) (or Tre (s)) • Consider the example plant of section 5.2.4 >> Guy_617_z= c2d(Guy_617_s, Ts, ’zoh’)„ Transfer function: 0.0409 z^2 + 0.1071 z + 0.01706 ---------------------------------z^3 - 1.753 z^2 + 0.982 z - 0.1738 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 67 >> Gc_617_PI_z = c2d(Gc_617_PI_s, Ts, ’tustin’) Transfer function: 5.25 z - 4.75 ------------z - 1 Sampling time: 0.5 >> Trez2 = feedback(1, Kc*Gc_617_PI_z*Guy_617_z) Transfer function: z^4 - 2.753 z^3 + 2.735 z^2 - 1.156 z + 0.1738 ---------------------------------------------z^4 - 2.732 z^3 + 2.772 z^2 - 1.198 z + 0.1657 Sampling time: 0.5 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 68 EE/ME 574: Intermediate Controls Section 6.2.1 EE/ME 574: Intermediate Controls • Looking at Bode plots of the two transfer functions: • Type I system (continued) Bode: Trez1 0 Magnitude (dB) Magnitude (dB) 20 −10 −20 −30 90 Trez z = e j ω Ts ≃ 0 −20 −40 1 jω KBode (58) Where KBode is KBode of the loop gain in Bode form. −60 − Evaluating Trez (z) at a low frequency ωa, KBode is given by: 90 Phase (deg) Phase (deg) − At low frequencies, the Bode plot of figure 38.b is approximated as: Bode: Trez2 10 Section 6.2.1 45 0 −45 −3 10 −2 −1 10 10 0 10 1 10 45 −45 −3 10 Frequency (rad/sec) (a) Trez1 (z) (Type 0 system) KBode ≃ 0 −2 −1 10 0 10 10 ωa |Trez (z = e j ωa Ts )| (59) 1 10 Frequency (rad/sec) (b) Trez2 (z) (Type I system) − The the steady-state error works out to be (for Trez2 (z)): Figure 38: Bode plots of Trez1 (z) and Trez2 (z). SSE (ramp) = 1 |Trez (z)| , with kv = KBode so SSE (ramp) ≃ (60) kv ωa • Type 0 system: − The limω→0 Terz z = e j ω Ts is evident in figure 1. For the Type 0 system, the steady-state error for a step input is given as: >> SSEstep1 = bode(Trez1, 0) SSEstep1 = 0.1000 − Simply evaluate the DC gain of Trez (z) (or Tre (s)) to determine SSE(step) • Type I system − We can recognize from the Bode plot of Trez2 (z) that the system is Type I. ∗ The Trez2 (z) increases 20 dB per decade in the low-frequency region, and ∗ The angle is +90o Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 69 − Example: >> wa = 0.001 >> KBode = wa / bode(Trez2, wa), >> SSEramp = bode(Trez2, wa)/wa, KBode = 0.3000 SSEramp = 3.3333 − KBode is not sensitive to changes in ωa , so long as ωa is sufficiently small >> wa = 0.0001 >> SSE = bode(Trez2, wa)/wa SSE = 3.3333 >> wa = 0.01 >> SSE = bode(Trez2, wa)/wa SSE = 3.3333 • The method of Eqns (59)-(60) works equally well with continuous time systems, |Tre (s = j ωa )| (61) SSE (ramp) ≃ ωa Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 70 EE/ME 574: Intermediate Controls Section 6.3.0 EE/ME 574: Intermediate Controls Section 7.0.0 7 Conclusion 6.3 Complex gain from a discrete TF • An important idea that underlies frequency-domain analysis and the Bode plot is complex gain. − A sinusoidal input gives a sinusoidal output, with a changed magnitude and phase − The complex gain is given as: • The vast majority of controllers are actually implemented in microprocessors, as discrete-time systems. • Discrete-time systems are implemented as difference equations, such as u (k) = −a1 u (k − 1) − a2 u (k − 2) − · · · + bo e (k) + b1 e (k − 1) + · · · ~Y = G (z) ~ U z=1∠(ω T ) − Outputs are governed by a sum of: s ∗ Current input and past inputs, and • Example: Sys167_cz = ∗ Past outputs 0.3443 z - 0.3115 ----------------z - 0.9672 • We have seen the z-transform, which Sampling time: 0.5 >> Nz = Sys617_cz.num{1} Nz = 0.3443 -0.3115 − Gives us many of the methods we use with Laplace transforms >> Dz = Sys617_cz.den{1} Dz = 1.0000 -0.9672 >> w = 2; >> z = 1.0*exp(j*w*Ts), z = 0.5403 + 0.8415i >> Gain0 = polyval(Nz, z) / polyval(Dz, z) Gain0 = 0.3340 - 0.0203i − Has certain differences with the Laplace transform, such as the region on the z-plane for stable poles. • Discrete controller design − Can be done by designing Gcs (s) and converting it to Gcz (z) %% Determine Gcz at w=2 with bode command, and convert to complex val. >> [Mag1, Th1] = bode( Sys617_cz, 2 ); >> Gain2 = Mag1*exp(j*(Th1*pi/180)) Gain2 = 0.3340 - 0.0203i − Can be done directly in the discrete domain ∗ Analyze the Bode plot and root locus of z-transforms • Controller performance is analyzed entirely in the z-domain. • The calculations above underlie the bode plot for discrete systems. Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 71 Part 5: Z-Transform and discrete control (Revised: Feb 13, 2013) Page 72 EE/ME 574: Intermediate Controls EE/ME 574: Intermediate Controls Section 1.0.0 1 Building a discrete state-space model Discrete State Space Methods • The discrete state-space model takes the form: Contents x (k + 1) = A p x (k) + B p u (k) 1 Building a discrete state-space model 1.1 Finding B p . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Converting continuous state space models to discrete . . . . 1.2.1 The output equation . . . . . . . . . . . . . . . . . 1.3 Discrete Transfer Function from a discrete state-space model 2 Control of discrete state-space systems 2.1 Pole placement . . . . . . . . . . 2.2 Linear Quadratic Regulator . . . . 2.2.1 Try with new Q . . . . . 2.2.2 Try another new Q . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 3 4 6 6 . . . . 9 9 14 16 17 3 Integral control for discrete state-space systems (draft) 18 4 Controllability and Observability 19 5 Conclusions, Discrete State-variable model formulation and control 22 (1) y (k) = C p x (k) + D p u (k) Notes: we’ll use Fp , G p, H p , J p for the continuous time model, and A p , B p, C p, D p for the discrete (sampled) model. • Starting with the continuous model, the discrete model is computed by solving the differential equation for one sample interval: − Starting with: ẋ (t) = Fp x (t) + G p u (t) (2) y (t) = H p x (t) + J p u (t) − And integrating the differential equation, gives: x (t) = eFp (t−t0 ) x (t0 ) + Z t t0 eFp (t−τ) G p u (τ) dτ (3) − By letting t0 = k Ts and t = t0 + Ts , Eqn (3) becomes: x ((k + 1) Ts ) = eFp Ts x (k Ts ) + Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 1 Part 6: Discrete State Space Methods Z (k+1)Ts k Ts eFp ((k+1)Ts−τ) G p u (τ) dτ (Revised: May 06, 2014) (4) Page 2 EE/ME 574: Intermediate Controls Section 1.1.0 − Which can be put in the discrete form: EE/ME 574: Intermediate Controls 1.2 Converting continuous state space models to discrete • Referring to Franklin et al. example 2.14, the voice-coil motor, with Fp, G p , H p , J p as given previously, then the discrete model is obtaned by starting with the continuous time state-space model, and converting it to discrete: x (k + 1) = A p x (k) + B p u (k) where A p = eFp Ts (5) 1.1 Finding B p • To find B p , the integral of Eqn (4) must be solved. • An assumption must be made about the input signal u (t) over the sample interval. >> SSuys = ss(Fp, Gp, Hp, Jp) a = x1 x2 x3 x1 -0.15 0 3.15 x2 1 0 0 x3 -31.5 0 -15 b = x1 x2 x3 • Assuming that the input to the continuous system is a Zero Order Hold (ZOH), − Term u (τ) is constant over the integration interval in Eqn (3), and G p and u (τ) come out of the integral. − Assuming ZOH, the integral of the input becomes: Z (k+1)Ts k Ts eFp ((k+1)Ts −τ) G p u (τ) dτ = so Bp = Z 0 Ts Section 1.2.0 Z 0 Ts eFp τ dτ G p u (k Ts ) eFp τ dτ G p (6) (7) c = y1 x1 0 x2 1 x3 0 d = y1 u1 0 Continuous-time model. %% Build the discrete SS model, set the sample rate to 6/second >> Fs = 6; Ts = 1/Fs„ Ts = 0.1667 >> SSuyz = c2d(SSuys, Ts, ’zoh’) a = x1 x2 x3 x1 0.4096 0.1245 -1.2 x2 0 1 -0 c = x3 0.12 0.01815 -0.1563 b = x1 x2 x3 u1 0.9076 0.06405 1.948 y1 u1 0 d = y1 • The integral of Eqn (7) can be solved numerically, giving B p. u1 0 0 50 %% First define the %% continuous-time model x1 0 x2 1 x3 0 Sampling time: 0.16667 Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 3 Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 4 EE/ME 574: Intermediate Controls Section 1.2.0 EE/ME 574: Intermediate Controls Section 1.3.0 1.2.1 The output equation Discrete-time model. • Since y (t) = H p x (t) + J p u (t) the sampled y (k) is given (simply) by: y (k) = H p x (k) + J p u (k) − In other words · The output equation does not change, C p = H p , D p = J p . 1.3 Discrete Transfer Function from a discrete state-space model • Starting with x (k + 1) = A p x (k) + B p u (k) (1, repeated) y (k) = C p x (k) + D p u (k) We get: z Z {x (k)} = A p Z {x (k)} + B p Z {u (k)} (8) This gives: (z I − A p) x (z) = B p U (z) (9) x (z) = (z I − A p)−1 B p U (z) (10) Y (z) = C p x (z) + D p U (z) (11) • Which gives the discrete transfer function Y (z) = C p (z I − A p)−1 B p + D p U (z) (12) • Eqn (12) has precisely the form of Y (s) /U (s) for continuous systems. Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 5 Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 6 EE/ME 574: Intermediate Controls Section 1.3.0 EE/ME 574: Intermediate Controls • Obtaining the discrete transfer function of the plant Section 1.3.0 • We can work directly with the discrete state-variable model to investigate the characteristics of the open-loop system 1. Approach one, discretize the State-variable model, then obtain the TF >> OLPolesz = pole(SSuyz) OLPolesz = 1.0000 0.1266 + 0.2530i 0.1266 - 0.2530i . %% Use SSuyz from above >> Guyz = tf(SSuyz) Transfer function: 0.06405 z^2 + 0.1322 z + 0.01766 -----------------------------------z^3 - 1.253 z^2 + 0.3333 z - 0.08006 Sampling time: 0.16667 • Note pole at z = +1.0, the system is Type1 − Note: The Discrete SS model and Discrete TF model have the sample period, Ts recorded, so the tf(·) command knows Ts . • Examining the pole-zero map and bode plot of the OL system 2. Approach two, Convert the continuous-time state-variable model to a continuous-time TF, the discretize that >> Guys = tf(SSuys) Transfer function: >> figure(1), clf >> bode(SSuyz) >> figure(2), clf >> pzmap(SSuyz) 157.5 ------------------------s^3 + 15.15 s^2 + 101.5 s Pole−Zero Map Bode Diagram 40 Magnitude (dB) 1 0.8 0.6 0.4 Imaginary Axis 20 0 −20 0.2 0 −40 −90 −0.2 −0.4 Phase (deg) >> Guyz2 = c2d(Guys, Ts, ’zoh’) Transfer function: 0.06405 z^2 + 0.1322 z + 0.01766 -----------------------------------z^3 - 1.253 z^2 + 0.3333 z - 0.08006 Sampling time: 0.16667 −0.6 −0.8 −1 −2 −1.5 −1 −0.5 0 0.5 1 Real Axis −180 −270 −360 −450 −1 10 0 1 10 10 2 10 Frequency (rad/sec) Figure 1: PZ Map and Bode plot for SSuyz. Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 7 Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 8 EE/ME 574: Intermediate Controls Section 2.1.0 2 Control of discrete state-space systems EE/ME 574: Intermediate Controls Section 2.1.0 3. Design the controller by pole-placement 2.1 Pole placement • Pole-placement design is carried out exactly as with continuous-time, statevariable model, − Except that the poles must make sense on the Z-plane >> >> >> >> Ap = SSuyz.a; %% Extract the Ap and Bp matrices Bp = SSuyz.b; Cp = SSuyz.c; Dp = SSuyz.d; Kz = place(Ap, Bp, DesiredPolesz) Kz = [ -0.0211 0.7572 0.0047 ] 1. Select S-plane closed-loop poles, si >> DesiredPoless = [-2, -8+j*2, >> Acl = (Ap - Bp*Kz) Acl = 0.4287 -0.6872 0.1259 0.9515 -1.1591 -1.4754 -8-j*2] 2. Convert the poles to the z-plane zi = esi Ts 0.1157 0.0178 -0.1655 (13) >> DesiredPolesz = exp(DesiredPoless * Ts) DesiredPolesz = [0.7165, 0.2491 + 0.0862i, 0.2491 - 0.0862i] %% Determine the DCGain, and Nf. Notice the discrete-time form >> Nfz = 1 / (Ccl*inv(eye(3)-Acl)*Bp + Dp) Nfz = 0.7572 • Examining the PZ map >> Bcl = Nfz * Bp Bcl = 0.6872 0.0485 1.4754 1.5 1 imaginary 0.5 0 >> Dcl = Dp*Nfz Dcl = 0 %% Form the closed-loop system %% Notice Ts on each line, this is what tells %% the ss() command to build a discrete-time system model >> SSryz = ss(Acl, Bcl, Ccl, Dcl, Ts); >> SSrez = ss(Acl, Bcl, -Ccl, (1-Dcl), Ts); >> SSruz = ss(Acl, Bcl, -Kz, Nfz, Ts ) 0 −0.5 −1 −1.5 −1.5 >> Ccl = Cp - Dp*Kz Ccl = 0 1 −1 −0.5 0 real 0.5 1 1.5 Figure 2: Pole-Zero map showing ’x’ open-loop and ’△’ desired CL poles. Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 9 Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 10 EE/ME 574: Intermediate Controls Section 2.1.0 EE/ME 574: Intermediate Controls • Examine the step response, output and error >> figure(1), clf >> step(SSryz) >> figure(2), clf >> step(SSrez) Step Response 1 0.9 0.9 0.8 0.8 0.7 0.7 0.6 0.6 Amplitude Amplitude Step Response 0.5 0.4 0.3 0.3 0.2 0.2 0.1 0.1 0.5 1 1.5 2 2.5 3 3.5 >> Gcl = Nfs * Gp Gcl = 0 0 43.1746 0.5 0.4 0 0 • Continuous controller given for comparison >> Ks = place(Fp, Gp, DesiredPoless) Ks = [ -0.0121 0.8635 0.0570 >> Fcl = (Fp - Gp*Ks) Fcl = -0.1500 0 3.1500 1.0000 0 0 -30.8960 -43.1746 -17.8500 >> Nfs = 1 / (Hcl*inv(-Fcl)*Gp + Jp) Nfs = 0.8635 >> figure(3), clf >> step(SSruz) 1 0.5 1 1.5 Time (sec) 2 2.5 3 3.5 >> Hcl = Hp - Jp*Ks Hcl = 0 1 0 >> Jcl = Jp*Nfs jcl = 0 4 Time (sec) (a) Step response ] >> SSrys = ss(Fcl, Gcl, Hp, Jp); 0 0 4 Section 2.1.0 %% Plot both continuous and discrete system response >> [Yz, Tz] = step(SSryz); step(SSrys); >> hold on, stem(Tz, Yz); hold off (b) Error response to a step input Figure 3: Step and error response Step Response Step Response 0.8 1 0.7 • The continuous and discrete systems agree quite well at the sample instants. 0.6 0.8 Amplitude Amplitude 0.5 0.4 0.3 0.6 0.4 − They do not exactly agree 0.2 0.2 0.1 0 0 0.5 1 1.5 2 2.5 3 3.5 0 0 4 Time (sec) 1 1.5 2 Time (sec) (Revised: May 06, 2014) 2.5 3 − The control signals are not quite the same. Figure 5: Continuous and discrete system response. Figure 4: Control effort response to a step input. Part 6: Discrete State Space Methods 0.5 Page 11 Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 12 EE/ME 574: Intermediate Controls Section 2.1.0 • Notice that Ks is comparable to Kz >> Ks = place(Fp, Gp, DesiredPoless) Ks = [ -0.0121 0.8635 0.0570 • To determine the LQR controller of a discrete system, − Choose Q and R (identical to continuous-time Q and R) − Matlab’s lqr() command automatically determines whether the system is discrete or continuous from the LTI model. ] >> >> >> >> >> >> Kz → Ks • Looking at N f >> Nfz Nfz = >> Nfs Nfs = Section 2.2.0 2.2 Linear Quadratic Regulator >> Kz = place(Ap, Bp, DesiredPolesz) Kz = [ -0.0211 0.7572 0.0047 ] • In the limit as Ts → 0 , EE/ME 574: Intermediate Controls %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LQR Example %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Q = diag([1 1 1]); Ks = lqr(SSuys, Q, Ks = [ 0.7711 >> Fcl = Fp-Gp*Ks; 0.7572 R = 1; R) %% Continuous lqr 1.0000 0.7896 ] Hcl = Hp - Jp*Ks 0.8635 >> Kz =lqr(SSuyz, Q, R) %% Discrete lqr Kz = [ -0.1314 0.3369 0.0083 ] >> Acl = Ap-Bp*Kz; Ccl = Cp - Dp*Kz − Again comparable, but not identical. • Notice the difference in calculation to determine N f : − Continuous N f = 1/ Hcl (sI − Fcl )−1 G p + J p s=0 = 1/ Hcl (−Fcl )−1 G p + J p %% Set up correct feed-forward gain, continuous %% Note (0*I - Fcl) >> Nfs = 1/(Hcl*inv(-Fcl)*Gp+Jp)„ %% Continuous: DC = lim s -> 0 Nfs = 1.0000 >> Gcl = Nfs * Gp; = 1/ Dcl (I − Fcl )−1 B p + D p %%Set up correct feed-forward gain, discrete >> Nfz = 1/(Ccl*inv(eye(3)-Acl)*Bp+Dp)„ %% Note (Eye - Acl) Nfz = 0.3369 %% Discrete: DC = lim z -> 1 >> Bcl = Nfz * Bp; − Discrete N f = 1/ Dcl (zI − Acl )−1 B p + D p Part 6: Discrete State Space Methods z=+1 (Revised: May 06, 2014) Page 13 Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 14 EE/ME 574: Intermediate Controls Section 2.2.0 • Determine closed-loop poles and build system models EE/ME 574: Intermediate Controls Section 2.2.1 2.2.1 Try with new Q >> CLPoless = eig(Fcl) CLPoless = -50.1257 -0.8634 -3.6392 %% Continuous >> CLPolesz = eig(Acl) CLPolesz = 0.8673 0.4440 0.0236 %% Discrete 0 0 0 Q2 = 100CTp C p = 0 100 0 0 0 0 , R = [1] >> K2z = lqr(SSuyz, Q2, R) >> ... >> figure(4), clf >> step(SSryz, 7) >> SSrys = ss(Fcl, Gcl, Hp-Jp*Ks, Jp*Nfs); >> SSryz = ss(Acl, Bcl, Cp-Dp*Kz, Dp*Nfz, Ts) %% Note Ts Discrete LQR, with continuous ’−−’ 1.4 Discrete LQR, with continuous ’−−’ 1 1.2 0.9 1 0.8 Amplitude 0.6 Q = [ 1.00 [ 0.00 [ 0.00 0.5 0.00 1.00 0.00 Amplitude 0.7 PO: 0%, 0.00] 0.00] 1.00] T : 2.50, 0.8 Q=[ [ [ PO: 5.54%, 0.00 0.00 0.00] 0.00 100.00 0.00] 0.00 0.00 0.00] T : 0.17, r 0.6 r T : 0.67, s T : 5.00, 0.4 s 0.4 ISE: 0.1677 ISE: 0.8383 0.3 0.2 0.2 0.1 0 0 1 2 3 4 5 6 7 Time (sec) 0 0 1 2 3 4 5 6 7 Figure 7: LQR design, response with a large cost on output error. Time (sec) Figure 6: LQR response for the sampled system,Ts = 1/6 [seconds. Dashed line: continuous-time system response. Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 15 Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 16 EE/ME 574: Intermediate Controls Section 2.2.2 EE/ME 574: Intermediate Controls Section 3.0.0 3 Integral control for discrete state-space systems 2.2.2 Try another new Q (draft) 1 0 0 Q = 0 100 0 , 0 0 0 • To use a controller design with internal state(s), we augment the state vector with the controller state(s), using Eqn (??). R = [1] • Specifically, to put in integral control introduce >> K3z = lqr(SSuyz, Q3, R) >> ... ie (k) = − ∑ e (k) = ie (k − 1)−e (k − 1) >> figure(4), clf >> step(SSryz, 7) by choosing Fcp = C p − D p K p , Discrete LQR, with continuous ’−−’ which gives ie (k + 1) = ie (k)+y (k)−r (k) Fcc = −D p Kc , Gcu = 0 , Gcr = −1 + Jcl 1 which leads to: 0.9 0.8 Q=[ [ [ Amplitude 0.7 PO: −0.00%, 1.00 0.00 0.00] 0.00 100.00 0.00] 0.00 0.00 0.00] Tr: 0.33, 0.6 T : 0.50, 0.5 ISE: 0.1785 s Fa = 0.4 0.3 Ap .. . ··· ··· ··· Cp − D p Kp .. . 1 − D p Kc 0 , B p Gau = · · · , 0 0.2 where the controller gain vector is partitioned according to Ka = 0.1 0 . 0 1 2 3 4 5 6 Gar = N f Bp ··· −1 + Dcl K p : Kc 7 Time (sec) Figure 8: LQR design, response with a modest additional cost on rate. • Control can then be designed by: 1. Determine the Ka vector by Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 17 Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 18 EE/ME 574: Intermediate Controls Section 4.0.0 EE/ME 574: Intermediate Controls Section 4.0.0 − Controllability (a) DLQR (b) Pole placement 2. Select N f for good transient response (as given in example ??, or by trial and error, or other method) • Integral control can significantly improve performance, especially accuracy. >> CCntl = [Bp, Ap*Bp, Ap*Ap*Bp] CCntl = 0.9076 0.6056 0.0807 0.0640 0.2124 0.2626 1.9484 -1.3938 -0.5090 >> rank(CCntl) ans = 3 4 Controllability and Observability − The system is controllable • The concepts of controllability and observability carry over to discrete systems. − The mathematical foundations are somewhat different − The equations for controllability and observability are the same. C = B A B A2 B · · · A(n−1) B O = C CA C A2 .. . C A(n−2) (14) (15) • Considering the voice coil motor: Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 19 Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 20 EE/ME 574: Intermediate Controls Section 4.0.0 − Observability: EE/ME 574: Intermediate Controls 5 Conclusions, Discrete Section 5.0.0 State-variable model formulation and control >> OObsvr = [Cp; Cp*Ap; Cp*Ap*Ap] OObsvr = 0 1.0000 0 0.1245 1.0000 0.0182 0.1538 1.0000 0.0303 >> rank(OObsvr) ans = 3 • Discrete state-variable models can be obtained by − Converting a continuous-time state-variable model − Converting a discrete transfer-function model, with tf2ss() − Some systems are naturally discrete (e.g., an inventory control system, or message queues in the controls of a communication network) − The system is observable • Poles are the eigenvalues of the system matrix, A p in the notation used here − Poles must be interpreted on the z-plane, or − Converted to equivalent s-plane poles and interpreted. • Controller design can be done in several ways − Pole placement, by determining the desired z-plane poles − By the Linear-Quadratic-Regulator algorithm • Matlab’s tools make it straight forward to generate various models, to address − Output response − Error response − Control response − Disturbance response Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 21 Part 6: Discrete State Space Methods (Revised: May 06, 2014) Page 22 EE/ME 574: Intermediate Controls EE/ME 574: Intermediate Controls Section 1.0.0 1 Introduction Direct Digital Design or The Discrete Root Locus • As we’ve seen, the digital equivalent of an S-plane controller design can break down if the sample rate is not 20 - 50 times faster than the closedloop bandwidth. – Sampling with 20 FBW ≤ Fs ≤ 50 FBW is sometimes called ’rapid sampling’ Contents 1 Introduction 1.1 Illustration of the effects of rapid sampling . . . . . . . . . . . . . 1.1.1 High noise sensitivity . . . . . . . . . . . . . . . . . . . 1.1.2 High sensitivity to parameter variation . . . . . . . . . . 2 Direct Digital Control Design (section 8.6 in edition)) 2.1 Direct digital design, example 1 . . . . . . 2.1.1 Example: apply PI compensation . 2.2 A more complex example . . . . . . . . . . Franklin et al. • Advantages of rapid sampling: – Minimal phase lag introduced by the Zero-Order-Hold – More accurately implement the discrete equivalent of Gc (s) • Rapid sampling, however, has some disadvantages. Disadvantages of rapid sampling: (5th . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Conclusions 2 3 3 4 10 12 16 21 27 – Sensitivity to sensor and round-off noise can increase with the sample rate (especially for PD, PID control) ∗ Rapid sampling gives high sensitivity to small variations in gain. ∗ Variations in gain arise through component variations, and also through round-off error • Direct digital design can permit slow sampling, 5 FBW ≤ Fs < 20 FBW which avoids the disadvantages of rapid sampling – In direct digital design all design work is done in the Z-domain – Phase lag introduced by the Zero-Order-Hold is explicitly considered, and compensated by phase lead – There is no Gc (s) – Sensitivity to sensor noise and round-off error can be lower with slower sampling – Sensitivity to coefficient variations is lower with slower sampling Part 7: Direct Digital Design (Revised: May 09, 2013) Page 1 Part 7: Direct Digital Design (Revised: May 09, 2013) Page 2 EE/ME 574: Intermediate Controls Section 1.1.1 1.1 Illustration of the effects of rapid sampling EE/ME 574: Intermediate Controls 1.1.2 High sensitivity to parameter variation 1.1.1 High noise sensitivity • Consider the plant given by: • Consider the PD compensator: Gc (s) = kd s + k p with kd = k p = 1 Section 1.1.2 G p (s) = (1) 1 , s2 + s + 0.1 Hy (s) = 1 , 0.02 s + 1 Gc (s) = 6 3s +1 3s +1 0.48 s + 1 30 s + 1 where the compensator is a Lead-Lag compensator chosen for a phase margin of PM ≥ 600, with steady-state error, SSE (step) ≤ 10%. – Gc (z), with Fs = 10 [samples/second] >> Ts=1/Fs Ts = 0.1000 >> GPDz = c2d(GPDs, Ts, ’tustin’) Transfer function: 21 z - 19 Gc(z) = --------z + 1, • The Bode plot and step response are seen in figure 1. Fbw =0.35 [Hz] Bode Diagram Gm = 30.7 dB (at 11.1 rad/sec) , Pm = 67.6 deg (at 1.34 rad/sec) Step Response 50 1.4 Magnitude (dB) 0 The implementation equation is 1.2 −50 1 u (k) = −u (k − 1) + 21 e (k) − 19 e (k − 1) Amplitude −100 −150 0 0.8 0.6 >> Ts=1/Fs Ts = 0.0100 >> GPDz = c2d(GPDs, Ts, ’tustin’) Transfer function: Gc(z) = Phase (deg) – Gc (z), with Fs = 100 [samples/second] −90 0.4 −180 0.2 −270 −3 10 −2 10 −1 10 0 10 Frequency (rad/sec) 1 10 2 10 3 10 0 0 2 4 6 8 10 Time (sec) 12 14 Figure 1: Bode plot and step response for example system. 201 z - 199 ----------- The implementation equation is • The closed-loop bandwidth is 2.2 [rad/second], so we can choose the sample rate to be as high as 17 samples/second, and stay within the range Fs ≤ 50 × FBW u (k) = −u (k − 1) + 201 e (k) − 199 e (k − 1) • Changing Fs from 10 to 100, the numerator terms (coefficients multiplying e (k)and e (k − 1)) have become 10x larger. • Choosing Fs = 17 [samples/second] gives • If there is noise on the e (k) signal, it will have a 10x larger impact on u (k) ! >> Gcz Part 7: Direct Digital Design (Revised: May 09, 2013) Page 3 Part 7: Direct Digital Design (Revised: May 09, 2013) Page 4 16 18 EE/ME 574: Intermediate Controls Section 1.1.2 • Looking at the closed-loop pole constellation, figure 2(a), the closed-loop poles seem reasonable. 3.6 z^2 - 7.059 z + 3.461 ------------------------z^2 - 1.883 z + 0.8828 • Figure 2(b) is more worrisome. It shows the constellation of poles given by a random variation with σ =0.01 in the compensator parameters. imaginary Transfer function: Section 1.1.2 1.5 1.5 1 1 0.5 0.5 imaginary EE/ME 574: Intermediate Controls 0 0 −0.5 −0.5 −1 −1 −1.5 −1.5 −1 −0.5 0 real 0.5 1 1.5 −1.5 −1.5 −1 −0.5 0 real 0.5 1 1.5 Cluster of poles given with (a) Pole constellation, ideal parameters (b) σ=0.01 parameter variation Figure 2: Closed-loop pole constellation for the digitized system, design by discrete equivalent. Fs = 17, or 50x Fbw . • Code to draw figure 2(b) sigma = 0.01; clear Poles; for jj = 1:100, Num = Gcz.num{1}; Den = Gcz.den{1}; Num = Num + sigma*randn(size(Num)); %% Add 0.01 variation Den = Den + sigma*randn(size(Den)); Den(1) = 1; Try_z = feedback(tf(Num, Den, Ts)*Gpz, 1); Poles(:,jj) = pole(Try_z); end Part 7: Direct Digital Design (Revised: May 09, 2013) Page 5 Part 7: Direct Digital Design (Revised: May 09, 2013) Page 6 EE/ME 574: Intermediate Controls Section 1.1.2 EE/ME 574: Intermediate Controls 1.1.2 High sensitivity to parameter variation (continued) Section 1.1.2 (Although controller parameters have to be at least 16 bit, and preferably 32 or 64 bit). • Figure 3 shows the range pole locations corresponding to Fs = 1.4 [Samples per second], (Fs ≃ 4 × Fbw ) , and coefficient variations of 0.01 standard deviation. 1.5 1.5 1 1 0.5 0.5 imaginary imaginary • While this system has variation in the closed-loop poles, it does not go unstable for any value with this range of variation. 0 0 −0.5 −0.5 −1 −1 −1.5 −1.5 −1 −0.5 0 real 0.5 1 1.5 −1.5 −1.5 −1 −0.5 0 real 0.5 1 1.5 Cluster of poles given with σ=0.01 parameter variation Figure 3: Closed-loop pole constellation for the digitized system, Fs = 1.4 [samples/second], or 4x Fbw , with variations with σ =0.01. (a) Pole constellation, ideal parameters (b) • Variation in the effective value of controller parameters can come about through round-off error in the digital control calculations. – This is especially true because controllers are often implemented with 16 or even 8-bit microprocessors Part 7: Direct Digital Design (Revised: May 09, 2013) Page 7 Part 7: Direct Digital Design (Revised: May 09, 2013) Page 8 EE/ME 574: Intermediate Controls Section 1.1.2 EE/ME 574: Intermediate Controls Section 2.0.0 2 Direct Digital Control Design (section 8.6 in 1.1.2 High sensitivity to parameter variation (concluded) • Random variations with σ = 0.001 and Fs = 100 [samples/second] are seen in figure 4. Franklin et al. (5th edition)) • The design process bears a strong relationship to continuous-time design: – Many of the cases give poles outside the unit circle – Analysis tools: • Round-off errors of ±0.001 are hard to avoid (especially with integer arithmetic) * Root locus • Fs = 100 will work very nicely in theory, but practically speaking, it is sampling too fast. 0.2 * Bode plot * Step response – Compensators: * Phase - lead * PD * Phase - lag * PI * Lead - Lag * PID 0.15 • For continuous design, learning to interpret pole-locations on the S-plane is essential. imaginary 0.1 0.05 • For discrete design it is essential to learn to interpret pole locations on the Z-plane. 0 −0.05 −0.1 −0.15 0.7 0.75 0.8 0.85 0.9 real 0.95 1 1.05 Figure 4: Closed-loop pole constellation for the digitized system, Fs = 100 [samples/second], or 290x Fbw , with variations with σ =0.001. Part 7: Direct Digital Design (Revised: May 09, 2013) Page 9 Part 7: Direct Digital Design (Revised: May 09, 2013) Page 10 EE/ME 574: Intermediate Controls Section 2.0.0 EE/ME 574: Intermediate Controls Section 2.1.0 2.1 Direct digital design, example 1 • Direct digital design proceeds by these three steps 1. Select sample rate, convert the models of continuous-time system elements to discrete-time (Z-transform) models. • A typical control loop is seen in figure 5. Discrete part, Computer Controller r(k) Trajectory Generator 2. Design the control, using, for example + e(k) ys(t) – Root locus ys(k) Kc Gc(z) u(k) ZOH (D/A Conv.) - u(t) Plant y(t) Gp(s) t=kTs (A/D Conv.) – Frequency response / Bode plot Sensor Hy(s) – Discrete Final Value Theorem Analog part 3. Analyze the resulting discrete time system in discrete-time Figure 5: Basic sampled control loop. 4. Iteratively adjust the design parameters to achieve performance goals. • Consider the example system G p1s (s) = • Direct digital design has the advantages: – It is exact, the sampled model obtained in step 1 is exact. 1 s+1 , Hy1 (s) = 1 (2) • Performance Requirements: – Generally speaking, lower sample rates are possible – ωb ≥ 1 [rad/sec] • Something that some people may consider a disadvantage is that pole-zero maps in the Z-plane must be considered; requiring a developed sense of how to interpret the Z-plane. – PO ≤ 20% – SSE(step) ≤ 10% • The performance requirements translate to: – ωc ≥ 0.5 [rad/sec] – PM ≥ 50o Part 7: Direct Digital Design (Revised: May 09, 2013) Page 11 Part 7: Direct Digital Design (Revised: May 09, 2013) Page 12 Section 2.1.0 • As a first selection, choose Ts = 0.25 [seconds] (we can revise Ts later) EE/ME 574: Intermediate Controls Section 2.1.0 • Looking at CL poles and response with proportional feedback Kc Root Locus >> jj=0; >> for Kc = [0.5, 2, 5, 9], >> jj=jj+1; >> Try =feedback(Kc*Gp1z, 1) >> Poles(:,jj) =pole(Try); >> end >> Gp1s = tf(1, [1 1]) ; Ts = 0.25 >> Gp1z = c2d(Gp1s, Ts, ’zoh’) Transfer function: 0.2212 ---------z - 0.7788 1 0.8 0.6 0.4 Imaginary Axis EE/ME 574: Intermediate Controls 0.2 9.0 5.0 2.0 0.5 0 −0.2 −0.4 −0.6 −0.8 • The root locus indicates pole-location for proportional control −1 −1.5 −1 −0.5 0 0.5 1 Real Axis Root Locus >> rlocus(Gp1z) Figure 7: Root locus for plant Eqn (2). 1 1 1 0.8 Kc = 2.00 Kc = 0.50 0.9 0.9 0.6 0.8 0.8 0.7 0.7 0.2 0.6 0.6 0 y(k) Imaginary Axis 0.4 −0.2 0.5 0.5 0.4 −0.4 0.4 −0.6 0.3 0.3 −0.8 0.2 0.2 −1 0.1 0 −1.5 −1 −0.5 0 0.5 1 0.1 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 4 4.5 5 Real Axis 40 Figure 6: Root locus for plant Eqn (2). Kc = 9.00 Kc = 5.00 30 1.2 20 1 10 0 y(k) 0.8 −10 0.6 −20 0.4 −30 0.2 0 −40 0 0.5 1 1.5 2 2.5 k [sample] 3 3.5 4 4.5 5 −50 0 0.5 1 1.5 2 2.5 k [sample] 3 3.5 Figure 8: Step responses for four values of K. Part 7: Direct Digital Design (Revised: May 09, 2013) Page 13 Part 7: Direct Digital Design (Revised: May 09, 2013) Page 14 EE/ME 574: Intermediate Controls Section 2.1.0 • Kc = 2 is the largest tested value for smooth proportional control. EE/ME 574: Intermediate Controls Section 2.1.1 2.1.1 Example: apply PI compensation • Consider the steady state error with Kc = 2.0. The discrete FVT: z−1 Trez (z) R (z) lim e (k) = lim 1 − z−1 E (z) = lim z→1 z→1 k→∞ z (3) • Since the speed and damping are adequate, but SSE is too large, consider PI control. Discrete PI control has the structure: Kc Gc1z (z) = Kc Note that 1 − z−1 = z−1 , z and E (z) = Trez (z) R (z) z + b1 z−1 (4) • Initial choice for b1, b1 = −0.2 (placing the zero on the real axis) with R (z) = z z−1 Ts z >> Gc1z= tf([1 -0.2], [1 -1], Ts) 1 step input 0.8 Transfer function: z - 0.2 Gc1z(a) = ------z - 1 0.6 ramp input 2 (z − 1) 0.4 Imaginary R (z) = • Forming the TF Trez (z) 0.2 0 −0.2 −0.4 −0.6 −0.8 >> Trez = feedback(1, K*Gp1z) Transfer function: z 0.7788 ------------z - 0.3364 −1 −1.5 −1 −0.5 0 0.5 1 Real Figure 9: PZ map with PI compensator. ⋄: compensator pole, o: comp. zero. • Forming the right-hand side of Eqn (3) SSE(step) = lim z→1 z−1 z z − 0.7788 z − 0.3364 z z−1 • Cancel the zero and pole at z = +1 SSE(step) = lim z→1 z − 0.7788 0.2212 = = 33% z − 0.3364 0.6636 • SSE(step) is much too large. Part 7: Direct Digital Design (Revised: May 09, 2013) Page 15 Part 7: Direct Digital Design (Revised: May 09, 2013) Page 16 EE/ME 574: Intermediate Controls Section 2.1.1 • Consider the Bode plot and root-locus for Gc1z (z) G p1z (z) , (initially set Kc = 1.0) EE/ME 574: Intermediate Controls Section 2.1.1 • Consider the step response: >> figure(3), clf >> step(Tryz) >> Kc = 1.0; >> figure(1), clf >> margin(Kc*Gc1z*Gp1z) Step Response >> Tryz = feedback(Kc*Gc1z*Gp1z, 1) >> Axis1 = [ -1.5 1.2 1.2*[-1 1]]; tt = 0:0.01:(2*pi); >> figure(3), clf >> rlocus(Kc*Gc1z*Gp1z) >> axis(Axis1); set(gca, ’DataAspectRatio’, [1 1 1]) >> hold on >> plot(cos(tt), sin(tt), ’k:’, ’linewidth’, 2); %% plot unit circle >> plot(real(pole(Tryz)), imag(pole(Tryz)), ’rd’) %% plot closed-loop poles >> hold off 1.4 1.2 Amplitude 1 0.8 0.6 0.4 0.2 0 0 Bode Diagram Gm = 22.5 dB (at 12.6 rad/sec) , Pm = 35.8 deg (at 1.7 rad/sec) 2 4 6 8 10 12 Time (sec) Root Locus Figure 11: Step response with K = 1 and PZ map of figure 10. 40 1 20 0.8 0 0.6 0.4 −20 Imaginary Axis Magnitude (dB) 60 Phase (deg) −40 −90 • Consider the bandwidth 0.2 0 −0.2 >> Wb = bandwidth(Tryz) Wb = 2.7175 −0.4 −135 −0.6 −0.8 −1 −180 −2 10 −1 10 0 10 1 10 2 10 −1.5 Frequency (rad/sec) −1 −0.5 0 0.5 1 Real Axis • Consider the steady-state error Figure 10: Margins plot and root locus for Gc1 (z) and CL poles with K = 1.0 . >> • The Bode plot shows more than adequate ωc • The phase margin is insufficient, but can be increased by reducing Kc . SSEStep = bode(Trez, 0), SSEStep = 8.8818e-16 – SSEstep is effectively 0, corresponding to the Type I system. • Since the control is PI, SSE(step) will be 0. Part 7: Direct Digital Design (Revised: May 09, 2013) Page 17 Part 7: Direct Digital Design (Revised: May 09, 2013) Page 18 Section 2.1.1 EE/ME 574: Intermediate Controls • Considering SSE for the ramp input (since the system is Type I) • Returning to the root locus, we know that if we move the zero closer to the poles, it will bring the root-locus branches closer to the real axis. • Method 1: Final value theorem lim e (k) = ess = lim 1 − z−1 Tre (z) R (z) – Moving the compensator zero to z = 0.5 (5) z→1 (z − 1) z2 − 1.779 z − 0.7788 Ts z z→1 1 z2 − 1.558 z + 0.7346 (z − 1)2 (z − 1) (z − 1) (z − 0.7788) Ts z = lim z→1 1 z2 − 1.558 z + 0.7346 (z − 1)2 (1 − 0.7788) 1 = Ts = 0.3125 1 − 1.558 + 0.7346 = lim (6) Bode Diagram Gm = 11.1 dB (at 12.6 rad/sec) , Pm = 46.1 deg (at 2.9 rad/sec) 60 (7) (8) Magnitude (dB) k→∞ >> SSE_ramp = bode( tf([1 -1], 1, Ts) ... * Trez ... * tf(Ts*[1 0], [1 -2 1], Ts), 0) SSE_ramp = 0.3125 Phase (deg) – Setup the Z-transform of Eqn (6) directly for Matlab’s bode command: 0 −0.2 −0.6 −0.8 −1 0 10 1 10 2 10 10 −1.5 −1 −0.5 0 0.5 1 Real Axis Figure 12: Margins plot and root locus for Gc2 (z) and CL Poles for Kc = 1.0 . >> Gc2z= tf([1 -0.5], [1 -1], Ts) Transfer function: z - 0.5 ------z - 1 SSEStep = 0 Wb = 2.04 [rad/sec] PO = 15.6% Step Response 1.4 1 Amplitude 0.8 0.6 • 1st PI controller: 0.2 −0.4 −135 1.2 term 0.4 0.2 – ωb OK, • Design Complete ! 0 0 – SSE(step) OK, 1 2 3 4 5 6 7 8 9 Time (sec) Figure 13: Step response with Kc = 1 and Gc2z (z). – PO too large. Part 7: Direct Digital Design 0.4 −1 term Ts z (z−1)2 0.6 0 Frequency (rad/sec) 2. The Tre (z) term 3. The 1 0.8 20 −180 −2 10 Note that the transfer function given the bode() command has three parts, corresponding to the three terms in Eqn (6) (z−1) z Root Locus 40 −20 −90 • Method 2: use matlab bode command: 1. The Section 2.1.1 Imaginary Axis EE/ME 574: Intermediate Controls (Revised: May 09, 2013) Page 19 Part 7: Direct Digital Design (Revised: May 09, 2013) Page 20 EE/ME 574: Intermediate Controls Section 2.2.0 EE/ME 574: Intermediate Controls 2.2 A more complex example • Phase-lead compensation, first engineered in continuous-time >> Kcs = 2.0; tau = 0.5; alpha = 0.2; >> Gcs = tf([tau 1], [tau*alpha 1]) Transfer function: 0.5 s + 1 Gcs(s) = --------0.1 s + 1 • Consider the Boeing 777 pitch control example from CTM: 1.151 s + 0.1774 ------------------------s^3 + 0.739 s^2 + 0.921 s Bode Diagram 20 15 50 10 0 −50 0 −100 0 −50 −100 0 −45 0 −45 −90 −10 −90 −15 −135 −180 −3 10 −2 10 −1 0 10 10 1 10 2 10 S−plane −20 −20 3 10 −10 0 10 Real Axis Frequency (rad/sec) −135 −180 −2 10 5 −5 Phase (deg) Magnitude (dB) 50 Root Locus Bode Diagram Gm = Inf dB (at Inf rad/sec) , Pm = 55.4 deg (at 1.93 rad/sec) 100 Magnitude (dB) Guy(s) = Imaginary Axis >> num=[1.151 0.1774]; >> den=[1 0.739 0.921 0]; >> Guy = tf(num,den) Transfer function: Phase (deg) Section 2.2.0 Figure 15: Margins plot and root locus for Gc (s) G p (s). −1 10 0 10 1 10 2 10 Frequency (rad/sec) Step Response Figure 14: Bode plot for Boeing 777 pitch control. 1 0.9 0.8 • Design goals: – Put cross-over above the resonance, increase accuracy and avoid a very low ωb Amplitude 0.7 0.6 0.5 0.4 0.3 • Plan: 0.2 0.1 – Apply phase-lead compensation to boost phase margin around ωc = 5.0 [rad/sec] Part 7: Direct Digital Design (Revised: May 09, 2013) Page 21 0 0 10 20 30 40 50 Time (sec) Figure 16: Continuous system step response with Kc = 10 and PZ map of Fig. 15. Part 7: Direct Digital Design (Revised: May 09, 2013) Page 22 EE/ME 574: Intermediate Controls Section 2.2.0 EE/ME 574: Intermediate Controls • First iteration: design by discrete equivalent Section 2.2.0 • Look at the root locus. • Notice many poles and zeros in a small region near z = +1.0 . – Start with rapid sampling, FBW = 0.43 , choose Fs = 20 or 47x FBW >> Fs = 20; Ts = 1/Fs; >> Gcz = c2d(Gcs, Ts, ’tustin’) Transfer function: Gcz(z) = • This will lead to the condition where small variations in parameters make large variations in closed-loop pole locations. 4.2 z - 3.8 ----------z - 0.6 • Several poles and zeros crowded into the region near z = +1 indicates that the sample rate is too high. Sampling time: 0.05 Root Locus • Taking a look at the margins and step response of the discrete system 0.8 Root Locus 0.6 2 • The response of the discrete implementation looks very 0.4 Imaginary Axis 1.5 1 Imaginary Axis comparable to the continuous system response. 0.5 0 Step Response −0.4 −1 −0.6 1.4 100 0 −0.2 −0.5 Bode Diagram Gm = 29.4 dB (at 17.1 rad/sec) , Pm = 52.7 deg (at 1.93 rad/sec) 0.2 −3 −2.5 −2 −1.5 −1 −0.5 0 0.5 1 0 0.5 1 Real Axis 1.5 Real Axis 1 Figure 18: Root locus corresponding to figure 17. −100 0 Phase (deg) −2 −3.5 −50 0.8 0.6 −90 0.4 −180 −270 −3 10 −0.8 Z−plane 1.2 0 Amplitude Magnitude (dB) −1.5 50 0.2 −2 10 −1 10 0 10 Frequency (rad/sec) 1 10 2 10 0 0 5 10 15 20 25 30 35 40 45 Time (sec) Figure 17: Margins plot and step response for Gcz (z) G pz (z). Part 7: Direct Digital Design (Revised: May 09, 2013) Page 23 Part 7: Direct Digital Design (Revised: May 09, 2013) Page 24 EE/ME 574: Intermediate Controls Section 2.2.0 • Second design iteration. Reduce the sample rate, Fs = 2.4 [Hz], or 5.6xFBW . >> Gcz = c2d(Gcs, Ts, ’tustin’) Transfer function: 2.297 z - 0.9459 ---------------z + 0.3514 Sampling time: 0.41667 EE/ME 574: Intermediate Controls Section 2.2.0 • Examine loop-gain poles, to determine system Type >> OLPoles = pole( Kcz*Gcz*Guyz) OLPoles = 1.0000 0.7996 + 0.3093i 0.7996 - 0.3093i -0.3514 • From Bode plot, choose Kc = 1.5 (ωc above resonance, reasonable PM) Bode Diagram Gm = 13 dB (at 4.19 rad/sec) , Pm = 39.6 deg (at 1.66 rad/sec) 1.2 20 >> Trez = feedback(1, Kz*Gcz*Guyz) Transfer function: z^4 - 2.248 z^3 + 1.421 z^2 + 0.08513 z - 0.2582 -----------------------------------------------z^4 - 1.934 z^3 + 1.286 z^2 - 0.1843 z - 0.1464 1 0 −20 Amplitude Magnitude (dB) 40 −40 0 Phase (deg) • Steady-state error Step Response 1.4 60 0.8 0.6 −90 0.4 −180 0.2 −270 −3 10 −2 −1 10 0 10 0 0 1 10 10 10 20 30 Frequency (rad/sec) 40 50 60 70 Time (sec) • One OL Pole at z = +1, system is Type I Figure 19: Margins plot and step response for Gc (z) G p (z). Root Locus • Check SSE(step) 0.8 Root Locus 2 0.6 1.5 >> SSEStep = bode(Trez, 0) SSEStep = 3.8733e-14 (0 to within round-off error) 0.4 Imaginary Axis Imaginary Axis 1 0.5 0 0.2 0 −0.2 • Check SSE(ramp) −0.5 −0.4 −1 −0.6 −1.5 −0.8 Z−plane −2 −3.5 −3 −2.5 −2 −1.5 −1 −0.5 0 0.5 1 1.5 0 0.5 1 Real Axis Real Axis Figure 20: Root locus corresponding to figure 19. • Result of reduced Fs : 3 poles have been moved away from the z = +1 region. Part 7: Direct Digital Design (Revised: May 09, 2013) Page 25 >> Wa = 0.001; >> SSE_ramp = 100/bode( Wa* Kcz*Gcz*Guyz , Wa) SSE_ramp = 346.10 – 346% SSE(ramp) appears large, but does not violate the specification. Part 7: Direct Digital Design (Revised: May 09, 2013) Page 26 EE/ME 574: Intermediate Controls Section 3.0.0 3 Conclusions • Design can combine a variety of processes – Direct Digital Design – Design by Discrete Emulation + Iteration based on Direct Digital Design • Direct Digital Design – Direct analysis of the discrete domain Bode plot and root locus needed to understand behavior of the discrete system. – Especially when Fs is only a little greater than the bandwidth. • Analysis of system response is done in the discrete domain – Step response – Margins – Bode plot – Steady-state error – Root locus Part 7: Direct Digital Design (Revised: May 09, 2013) Page 27