413Presentation

Page 1

Digital Controls Course Outline • Introduction to control systems; control system examples; basic principle of feedback control’ brief review of control development history. • Digital control systems design: Time domain specifications; Dynamic response to unit step and ramp functions. Stability of discrete time system; Digital PID design; Pole placement design. • Digital Control system design: Frequency domain specifications; Gain and phase margins; Compensator design with bilinear transformations. • Digital control system design through state space approach: State space description of discrete systems; State feedback design via pole placement; State estimator design; Controller design with state estimator. EECE 413, Fall, 2006

1


What Is a Control System? Desired Performance: REFERENCE

Difference:

INPUT

ERROR

To the System

Controller

Aircraft, missiles, cars, appliances, economic systems, etc.

Information about the system: OUTPUT

System to be controlled

• Control system objective: To make the system output and desired reference as close as possible, i.e., to make the error as small as possible. • Key issues: – How to describe the system to be controlled? (Modeling) – How to design the controller? (Control) EECE 413, Fall, 2006

2


Simple System Model for Cruise Control acceleration Friction force

bx

x displacement Mass m

Force u

By Newton’s Law of motion: f = ma, where f is the total force applied to an object with a mass m and a is the acceleration, we have

b u u − bx = mx ⇔ x + x = m m This is a 2nd order Ordinary Differential Equation (ODE) with respect to displacement x. It can be written as a 1st order ODE with respect to speed v = x

v +

b u v=  Model of the cruise control system, u is input force, v is output. m m

EECE 413, Fall, 2006

3


Cruise Control System REFERENCE

INPUT

OUTPUT

Controller

70 MPH

u ?

Speed v

b u v + v = m m

Control engineering is to design the controller in a way that the system meets desired performance specifications. EECE 413, Fall, 2006

4


Basic Electrical Systems Resistor

i v

i(t)

V = iR

R

v(t)

Capacitor

i(t) v(t)

C

L

i = C dv/dt

Kirchhoff’s Voltage Law (KVL) The sum of voltage drops around any closed loop in a circuit is 0. v2

Inductor

v = L di/dt

Kirchhoff’s Current Law (KCL) The sum of currents entering/leaving a i2 node/closed surface is 0. i1

i2

i1 i3

i3 v1

v3

i5

i4

v1 + v2 + v3 + v4 + v5 = 0 v5

i5 i1 + i2 + i3 + i4 + i5 = 0

v4

EECE 413, Fall, 2006

5

i4


Modeling of a simple electrical system: To find out the relationship between the input (vi) and the output (vo) for the circuit:

vR = Ri = RC

dvo dt

i vi

By KVL, we have

R

C

dvo i=C dt

vo

vo + vR − vi = 0 ⇒ dvo vo + vR − vi = vo + RC − vi = 0 dt

dvo ⇒ RC + vo = vi ⇔ RCv o + vo = vi dt EECE 413, Fall, 2006

A dynamic model of the circuit 6


Dynamic Analogies Physically dissimilar systems can have similar dynamic properties. For example, consider a spring-mass system. v(t)

K

f(t)

M

M = mass, B = friction constant, K = spring constant, f(t) = external force, and v(t) = velocity of the mass.

B Summing the forces yields: t

dv(t ) f (t ) = M + Bv(t ) + K ∫ v(τ )dτ dt −∞ Inertial force spring force friction force

EECE 413, Fall, 2006

7


More Dynamic Analogies Electric network

iC(t) i(t)

C

iR(t) R

iL(t) L

Summing the currents (Kirchhoff’s Current law) yields: t

dv(t ) v(t ) 1 i (t ) = C + + ∫ v(τ )dτ dt R L −∞ capacitance resistance

inductance

EECE 413, Fall, 2006

8


Mechanical and Electrical systems are dynamically analogous t

dv(t ) f (t ) = M + Bv(t ) + K ∫ v(τ )dτ dt −∞ t

dv(t ) v(t ) 1 i (t ) = C + + ∫ v(τ )dτ dt R L −∞ Thus, understanding one of these systems gives insights into the other.

EECE 413, Fall, 2006

9


Block Diagrams A block diagram using integrators, adders, and gains: t

dv(t ) f (t ) = M + Bv(t ) + K ∫ v(τ )dτ = Mx + Bx + Kx dt −∞ f(t) + -

+

dv(t ) dt

1/M -

v(t)

B

K

t

∫ v(τ )dτ

−∞

EECE 413, Fall, 2006

Solve for

x

for starting point

Mx = f (t ) − Bx − Kx x =

1 [ f (t ) − Bx − Kx ] M

where x =

dv(t ) & x = v(t ) dt

Conclusion: We have seen several types of descriptions of systems: spring-mass, RLC circuit, block diagram, and equations. All four descriptions define a system with the same dynamic properties. We will develop methods that characterize these systems efficiently and that abstract their critical dynamic properties.

10


Voltage Control of the Simple Electrical System REFERENCE

INPUT Controller

220 volts

vi

vi ?

i

OUTPUT R

C

vo

RCv o + vo = vi

vo

Control engineering is to design the controller in a way that the system meets desired performance specifications. EECE 413, Fall, 2006

11


Ordinary Differential Equations (ODE) Many real life problems can be modeled as an ODE of the following form:

y ( t ) + a1 y ( t ) + a0 y ( t ) = b0u ( t ) This is called a 2nd order ODE as the highest order derivative in the equations is 2. The ODE is said to be homogeneous if u(t) = 0. Many systems can be modeled or approximated as a 1st order ODE.

y ( t ) + a0 y ( t ) = b0u ( t ) An ODE is also called the time-domain model of the system, because it can be seen from the above equations that y(t) and u(t) are functions of time t. The key issue associated with ODE is: how to find its solution? That is: how to find an explicit expression for y(t) from the given equation(s)?

EECE 413, Fall, 2006

12


Laplace Transform and Inverse Laplace Transform Let’s first examine the following time-domain functions: x(t) = cos(0.4*pi*t) + sin(0.8*pi*t)*cos(1.6*pi*t) What are the frequencies of this function?

1

2

0.5

1 magnitude

Signal plots

magnitude

Cosine function with a frequency f = 0.2 Hz Note it has a period T = 1/f = 5 seconds

0 -0.5 -1

0

5

0 -1 -2

10

0

15 10 5 0

0.1

0.2 0.3 0.4 0.5 frequency (Hz)

10

f = 0.2, 0.4, & 1.2 Hz Frequency magnitude of y

PSD plots

Frequency magnitude of y

f = 0.2 Hz

5

15 10 5 0 0

0.5 1 frequency (Hz)

The Laplace transform is a tool to convert a time-domain function into a frequency-domain function in which information about frequencies of the function can be captured. It is often much easier to solve problems in frequency-domain with the help of Laplace transform.

EECE 413, Fall, 2006

13


Matlab Code for Previous Sinusoid Plots subplot(223) nfft = 512; Y = fft(s1',nfft); Pyy = Y.* conj(Y) / nfft; f = 1*(0:nfft/2)/nfft/dt; plot(f,Pyy(1:nfft/2+1)),grid on ylabel('Frequency magnitude of y') xlabel('frequency (Hz)')

% l1_sinusoids.m % dt = 0.05; f1 = 0.2; f2 = 0.4; f3 = 0.8; ntime = 10; ti = [0:dt:ntime-dt]; s1 = cos(f1*2*pi*ti); s2 = s1 + sin(f2*2*pi*ti).*cos(f3*2*pi*ti); figure(1) subplot(221) plot(ti',s1'),grid on % for 1 second trajectory ylabel('magnitude')

subplot(222) plot(ti',s2'),grid on ylabel('magnitude') subplot(224) nfft = 512; Y = fft(s2',nfft); Pyy = Y.* conj(Y) / nfft; f = 1*(0:nfft/2)/nfft/dt; plot(f,Pyy(1:nfft/2+1)),grid on ylabel('Frequency magnitude of y') xlabel('frequency (Hz)')

EECE 413, Fall, 2006

14


Laplace Transform Given a time-domain function f(t), its Laplace transform is defined as follows: ∞

F ( s ) = L{ f ( t )} = ∫ f ( t ) e − st dt 0

Example 1: Find the Laplace transform of a constant function f(t) = 1. ∞

F ( s) = ∫ 0

1 f ( t ) e − st dt = ∫ e − st dt = − e − st s 0

Re( s ) > 0

0

1 1 1 1  1  = − e −∞ −  − e 0  = − 0 + 1 = s s s s  s 

Example 2: Find the Laplace transform of an exponential function ∞

F ( s) = ∫ 0

1 −( s + a ) t f ( t ) e − st dt = ∫ e − at e − st dt = ∫ e −( s + a ) t dt = − e s + a 0 0

Re( s ) > −a

EECE 413, Fall, 2006

=− 0

f ( t ) = e − at

1 1 1 0+ 1= s+a s+a s+a

15


Inverse Laplace Transform Given a frequency-domain function F(s), the inverse Laplace transform is to convert it back to its original time domain function f(t). Here are some useful Laplace and inverse Laplace transform pairs. (See Appendix B)

f (t ) ⇔ F ( s ) 1 1⇔ s 1 t⇔ 2 s 1 − at e ⇔ s+a 1 − at te ⇔ ( s + a) 2

f (t ) ⇔ F ( s ) a s2 + a2 s cos( at ) ⇔ 2 s + a2

sin ( at ) ⇔

b e sin ( bt ) ⇔ ( s + a) 2 + b2 s+a − at e cos( bt ) ⇔ ( s + a) 2 + b2 − at

EECE 413, Fall, 2006

16


Laplace Transform Properties 1. Superposition:

L{ a1 f1 ( t ) + a2 f 2 ( t )} = a1 L{ f1 ( t )} + a2 L{ f 2 ( t )} = a1 F1 ( s ) + a2 F2 ( s ) 2. Differentiation: Assume that f(0) = 0.

 df ( t )  L  = L f ( t ) = sL{ f ( t )} = sF ( s )  dt 

{ }

d 2 f (t)  f ( t ) = s 2 L{ f ( t )} = s 2 F ( s ) L = L  2  dt 

{ }

3. Integration:

t  1 1 L ∫ f ( ζ ) dζ  = L{ f ( t )} = F ( s ) s 0  s

EECE 413, Fall, 2006

17


Express ODE models using Laplace Transforms to get transfer functions The mechanical system in the cruise-control problem can be represented by an ODE:

mv + bv = u Taking Laplace transforms on both sides of the equation, we obtain

L{ mv + bv} = L{ u} ⇒ L{ mv } + L{ bv} = L{ u} ⇒ msL{ v} + bL{ v} = L{ u} ⇒ msV ( s ) + bV ( s ) = U ( s ) V ( s) 1 ⇒ ( ms + b )V ( s ) = U ( s ) ⇒ = = G( s ) U ( s ) ms + b G(s) is called the transfer function of the system model.

EECE 413, Fall, 2006

18


Classical Feedback Control in Continuous Setting Examine block diagram of continuous time (CT) control system: R(s)

E(s) +

-

D(s)

U(s)

G(s)

Y(s)

Note that the objective of control system design is to match the output Y(s) to the reference R(s). So, we must compute the relationship between them. G(s) =

Y (s) ⇒ Y ( s ) = G ( s )U ( s ) U (s)

We also have U(s) = D(s)E(s), and E(s) = R(s) – Y(s), and

Y ( s ) = G ( s )U ( s ) = G ( s ) D ( s ) E ( s ) = G ( s ) D( s )[ R ( s ) − Y ( s )]

Y ( s ) = G ( s )U ( s ) = G ( s ) D ( s ) R ( s ) − G ( s ) D ( s )Y ( s ) ⇒ [1 + G ( s) D( s)]Y ( s) = G ( s) D( s) R( s) H (s) =

Y (s) G ( s ) D( s ) = R( s ) 1 + G ( s) D( s)

Closed-loop transfer function from R to Y.

EECE 413, Fall, 2006

19


Simplified Block Diagram in Continuous Setting The CT block diagram of the previous control system may be simplified as, R(s) r(t)

G ( s) D( s) H ( s) = 1 + G ( s) D( s)

Y(s) y(t)

The control problem is to choose an appropriate D(s) such that H(s) will have desired properties. We have,

 G ( s) D( s)  R(s) E ( s ) = R( s ) − Y ( s ) = R( s ) − H ( s ) R ( s ) = 1 − R ( s ) =  1 + G ( s ) D ( s ) 1 + G ( s) D( s)   The problem is equivalent to finding an appropriate control law D(s) such that the resulting error function e(t) goes to zero as quick and smooth as possible, which is the same as saying that the output y(t) is tracking the given reference r(t) as quick and as smooth as possible. We will mainly focus on the cases when r(t) is either a step function or a ramp function.

EECE 413, Fall, 2006

20


Two Approaches to Design a Digital Controller The 1st is to discretize the controller: R(s)

E(s) +

-

D(s)

U(s)

G(s)

ZOH

R(s) +

T

-

G(s)

D(z)

Y(s)

Y(s)

The 2nd is to discretize the plant and then apply digital control techniques for the controller:

R(z)

E(z) +

-

R(z)

E(z) +

-

U(z) D(z)

D(z)

ZOH Y(z) T

G(s)

U(z)

EECE 413, Fall, 2006

G(z)

Y(z)

21


Classical Feedback Control in Discrete Setting Examine block diagram of discrete time (DT) control system: R(z)

E(z) +

-

D(z)

U(z)

G(z)

Y(z)

Note that the objective of control system design is to match the output Y(z) to the reference R(z). So, we must compute the relationship between them. G( z) =

Y ( z) ⇒ Y ( z ) = G ( z )U ( z ) U ( z)

We also have U(z) = D(z)E(z), and E(z) = R(z) – Y(z), and

Y ( z ) = G ( z )U ( z ) = G ( z ) D( z ) E ( z ) = G ( z ) D ( z )[ R ( z ) − Y ( z )]

Y ( z ) = G ( z )U ( z ) = G ( z ) D ( z ) R ( z ) − G ( z ) D( z )Y ( z ) ⇒ [1 + G ( z ) D( z )]Y ( z ) = G ( z ) D( z ) R( z ) H ( z) =

Y ( z) G ( z ) D( z ) = R( z ) 1 + G ( z ) D( z )

Closed-loop transfer function from R to Y.

EECE 413, Fall, 2006

22


Simplified Block Diagram in Discrete Setting The DT block diagram of the previous control system may be simplified as, R(z) r(k)

G ( z ) D( z ) H ( z) = 1 + G ( z ) D( z )

Y(z) y(k)

The control problem is to choose an appropriate D(z) such that H(z) will have desired properties. We have,

 G ( z ) D( z )  R( z ) E ( z ) = R( z ) − Y ( z ) = R( z ) − H ( z ) R( z ) = 1 − R ( z ) =  1 + G ( z ) D ( z ) 1 + G ( z ) D( z )   The problem is equivalent to finding an appropriate control law D(z) such that the resulting error function e(k) goes to zero as quick and smooth as possible, which is the same as saying that the output y(k) is tracking the given reference r(k) as quick and as smooth as possible. We will mainly focus on the cases when r(k) is either a step function or a ramp function.

EECE 413, Fall, 2006

23


Steady State Errors In order to evaluate steady-state errors must evaluate the system error e: S(s) is called the sensitivity. In the E (s) 1 = = S ( s ) step input case to a stable system R( s ) 1 + D( s )G ( s ) the final value theorem tells us:

ess =

1 , 1+ K p

K p = lim D( s)G ( s ) s →0

Position error constant Kp If Kp and ess are finite (no s in D(s)G(s)), the system is type 0. Kv is the velocity constant & if finite (one s in D(s)G(s)), the system is type 1. Ka is the acceleration constant & if finite (two s’ in D(s)G(s)), the system is type 2.

K v = lim sD( s )G ( s) s →0

K a = lim s 2 D ( s )G ( s) s →0

See Table 2.1, p. 23, for error vs. system type.

EECE 413, Fall, 2006

24


Steady State Errors - continuous Case 1: If r(t) is a unit step, R(s) = 1/s, & by the final value theorem of Laplace Transform

e(∞) = lim sE ( s ) = lim s s →0

s →0

1 1 1 1 = = s 1 + G ( s ) D ( s ) 1 + G (0) D(0) 1 + K p

Proportional Error constant

Obviously, we need the proportional error constant to be infinity, which implies G(s)D(s) has at least a factor of 1/s (type 1 system) in order to make e(inf) zero. If Kp is a finite scalar, the open-loop system G(s)D(s) is said to be a Type 0 system. Case 2: If r(t) is a unit ramp, R(s) = 1/s2, & by the final value theorem of Laplace Transform

e(∞) = lim sE ( s ) = lim s s →0

s →0

1 1 1 1 = = s 2 1 + G ( s ) D ( s ) lim sG ( s ) D( s ) K v s →0

Velocity Error constant

Here we need the velocity error constant to be infinity, which implies G(s)D(s) has at last a factor of 1/s2 (Type 2 system) in order to make e(inf) zero.

EECE 413, Fall, 2006

25


Steady State Errors - discrete Case 1: If r(k) is a unit step, R(z) = z/(z-1), & by the final value theorem of z-Transform e(∞) = lim( z − 1) E ( z ) = lim( z − 1) z →1

z →1

z 1 1 1 = = z − 1 1 + G ( z ) D( z ) 1 + G (1) D(1) 1 + K p

Proportional Error constant

Obviously, we need the proportional error constant to be infinity, which implies G(z)D(z) has at least a factor of 1/(z-1) (type 1 system) in order to make e(inf) zero. If Kp is a finite scalar, the open-loop system G(z)D(z) is said to be a Type 0 system. Case 2: If r(k) is a unit ramp, R(z) = Tz/(z-1)2, & by the final value theorem of z-Transform

e(∞) = lim( z − 1) z →1

Tz 1 T 1 = = ( z − 1) 2 1 + G ( z ) D( z ) lim( z − 1) G ( z ) D( z ) K v z →1

Velocity Error constant

Here we need the velocity error constant to be infinity, which implies G(z)D(z) has at last a factor of 1/(z-1)2 (Type 2 system) in order to make e(inf) zero.

EECE 413, Fall, 2006

26


Final Value Theorem If a system is stable and has a final, constant value

lim x(t ) = xss = lim sX ( s ) t →∞

s →o

The final value theorem allows us to solve for that final value without extensive simulation. Useful for steady-state error estimation for control systems.

Time Domain Specifications • • • • • • •

Steady state accuracy Stability Rise time Overshoot Settling time Disturbance rejection others

Mp (in %)

overshoot

+-1%

1 0.9

Steady state error Rise time

1% settling time

0.1 td

tr ts

Transport delay – e-tds

EECE 413, Fall, 2006

27

t


Feedback Control System Block Diagram Properties Figure 2.8, p. 22 r + + Command Input

e

Disturbance, w

Compensation D(s)

+ +

+

Plant

y

G(s) Sensor

+

+

+

1

Measurement noise, v Transfer function of the closed-loop system, also called complementary sensitivity

The dynamic characteristics and stability are determined by the poles of the closed-loop transfer function of the characteristic equation. The sensitivity equation is useful to determine the effect of disturbances on the system error.

Y (s) D ( s )G ( s ) = = Τ( s) R ( s ) 1 + D ( s )G ( s )

1 + D( s )G ( s ) = 0 E ( s) 1 = = S (s) R ( s) 1 + D( s )G ( s )

EECE 413, Fall, 2006

Step

Ramp

Parabola

Type 0

1/(1+Kp)

Type 1

0

1/Kv

Type 2

0

0

1/Ka

28


Simplified Block Diagram in CT with PI Controller The CT block diagram of the previous control system may be simplified as, R(s)

G ( s) D( s) H ( s) = 1 + G ( s) D( s)

Y(s)

The control problem is to choose an appropriate D(s) such that H(s) will have desired properties between R(s) & Y(s). We’ll focus on control system design of some 1st order systems G(s) with a proportional-integral (PI) controller, D(s).

ki k p s + ki b G(s) = , D( s) = k p + = s+a s s bk p s + bki G ( s ) D( s) H ( s) = = 2 1 + G ( s ) D( s ) s + ( a + bk p ) s + bki The closed-loop system H(s) is a 2nd order system as its denominator is a polynomial s of degree 2.

EECE 413, Fall, 2006

29


Control System Stability e − at ⇔

Example 1: Consider a closed-loop system with, R(s) = 1

H (s) =

1 s2 −1

Y(s)

We have,

Y ( s) = H ( s) R( s) =

1 1 0.5 0.5 = = − 2 s − 1 ( s + 1)( s − 1) s − 1 s + 1

Using the Laplace transform table, we have,

(

y (t ) = 0.5 et − e − t

1 s+a

0.5e −t ⇔

0.5 s +1

0.5e t ⇔

0.5 s −1

)

Step Response 12000

This system is said to be unstable because the output response y(t) goes to infinity or is unbounded as time t gets large. This happens because the denominator of H(s) has one positive root at s = 1.

10000

Amplitude

8000

6000

4000

2000

0

0

1

2

3

4

5 Time (sec)

6

7

8

9

Matlab code: step(tf(1,[1 0 -1]),10),grid on 30 EECE 413, Fall, 2006 10


Control System Stability Example 2: Consider a closed-loop system with, R(s) = 1

1 H (s) = 2 s + 3s + 2

We have, 1 1 1 1 = = − s + 3s + 2 ( s + 1)( s + 2) s + 1 s + 2 A B A( s + 2) + B( s + 1) ( A + B ) s + 2 A + B + = = s +1 s + 2 ( s + 1)( s + 2) ( s + 1)( s + 2) A + B = 0 ⇒ A = − B,2 A + B = 1 = −2 B + B = 1 ⇒ B = −1 & A = 1

Y ( s) = H ( s) R( s) =

1 a ⇒ e − at , ⇒ 1 − e − at s+a s( s + a )

Y(s)

Using the Laplace transform table, for an impulse, we have,

(

1 1 1  ka − ⇒ k 1 − e − at  , s  s + 1 s + 2  s( s + a )

2

For a step we have,

(

1 1  −t   ⇒ 1− e s  s +1

) (

0.4 0.3

(

)

(

)

y (t ) = 1 − e − t − 0.5 1 − e −2t = 0.5 − e −t + 0.5e −2t

0.2 0.1 0

0

1

2

3

4

5

6

7

8

9

10

Time (sec) Step Response 0.8

This system is said to be stable to both an impulse and a step because the output response y(t) is bounded as time t gets large. This happens because the denominator of H(s) has no positive roots.

0.6 Amplitude

)

1  − 1  1  2k  − 2t  =  , ( k = −0.5) ⇒ −0.5 1 − e s  s+2 s  s+2

Impulse Response

Amplitude

y (t ) = e − t − e −2t

0.4 0.2 0

0

1

2

3

4

5

6

7

8

9

10

Matlab code: figure(1),subplot(211),impulse(tf(1,[1 3 2]),10), grid on,subplot(212),step(tf(1,[1 3 2]),10),grid on

Time (sec)

EECE 413, Fall, 2006

31

)


Control System Stability Consider a general 2nd order system, R(s) = 1

ωn2 H (s) = 2 s + 2ζω n s + ωn2

Y(s)

The system is stable if the denominator of the system has no positive roots. It is unstable if it has positive roots.

s 2 + 2ζω n s + ωn2 = 0

Consider a general linear system characterized by a state space form. 1. 2. 3.

x = Ax + Bu y = Cx + Du

It is stable if and only if all the eigenvalues of A are in the open left-half plane. It is marginally stable if and only if A has eigenvalues are in the closed left-half plane with some (simple) eigenvalues on the imaginary axis. It is unstable if and only if A has at least one eigenvalue in the right-half plane.

L.H.P.

R.H.P.

Stable Region

Unstable Region

EECE 413, Fall, 2006

32


Stability – Discrete Systems A discrete-time system is said to be stable if its denominator of the system has no roots or poles outside the unit circle. It is unstable if it has poles or roots outside the unit circle. Marginally Stable

x

Stable

x x

x x

x

x

Consider a 1st order low-pass filter: y = a*yp + (1-a)*up Where y is the output, yp is previous output, a is the filter pole, & up is the previous input. If |a|<=1 y is bounded. If |a|>1 is not bounded.

EECE 413, Fall, 2006

x Unstable x

33


2nd Order Control System Stability Consider a general 2nd order system, R(s) = 1

Y(s)

ωn2 H (s) = 2 s + 2ζω n s + ωn2

The behavior of the system is as follows:

The behavior of the system is fully characterized by ς, which is called the damping ratio, and ωn, which is called the natural frequency.

Step Response 2 1.8 ζ=0 0.1 0.2 0.3 0.4 0.5 0.6

1.6 1.4

Amplitude

1.2

Matlab code: % Two_order.m w=1; z=[0:0.1:1]; for i=1:11,tfbig(i)=tf(w,[1 2*z(i)*w w*w]);end, for i = 1:11, step(tfbig(i),12),grid on,hold on end

1 0.8 ζ = 0.7 0.8 0.9 1.0

0.6 0.4 0.2 0

0

2

4

6

8

10

12

Time (sec)

EECE 413, Fall, 2006

34


Control System Design with Time-Domain Specs Consider a general 2nd order system again, 100 90

r(t) = 1

ωn2 H (s) = 2 s + 2ζω n s + ωn2

Y(s)

80 70 60 Mp, %

R(s) = 1/s

50 40 30 20

See page 21 of Franklin - Powell Mp (in %)

overshoot

Mp ≈e

−πζ 1−ζ 2

,0 ≤ ζ < 1

10 0

+-1%

1 0.9

tr ≅

1.8 ωn

Steady state error

Rise time

1% settling time

0.1

ts ≅ t

4.6 ζω n

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

Time domain specs for simple systems: • Rise time •Settling time •Overshoot For complex systems must use simulation.

tr ts

EECE 413, Fall, 2006

ς

35

1


PI Design Technique: Design D(s) with PI (proportional-integral) structure: R(s)

E(s) +

-

D(s)

U(s)

G(s)

G(s) =

Y(s)

D(s) = k p +

b s+a k i k p s + ki = s s

With G(s) & D(s) as defined above, the system becomes a closed-loop system.

bk p s + bki Y ( s) G ( s) D( s) H ( s) = = = 2 R ( s ) 1 + G ( s ) D( s ) s + ( a + bk p ) s + bki Compare this with the standard 2nd order system by equating the denominators:

s 2 + 2ζω n s + ω n2 = s 2 + ( a + bk p ) s + bki

ωn2 H ( s) = 2 s + 2ζω n s + ωn2

2ζω n = a + bk p

The key issue now is to choose parameters kp & ki such that the above resulting system has desired properties, such as prescribed settling time & overshoot.

ωn2 = bki

EECE 413, Fall, 2006

36

2ζω n − a b ωn2 ki = b kp =


Cruise-Control Example Design 1 For the cruise-control system, we have:

1 m

V (s) = U (s) s + b m

Assume the mass of the car m = 3000 kg and the friction coefficient b = 1. Design a PI controller for it such that the speed of the car will reach the desired speed 90 km/h in 10 seconds (i.e., the settling time is 10 s) and the maximum overshoot is less than 25%. To achieve an overshoot < 25%, we obtain from the Mp figure that: To be safe, we choose

ζ > 0.4

100 90

ζ = 0.6

80 70

To achieve a settling time of 10 s, we use

Mp, %

60 50 40

x

30

4. 6 4.6 4.6 ts = ⇒ ωn = = = 0.767 ζω n ζ * t s 0.6 *10

EECE 413, Fall, 2006

20 10 0

0

0.1

0.2

0.3

37

0.4

0.5

0.6

0.7

0.8

0.9

1


Cruise-Control Example Design 1 – cont. The transfer function of the cruise-control system is below. Assume the mass of the car m = 3000 kg and the friction coefficient b = 1: 1 m

1 V (s) 1 = = 3000 ⇒ a = b = = 0.000333 U (s) s + b s + 1 3000 m 3000

Again, using the formulae derived,

2ζω n − a kp = b ωn2 ki = b

2ζω n − a kp = = b

2 * 0.6 * 0.767 − 1 3000

ts =

4.6 4.6 4.6 ⇒ ωn = = = 0.767 ζω n ζ * t s 0.6 *10

1 3000 = 2760

ωn2 0.767 2 ki = = = 1765 1 b 3000

k i k p s + ki = s s 2760 s + 1765 D(s) = s D(s) = k p +

The final cruise-control system:

car 70 MPH

u 2760 s + 1765 s

1 3000 1 s+ 3000

EECE 413, Fall, 2006

Speed v

38


Cruise-Control Example Design 1 – Results car

70 MPH

1 3000 1 s+ 3000

u 2760 s + 1765 s

ts spec = 10 s ts result < 7 s

Speed v

% cruise_validate.m a = 1/3000; b = a; g1 = tf(b,[1 a]);

ωn spec = 0.767 ωn result ~ 1.8 rad/s Step Response

Amplitude

1.5

d1 = tf([2760 1765],[1 0]); sys1 = d1*g1; sys1 = feedback(sys1,1);

1

0.5

0

0

2

4

6

8

10

12

Time (sec)

magnitude in dB

10 0 -10 -20 -30 -1 10

0

10 frequency in rad/sec

1

10

figure(1) subplot(211) step(sys1,12);grid on subplot(212) [mag,phase,w] = bode(sys1); semilogx(w,20*log10([mag(:),ones(length(w),1)* 0.7])),grid on ylabel('magnitude in dB') xlabel('frequency in rad/sec')

39 Risky design. High control bandwidth gives poor disturbance rejection. EECE 413, Fall, 2006


Cruise-Control Example Design 2 For the cruise-control system, we have:

1 m

V (s) = U (s) s + b m

Assume the mass of the car m = 1000 kg and the friction coefficient b = 100. Design a PI controller for it such that the speed of the car will reach the desired speed 100 km/h from 0 in 8 seconds (i.e., the settling time is 8 s) and the maximum overshoot is less than 20%. To achieve an overshoot < 20%, we obtain from the Mp figure that: To be safe, we choose

ζ > 0.46 100 90

ζ = 0.7

80 70

To achieve a settling time of 8 s, we use

Mp, %

60 50 40 30

ts =

4.6 4.6 4.6 ⇒ ωn = = = 0.82 ζω n ζ * t s 0. 7 * 8

EECE 413, Fall, 2006

x

20 10 0

0

0.1

0.2

0.3

40

0.4

0.5

0.6

0.7

0.8

0.9

1


Cruise-Control Example Design 2 – cont. The transfer function of the cruise-control system is below. Assume the mass of the car m = 1000 kg and the friction coefficient b = 100: 1 m

1 V (s) 100 = = 1000 ⇒ a = 0.001, b = = 0.1 U ( s ) s + b s + 100 1000 m 1000

Again, using the formulae derived,

2ζω n − a kp = b ωn2 ki = b

2ζω n − a kp = = b ki =

2 * 0.7 * 0.82 − 1 10

ts =

4.6 4.6 4.6 ⇒ ωn = = = 0.82 ζω n ζ * t s 0.7 * 8

1 1000 = 1050

k i k p s + ki = s s 1050 s + 670 D(s) = s D(s) = k p +

ωn2 0.82 2 = = 670 1 b 10

The final cruise-control system:

car 100 km/H

u 1050 s + 670 s

EECE 413, Fall, 2006

1 1000 1 s+ 10

Speed v

41


Cruise-Control Example Design 2 – Results car

100 km/H

1 1000 1 s+ 10

u 1050 s + 670 s

ts spec = 8 s ts result < 7 s

% cruise_validate.m % a = 1/10; b = 1/1000; g2 = tf(b,[1 a]);

ωn spec = 0.82 ωn result ~ 1.8 rad/s Step Response

Amplitude

1.5

1

0.5

0

0

2

4

6

8

10

12

Time (sec)

5 magnitude in dB

Speed v

0 -5 -10 -15 -20 -1 10

0

10 frequency in rad/sec

1

10

d2 = tf([1050 670],[1 0]); sys2 = d2*g2; sys2 = feedback(sys2,1); figure(2) subplot(211) step(sys2,12);grid on subplot(212) [mag,phase,w] = bode(sys2); semilogx(w,20*log10([mag(:),ones(length(w),1)* 0.7])),grid on ylabel('magnitude in dB') xlabel('frequency in rad/sec')

42 Design risk. High control bandwidth poor2006 disturbance rejection. EECE gives 413, Fall,


Problem 2.1 in Text Design feedback with lead compensation for the open-loop system: G ( s) = 102

D(s) ks s+b

R(t)

s

G(s)

s 10 10k = s + b s 2 s( s + b) 10k D( s)G ( s) s( s + b ) = = 1 + D( s )G ( s ) 1 + 10k The rise time should be <= 1 sec & the overshoot should be <= 10%. s( s + b ) 10k 10k s 2 + 2ζω n s + ωn2 = s 2 + bs + 10k = 2 s ( s + b ) + 10k s + bs + 10k 2

10 s2

D ( s)G ( s) = k

2ζω n = b, ωn = 10k

100

4.6 4.6 4.6 ts = ⇒ ωn = = = 7.6667 ζω n ζ * t s 0.6 *1

90 80 70

Mp, %

60

ζ ≥ 0.58

40

b = 2ζω n = 2 * 0.6 * 7.6667 = 9.2,

ω2 k = n = 5.8778 10

50

30

D(s) =

ks 5.8778s = s + b s + 9.2

20

0

EECE 413, Fall, 2006

x

10

0

0.1

0.2

0.3

43

0.4

0.5

0.6

0.7

0.8

0.9

1


Problem 2.1 in Text – Results 10 s2

5.8778s s + 9 .2

% Prob2_1.m k = 5.8778; b = 9.2; g1 = tf(10,[1 0 0]);

ts spec = 1 s ωn spec = 7.6667 rad/s ts result < 0.9 s ωn result ~ 9.0 rad/s Step Response

Amplitude

1.5

d1 = tf([k 0],[1 b]); sys1 = d1*g1; sys1 = feedback(sys1,1);

1

0.5

0

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

figure(1) subplot(211) step(sys1,2);grid on

2

Time (sec)

magnitude in dB

50

0

-50

-100 -1 10

0

10

1

10 frequency in rad/sec

2

10

3

10

subplot(212) [mag,phase,w] = bode(sys1); semilogx(w,20*log10([mag(:),ones(length(w),1)* 0.7])),grid on ylabel('magnitude in dB') xlabel('frequency in rad/sec')

Slightly high control bandwidth may give poor EECE 413, disturbance Fall, 2006 rejection.

44


Problem 2.2 (mod) in Text Design feedback with lead compensation for the open-loop system: G ( s) = 52

D(s) ks s+b

R(t)

s

G(s)

s 5 5k = s + b s 2 s( s + b ) 5k D( s)G ( s) s( s + b ) = = 1 + D( s )G ( s ) 1 + 5k The rise time should be <= 1 sec & the overshoot should be <= 10%. s( s + b ) 5k 5k s 2 + 2ζω n s + ωn2 = s 2 + bs + 5k = 2 s ( s + b ) + 5k s + bs + 5k 2

5 s2

D ( s)G ( s ) = k

2ζω n = b, ωn = 5k

100

4.6 4.6 4.6 ts = ⇒ ωn = = = 7.6667 ζω n ζ * t s 0.6 *1

90 80 70

Mp, %

60 50

ζ ≥ 0.58

40

b = 2ζω n = 2 * 0.6 * 7.6667 = 9.2,

ωn2 k= = 11.7556 5

30

D(s) =

ks 11.7556s = s+b s + 9.2

20

0

EECE 413, Fall, 2006

x

10

0

0.1

0.2

0.3

45

0.4

0.5

0.6

0.7

0.8

0.9

1


Problem 2.2 (mod) in Text – Results 10 s2

11.7556 s s + 9 .2

% Prob2_1.m k = 5.8778; b = 9.2; g1 = tf(10,[1 0 0]);

ts spec = 1 s ωn spec = 7.6667 ts result < 0.9 s ωn result ~ 9.0 rad/s Step Response

Amplitude

1.5

d1 = tf([k 0],[1 b]); sys1 = d1*g1; sys1 = feedback(sys1,1);

1

0.5

0

0

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

figure(1) subplot(211) step(sys1,2);grid on

2

Time (sec)

magnitude in dB

50

0

-50

-100 -1 10

0

10

1

10 frequency in rad/sec

2

10

3

10

subplot(212) [mag,phase,w] = bode(sys1); semilogx(w,20*log10([mag(:),ones(length(w),1)* 0.7])),grid on ylabel('magnitude in dB') xlabel('frequency in rad/sec')

Slightly high control bandwidth may give poor EECE 413, disturbance Fall, 2006 rejection.

46


PID Control r(t)

e(t)

y(t)

Plant

PID

Proportional control term:

u (t ) = Ke(t ) ⇒ D( s ) = K t

Integral control term: Derivative control term:

K K u (t ) = ∫ e(η )dη ⇒ D ( s ) = Ti 0 Ti s

u (t ) = KTd e (t ) ⇒ D( s ) = KTd s

Where Ti is called the integral (or reset) time, Td the derivative time, and K the position feedback gain. The combined transfer function is: D( s) =

  u (s) 1 = K 1 + + Td s  e( s )  Ti s 

EECE 413, Fall, 2006

47


PID Control • • • •

Proportional feedback control can lead to reduced errors to disturbances but still maintains errors bounded. It can reduce the rise time, but at the cost of a larger overshoot. Integral control can eliminate steady state error, but can contribute to oscillation as contributes an additional pole. Derivative control adds damping at the expense of disturbance noise sensitivity. Usually this term or a component is low-pass filtered.

Root Locus • • • • •

Root locus shows how changes in the system’s open-loop characteristics influence the closed-loop dynamics characteristics. Requires a variable open-loop parameter which produces a root-locus of characteristic equation roots. Allows study of the closed-loop roots while only knowing the factors (poles & zeros) of the open-loop system. The term D(s)G(s) (open-loop transfer function) must be formulated as Kb(s)/a(s). See drawing rules, p. 26. It is useful to help visualize the system.

EECE 413, Fall, 2006

48


Matlab Root Locus e(t)

r(t)

Example 2.2 (p. 29) 1. Plot the root locus using matlab for the open-loop system shown. 2. Find the gain K associated with the point of maximum damping and plot the step response with that value of K. Root Locus

G(s) =

Step Response

4

1.4 0.91

0.83 0.72 0.58 0.4 0.2

3 0.96

1.2

2 1 0.99

8

6

4

Amplitude

Imaginary Axis

1 10 0

2

0.8

0.6

-1 0.99 0.4 -2 -3 0.96 0.91 -4 -10

0.2 0.83 0.72 0.58 0.4 0.2 -5 Real Axis

0

0

0

y(t)

10 s( s + 2)

s+3 K s + 10

0.5

1 Time (sec)

1.5

2

EECE 413, Fall, 2006

10 s+3 , D( s ) = K s( s + 2) s + 10 % example2_2.m % numD = [1 3]; denD = [1 10]; numG = 10; denG = [1 2 0]; sys = tf(numD,denD)*tf(numG,denG); k = 0:0.1:4; figure(1) subplot(121) rlocus(sys,k),grid on % [K,p] = rlocfind(sys); subplot(122) K = 3.7; sysCL = feedback(K*sys,1); step(sysCL,2),grid on

49


Stability Margins Gain margin (GM), phase margin (PM), & V margin (VM) All root locus points have the property that |KG(s)| = 1 & (KG(s)) = 180 degrees. At the point of neutral stability these root-locus conditions hold for s = jw, so |KG(s)| = 1 & (KG(s)) = 180 degrees. The GM is the factor by which the gain < the neutral stability value when the phase = 180 degrees. The PM is the amount by which the phase of G(s) exceeds – 180 degrees when |KG(s)| = 1. VM is a combination of both. PM

PM is generally related to the damping of a system. For a 2nd order system, ζ = 100 is commonly used. Thus, the speed of response of the system is associated with the GM while the stability is associated with the PM. GM =

1 , ω p → angle( K ( jω p )G ( jω p ) ) = 180 K ( jω p ) G ( j ω p )

PM = angle( K ( jω g )G ( jω g ) ) + 180, ω g → K ( jω g )G ( jω g ) = 1

EECE 413, Fall, 2006

GM is the maximum additional gain you can apply to the closed-loop system such that it will still remain stable. Similarly, PM is the maximum phase you can add to the closed-loop system such that it will still remain stable.

50


Example 2.3 G(s) = K

1 2 s( s + 1) determine the PM and GM for the system with unity feedback and a)

For the plant: K=1, b) determine if the system is stable if K = 5, & c) find what value of K is required to achieve a PM of 45 & 70. GM

margin(tf(1,[1 2 1 0]))

a) K=1

Bode Diagram Gm = 6.02 dB (at 1 rad/sec) , Pm = 21.4 deg (at 0.682 rad/sec)

Read system bandwidth frequency following ‘crossover’ @ -3 dB

100

Magnitude (dB)

50 0 -50 -100 -150 -90

Unstable line < -180

Phase (deg)

-135 -180 -225 -270 -2

10

10

-1

0

1

10

10

2

10

Frequency (rad/sec)

PM

EECE 413, Fall, 2006

51


Example 2.3 – cont. G(s) = K

1 2 s( s + 1) determine the PM and GM for the system with unity feedback and a)

For the plant: K=1, b) determine if the system is stable if K = 5, & c) find what value of K is required to achieve a PM of 45 & 70. b) K=5  stable?

GM

margin(tf(1,[1 2 1 0]))

Bode Diagram Gm = -7.96 dB (at 1 rad/sec) , Pm = -23.2 deg (at 1.52 rad/sec)

20*log10(1/5) ~ -14 dB -> phase < -180 or system is unstable with K = 5. For stability both PM & GM must be stable.

100

Magnitude (dB)

50

K=5

0 -50

K=1

-100

Unstable line < -180

-150 -90

Phase (deg)

-135 -180 -225 -270 -2

-1

10

10

PM

0

10

10

1

2

10

Note that change in gain only moves magnitude plot up or down, but doesn’t affect phase plot.

Frequency (rad/sec)

EECE 413, Fall, 2006

52


Example 2.3 – cont. G(s) = K

1 2 s( s + 1) determine the PM and GM for the system with unity feedback and a)

For the plant: K=1, b) determine if the system is stable if K = 5, & c) find what value of K is required to achieve a PM of 45 & 70. hold on, margin(tf(5,[1 2 1 0])), c) K=? for PM = 45 & 70? margin(tf(1,[1 2 1 0])), margin(tf(.5,[1 2 1 0])), margin(tf(.2,[1 2 1 0])), hold off Bode Diagram Gm = 20 dB (at 1 rad/sec) , Pm = 68.2 deg (at 0.193 rad/sec) 100

Magnitude (dB)

50 0

K=1 Xover K=.5 Xover K=.2 Xover

-50 -100

K=5 crossover

Unstable line < -180

-150 -90

Phase (deg)

-135

K=1 PM=21 K=.5 PM=45 K=.2 PM=68

-180

Note that change in gain only moves magnitude plot up or down, but doesn’t affect phase plot.

K=5 PM=-22

-225 -270 -2

10

-1

10

0

10

10

1

2

10

Frequency (rad/sec)

EECE 413, Fall, 2006

53


Example: Root Locus Design Method for DC Motor Position Control From the main problem, the dynamic equations in transfer function form are the following:

4.6 4.6 4.6 ⇒ ωn = = = 230 ζω n ζ * t s 0.5 * 0.04

With a 1 rad/sec step reference, the design criteria are: Settling time less than 0.04 seconds Overshoot less than 16% No steady-state error to a reference No steady-state error due to a disturbance Now let's design a controller using the root locus method

100 90 80 70 60 Mp, %

ts =

and the system schematic looks like:

50 40

Matlab Code: % motor.m J=3.2284E-6; b=3.5077E-6; K=0.0274; R=4; L=2.75E-6; num=K; den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2) 0]; motorTF=tf(num,den); gain = 0:0.1:20; rlocus(motorTF,gain)

30

ζ = 0.5, ω n = 230

x

20

ζ ≥ 0 .5

10 0

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

First, try simple P (proportional controller). Note motor parameters given. EECE 413, Fall, 2006

54

0.9

1


Example: Root Locus Design Method for DC Motor Position Control – cont. Close up view, note bandwidth spec = 230 rad/s

Very large pole

Root Locus 0.25

Root Locus 250

0.2 200

0.15 150

0.1 100

Imaginary Axis

Imaginary Axis

0.05 50 0 -50

0 -0.05 -0.1

-100

-0.15 -150

-0.2 -200

-0.25 -250 -15

-10

-5 Real Axis

0

-250

5

x 10

-200

-150

-100

-50

0

Real Axis

With P only controller, motor will never be fast enough to satisfy bandwidth of 230 rad/s. Also, recall that we need an integrator in the controller (not just in the system) to remove steady-state error due to a disturbance.

EECE 413, Fall, 2006

55

50


Example: Root Locus Design Method for DC Motor Position Control – cont. Close up view, note bandwidth spec = 230 rad/s Root Locus

Root Locus 80 60

-20

100

gain = [0:.01:20]; numc=conv([1 60],[1 70]); denc=[1 0]; contr=tf(numc,denc); rlocus(contr*motorTF,gain)

PI controller Imaginary Axis

Imaginary Axis

0

150

PID controller

40 20

200

0.5

50

gain = [0:.1:20]; contr=tf([1 20],[1 0]); rlocus(contr*motorTF,gain)

0

-50

-40

-100

-60 -80

-150

0.5 -300

-250

-200

-150 Real Axis

-100

-50

0

-200 -300

-250

-200

-150

-100

-50

0

Real Axis

With PI only controller, motor will never be fast enough to satisfy bandwidth of 230 rad/s. In order to pull the root locus further to the left, to make it faster, we need to place a second open-loop zero, resulting in a PID controller. After some experimentation, we can place the two PID zeros at s=-60 and s=-70.

EECE 413, Fall, 2006

56


Example: Root Locus Design Method for DC Motor Position Control – cont. If you recall, we need the settling time and the overshoot to be as small as possible, particularly because of the effect of the extra zero. Large damping corresponds to points on the root locus near the real axis. A fast response corresponds to points on the root locus far to the left of the imaginary axis. To find the gain corresponding to a point on the root locus, we can use the rlocfind command. We can find the gain and plot the step response using this gain all at once.

PID controller

.1565

( s + 60)( s + 70) = s 2 + 130s + 4200 = 130 + 4200 + s s

s

s

motor step response, k = 0.1565, dominant poles are -230

-101.756

-59.6074

1.4

1.2 System: sys_cl Time (sec): 0.0129 Amplitude: 1.12

1

Amplitude

gain = [0:.01:20]; % contr=tf([1 20],[1 0]); % rlocus(contr*motorTF,gain) numc=conv([1 60],[1 70]); denc=[1 0]; contr=tf(numc,denc); rlocus(contr*motorTF,gain) sgrid(0.5,0) sigrid(230) [k,poles] = rlocfind(contr*motorTF,-230) sys_cl=feedback(k*contr*motorTF,1); t=0:0.001:.1; step(sys_cl,t),grid on title(['motor step response, k = ',num2str(k),... ', dominant poles are ',num2str(poles(2:4)')])

0.8

System: sys_cl Time (sec): 0.0402 Amplitude: 1.01

0.6

0.4

0.2

0

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0.08

0.09

0.1

Time (sec)

Settling time criteria met @ 1% @ 0.04 s. Overshoot criteria met @ 12% @ 0.013 s and no steady state error.

EECE 413, Fall, 2006

57


Example: Root Locus Design Method for DC Motor Position Control – cont. The disturbance response may be found by computing the closed-loop disturbance transfer function and plotting its step response. As you recall the controller must minimize disturbance. The response to a step disturbance reaches a steady-state value of zero, and in fact, stays within 0.02 (or 2%) after 0.04 seconds. Therefore, all the design requirements have been met.

motor step response 0.04

0.035

0.03 System: dist_cl Time (sec): 0.04 Amplitude: 0.0206

0.025 Amplitude

dist_cl=feedback(motorTF,k*contr); step(dist_cl,t),grid on title('motor step response')

0.02

0.015

0.01

0.005

0

0

0.01

0.02

0.03

0.04

0.05

0.06

Time (sec)

EECE 413, Fall, 2006

58

0.07

0.08

0.09

0.1


Example: Bode Plot Design Method for DC Motor Position Control From the main problem, the dynamic equations in transfer function form are the following:

4.6 4.6 4.6 ⇒ ωn = = = 230 ζω n ζ * t s 0.5 * 0.04

With a 1 rad/sec step reference, the design criteria are: Settling time less than 0.04 seconds Overshoot less than 16% No steady-state error to a reference No steady-state error due to a disturbance Now let's design a controller using the bode plot method

100 90 80 70 60 Mp, %

ts =

and the system schematic looks like:

50 40

Matlab Code: % motor_bode.m clear all J=3.2284E-6; b=3.5077E-6; K=0.0274; R=4; L=2.75E-6; num=K; den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2) 0]; motorTF=tf(num,den); contr=1; margin(contr*motorTF),

ζ = 0.5, ωn = 230 PM ζ = → 100 PM = 100ζ = 100 * 0.5 = 50

30

x

20

ζ ≥ 0 .5

10 0

0

0.1

0.2

0.3

0.4

0.5

0.6

First, try simple P (proportional controller). Note motor parameters given. Try to get PM = 50 & GM = 3 dB @ 230 rad/s

EECE 413, Fall, 2006

59

0.7

0.8

0.9

1


Example: Bode Plot Design Method for DC Motor Position Control – cont. Increasing gain K raises magnitude curve without changing phase curve. However, mag crossover moves to the right reducing the PM in this case. Can’t use P controller since the PM will go negative long before GM is satisfied, therefore, try PI.

Again, while from the root locus analysis we removed steady state error, the PM potential is too low. Can’t satisfy the bandwidth = 230 rad/sec while satisfying GM & PM.

P controller

PI controller Bode Diagram Gm = 88.6 dB (at 7.55e+003 rad/sec) , Pm = 29.7 deg (at 35.3 rad/sec)

Bode Diagram Gm = 92.2 dB (at 9.28e+003 rad/sec) , Pm = 61.9 deg (at 31.6 rad/sec)

100

100

0

Increasing gain

-100

Decreasing -200 gain

Magnitude (dB)

Magnitude (dB)

0

Increasing gain

Decreasing gain

-200

-300 -135

Phase (deg)

-300 -90 -135 Phase (deg)

-100

-180

-180

-225

-225 -270 0

10

-270 10

0

2

10

4

10

6

10

8

10

2

10

4

10

6

10

Frequency (rad/sec)

Frequency (rad/sec)

contr=tf([1 20],[1 0]); margin(contr*motorTF),

motorTF=tf(num,den); contr=1; margin(contr*motorTF), EECE 413, Fall, 2006

60

8

10


Example: Bode Plot Design Method for DC Motor Position Control – cont. numc1=conv([1 60],[1 70]); numc2=conv([1 100],[1 140]); denc=[1 0]; contr1=tf(numc1,denc); contr2=tf(numc2,denc); margin(0.1565*contr1*motorTF),hold on margin(0.09*contr2*motorTF),hold off .1565

This is quick & dirty solution starting with root locus solution. Bandwidth is close to 230 rad/sec and PM is good. However, overshoot doesn’t meet specs<16%.

PID controller

( s + 60)( s + 70) = .1565 s 2 + 130s + 4200 = .1565130 + 4200 + s  s

 

s

Bode Diagram Gm = Inf dB (at Inf rad/sec) , Pm = 50.2 deg (at 234 rad/sec)

 

s

150 100

s

s

 

System: sys_cl Time (sec): 0.0131 motor step response, k = 0.09 Amplitude: 1.32

1.5

Amplitude

 

s

Magnitude (dB)

( s + 100 )( s + 140 ) = .09 s 2 + 240 s + 14000 = .09 240 + 14000 + s 

0 -50

-150 -90

1 System: sys_cl Time (sec): 0.0399 Amplitude: 0.965

0.5

0

50

-100

0

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0.08

0.09

0.1

Time (sec)

Phase (deg)

.09

-135

motor step response 0.06

Amplitude

-180

System: dist_cl Time (sec): 0.0241 Amplitude: 0.0202

0.04

0

10

0

0

0.01

0.02

0.03

0.04

4

6

10

10

Frequency (rad/sec)

0.02

-0.02

2

10

0.05

0.06

0.07

0.08

0.09

0.1

Time (sec)

EECE 413, Fall, 2006

sys_cl=feedback(k2*contr2*motorTF,1); t=0:0.001:.1; step(sys_cl,t),grid on title(['motor step response, k = ',num2str(k2)]) dist_cl=feedback(motorTF,k2*contr2); step(dist_cl,t),grid on title('motor step response')

61

8

10


Lead Compensation Lead compensation has a transfer function of: For small α, it is an approximation of PD control. The frequency response of a typical lead compensator is shown in the figure below:

D( s ) = K

τs + 1 ,α < 1 ατs + 1

1 − sin φmax 1 α= , andτ = 1 + sin φmax ωmax α Here parameters K, φmax and ωmax are to be determined from design specifications.

EECE 413, Fall, 2006

62


Uncompensated and lead-compensated systems

The Key Idea The key idea using the lead compensation is to enlarge the gain crossover frequency and add additional phase. Thus, if the desired gain crossover frequency is larger than that of KG(s), the lead compensation should be used.

EECE 413, Fall, 2006

63


Lead Compensation Design Procedure Step 1: Determine open-loop gain K to satisfy requirements on steady state error. Step 2: Find new open-loop crossover frequency from desired ωn=ωmax, the point the phase lead is added. Step 3: Evaluate the PM of KG(ω) at the desired cross over frequency ωn. Step 4: Allow for some extra PM (5 to 12 degrees), and determine the needed phase lead φmax. 1 − sin φmax 1 Step 5: Compute α= ,τ =

1 + sin φmax

ωmax α

Step 6: Verify the design using matlab. Redo if needed.

EECE 413, Fall, 2006

64


Lead Compensator Design Example An electric motor can be modeled with a sampling period T = 0.1 s as follows:

0.5 z + 0.5 G( z) = ( z − 0.5)( z − 0.9) Design a digital control system with a lead compensator such that the resulting system output tracks a step reference with a settling time less than 1s with an overshoot < 20% and steady state error < 12.5%. Converting this to w-plane we have: 20 + w + 0 .5 20( 20 − w) 20 − w G ( w) = G ( z ) | 2 / T + w = = z=  20 + w  20 + w  (1.5w + 10)(1.9 w + 2) 2 /T −w − 0.5  − 0 .9    20 − w  20 − w  0 .5

EECE 413, Fall, 2006

65


Lead Compensator Design Example 20% PM = 100ζ = 50

overshoot x

4.6 Open-loop gain crossover frequency ωg ~ ωn = 9 ζt s 4.6 1 second ωn ≅ = 9.2 ωg ~ ωn = 9 Step 2 0.5 x1 Steady state error – Step 1: Determination of the static gain K for this type 0 system. Settling time

ωn ≅

e(∞ ) =

1 1 − e( ∞ ) = 0.125 ⇒ K p = = 7, 1+ K p e (∞ )

K p = D(1)G (1) = Kx

0.5 + 0.5 = 7 ⇒ K = 0.35 (1 − 0.5)(1 − 0.9)

EECE 413, Fall, 2006

66


Step 3: Bode Diagram Gm = 9.95 dB (at 12.7 rad/sec) , Pm = 43.8 deg (at 5.72 rad/sec)

% lead_example.m % numG = 20*[-1 20]; denG = conv([1.5 10],[1.9 2]); sys = tf(numG,denG); figure(1) margin(sys),hold on numG1 = 0.35*20*[-1 20]; sys1 = tf(numG1,denG); margin(sys1),hold off

40

K = 1 System: sys

Magnitude (dB)

20

Frequency (rad/sec): 8.93 Magnitude (dB): -5.42

K = 0.35

0 -20 -40

Phase (deg)

-60 360

System: sys Frequency (rad/sec): 9.05 Phase (deg): 199

270

180

90 -2

10

-1

10

0

10

1

10

2

10

3

10

Frequency (rad/sec)

Step 4: Φmax = Desired PM – Original PM + Allowance = 50 + (180 – 199) + 4 = 35 EECE 413, Fall, 2006

67


Step 5 1 − sin φmax 1 − sin ( 35π / 180 ) 1 α= = = 0.27,τ = = 0.213 1 + sin φmax 1 + sin ( 35π / 180 ) ωmax α Finally, we obtain the lead compensator in w-domain:

 0.213w + 1  τw + 1  D( w) = K = 0.35 ατw + 1  0.27( 0.213) w + 1  Which can be converted back to z-domain using the inverse bilinear transformation. T = 1/30/9.2 = 0.0036 s. Use T = 0.01.

2 z −1   +1  0.213 0.01 z + 1  = 1.848 z − 1.148 D( z ) = D( w) | 2 z −1 = 0.35 w=  0.058 2 z − 1 + 1  2.16 z − 0.16 T z +1   0.01 z + 1   The above is the digital lead compensator. However, nothing is certain without verification. We need to first verify our design in frequency domain. More importantly, it should also meet the design specifications in time domain. EECE 413, Fall, 2006

68


Verification in w-domain (pseudo s-domain Bode Diagram Gm = 7.08 dB (at 21.3 rad/sec) , Pm = 52.7 deg (at 9.21 rad/sec)

% lead_example.m % numG = 20*[-1 20]; denG = conv([1.5 10],[1.9 2]); sys = tf(numG,denG); figure(1) margin(sys),hold on numG1 = 0.35*20*[-1 20]; sys1 = tf(numG1,denG); margin(sys1),hold off numD = 0.35*[0.214 1]; denD = [0.058 1]; sysC = tf(numD,denD); figure(2) margin(sysC*sys)

20

Magnitude (dB)

0

-20

-40

Phase (deg)

-60 360

270

180

90 -2

10

-1

10

0

10

1

10

2

10

3

10

Frequency (rad/sec)

Resulting gain crossover frequency is 9.21 rad/s & PM = 52.7 Desired gain crossover frequency is 9.2 rad/s & PM = 54 69 EECE 413, Fall, 2006


Verification in z-domain Bode Diagram Gm = 6.3 dB (at 19.5 rad/sec) , Pm = 50.1 deg (at 9.2 rad/sec) 20

Magnitude (dB)

10 0 -10 -20 -30 360

Phase (deg)

270 180 90 0 -90 -2

10

-1

10

0

10

1

10

2

10

Frequency (rad/sec)

3

10

% lead_example.m % numG = 20*[-1 20]; denG = conv([1.5 10],[1.9 2]); sys = tf(numG,denG); figure(1) margin(sys),hold on numG1 = 0.35*20*[-1 20]; sys1 = tf(numG1,denG); margin(sys1),hold off numD = 0.35*[0.214 1]; denD = [0.058 1]; sysC = tf(numD,denD); figure(2) margin(sysC*sys) % verification in z domain figure(3) margin(c2d(sysC*sys,0.04)),hold on margin(c2d(sysC*sys,0.02)),hold on margin(c2d(sysC*sys,0.01)),hold off

Sampling rate of 0.01 matches specs well, however reducing the sampling rate doesn’t change the 0 dB magnitude crossover, but reduces the phase margin noticeably. Note that the 4 degree continuous PM allowance forced the discrete PM to be very close to 50.

EECE 413, Fall, 2006

70


Verification in Time Domain Overshoot = 23.4% System: untitled2 Step Response Time (sec): 0.279 Amplitude: 1.08

1.2

Steady state error = 12.5%

1

Amplitude

0.8 System: untitled2 Time (sec): 0.18 Amplitude: 0.789

0.6

System: untitled2 Time (sec): 1.24 Amplitude: 0.875

System: untitled2 Time (sec): 0.63 Amplitude: 0.863

0.4

Settling time = 0.63s 0.2

0

-0.2

0

0.5

1

1.5

Time (sec)

EECE 413, Fall, 2006

71


Lag Compensation Lag compensation has a transfer function of:

D( s ) = K

τs + 1 ,α > 1 ατs + 1

For large α, it is an approximation of PI control. The frequency response of a typical lag compensator is shown in the figure below:

Key idea: Lag compensator reduces the gain crossover frequency to where the phase margin is required to be.

EECE 413, Fall, 2006

72


PID Compensation Note that the lead compensation is the approximation of PD control and the lag compensation approximates PI control. PID compensation is nothing more than the combination of lead compensation (PD) and lag compensation (PI), which has the following frequency responses:

Design procedures for the lag compensation and PID compensation can be found in almost any textbook on introduction to classical control. EECE 413, Fall, 2006

73


Optimization of Controllers Assume a plant:

G (s) =

50 s2

with time domain specifications: ts = 10 sec & Mp <= 22%.

How can we avoid the tedious manual iterations needed to solve? Optimization using matlab’s fminsearch is one approach. load hmwk1_param % xin = [0.0130 0.7588]; xout = fminsearch('optim_hmwk1',xin);

Assume a controller: D( s ) = K p + K d s = K p ( s + K d ) The 2nd form allows specifying zero.

General steps: •Determine specifications •Generate plant representation •Determine and generate controller •Calculate numerically specifications •Generate optimization cost function •Code cost function in matlab function script •Code calling function in matlab script

function cf = optim_hmwk1(xin); % sys1 = tf(50,[1 0 0]); gc1 = tf(xin(1)*[1 xin(2)],1); [Gm,Pm,Wcg,Wcp] = margin(gc1*sys1); [mag,phase,w] = bode(gc1*sys1); i = find(mag >= 0.7); [y,i] = min(mag(i)); [y,t] = step(feedback(gc1*sys1,1),20); if max(y)>1.22, cf = abs(Pm - 45)/100 + abs(0.92 - w(i)) + 15*(max(y)-1.22); else cf = abs(Pm - 45)/100 + abs(0.92 - w(i)); end [xin, cf] save hmwk1_param xin

Phase margin/100 ~ damping coefficient For bandwidth check Do step for overshoot check

EECE 413, Fall, 2006

74


Optimizer Example 1 Results 70

load hmwk1_param sys1 = tf(50,[1 0 0]); figure(1) margin(sys1),grid on

60 50 40 magnitude in dB

figure(2) gc1 = tf(xin(1)*[1 xin(2)],1); margin(gc1),grid on,hold on margin(sys1),grid on,hold on margin(gc1*sys1),grid on,hold off legend('gc','gp','gc*gp')

10

-10 -20 -30 -2 10

-1

0

10

1

10

10

frequency in rad/sec

Step Response

figure(4) step(feedback(gc1*sys1,1));grid on

1.4

Mp = 22% GM = 63.7

Bode Diagram Gm = Inf , Pm = 63.7 deg (at 0.699 rad/sec)

1.2 System: untitled1 Time (sec): 4.84 Amplitude: 1.22

1

100

50

Amplitude

Magnitude (dB)

BW ~ 0.92

20

0

figure(3) [mag,phase,w] = bode(gc1*sys1); semilogx(w,20*log10([mag(:),ones(length(w),1)*0.7])),grid on ylabel('magnitude in dB') xlabel('frequency in rad/sec')

150

30

0

System: untitled1 Time (sec): 10.7 Amplitude: 1.01

0.8

0.6

-50 90

0.4

gc Phase (deg)

gp 0

gc*gp

0.2 -90

0 -180 10

-2

-1

10

10

0

Frequency (rad/sec)

1

10

0

2

2

10

EECE 413, Fall, 2006

4

6

8

75

10

Time (sec)

12

14

16

18


Optimizer Example 2 D( s) =

k p s + ki s

2 2 s+3 , G ( s) = , G ( s) = 2 s+5 s −5 s+5 Generate a PI controller for the following plants: Tune the system to the time domain specifications: ts = 10 sec & Mp <= 22%. Iterate to match them as closely as possible. Solve using pole placement. Verify using step responses. Calculate an appropriate sampling rate. What are the steady state errors of the systems?

T=

G(s) =

1 30 * ωn

EECE 413, Fall, 2006

76


Optimization of Controllers, Example 2

2 G ( s ) = Assume a plant: s+5

with time domain specifications: ts = 10 sec & Mp <= 22%.

load hmwk1_param xout = fminsearch('optim_hmwk1',xin);

Assume a PI controller: D( s) =

k p s + ki s

=

k p ( s + ki ) s

The 2nd form allows specifying zero.

function out = optim_hmwk1b(xin); % sys1 = tf(2,[1 5]); gc1 = tf(xin(1)*[1 xin(2)],[1 0]); [Gm,Pm,Wcg,Wcp] = margin(gc1*sys1); [y,t] = step(feedback(gc1*sys1,1),10); wn = 0.657; z = 0.6; [y1,t] = step(tf(wn*wn,[1 2*z*wn wn*wn]),10); out = abs(Pm - 50) + sum(abs(y - y1)); [xin, out] save hmwk1_param xin

Phase margin/100 ~ damping coefficient Do step comparison for bandwidth & overshoot check Cost function

EECE 413, Fall, 2006

77


Optimizer Example 2 Results load hmwk1_param sys1 = tf(2,[1 5]); figure(1) margin(sys1),grid on

20 0 -20

figure(2) gc1 = tf(xin(1)*[1 xin(2)],[1 0]); margin(gc1),grid on,hold on margin(sys1),grid on,hold on margin(gc1*sys1),grid on,hold off legend('gc','gp','gc*gp')

magnitude in dB

-40

BW ~ 0.92

-60 -80 -100

figure(3) [mag,phase,w] = bode(gc1*sys1); semilogx(w,20*log10([mag(:),ones(length(w),1)*0.7])),grid on ylabel('magnitude in dB') xlabel('frequency in rad/sec')

-120 -140 -160 -1 10

figure(4) step(feedback(gc1*sys1,1));grid on

0

1

10

2

3

4

10 10 frequency in rad/sec Step Response

5

10

10

1

GM = 82.9

100

System: untitled1 Time (sec): 6.53 Amplitude: 0.99

0.9

Bode Diagram Gm = Inf , Pm = 82.9 deg (at 0.627 rad/sec)

0.8

50

0.7

ts <= 10 s

0

0.6

-50

Amplitude

Magnitude (dB)

10

-100 -150 -200 0

0.5 0.4 0.3

gc gp

Phase (deg)

-45

0.2

gc*gp -90

0.1

-135

0

-180 -1

10

0

10

1

10

2

10

Frequency (rad/sec)

3

10

0

1

EECE 413, Fall, 2006 4

10

5

10

2

3

4

78

Time (sec)

5

6

7

8


State-Space Design • • • • •

Estimator/observer design Control law design Combine/integrate observer & control law Tune the control system to achieve desired performance Note that the order is different from the text, because the observer dynamics must be incorporated into the control law.

State space formulation u

plant

x = Fx + Gu x Control law

-K

y

H

+ Estimator

-

Estimator/Observer Design xˆ = Fxˆ + Gu + L( y − Hxˆ ) xˆ = ( F − LH ) xˆ

is the estimator formulation where L is a proportional gain in the form of a vector or matrix depending on the dimensions of y.

is the error equation from which the dynamics may be obtained.

The characteristic equation of the error is: det[sI – (F – LH)] = 0.

EECE 413, Fall, 2006

79

r


State-Space Block Diagram Plant

State space formulation

u

J u

plant

x = Fx + Gu x

y

H

1 s

xdot

G

x

H

+ - r

F Control law

-K

+ Estimator

-

r -K

xˆ = Fxˆ + Gu + L( y − Hxˆ ) is the estimator formulation where L is a proportional gain in the form of a vector or matrix depending on the dimensions of y.

1 s

xˆ

F-LH-GK Controller/Estimator

Control engineer’s job is to: 1) determine plant description [ F,G,H,J] matrices, 2) Calculate and justify L matrix for estimator, and 3) calculate and justify K matrix for controller to satisfy requirements.

EECE 413, Fall, 2006

80

y

L


Estimator/Observer Design •

The 2 general approaches to observer design are: – Pole placement – Optimal design (Kalman filter)

Both rely on selection of the observer eigenvalues or observer poles. • The observer poles are selected to be 2-10 faster than the controller poles. This allows the control derived poles to dominate. It allows a faster decay of estimator errors compared with the desired dynamics. • However, if sensor noise is large the estimator poles may need to be less than 2 times the speed of the controller poles. This yields a system with lower bandwidth and more noise smoothing. • The trade-off is that if the estimator poles are too fast the system becomes more noise sensitive. Matlab code for pole placement: L = acker(F’,H’,p)’ L = place(F’,H’,p)’ Where p is the vector of desired poles which is the same dimension as the state vector.

Matlab code for optimal estimation theory: L = kalman(sys,Rw,Rv) Where sys is the system formulation, Rw is the process noise intensity, and Rv is the sensor noise intensity. A possible approach is to let Rv = 1 & vary Rw. Thus, Rw can be the only tuning variable in this approach.

EECE 413, Fall, 2006

81


State Space Control Law •

Two major approaches – –

Pole placement Linear quadratic regulator (LQR)

u = − Kx = −[ K1

K2

 x1  x   Kn ] 2       xn 

Both rely on pole or eigenvalue selection and state estimation (although output feedback is occasionally used). The control law is a linear combination System equation of all the state variables. For an nth order system there are n feedback gains & and n poles of the system. By Control law choosing proper values of Ki we should be able to place the poles at the substitution desired locations. It is assumed that the system is controllable, ie., it is affected by control The characteristic equation of the closed-loop system is det[sI - (F – GK)] = 0. inputs.

x = Fx − Gu , u = − Kx, x = Fx − GKx

Matlab code for pole placement: K = acker(F,G,p) K = place(F,G,p) Where p is the vector of desired poles which is the same dimension as the state vector. Note the difference between control law & observer design.

Matlab code for lqr: K = lqr(F,G,Q,R)) Where Q is the nxn state weighting matrix, R is the mxm control weighting matrix. Since we are concerned now with SISO systems R may be set to 1. Q becomes a tuning matrix to produce the desired response.

EECE 413, Fall, 2006

82


LQR • When selecting the desired root locations, remember that the control effort required is related to how far the openloop poles are moved by the feedback. • When a zero is near a pole, the system may be nearly uncontrollable (because of near cancellation) & moving such a pole may require a large control effort. • Pole placement may only fix undesirable aspects of the open-loop response & move poles that are near zeros will allow smaller gains and smaller control actuators. • LQR achieves a balance between good system response and control effort required. It consists of calculating the gain K by minimizing a cost function J: ∞

[

]

J = ∫ x Qx + u Ru dt T

T

0

EECE 413, Fall, 2006

83


LQR/Observer Closed-Loop The observer becomes part of the system & contributes dynamics to the system response. Consequently, the observer poles must be considered in the control law. The control matrix becomes F – LH – GK.

xˆ = Fxˆ + Gu + L( y − Hxˆ ) xˆ = ( F − LH ) xˆ + Gu + Ly

xˆ = ( F − LH − GK ) xˆ + Ly Observer matrix

xˆ = ( F − LH ) xˆ Linear system xˆ = Fxˆ − Gu, Example description y = Hx + Ju 0 1  clear * F = [0 1;0 0]; G = [0;1]; H = [1 0]; J = 0; wn = 3; wno = wn*4; z = 0.8; po = roots([1 2*wno*z wno*wno]); p = roots([1 2*wn*z wn*wn]); L = acker(F',H',po)'; K = acker(F,G,p); p = eig(F-G*K); [w,ze] = damp(p) sys = ss(F,G,H,J); rsys = ss(F-L*H-G*K,L,-K,J); sysCL = -feedback(sys*rsys,1,+1); figure(1) step(sysCL,10),grid on,

0  F = , G =  ,  0 0  1 H = [1 0], J = 0

Results for pole placement: w = 3.0000 3.0000 ze = 0.8000 0.8000 L= 19.2000 144.0000 K = 9.0000 4.8000

0 = s 2 + 2ζω n s + ωn , is the desired characteristic equation wn = 3, z = 0.8 2

%lqr code Q = [1 0;0 0]; Q = [100 0;0 5]; R = 1; K = lqr(F-L*H,G,Q,R); p = eig(F-G*K); [w,ze] = damp(p) sys = ss(F,G,H,J); rsys = ss(F-L*H-G*K,L,-K,J); sysCL = -feedback(sys*rsys,1,+1); figure(1) step(sysCL,10),grid on,

EECE 413, Fall, 2006

Results for lqr: w = 3.1623 3.1623 ze = 0. 7906 0. 7906 L= 19.2000 144.0000 K = 10 5

84


SS Pole Placement Results Note that increasing magnitude of observer poles reduces overshoot.

LQR s tep response, desired/obs erv er poles = 3 24 1.4

1.2

1.2

1

1

0.8

0.8 Amplitude

Amplitude

LQR step response, desired/observer poles = 3 12 1.4

0.6

0.6

0.4

0.4

0.2

0.2

0

0

1

2

3

4

5 Time (sec)

6

7

8

9

10

0

0

1

EECE 413, Fall, 2006

2

3

4

5

85

Time (sec)

6

7

8

9

10


SS LQR Results Note the effect of the state weights. Heavier weights give a faster response. The observer poles are fixed at 8x the previous desired response value of 3.

Q = [1 0;0 0]; Q = [10 0;0 5]; Q = [100 0;0 5]; Step Response 1.4

1.2

1

Amplitude

clear * F = [0 1;0 0]; G = [0;1]; H = [1 0]; J = 0; wn = 3; wno = wn*8; z = 0.8; po = roots([1 2*wno*z wno*wno]); p = roots([1 2*wn*z wn*wn]); L = place(F',H',po)'; Q = [1 0;0 0]; Q = [10 0;0 5]; Q = [100 0;0 5]; R = 1; K = lqr(F,G,Q,R); p = eig(F-L*H-G*K); p = eig(F-G*K); [w,ze] = damp(p) sys = ss(F,G,H,J); rsys = ss(F-L*H-G*K,L,-K,J); sysCL = -feedback(sys*rsys,1,+1); figure(1) step(sysCL,10),grid on,hold off

0.8

0.6

0.4

0.2

0

0

1

2

EECE 413, Fall, 2006

3

4

5

6

Time (sec)

86

7

8

9

10


Closed-Loop Feedback The observer now estimates the error = r-y, where r is the setpoint & y is the feedback measurement. The system control matrix is still F – LH – GK.

xˆ = Fxˆ + Gu + L( r − yˆ ) u = − Kxˆ, yˆ = Hxˆ → yˆ = Hxˆ xˆ = Fxˆ − GKxˆ + L( r − Hxˆ ) xˆ = ( F − LH − GK ) xˆ + Lr

System equations

Same Example with pole placement 2 0 = s 2 + 2ζω n s + ωn , is the desired 0 1  0  Linear system xˆ = Fxˆ − Gu, F = 0 0, G = 1, characteristic equation wn = 3, z = 0.8 description y = Hx + Ju H = [1 0], J = 0 L = place(F',H',po)'; % lqr_example_series.m % clear * F = [0 1;0 0]; G = [0;1]; H = [1 0]; J = 0; wn = 3; wno = wn*6; z = 0.8; po = roots([1 2*wno*z wno*wno]); p = roots([1 2*wn*z wn*wn]); L = place(F',H',po)'; K = acker(F-L*H,G,p); K = acker(F,G,p); p = eig(F-L*H-G*K); [w,ze] = damp(p) sys = ss(F,G,H,J); rsys = ss(F-L*H-G*K,L,-K,J); % sysCL = -feedback(sys*rsys,1,+1); sysCL = -sys*rsys/(1 - sys*rsys);

Results for pole placement: w = 21.7081 21.7081 ze = 0.7739 0.7739 L= 28.8000 324.0000 K = 9.0000 4.8000

EECE 413, Fall, 2006

Q = [1 0;0 0]; Q = [10 0;0 5]; Q = [100 0;0 5]; R = 1; K = lqr(F,G,Q,R); p = eig(F-L*H-G*K); [w,ze] = damp(p) sys = ss(F,G,H,J); rsys = ss(F-L*H-G*K,L,-K,J); Results for lqr: w = 21.8632 21.8632 ze = 0.7730 0.7730 L= 28.8000 324.0000 87 5.0000 K = 10.0000


SS Pole Placement Feedback Results Results for pole placement: w = 21.7081 21.7081 ze = 0.7739 0.7739 L= 28.8000 324.0000 K = 9.0000 4.8000

Step Response 1.4

1.2

1

Amplitude

% lqr_example_series.m % clear * F = [0 1;0 0]; G = [0;1]; H = [1 0]; J = 0; wn = 3; wno = wn*6; z = 0.8; po = roots([1 2*wno*z wno*wno]); p = roots([1 2*wn*z wn*wn]); L = place(F',H',po)'; K = acker(F-L*H,G,p); K = acker(F,G,p); p = eig(F-L*H-G*K); [w,ze] = damp(p) sys = ss(F,G,H,J); rsys = ss(F-L*H-G*K,L,-K,J); sysCL = -feedback(sys*rsys,1,+1); figure(1) step(sysCL,10),grid on,

0.8

0.6

0.4

0.2

0

0

1

2

3

4

5

6

Time (sec)

EECE 413, Fall, 2006

88

7

8

9

10


SS LQR Feedback Results This is a tracking controller. Note how the heavier weight on the 2nd state reduces the overshoot. Q = [1 0;0 0];

Q = [10 0;0 1];

Q = [100 0;0 5];

Step Response 1.4

1.2

1

Amplitude

% lqr_example_series.m % clear * F = [0 1;0 0]; G = [0;1]; H = [1 0]; J = 0; wn = 3; wno = wn*6; z = 0.8; po = roots([1 2*wno*z wno*wno]); p = roots([1 2*wn*z wn*wn]); L = place(F',H',po)'; Q = [1 0;0 0]; Q = [10 0;0 1]; Q = [100 0;0 5]; R = 1; K = lqr(F,G,Q,R); p = eig(F-L*H-G*K); [w,ze] = damp(p) sys = ss(F,G,H,J); rsys = ss(F-L*H-G*K,L,-K,J); sysCL = -feedback(sys*rsys,1,+1); figure(1) step(sysCL,10),grid on,

0.8

Q = [100 0;0 50];

0.6

0.4

0.2

0

0

1

2

EECE 413, Fall, 2006

3

4

5

6

Time (sec)

89

7

8

9

10


SS Pole Placement Feedback Prob. 2.9 Given equations

θ  θ + 4θ = Tc + Td →   , θ 

2 states, since 2nd order system State space matrix values.

 0 1 0  F = , G =  1, H = [1 0], J = 0 − 4 0    

Taking Laplace transforms: θ + 4θ = Tc + Td → s 2θ ( s ) + 4θ ( s ) = Tc ( s ) + Td ( s ), ( s 2 + 4)θ (s) = Tc (s) + Td (s) → T (sθ) +(sT) (s) = s 2 1+ 4 c d

% Prob2_9.m % clear * F = [0 1;-4 0]; G = [0;1]; H = [1 0]; J = 0; po = [-10;-10]; p = [-2+2*i;-2-2*i]; L = acker(F',H',po)'; K = acker(F,G,p);

L= 20 96 K= 4

Characteristic equation from denominator.

4

EECE 413, Fall, 2006

90


SS Pole Placement Feedback Prob. 2.9 Results for pole placement: w = 21.7081 21.7081 ze = 0.7739 0.7739 L= 28.8000 324.0000 K = 9.0000 4.8000

Observer poles This is a stabilizing controller. This is not shown in the text. Step Response

1.4

1.2

1

Amplitude

% lqr_example_series.m % clear * F = [0 1;0 0]; G = [0;1]; H = [1 0]; J = 0; wn = 3; wno = wn*6; z = 0.8; po = roots([1 2*wno*z wno*wno]); p = roots([1 2*wn*z wn*wn]); L = place(F',H',po)'; K = acker(F,G,p); p = eig(F-L*H-G*K); [w,ze] = damp(p) sys = ss(F,G,H,J); rsys = ss(F-L*H-G*K,L,-K,J); sysCL = -feedback(sys*rsys,1,+1); figure(1) step(sysCL,10),grid on,

0.8

0.6

0.4

0.2

0

0

1

2

3

4

5

6

Time (sec)

EECE 413, Fall, 2006

91

7

8

9

10


SS with Integral Control Integral control is accomplished by augmenting (adding) the state vector with the desired integral xi. It obeys the differential equation: t

x i = r − Hx = e → xi = ∫ edt

Augmentation is shown below:  x i  0 − H   xi   0  1  x  = 0 G   x  + G u + 0 r ,          x  x  u = −[ Ki Ko ]  i  = − K  i  x x

A pole placement example will illustrate the procedure. The advantage of this procedure is to add in the integral controller to an automatic design method.

EECE 413, Fall, 2006

92


SS Pole Placement with Integrator Results Step Response

Setpoint Input

1.5

1

0.5

0

0

1

2

3

4

5

6

7

8

9

10

6

7

8

9

10

Time (sec) Step Response Disturbance Input

0.15 0.1 0.05 0 -0.05

0

1

2

3

4

5

Time (sec) Step Response

1.4 setpoint combination 1.2

1 SP/Disturbance Input

% lqr_example_integrator.m % clear * F = [0 1;-4 0]; G = [0;1]; H = [1 0]; J = 0; Fbar = [0 -H;[0;0],F]; Gbar = [0;G]; Hbar = [0 H]; Jbar = [0 0]; po = [-10;-10]; p = [-2+2*i;-2-2*i;-4]; L = acker(F',H',po)'; K = acker(Fbar,Gbar,p); Ki = K(1); Ko = K(2:3); A = [Fbar-Gbar*[Ki 0 0],-Gbar*Ko;-G*Ki,L*H,F-L*H-G*Ko]; B = [1;0;0;0;0]; C = [Hbar 0 0]; D = 0; sysCL = ss(A,B,C,D); figure(1) subplot(211) step(sysCL,10),grid on, ylabel('Setpoint Input') subplot(212) B2 = [0;G;0;0]; sysCL1 = ss(A,B2,C,D); step(sysCL1,10),grid on, ylabel('Disturbance Input') figure(2) B3 = [1;G;0;0]; sysCL2 = ss(A,B3,C,D); step(sysCL,sysCL2,10),grid on, ylabel('SP/Disturbance Input') legend('setpoint','combination')

0.8

0.6

0.4

0.2

0

0

1

EECE 413, Fall, 2006

2

3

4

5

93

Time (sec)

6

7

8

9

10


Prob 2.20 modified 5000( s + 1) G ( s ) = Determine if G(s) is stable. If stable, how to stabilize to PM = 45 using bode s 2 ( s + 10 )( s + 50 ) plots? Using pole placement & estimator place poles at [-4+4i,-4-4i,-5,-5].

Bode Diagram Gm = 14.5 dB (at 21 rad/sec) , Pm = 35.7 deg (at 7.84 rad/sec)

% Prob_2_20_mod.m % clear * sys = tf(5000*[1 1],[1 60 500 0 0]); figure(1) margin(sys),grid

150

Magnitude (dB)

100 50 0 -50 -100 -150 -90

Bode Diagram Gm = 18.8 dB (at 21 rad/sec) , Pm = 45 deg (at 5.4 rad/sec)

-135 Phase (deg)

200

Magnitude (dB)

100

0

-180 -225 -270 -2

10

-100

0

10

1

10

2

10

3

10

Frequency (rad/sec)

-200 -90

% Prob_2_20_mod.m % clear * sys = tf(5000*[1 1],[1 60 500 0 0]); figure(2) margin(0.607*sys),grid

-135 Phase (deg)

-1

10

-180 -225 -270 -2

10

-1

10

0

10

1

10

2

10

3

10

4

10

Frequency (rad/sec)

EECE 413, Fall, 2006

94

4

10


Prob 2.20 modified – cont. System: sysCL Time (sec): 1.06Step Response Amplitude: 1.28

1 System: sysCL Time (sec): 2.79 Amplitude: 1.01

0.5

0

0

0.5

1

1.5

2

2.5

3

3.5

4

4.5

5

Time (sec)

20 Imaginary Axis

% Prob_2_20_mod.m % clear * sys = tf(5000*[1 1],[1 60 500 0 0]); figure(1) margin(sys),grid figure(2) margin(0.607*sys),grid [F,G,H,J] = ssdata(sys); p = [-2+1i,-2-1i,-10,-15]; po = 6*p; L = acker(F',H',po)'; K = acker(F-L*H,G,p); K = acker(F,G,p); sys = ss(F,G,H,J); rsys = ss(F-L*H-G*K,L,-K,J); sysCL = -feedback(sys*rsys,1,+1); figure(3) subplot(211) step(sysCL,5),grid on, subplot(212) pzmap(sysCL)

Amplitude

1.5

10

Pole-Zero Map System: sysCL Zero : -10 Damping: 1 Overshoot (%): 0 Frequency (rad/sec): 10

0 -10 -20 2 -10

System: sysCL Pole : -15 Damping: 1 Overshoot (%): 0 Frequency (rad/sec): 15

System: sysCL Pole : -2 - 1i Damping: 0.894 Overshoot (%): 0.187 1 -10 Frequency (rad/sec): 2.24 Real Axis

EECE 413, Fall, 2006

95

0

-10


b) c)

Design a continuous lead compensation D(s) for the plant G(s) so that the complex roots are at approximately s = -4.4 +j4.4 rad/s Implement a delay of T/2 & determine the approximate effect. Determine the revised root locations for sample rates of ws = 5, 10, & 20 Hz, where T = 1/ws.

% Prob_3_1.m % clear * sysG = tf(1,[1 0 0]); sysD = tf([1 2.5],[1 15]); % part a k = 0:400; sys = sysG*sysD; pdes = -4.4 + j*4.4; figure(1) rlocus(sys,k), hold on,grid axis([-16 0 0 8]) [k,poles] = rlocfind(sys,pdes); p = rlocus(sys,k);i = find(imag(p)>0); plot(real(p(i)),imag(p(i)),'+'),hold on xlabel(['real axis, k = ',num2str(k)]) % part b T = 1/20; sysGh = tf(2/T,[1 2/T]); sysh = sysGh*sys; p = rlocus(sysh,k);i = find(imag(p)>0); plot(real(p(i)),imag(p(i)),'+'),hold on T = 1/10; sysGh = tf(2/T,[1 2/T]); sysh = sysGh*sys; p = rlocus(sysh,k);i = find(imag(p)>0); plot(real(p(i)),imag(p(i)),'+'),hold on T = 1/5; sysGh = tf(2/T,[1 2/T]); sysh = sysGh*sys; p = rlocus(sysh,k);i = find(imag(p)>0); plot(real(p(i)),imag(p(i)),'+'),hold on

G (s) =

1 s2

D( s) = k

Prob 3.1

s+a s+b

Zero a @ 2.5 & pole b @ 15 found by iteration. At this time can use rlocfind to get k. G(s) =

2/T s + 2/T

Decreasing sample rate degrades performance.

RL pole placement using rlocfind

Root Locus

8 0.86

0.76

0.58

0.35

7 0.92

10 Hz

6

20 Hz

5 Imaginary Axis

a)

5 Hz

0.96 4

3

0.984

2 0.996 1 16 0 -16

14

12

10

8

6

4

2

-14

-12

-10

-8

-6

-4

-2

real axis, k = 92.7216

EECE 413, Fall, 2006

96

0


Prob. 3.2 Repeat Example 3.1, but use the approximation that

x (k ) ≅

x(k ) − x(k − 1) T

Which is the backward rectangular version of Euler’s method. Compare the resulting difference equations with the forward rectangular Euler method. Also compute the numerical value of the coefficients for both cases vs. sample rate for ωs = 1 to 100 Hz. Assume the continuous values from eq. 3.8. Note that the coefficients of interest are given in eq. 3.7 for the forward rectangular case as (1 – bT) and (aT – 1).

Starting with

D( s) =

U (s) s+a = Ko ⇒ ( s + b )U ( s ) = K o ( s + a ) E ( s ) ⇒ u + bu = K o ( e + ae ) E ( s) s+b

u (k ) − u (k − 1)  e( k ) − e(k − 1)  + bu (k ) = K o  + ae( k )  T T  

Plug in the approximation above for each derivative Or change k->k+1 & k-1->k to solve for u(k+1)

 1   Ko   1 + aT  u ( k + 1) =  u ( k ) − e ( k ) + 1 + bT   K o 1 + bT  e( k + 1) 1 + bT   

Compare with forward rectangular from eq. 3.7

u ( k + 1) = [1 − bT ]u ( k ) − [ K o ( aT − 1) ] e(k ) + [ K o ] e(k + 1)

d i s c r e t e p o l e

1 0 . 5 0 0 . 5 1 1 . 5 2 2 . 5 3 0

1 0

2 0

3 0

4 0 5 0 6 0 s a m p l i n g r a t e -H z

7 0

8 0

EECE 413, Fall, 2006

9 0

1 0 0

a = 2; b = 10; Ko = 70; Ws = 1:100; T = 1./Ws; cl = 1./(1+b*T); plot(Ws,cl,'-'),hold on cl = 1 - b*T; plot(Ws,cl,'--'), hold on plot(Ws,-ones(length(Ws),1),'r--'), hold off axis([0 100 -3 1]) ylabel('discrete pole') xlabel('sampling rate - Hz')

97


Prob. 3.3 For the compensation: D( s) = 25

s +1 s + 15

Use Euler’s forward rectangular method to determine the difference equations for a digital implementation with a sample rate of 80 Hz. Repeat the calculations using the backward rectangular method & compare the difference equation coefficients.

For u(k+1) = c1 u(k) + c2 e(k) + c3 e(k+1) Forward rectangular Backward rectangular

c1

c2

c3

1 - bT

Ko(aT -1 )

Ko

1/(1 + bT)

-Ko /(1 + bT)

Ko(1+aT) /(1 + bT)

c1

c2

c3

0.8125

-24.6875

25

0.8421

-21.0526

21.3158

For a=1, b=15, Ko=25 Forward rectangular Backward rectangular

EECE 413, Fall, 2006

98


Prob. 3.8 The read arm on a computer disk drive has the transfer function G ( s ) =

500 s2

Design a continuous lead compensation so that the closed-loop system has a bandwidth of 100 Hz and a phase margin of 50. Modify the matlab file fig32.m so that you can evaluate the digital version of your lead compensation using Euler’s forward rectangular method. Try different sample rates, and find the slowest one where the overshoot does not exceed 30%. Simplest is to start with a single lead with 10:1 lead ratio (b/a = 10) for ~ 50 PM, where

D( s) = K

s+a s+b

For bandwidth of 100 Hz = 630 rad/s, pick crossover frequency of 400 rad/s, so a = 400/sqrt(10) ~ 125 & b = 400*sqrt(10) ~ 1250, then iterate on k until find max phase @ k ~ 1000. Then plug into optimizer until convergence to PM & crossover frequency. Bode Diagram Gm = Inf dB (at Inf rad/sec) , Pm = 29.4 deg (at 432 rad/sec)

% Prob_3_8.m % clear * sys = tf(500,[1 0 0]); figure(1) margin(sys),hold on xin = [1000 125 1250]; k = xin(1); a = xin(2); b = xin(3); sysD = tf([1 a],[1 b]); margin(sysD*sys),hold on sysD = tf(k*[1 a],[1 b]); margin(sysD*sys),hold off figure(2) sysCL = feedback(sysD*sys,1); margin(sysCL)

100

Magnitude (dB)

50 0 -50 -100

Phase (deg)

-150 -150

-160

-170

-180 1

10

2

3

10

10

4

10

Frequency (rad/sec)

EECE 413, Fall, 2006

99


Prob. 3.8 – optimizer code Once the starting point is established of [1000 125 1250], it is a simple thing to optimize to find a closed-loop solution to the system. The final solution is [612.1357 231.2867 678.5847]. The cost function must cause convergence to PM = 50 + Allowance = 54 & crossover frequency = 100 Hz. The absolute values of the deviations from these values are used as shown below. The command fminsearch accesses a Nelder-Mead simplex optimization package. The main script initializes & starts the optimization. The function Optim_Prob_3_8 calculates the cost function for each trial. Each trial set of three values is passed in as a vector. The cost function (out) is a scalar value that can be compared to other trials to pick the best. Even with the optimization there are an infinite combination of solutions, also, the optimizer may get stuck on a local minimum. If so, modify the initialization & restart. The global minimum is very close to 0 in this case. Bode Diagram Gm = Inf dB (at Inf rad/sec) , Pm = 54 deg (at 628 rad/sec) 20

Magnitude (dB)

0

% main_optim_prob_3_8.m % xin = [1000 125 1250]; xin = fminsearch('Optim_Prob_3_8',xin);

-20

-40

function out = Optim_Prob_3_8(xin); % sys = tf(500,[1 0 0]); k = xin(1); a = xin(2); b = xin(3); sysD = tf(k*[1 a],[1 b]); sysCL = feedback(sysD*sys,1); [gm,pm,wcg,wcp] = margin(sysCL); out = abs(pm - 54) + abs(wcp - 2*pi*100); [xin,out]

-60 0

Phase (deg)

-45 -90 -135 -180 1

10

2

3

10

10

4

10

Frequency (rad/sec)

EECE 413, Fall, 2006

100


Prob 3.8 – Different Sampling Rates [1.2459

0.1036

[1000 125 1250]

1.1]*1e3

Step Response

1.4

1.2

Note: the optimized gains improve the settling time. Also, 500 Hz is unstable -> -(1b*T) > 1.

Amplitude

1

0.8

0.6

0.4

0.2

0

0

0.001

0.002

0.003

0.004

0.005

0.006

0.007

0.008

0.009

0.01

Time (sec) Step Response

800 Hz 2

600 Hz

500 Hz

continuous

1.8 1.6 1.4

Amplitude

1.2 1 0.8

xin = [1.2459 0.1036 1.1000]*1e3; kk = xin(1); a = xin(2); b = xin(3); tf = 0.01; Ws = 500; T = 1/Ws; [numGd,denGd] = c2dm(500,[1 0 0],T,'zoh'); numDd = kk*[1 -(1-a*T)]; denDd = [1 -(1-b*T)]; numd = conv(numGd,numDd); dend = conv(denGd,denDd); [numcld,dencld] = feedback(numd,dend,1,1); td = 0:T:(tf*Ws-1)*T; dstep(numcld,dencld,td),grid on,hold on Ws = 600; T = 1/Ws; numDd = kk*[1 -(1-a*T)]; denDd = [1 -(1-b*T)]; numd = conv(numGd,numDd); dend = conv(denGd,denDd); [numcld,dencld] = feedback(numd,dend,1,1); td = 0:T:(tf*Ws-1)*T; dstep(numcld,dencld,td),grid on,hold on Ws = 800; T = 1/Ws; numDd = kk*[1 -(1-a*T)]; denDd = [1 -(1-b*T)]; numd = conv(numGd,numDd); dend = conv(denGd,denDd); [numcld,dencld] = feedback(numd,dend,1,1); td = 0:T:(tf*Ws-1)*T; dstep(numcld,dencld,td),grid on,hold off

0.6 0.4 0.2 0

0

1

2

3

4 Time (sec)

5

6

EECE 413, Fall, 2006 7

8

-3

x 10

101


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.