Upload
steve-rogers
View
214
Download
0
Embed Size (px)
DESCRIPTION
EECE 413, Fall, 2006 1 Desired Performance: REFERENCE INPUT EECE 413, Fall, 2006 Difference: ERROR Information about the system: OUTPUT Aircraft, missiles, cars, appliances, economic systems, etc. To the System 2
Citation preview
EECE 413, Fall, 20061
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, 20062
What Is a Control System?
• 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)
Controller System to be controlled
Desired
Performance:
REFERENCE
Difference:
ERROR
INPUTTo the System
Aircraft, missiles, cars, appliances, economic
systems, etc.
Information about the system:
OUTPUT
EECE 413, Fall, 20063
Simple System Model for Cruise Control
mux
mbxxmxbu
xb
xv
Mass m
acceleration
x displacement
Force uFriction force
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
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
muv
mbv Model of the cruise control system, u is input force, v is output.
EECE 413, Fall, 20064
Cruise Control System
Controller
REFERENCEINPUT OUTPUT
?
70 MPHu Speed v
muv
mbv
Control engineering is to design the controller in a way that the system meets desired performance specifications.
EECE 413, Fall, 20065
Basic Electrical Systems
v
i
RV = iR
Resistor
v(t)
i(t)
C
i = C dv/dt
Capacitor
v(t)
i(t)
L
v = L di/dt
Inductor
Kirchhoff’s Voltage Law (KVL)The sum of voltage drops around any closed loop in a circuit is 0.
v1
v2
v3
v5 v4
v1 + v2 + v3 + v4 + v5 = 0
Kirchhoff’s Current Law (KCL)The sum of currents entering/leaving a node/closed surface is 0.
i1 i2
i3
i5i4
i1 + i2 + i3 + i4 + i5 = 0
i1
i2
i3
i4i5
EECE 413, Fall, 20066
Modeling of a simple electrical system:
dtdvRCRiv o
R
dtdvCi o
0
0
io
oiRo
iRo
vdtdvRCvvvv
vvv
iooioo vvvRCvv
dtdvRC
To find out the relationship between the input (v i) and the output (vo) for the circuit:
vi
i
vo
RC
By KVL, we have
A dynamic model of the circuit
EECE 413, Fall, 20067
Dynamic AnalogiesPhysically dissimilar systems can have similar dynamic properties. For example, consider a spring-mass system.
MK
B
f(t)
v(t)
M = mass, B = friction constant, K = spring constant, f(t) = external force, and v(t) = velocity of the mass.
Summing the forces yields:
t
dvKtBvdttdvMtf )()()()(
Inertial forcefriction force
spring force
EECE 413, Fall, 20068
More Dynamic Analogies
t
dvLR
tvdttdvCti )(1)()()(
i(t)
iC(t) iR(t) iL(t)
C R L
Electric network
capacitanceresistance
inductance
Summing the currents (Kirchhoff’s Current law) yields:
EECE 413, Fall, 20069
Mechanical and Electrical systems are dynamically analogous
t
dvLR
tvdttdvCti )(1)()()(
t
dvKtBvdttdvMtf )()()()(
Thus, understanding one of these systems gives insights into the other.
EECE 413, Fall, 200610
Block Diagrams
KxxBxMdvKtBvdttdvMtf
t
)()()()(
dttdv )(
t
dv )(
A block diagram using integrators, adders, and gains:
f(t)+ 1/M
v(t)
B
K
+
- -
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.
Solve for x
KxxBtfM
x
KxxBtfxM
)(1)(
where )(&)( tvxdttdvx
for starting point
EECE 413, Fall, 200611
Voltage Control of the Simple Electrical System
Controller
REFERENCEINPUT OUTPUT
?
220 voltsvi vo
Control engineering is to design the controller in a way that the system meets desired performance specifications.
ioo vvvRC
vi
i
voR C
EECE 413, Fall, 200612
Ordinary Differential Equations (ODE)
tubtyatyaty 001
tubtyaty 00
Many real life problems can be modeled as an ODE of the following form:
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.
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, 200613
Laplace Transform and Inverse Laplace Transform
0 5 10-1
-0.5
0
0.5
1
mag
nitu
de
0.1 0.2 0.3 0.4 0.50
5
10
15
Freq
uenc
y m
agni
tude
of y
frequency (Hz)
0 5 10-2
-1
0
1
2
mag
nitu
de
0 0.5 10
5
10
15
Freq
uenc
y m
agni
tude
of y
frequency (Hz)
Let’s first examine the following time-domain functions:
Cosine function with a frequency f = 0.2 HzNote it has a period T = 1/f = 5 seconds
x(t) = cos(0.4*pi*t) + sin(0.8*pi*t)*cos(1.6*pi*t)What are the frequencies of this function?
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.
Signal plots
PSD plots
f = 0.2 Hz f = 0.2, 0.4, & 1.2 Hz
EECE 413, Fall, 200614
% 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 trajectoryylabel('magnitude')
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 onylabel('Frequency magnitude of y')xlabel('frequency (Hz)') 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 onylabel('Frequency magnitude of y')xlabel('frequency (Hz)')
Matlab Code for Previous Sinusoid Plots
EECE 413, Fall, 200615
Laplace Transform
0
dtetftfLsF st
0Re
11101111 0
000
ssss
es
es
es
dtedtetfsF ststst
atetf
asasasas
eas
dtedteedtetfsF tastasstatst
Re
111011
0000
Given a time-domain function f(t), its Laplace transform is defined as follows:
Example 1: Find the Laplace transform of a constant function f(t) = 1.
Example 2: Find the Laplace transform of an exponential function
EECE 413, Fall, 200616
Inverse Laplace Transform
2
2
1
1
1
11
)()(
aste
ase
st
s
sFtf
at
at
22
22
22
22
cos
sin
cos
sin
)()(
basasbte
basbbte
assat
asaat
sFtf
at
at
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)
EECE 413, Fall, 200617
Laplace Transform Properties
sFasFatfLatfLatfatfaL 221122112211
ssFtfsLtfLdttdfL
sFstfLstfLdt
tfdL 222
2
sFs
tfLs
dfLt 11
0
1. Superposition:
2. Differentiation: Assume that f(0) = 0.
3. Integration:
EECE 413, Fall, 200618
Express ODE models using Laplace Transforms to get transfer functions
ubvvm
sG
bmssUsVsUsVbms
sUsbVsmsVuLvbLvmsLuLbvLvmLuLbvvmL
1
The mechanical system in the cruise-control problem can be represented by an ODE:
Taking Laplace transforms on both sides of the equation, we obtain
G(s) is called the transfer function of the system model.
EECE 413, Fall, 200619
Classical Feedback Control in Continuous Setting
)()()()()()( sUsGsYsUsYsG
)()()()()()()()()()( sYsRsDsGsEsDsGsUsGsY
)()(1)()(
)()()(
sDsGsDsG
sRsYsH
Examine block diagram of continuous time (CT) control system:
R(s)D(s)
E(s)G(s)
U(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.
We also have U(s) = D(s)E(s), and E(s) = R(s) – Y(s), and
)()()()()()(1)()()()()()()()()(
sRsDsGsYsDsGsYsDsGsRsDsGsUsGsY
Closed-loop transfer function from R to Y.
EECE 413, Fall, 200620
Simplified Block Diagram in Continuous Setting
)()(1)()(
)()(1)()(1)()()()()()(
sDsGsRsR
sDsGsDsGsRsHsRsYsRsE
)()(1)()()(sDsG
sDsGsH
The CT block diagram of the previous control system may be simplified as,
R(s) Y(s)
The control problem is to choose an appropriate D(s) such that H(s) will have desired properties. We have,
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.
r(t) y(t)
EECE 413, Fall, 200621
Two Approaches to Design a Digital ControllerThe 1st is to discretize the controller:
R(s)D(s)
E(s)G(s)
U(s) Y(s)+
-
R(s)D(z) G(s)
Y(s)+
-
ZOH
T
The 2nd is to discretize the plant and then apply digital control techniques for the controller:
R(z)D(z)
E(z)U(z)
Y(z)
+-
G(s)ZOH
T
R(z)D(z)
E(z)G(z)
U(z) Y(z)+
-
EECE 413, Fall, 200622
Classical Feedback Control in Discrete Setting
)()()()()()( zUzGzYzUzYzG
)()()()()()()()()()( zYzRzDzGzEzDzGzUzGzY
)()(1)()(
)()()(
zDzGzDzG
zRzYzH
Examine block diagram of discrete time (DT) control system:
R(z)D(z)
E(z)G(z)
U(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.
We also have U(z) = D(z)E(z), and E(z) = R(z) – Y(z), and
)()()()()()(1)()()()()()()()()(
zRzDzGzYzDzGzYzDzGzRzDzGzUzGzY
Closed-loop transfer function from R to Y.
EECE 413, Fall, 200623
Simplified Block Diagram in Discrete Setting
)()(1)()(
)()(1)()(1)()()()()()(
zDzGzRzR
zDzGzDzGzRzHzRzYzRzE
)()(1)()()(zDzG
zDzGzH
The DT block diagram of the previous control system may be simplified as,
R(z) Y(z)
The control problem is to choose an appropriate D(z) such that H(z) will have desired properties. We have,
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.
r(k) y(k)
EECE 413, Fall, 200624
Steady State Errors
)()()(1
1)()( sS
sGsDsRsE
)()(lim
,11
0sGsDK
Ke
sp
pss
In order to evaluate steady-state errors must evaluate the system error e:
S(s) is called the sensitivity. In the step input case to a stable system the final value theorem tells us:
Position error constant Kp
If Kp and ess are finite (no s in D(s)G(s)), the system is type 0.
)()(lim0
sGssDKsv
Kv is the velocity constant & if finite (one s in D(s)G(s)), the system is type 1.
)()(lim 2
0sGsDsK
sa Ka is the acceleration constant & if finite
(two s’ in D(s)G(s)), the system is type 2.
See Table 2.1, p. 23, for error vs. system type.
EECE 413, Fall, 200625
Steady State Errors - continuous
pss KDGsDsGs
sssEe
1
1)0()0(1
1)()(1
11lim)(lim)(00
Case 1: If r(t) is a unit step, R(s) = 1/s, & by the final value theorem of Laplace Transform
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.
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.
ProportionalError constant
Case 2: If r(t) is a unit ramp, R(s) = 1/s2, & by the final value theorem of Laplace Transform
vsss KsDssGsDsGs
sssEe 1)()(lim
1)()(1
11lim)(lim)(0
200
VelocityError constant
EECE 413, Fall, 200626
Steady State Errors - discrete
p
zz KDGzDzGzzzzEze
11
)1()1(11
)()(11
11lim)(1lim)(
11
Case 1: If r(k) is a unit step, R(z) = z/(z-1), & by the final value theorem of z-Transform
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.
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.
ProportionalError constant
Case 2: If r(k) is a unit ramp, R(z) = Tz/(z-1)2, & by the final value theorem of z-Transform
vz
z KzDzGzT
zDzGzTzze 1
)()(1lim)()(11
11lim)(
1
21
VelocityError constant
EECE 413, Fall, 200627
Final Value Theorem
• Steady state accuracy• Stability• Rise time• Overshoot• Settling time• Disturbance rejection• others
)(lim)(lim ssXxtxossst
If a system is stable and has a final, constant value
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
1
0.9
0.1
tr
Rise time
Mp (in %)overshoot
1% settling time
ts
Steady state error
+-1%
t
Transport delay – e-tds
td
EECE 413, Fall, 200628
Feedback Control System Block Diagram Properties
)()()(1)()(
)()( s
sGsDsGsD
sRsY
0)()(1 sGsD
)()()(1
1)()( sS
sGsDsRsE
Figure 2.8, p. 22r
CommandInput
++
Compensation
D(s)e
+
Disturbance, w
-+
+ Plant
G(s)y
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.
Step Ramp Parabola
Type 0 1/(1+Kp) ∞ ∞
Type 1 0 1/Kv ∞
Type 2 0 0 1/Ka
EECE 413, Fall, 200629
Simplified Block Diagram in CT with PI Controller
sksk
skksD
asbsG ipi
p
)(,)(
ip
ip
bksbkasbksbk
sDsGsDsGsH
2)()(1)()()(
The CT block diagram of the previous control system may be simplified as,
R(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).
The closed-loop system H(s) is a 2nd order system as its denominator is a polynomial s of degree 2.
)()(1)()()(sDsG
sDsGsH
EECE 413, Fall, 200630
Control System Stability
11)( 2
s
sH
ase at
1
tt eety 5.0)(
15.05.0
set
15.0
15.0
111
11)()()( 2
sssss
sRsHsY
15.05.0
se t
Example 1: Consider a closed-loop system with,
R(s) = 1 Y(s)
We have,
Using the Laplace transform table, we have,
0 1 2 3 4 5 6 7 8 9 100
2000
4000
6000
8000
10000
12000Step Response
Time (sec)
Ampl
itude
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.
Matlab code:step(tf(1,[1 0 -1]),10),grid on
EECE 413, Fall, 200631
Control System Stability
231)( 2
ss
sH
tt eety 2)(
atat e
assae
as
1,1
1&11212,021
221
)1(221
21
11
211
231)()()( 2
ABBBBABABAss
BAsBAss
sBsAsB
sA
sssssssRsHsY
Example 2: Consider a closed-loop system with,
R(s) = 1 Y(s)
We have, Using the Laplace transform table, for an impulse, we have,
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.
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
For a step we have,
t
t
at
eksk
sss
ess
ekass
kasss
215.05.0,2
21211
1111
1,21
111
tttt eeeety 22 5.05.015.01)(
0 1 2 3 4 5 6 7 8 9 100
0.1
0.2
0.3
0.4Impulse Response
Time (sec)
Ampl
itude
0 1 2 3 4 5 6 7 8 9 100
0.2
0.4
0.6
0.8Step Response
Time (sec)
Ampl
itude
EECE 413, Fall, 200632
L.H.P.
Stable Region
R.H.P.
Unstable Region
Control System Stability
22
2
2)(
nn
n
sssH
DuCxyBuAxx
02 22 nnss
Consider a general 2nd order system,
R(s) = 1 Y(s)
The system is stable if the denominator of the system has no positive roots. It is unstable if it has positive roots.
Consider a general linear system characterized by a state space form.
1. It is stable if and only if all the eigenvalues of A are in the open left-half plane.2. 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.3. It is unstable if and only if A has at least one eigenvalue in the right-half plane.
EECE 413, Fall, 200633
Stability – Discrete SystemsA 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.
x
x x
Stablex
x
x
Marginally Stable
Unstable
x
xxConsider a 1st order low-pass filter:
y = a*yp + (1-a)*upWhere 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, 200634
2nd Order Control System Stability
22
2
2)(
nn
n
sssH
Consider a general 2nd order system,
R(s) = 1 Y(s)
The behavior of the system is as follows:
0 2 4 6 8 10 120
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2Step Response
Time (sec)
Ampl
itude
The behavior of the system is fully characterized by ς, which is called the damping ratio, and ωn, which is called the natural frequency.
Matlab code:% Two_order.mw=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 onend
EECE 413, Fall, 200635
Control System Design with Time-Domain Specs
22
2
2)(
nn
n
sssH
nrt
8.1
Consider a general 2nd order system again,
R(s) = 1/s Y(s)
See page 21 of Franklin - Powell
r(t) = 1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
10
20
30
40
50
60
70
80
90
100
Mp,
%
ς
1
0.9
0.1
tr
Rise time
Mp (in %)overshoot
1% settling time
ts
Steady state error
+-1%
t
nst
6.4
10,21 eM p
Time domain specs for simple systems:• Rise time•Settling time•Overshoot
For complex systems must use simulation.
EECE 413, Fall, 200636
PI Design Technique:
asbsG
)(
sksk
skksD ipi
p
)(
22
2
2)(
nn
n
sssH
Design D(s) with PI (proportional-integral) structure:
R(s)D(s)
E(s)G(s)
U(s) Y(s)+
-
With G(s) & D(s) as defined above, the system becomes a closed-loop system.
ip
ip
bksbkasbksbk
sDsGsDsG
sRsYsH
2)()(1)()(
)()()(
Compare this with the standard 2nd order system by equating the denominators:
ipnn bksbkasss 222 2
in
pn
bk
bka
2
2
bk
bak
ni
np
2
2
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.
EECE 413, Fall, 200637
Cruise-Control Example Design 1
mbs
msUsV
1
)()(
4.0
767.010*6.06.4
*6.46.4
s
nn
s tt
For the cruise-control system, we have:
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%.
6.0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
10
20
30
40
50
60
70
80
90
100
Mp,
%
x
To achieve an overshoot < 25%, we obtain from the Mp figure that:
To be safe, we choose
To achieve a settling time of 10 s, we use
EECE 413, Fall, 200638
Cruise-Control Example Design 1 – cont.
000333.030001
30001
300011
)()(
bas
mbs
msUsV
bk
bak
ni
np
2
2
767.010*6.06.4
*6.46.4
s
nn
s tt
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:
Again, using the formulae derived,
The final cruise-control system:
1765
30001767.0
2760
30001
30001767.0*6.0*22
22
bk
bak
ni
np
70 MPHu Speed v
30001
30001
s
car
sssD
sksk
skksD ipi
p
17652760)(
)(
ss 17652760
EECE 413, Fall, 200639
Cruise-Control Example Design 1 – Results
10-1
100
101
-30
-20
-10
0
10
mag
nitu
de in
dB
frequency in rad/sec
0 2 4 6 8 10 120
0.5
1
1.5Step Response
Time (sec)
Am
plitu
de
70 MPHu Speed v
30001
30001
s
car
ss 17652760
ts spec = 10 sts result < 7 s
ωn spec = 0.767ωn result ~ 1.8 rad/s
% cruise_validate.ma = 1/3000;b = a;g1 = tf(b,[1 a]); d1 = tf([2760 1765],[1 0]);sys1 = d1*g1;sys1 = feedback(sys1,1); 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 onylabel('magnitude in dB')xlabel('frequency in rad/sec')
Risky design. High control bandwidth gives poor disturbance rejection.
EECE 413, Fall, 200640
Cruise-Control Example Design 2
mbs
msUsV
1
)()(
46.0
82.08*7.06.4
*6.46.4
s
nn
s tt
For the cruise-control system, we have:
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%.
7.0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
10
20
30
40
50
60
70
80
90
100
Mp,
%
x
To achieve an overshoot < 20%, we obtain from the Mp figure that:
To be safe, we choose
To achieve a settling time of 8 s, we use
EECE 413, Fall, 200641
Cruise-Control Example Design 2 – cont.
1.01000100,001.0
1000100
100011
)()(
bas
mbs
msUsV
bk
bak
ni
np
2
2
82.08*7.06.4
*6.46.4
s
nn
s tt
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:
Again, using the formulae derived,
The final cruise-control system:
670
10182.0
1050
101
1000182.0*7.0*22
22
bk
bak
ni
np
100 km/Hu Speed v
101
10001
s
car
sssD
sksk
skksD ipi
p
6701050)(
)(
ss 6701050
EECE 413, Fall, 200642
0 2 4 6 8 10 120
0.5
1
1.5Step Response
Time (sec)
Am
plitu
de
10-1
100
101
-20
-15
-10
-5
0
5
mag
nitu
de in
dB
frequency in rad/sec
Cruise-Control Example Design 2 – Results100 km/H
u Speed v
101
10001
s
car
ss 6701050
ts spec = 8 sts result < 7 s
ωn spec = 0.82ωn result ~ 1.8 rad/s
% cruise_validate.m%a = 1/10;b = 1/1000;g2 = tf(b,[1 a]); 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 onylabel('magnitude in dB')xlabel('frequency in rad/sec')
Design risk. High control bandwidth gives poor disturbance rejection.
EECE 413, Fall, 200643
Problem 2.1 in Text2
10)(s
sG
bsks
kb
kbssss
nn
nn
10,2
1022
222
Design feedback with lead compensation for the open-loop system:
kbssk
kbssk
bsskbssk
sGsDsGsD
bssk
sbssksGsD
1010
1010
101
10
)()(1)()(
1010)()(
2
2
R(t)
2
10s
The rise time should be <= 1 sec & the overshoot should be <= 10%.
D(s) G(s)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
10
20
30
40
50
60
70
80
90
100
Mp,
%
6667.71*6.06.4
*6.46.4
s
nn
s tt
x
58.0
8778.510
,2.96667.7*6.0*222
n
n
k
b
2.98778.5)(
s
sbs
kssD
EECE 413, Fall, 200644
10-1
100
101
102
103
-100
-50
0
50
mag
nitu
de in
dB
frequency in rad/sec
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20
0.5
1
1.5Step Response
Time (sec)
Am
plitu
de
Problem 2.1 in Text – Results
2
10s2.9
8778.5s
s
ts spec = 1 sts result < 0.9 s
ωn spec = 7.6667 rad/sωn result ~ 9.0 rad/s
% Prob2_1.mk = 5.8778;b = 9.2;g1 = tf(10,[1 0 0]); d1 = tf([k 0],[1 b]);sys1 = d1*g1;sys1 = feedback(sys1,1); figure(1)subplot(211)step(sys1,2);grid on subplot(212)[mag,phase,w] = bode(sys1);semilogx(w,20*log10([mag(:),ones(length(w),1)*0.7])),grid onylabel('magnitude in dB')xlabel('frequency in rad/sec')
Slightly high control bandwidth may give poor disturbance rejection.
EECE 413, Fall, 200645
Problem 2.2 (mod) in Text2
5)(s
sG
bsks
kb
kbssss
nn
nn
5,2
522
222
Design feedback with lead compensation for the open-loop system:
kbssk
kbssk
bsskbss
k
sGsDsGsD
bssk
sbssksGsD
55
55
51
5
)()(1)()(
55)()(
2
2
R(t)
2
5s
The rise time should be <= 1 sec & the overshoot should be <= 10%.
D(s) G(s)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
10
20
30
40
50
60
70
80
90
100
Mp,
%
6667.71*6.06.4
*6.46.4
s
nn
s tt
x
58.0
7556.115
,2.96667.7*6.0*222
n
n
k
b
2.97556.11)(
s
sbs
kssD
EECE 413, Fall, 200646
10-1
100
101
102
103
-100
-50
0
50
mag
nitu
de in
dB
frequency in rad/sec
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20
0.5
1
1.5Step Response
Time (sec)
Ampl
itude
Problem 2.2 (mod) in Text – Results
2
10s2.9
7556.11s
s
ts spec = 1 sts result < 0.9 s
ωn spec = 7.6667ωn result ~ 9.0 rad/s
% Prob2_1.mk = 5.8778;b = 9.2;g1 = tf(10,[1 0 0]); d1 = tf([k 0],[1 b]);sys1 = d1*g1;sys1 = feedback(sys1,1); figure(1)subplot(211)step(sys1,2);grid on subplot(212)[mag,phase,w] = bode(sys1);semilogx(w,20*log10([mag(:),ones(length(w),1)*0.7])),grid onylabel('magnitude in dB')xlabel('frequency in rad/sec')
Slightly high control bandwidth may give poor disturbance rejection.
EECE 413, Fall, 200647
PID Control
KsDtKetu )()()(
sTKsDde
TKtu
i
t
i
)()()(0
sT
sTK
sesusD d
i
11)()()(
sKTsDteKTtu dd )()()(
PlantPIDe(t)r(t) y(t)
Proportional control term:
Integral control term:
Derivative control term:
Where Ti is called the integral (or reset) time, Td the derivative time, and K the position feedback gain. The combined transfer function is:
EECE 413, Fall, 200648
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, 200649
Matlab Root Locus
210ss
103)(,
210)(
ssKsD
sssG
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.
e(t)r(t) y(t)
103
ssK
-10 -5 0-4
-3
-2
-1
0
1
2
3
40.20.40.580.720.830.91
0.96
0.99
0.20.40.580.720.830.91
0.96
0.99
246810
Root Locus
Real Axis
Imag
inar
y A
xis
0 0.5 1 1.5 20
0.2
0.4
0.6
0.8
1
1.2
1.4Step Response
Time (sec)
Ampl
itude
% 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
EECE 413, Fall, 200650
Stability Margins
1,180
180,1
ggggg
ppppp
jGjKjGjKanglePM
jGjKanglejGjK
GM
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 is generally related to the damping of a system. For a 2nd order system, is commonly used. Thus, the speed of response of the system is associated with the GM while the stability is associated with the PM.
100PM
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.
EECE 413, Fall, 200651
Example 2.3 211)(
ss
KsGFor the plant: determine the PM and GM for the system with unity feedback and a) 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.
-150
-100
-50
0
50
100
Mag
nitu
de (
dB)
10-2
10-1
100
101
102
-270
-225
-180
-135
-90
Pha
se (
deg)
Bode DiagramGm = 6.02 dB (at 1 rad/sec) , Pm = 21.4 deg (at 0.682 rad/sec)
Frequency (rad/sec)
margin(tf(1,[1 2 1 0]))GM
PM
Unstable line < -180
Read system bandwidth frequency following ‘crossover’ @ -3 dB
a) K=1
EECE 413, Fall, 200652
-150
-100
-50
0
50
100
Mag
nitu
de (
dB)
10-2
10-1
100
101
102
-270
-225
-180
-135
-90
Pha
se (
deg)
Bode DiagramGm = -7.96 dB (at 1 rad/sec) , Pm = -23.2 deg (at 1.52 rad/sec)
Frequency (rad/sec)
Example 2.3 – cont. 211)(
ss
KsGFor the plant: determine the PM and GM for the system with unity feedback and a) 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.
margin(tf(1,[1 2 1 0]))GM
PM
Unstable line < -180
20*log10(1/5) ~ -14 dB -> phase < -180 or system is unstable with K = 5. For stability both PM & GM must be stable.
b) K=5 stable?
Note that change in gain only moves magnitude plot up or down, but doesn’t affect phase plot.
K=5
K=1
EECE 413, Fall, 200653
-150
-100
-50
0
50
100
Mag
nitu
de (
dB)
10-2
10-1
100
101
102
-270
-225
-180
-135
-90
Pha
se (
deg)
Bode DiagramGm = 20 dB (at 1 rad/sec) , Pm = 68.2 deg (at 0.193 rad/sec)
Frequency (rad/sec)
Example 2.3 – cont. 211)(
ss
KsGFor the plant: determine the PM and GM for the system with unity feedback and a) 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])),margin(tf(1,[1 2 1 0])),margin(tf(.5,[1 2 1 0])),margin(tf(.2,[1 2 1 0])),hold off
Unstable line < -180
c) K=? for PM = 45 & 70?
K=5 crossover
K=1 XoverK=.5 XoverK=.2 Xover
K=1 PM=21K=.5 PM=45K=.2 PM=68 K=5 PM=-22
Note that change in gain only moves magnitude plot up or down, but doesn’t affect phase plot.
EECE 413, Fall, 200654
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
10
20
30
40
50
60
70
80
90
100
Mp,
%
Example: Root Locus Design Method for DC Motor Position Control
230,5.0 n
5.0
From the main problem, the dynamic equations in transfer function form are the following:
and the system schematic looks like:
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
Matlab Code:% motor.mJ=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)
First, try simple P (proportional controller).Note motor parameters given.
x
23004.0*5.06.4
*6.46.4
s
nn
s tt
EECE 413, Fall, 200655
Example: Root Locus Design Method for DC Motor Position Control – cont.
-15 -10 -5 0
x 105
-250
-200
-150
-100
-50
0
50
100
150
200
250Root Locus
Real Axis
Imag
inar
y A
xis
Very large pole
-250 -200 -150 -100 -50 0 50
-0.25
-0.2
-0.15
-0.1
-0.05
0
0.05
0.1
0.15
0.2
0.25Root Locus
Real Axis
Imag
inar
y A
xis
Close up view, note bandwidth spec = 230 rad/s
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, 200656
-300 -250 -200 -150 -100 -50 0
-80
-60
-40
-20
0
20
40
60
80 0.5
0.5
Root Locus
Real Axis
Imag
inar
y A
xis
-300 -250 -200 -150 -100 -50 0
-200
-150
-100
-50
0
50
100
150
200
Root Locus
Real Axis
Imag
inar
y A
xis
Example: Root Locus Design Method for DC Motor Position Control – cont.
Close up view, note bandwidth spec = 230 rad/s
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.
PI controller
gain = [0:.1:20];contr=tf([1 20],[1 0]);rlocus(contr*motorTF,gain)
PID controllergain = [0:.01:20];numc=conv([1 60],[1 70]);denc=[1 0];contr=tf(numc,denc);rlocus(contr*motorTF,gain)
EECE 413, Fall, 200657
motor step response, k = 0.1565, dominant poles are -230 -101.756 -59.6074
Time (sec)
Am
plitu
de
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10
0.2
0.4
0.6
0.8
1
1.2
1.4
System: sys_clTime (sec): 0.0402Amplitude: 1.01
System: sys_clTime (sec): 0.0129Amplitude: 1.12
Example: Root Locus Design Method for DC Motor Position Control – cont.
Overshoot criteria met @ 12% @ 0.013 s and no steady state error.
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
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 ontitle(['motor step response, k = ',num2str(k),... ', dominant poles are ',num2str(poles(2:4)')])
Settling time criteria met @ 1% @ 0.04 s.
sss
sssss
4200130420013070601565.
2
EECE 413, Fall, 200658
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10
0.005
0.01
0.015
0.02
0.025
0.03
0.035
0.04
System: dist_clTime (sec): 0.04Amplitude: 0.0206
motor step response
Time (sec)
Am
plitu
de
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.
dist_cl=feedback(motorTF,k*contr);step(dist_cl,t),grid ontitle('motor step response')
EECE 413, Fall, 200659
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
10
20
30
40
50
60
70
80
90
100
Mp,
%
Example: Bode Plot Design Method for DC Motor Position Control
505.0*100100100
230,5.0
PM
PMn
5.0
From the main problem, the dynamic equations in transfer function form are the following:
and the system schematic looks like:
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
Matlab Code:% motor_bode.mclear allJ=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),
First, try simple P (proportional controller).Note motor parameters given. Try to get PM = 50 & GM = 3 dB @ 230 rad/s
x
23004.0*5.06.4
*6.46.4
s
nn
s tt
EECE 413, Fall, 200660
-300
-200
-100
0
100
Mag
nitu
de (d
B)
100
102
104
106
108
-270
-225
-180
-135
-90
Phas
e (d
eg)
Bode DiagramGm = 92.2 dB (at 9.28e+003 rad/sec) , Pm = 61.9 deg (at 31.6 rad/sec)
Frequency (rad/sec)
Example: Bode Plot Design Method for DC Motor Position Control – cont.
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.
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.
Increasing gain
Decreasing gain
Increasing gainDecreasing gain
P controller
-300
-200
-100
0
100
Mag
nitu
de (d
B)
100
102
104
106
108
-270
-225
-180
-135
Phas
e (d
eg)
Bode DiagramGm = 88.6 dB (at 7.55e+003 rad/sec) , Pm = 29.7 deg (at 35.3 rad/sec)
Frequency (rad/sec)
PI controller
motorTF=tf(num,den);contr=1;margin(contr*motorTF),
contr=tf([1 20],[1 0]);margin(contr*motorTF),
EECE 413, Fall, 200661
motor step response, k = 0.09
Time (sec)
Ampl
itude
motor step response
Time (sec)
Ampl
itude
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1-0.02
0
0.02
0.04
0.06System: dist_clTime (sec): 0.0241Amplitude: 0.0202
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10
0.5
1
1.5
System: sys_clTime (sec): 0.0399Amplitude: 0.965
System: sys_clTime (sec): 0.0131Amplitude: 1.32
-150
-100
-50
0
50
100
150
Mag
nitu
de (d
B)
100
102
104
106
108
-180
-135
-90
Phas
e (d
eg)
Bode DiagramGm = Inf dB (at Inf rad/sec) , Pm = 50.2 deg (at 234 rad/sec)
Frequency (rad/sec)
Example: Bode Plot Design Method for DC Motor Position Control – cont.
sss
sssss 42001301565.42001301565.70601565.
2
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
sss
sssss 1400024009.1400024009.14010009.
2
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 onmargin(0.09*contr2*motorTF),hold off
sys_cl=feedback(k2*contr2*motorTF,1);t=0:0.001:.1;step(sys_cl,t),grid ontitle(['motor step response, k = ',num2str(k2)])dist_cl=feedback(motorTF,k2*contr2);step(dist_cl,t),grid ontitle('motor step response')
EECE 413, Fall, 200662
Lead Compensation
maxmax
max 1,sin1sin1
and
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:
Here parameters K, φmax and ωmax are to be determined from design specifications.
1,11)(
ssKsD
EECE 413, Fall, 200663
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, 200664
Lead Compensation Design Procedure
maxmax
max 1,sin1sin1
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. Step 5: Compute
Step 6: Verify the design using matlab. Redo if needed.
EECE 413, Fall, 200665
Lead Compensator Design Example
9.05.05.05.0)(
zz
zzG
29.1105.1
2020
9.020205.0
2020
5.020205.0
|)()(/2/2
www
ww
ww
ww
zGwGwTwTz
An electric motor can be modeled with a sampling period T = 0.1 s as follows:
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:
EECE 413, Fall, 200666
Lead Compensator Design Example
50100 PM
sn t
6.4
overshootx
20%
35.079.015.01
5.05.0)1()1(
,7)()(1125.0
11)(
KKxGDK
eeK
Ke
p
pp
Settling time Open-loop gain crossover frequency ωg ~ ωn = 9
1 second 2.915.06.4
xn ωg ~ ωn = 9 Step 2
Steady state error – Step 1: Determination of the static gain K for this type 0 system.
EECE 413, Fall, 200667
Bode DiagramGm = 9.95 dB (at 12.7 rad/sec) , Pm = 43.8 deg (at 5.72 rad/sec)
Frequency (rad/sec)
-60
-40
-20
0
20
40
Mag
nitu
de (d
B)
System: sysFrequency (rad/sec): 8.93Magnitude (dB): -5.42
10-2
10-1
100
101
102
103
90
180
270
360
Phas
e (d
eg) System: sys
Frequency (rad/sec): 9.05Phase (deg): 199
Step 3:
K = 1K = 0.35
Step 4:Φmax = Desired PM – Original PM + Allowance = 50 + (180 – 199) + 4 = 35
% lead_example.m%numG = 20*[-1 20];denG = conv([1.5 10],[1.9 2]);sys = tf(numG,denG);figure(1)margin(sys),hold onnumG1 = 0.35*20*[-1 20];sys1 = tf(numG1,denG);margin(sys1),hold off
EECE 413, Fall, 200668
Step 5
1213.027.0
1213.035.011)(
ww
wwKwD
213.01,27.0
180/35sin1180/35sin1
sin1sin1
maxmax
max
Finally, we obtain the lead compensator in w-domain:
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.
16.016.2148.1848.1
111
01.02058.0
111
01.02213.0
35.0|)()(112
zz
zzzz
wDzDzz
Tw
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, 200669
Verification in w-domain (pseudo s-domain
-60
-40
-20
0
20
Mag
nitu
de (d
B)
10-2
10-1
100
101
102
103
90
180
270
360
Phas
e (d
eg)
Bode DiagramGm = 7.08 dB (at 21.3 rad/sec) , Pm = 52.7 deg (at 9.21 rad/sec)
Frequency (rad/sec)
Resulting gain crossover frequency is 9.21 rad/s & PM = 52.7Desired gain crossover frequency is 9.2 rad/s & PM = 54
% lead_example.m%numG = 20*[-1 20];denG = conv([1.5 10],[1.9 2]);sys = tf(numG,denG);figure(1)margin(sys),hold onnumG1 = 0.35*20*[-1 20];sys1 = tf(numG1,denG);margin(sys1),hold offnumD = 0.35*[0.214 1];denD = [0.058 1];sysC = tf(numD,denD);figure(2)margin(sysC*sys)
EECE 413, Fall, 200670
Verification in z-domain% lead_example.m%numG = 20*[-1 20];denG = conv([1.5 10],[1.9 2]);sys = tf(numG,denG);figure(1)margin(sys),hold onnumG1 = 0.35*20*[-1 20];sys1 = tf(numG1,denG);margin(sys1),hold offnumD = 0.35*[0.214 1];denD = [0.058 1];sysC = tf(numD,denD);figure(2)margin(sysC*sys)% verification in z domainfigure(3)margin(c2d(sysC*sys,0.04)),hold onmargin(c2d(sysC*sys,0.02)),hold onmargin(c2d(sysC*sys,0.01)),hold off
-30
-20
-10
0
10
20
Mag
nitu
de (
dB)
10-2
10-1
100
101
102
103
-90
0
90
180
270
360
Pha
se (d
eg)
Bode DiagramGm = 6.3 dB (at 19.5 rad/sec) , Pm = 50.1 deg (at 9.2 rad/sec)
Frequency (rad/sec)
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, 200671
Verification in Time Domain
Steady state error = 12.5%
Step Response
Time (sec)
Ampl
itude
0 0.5 1 1.5-0.2
0
0.2
0.4
0.6
0.8
1
1.2
System: untitled2Time (sec): 1.24Amplitude: 0.875
System: untitled2Time (sec): 0.63Amplitude: 0.863
System: untitled2Time (sec): 0.279Amplitude: 1.08
System: untitled2Time (sec): 0.18Amplitude: 0.789
Settling time = 0.63s
Overshoot = 23.4%
EECE 413, Fall, 200672
Lag Compensation1,
11)(
ssKsDLag compensation has a transfer function of:
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, 200673
PID CompensationNote 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, 200674
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
Optimization of Controllers2
50)(s
sG Assume a plant: 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);
dpdp KsKsKKsD )(Assume a controller:
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
Phase margin/100 ~ damping coefficient
For bandwidth check
Do step for overshoot check
EECE 413, Fall, 200675
Step Response
Time (sec)
Am
plitu
de
0 2 4 6 8 10 12 14 16 180
0.2
0.4
0.6
0.8
1
1.2
1.4
System: untitled1Time (sec): 10.7Amplitude: 1.01
System: untitled1Time (sec): 4.84Amplitude: 1.22
10-2
10-1
100
101
-30
-20
-10
0
10
20
30
40
50
60
70
mag
nitu
de in
dB
frequency in rad/sec
-50
0
50
100
150
Mag
nitu
de (
dB)
10-2
10-1
100
101
102
-180
-90
0
90
Pha
se (
deg)
Bode DiagramGm = Inf , Pm = 63.7 deg (at 0.699 rad/sec)
Frequency (rad/sec)
gcgpgc*gp
Optimizer Example 1 Results load hmwk1_param sys1 = tf(50,[1 0 0]); figure(1) margin(sys1),grid on 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') 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') figure(4) step(feedback(gc1*sys1,1));grid on
BW ~ 0.92
GM = 63.7Mp = 22%
EECE 413, Fall, 200676
Optimizer Example 2sksk
sD ip )(
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?
532)(,
52)(,
52)(
sssG
ssG
ssG
n
T*301
EECE 413, Fall, 200677
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
Optimization of Controllers, Example 252)(
s
sGAssume a plant: with time domain specifications: ts = 10 sec & Mp <= 22%.
load hmwk1_paramxout = fminsearch('optim_hmwk1',xin);
Assume a PI controller:
The 2nd form allows specifying zero.
Phase margin/100 ~ damping coefficient
Do step comparison for bandwidth & overshoot check
sksk
sksk
sD ipip
)(
Cost function
EECE 413, Fall, 200678
Step Response
Time (sec)
Am
plitu
de
0 1 2 3 4 5 6 7 80
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
System: untitled1Time (sec): 6.53Amplitude: 0.99
10-1
100
101
102
103
104
105
-160
-140
-120
-100
-80
-60
-40
-20
0
20
mag
nitu
de in
dB
frequency in rad/sec
-200
-150
-100
-50
0
50
100
Mag
nitu
de (
dB)
10-1
100
101
102
103
104
105
-180
-135
-90
-45
0
Pha
se (
deg)
Bode DiagramGm = Inf , Pm = 82.9 deg (at 0.627 rad/sec)
Frequency (rad/sec)
gcgpgc*gp
Optimizer Example 2 Results load hmwk1_param sys1 = tf(2,[1 5]); figure(1) margin(sys1),grid on 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') 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') figure(4) step(feedback(gc1*sys1,1));grid on
BW ~ 0.92
GM = 82.9
ts <= 10 s
EECE 413, Fall, 200679
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.
GuFxx Hx
x̂
plant
+- rEstimator-K
uy
Control law
State space formulation
xHyLGuxFx ˆˆˆ is the estimator formulation where L is a proportional gain in the form of a vector or matrix depending on the dimensions of y.
xLHFx ˆˆ is the error equation from which the dynamics may be obtained.
The characteristic equation of the error is: det[sI – (F – LH)] = 0.
Estimator/Observer Design
EECE 413, Fall, 200680
State-Space Block Diagram
GuFxx s1
Hx
plant
+- rEstimator-K
u y
Control law
State space formulation
xHyLGuxFx ˆˆˆ
is the estimator formulation where L is a proportional gain in the form of a vector or matrix depending on the dimensions of y.
uG xdot x H y
F
J
L
s1 x̂x̂-K
F-LH-GK
Plant
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.
- r+
EECE 413, Fall, 200681
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, 200682
State Space Control Law• Two major approaches
– Pole placement– Linear quadratic regulator (LQR)
• Both rely on pole or eigenvalue selection and state estimation (although output feedback is occasionally used).
• The control law is a linear combination of all the state variables. For an nth order system there are n feedback gains & and n poles of the system. By choosing proper values of Ki we should be able to place the poles at the desired locations.
• It is assumed that the system is controllable, ie., it is affected by control inputs.
n
n
x
xx
KKKKxu
2
1
21
GKxFxxKxu
GuFxx
,,System equation
Control law
substitutionThe characteristic equation of the closed-loop system is det[sI - (F – GK)] = 0.
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, 200683
LQR• When selecting the desired root locations, remember that
the control effort required is related to how far the open-loop 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:
dtRuuQxxJ TT
0
EECE 413, Fall, 200684
LQR/Observer Closed-Loop
JuHxyGuxFx
,ˆ̂
LyxGKLHFx
LyGuxLHFx
xHyLGuxFx
ˆˆ
ˆˆ
ˆˆˆ
xLHFx ˆˆ
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.
Observer matrix
ExampleLinear systemdescription
0,01
,10
,0010
JH
GF8.0,3
,20 22
zwss
n
nn is the desired characteristic equation
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,
Results for pole placement:w = 3.0000 3.0000ze = 0.8000 0.8000L = 19.2000 144.0000K = 9.0000 4.8000
%lqr codeQ = [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,
Results for lqr:w = 3.1623 3.1623ze = 0. 7906 0. 7906L = 19.2000 144.0000K = 10 5
EECE 413, Fall, 200685
SS Pole Placement Results
Note that increasing magnitude of observer poles reduces overshoot.
0 1 2 3 4 5 6 7 8 9 100
0.2
0.4
0.6
0.8
1
1.2
1.4LQR step response, desired/observer poles = 3 24
Time (sec)
Am
plitu
de
0 1 2 3 4 5 6 7 8 9 100
0.2
0.4
0.6
0.8
1
1.2
1.4LQR step response, desired/observer poles = 3 12
Time (sec)
Ampl
itude
EECE 413, Fall, 200686
0 1 2 3 4 5 6 7 8 9 100
0.2
0.4
0.6
0.8
1
1.2
1.4Step Response
Time (sec)
Ampl
itude
SS LQR Resultsclear *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
Q = [1 0;0 0]; Q = [10 0;0 5]; Q = [100 0;0 5];
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.
EECE 413, Fall, 200687
Closed-Loop Feedback
JuHxyGuxFx
,ˆˆ
LrxGKLHFx
xHrLxGKxFx
xHyxHyxKu
yrLGuxFx
ˆˆ
ˆˆˆˆ
ˆˆˆˆ,ˆ
ˆˆˆ
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.
Same Example with pole placement
Linear systemdescription 0,01
,10
,0010
JH
GF8.0,3
,20 22
zwss
n
nn is the desired characteristic equation
% 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.7081ze = 0.7739 0.7739L = 28.8000 324.0000K = 9.0000 4.8000
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);[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.8632ze = 0.7730 0.7730L = 28.8000 324.0000K = 10.0000 5.0000
System equations
EECE 413, Fall, 200688
0 1 2 3 4 5 6 7 8 9 100
0.2
0.4
0.6
0.8
1
1.2
1.4Step Response
Time (sec)
Am
plitu
de
SS Pole Placement Feedback Results% 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,
Results for pole placement:w = 21.7081 21.7081ze = 0.7739 0.7739L = 28.8000 324.0000K = 9.0000 4.8000
EECE 413, Fall, 200689
0 1 2 3 4 5 6 7 8 9 100
0.2
0.4
0.6
0.8
1
1.2
1.4Step Response
Time (sec)
Ampl
itude
SS LQR Feedback Results% 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,
Q = [100 0;0 5];
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 50];
EECE 413, Fall, 200690
SS Pole Placement Feedback Prob. 2.9
0,01,10
,0410
,4
JHGF
TT dc
Characteristic equation from denominator.
Given equations2 states, since 2nd order system
State space matrix values.
4
1)()(
)()()()(4
),()()(4)(4
22
2
ssTsTssTsTss
sTsTsssTT
dcdc
dcdc
Taking Laplace transforms:
L = 20 96K = 4 4
% 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);
EECE 413, Fall, 200691
0 1 2 3 4 5 6 7 8 9 100
0.2
0.4
0.6
0.8
1
1.2
1.4Step Response
Time (sec)
Am
plitu
de
SS Pole Placement Feedback Prob. 2.9% 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,
Results for pole placement:w = 21.7081 21.7081ze = 0.7739 0.7739L = 28.8000 324.0000K = 9.0000 4.8000
This is a stabilizing controller. This is not shown in the text.
Observer poles
EECE 413, Fall, 200692
SS with Integral Control
t
ii edtxeHxrx
xx
Kxx
KoKiu
ruGx
xGH
xx
ii
ii ,010
00
Integral control is accomplished by augmenting (adding) the state vector with the desired integral xi. It obeys the differential equation:
Augmentation is shown below:
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, 200693
SS Pole Placement with Integrator Results% 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 1 2 3 4 5 6 7 8 9 100
0.5
1
1.5Step Response
Time (sec)
Set
poin
t Inp
ut
0 1 2 3 4 5 6 7 8 9 10-0.05
0
0.05
0.1
0.15Step Response
Time (sec)
Dis
turb
ance
Inpu
t
0 1 2 3 4 5 6 7 8 9 100
0.2
0.4
0.6
0.8
1
1.2
1.4
Step Response
Time (sec)
SP
/Dis
turb
ance
Inpu
t
setpointcombination
EECE 413, Fall, 200694
Prob 2.20 modified
501015000)( 2
sssssGDetermine if G(s) is stable. If stable, how to stabilize to PM = 45 using bode
plots? Using pole placement & estimator place poles at [-4+4i,-4-4i,-5,-5].
% Prob_2_20_mod.m%clear *sys = tf(5000*[1 1],[1 60 500 0 0]);figure(1)margin(sys),grid
-150
-100
-50
0
50
100
150
Mag
nitu
de (
dB)
10-2
10-1
100
101
102
103
104
-270
-225
-180
-135
-90
Phas
e (d
eg)
Bode DiagramGm = 14.5 dB (at 21 rad/sec) , Pm = 35.7 deg (at 7.84 rad/sec)
Frequency (rad/sec)
% Prob_2_20_mod.m%clear *sys = tf(5000*[1 1],[1 60 500 0 0]);figure(2)margin(0.607*sys),grid
-200
-100
0
100
200
Mag
nitu
de (d
B)
10-2
10-1
100
101
102
103
104
-270
-225
-180
-135
-90
Phas
e (d
eg)
Bode DiagramGm = 18.8 dB (at 21 rad/sec) , Pm = 45 deg (at 5.4 rad/sec)
Frequency (rad/sec)
EECE 413, Fall, 200695
% Prob_2_20_mod.m%clear *sys = tf(5000*[1 1],[1 60 500 0 0]);figure(1)margin(sys),gridfigure(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)
Prob 2.20 modified – cont.
Step Response
Time (sec)
Ampl
itude
Pole-Zero Map
Real Axis
Imag
inar
y Ax
is
-102
-101
-100
-20
-10
0
10
20
System: sysCLPole : -2 - 1i
Damping: 0.894Overshoot (%): 0.187
Frequency (rad/sec): 2.24
System: sysCLPole : -15
Damping: 1Overshoot (%): 0
Frequency (rad/sec): 15
System: sysCLZero : -10
Damping: 1Overshoot (%): 0
Frequency (rad/sec): 10
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 50
0.5
1
1.5
System: sysCLTime (sec): 1.06Amplitude: 1.28
System: sysCLTime (sec): 2.79Amplitude: 1.01
EECE 413, Fall, 200696
Prob 3.12
1)(s
sG
TsTsG/2/2)(
bsasksD
)(
a) 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
b) Implement a delay of T/2 & determine the approximate effect.
c) 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 ak = 0:400;sys = sysG*sysD;pdes = -4.4 + j*4.4;figure(1)rlocus(sys,k), hold on,gridaxis([-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 onxlabel(['real axis, k = ',num2str(k)])% part bT = 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 onT = 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 onT = 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
-16 -14 -12 -10 -8 -6 -4 -2 00
1
2
3
4
5
6
7
80.350.580.760.86
0.92
0.96
0.984
0.996
246810121416
Root Locus
real axis, k = 92.7216
Imag
inar
y Ax
is20 Hz
10 Hz
5 Hz
RL pole placement using rlocfind
Decreasing sample rate degrades performance.
Zero a @ 2.5 & pole b @ 15 found by iteration. At this time can use rlocfind to get k.
EECE 413, Fall, 200697
Prob. 3.2
aeeKbuusEasKsUbsbsasK
sEsUsD ooo
)()()()()(
Tkxkxkx )1()()(
)1(11)(
1)(
11)1(
ke
bTaTKke
bTKku
bTku o
o
Repeat Example 3.1, but use the approximation that
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
Plug in the approximation above for each derivative
)()1()()()1()( kaeTkekeKkbu
Tkuku
o
Or change k->k+1 & k-1->k to solve for u(k+1)
)1()(1)(1)1( keKkeaTKkubTku ooCompare with forward rectangular from eq. 3.7
0 10 20 30 40 50 60 70 80 90 100-3
-2.5
-2
-1.5
-1
-0.5
0
0.5
1
disc
rete
pol
e
sampling rate - Hz
a = 2;b = 10;Ko = 70;Ws = 1:100;T = 1./Ws;cl = 1./(1+b*T);plot(Ws,cl,'-'),hold oncl = 1 - b*T;plot(Ws,cl,'--'), hold onplot(Ws,-ones(length(Ws),1),'r--'), hold offaxis([0 100 -3 1])ylabel('discrete pole')xlabel('sampling rate - Hz')
EECE 413, Fall, 200698
Prob. 3.315125)(
sssD
c1 c2 c3
1 - bT Ko(aT -1 ) Ko
1/(1 + bT) -Ko /(1 + bT) Ko(1+aT) /(1 + bT)
For the compensation:
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 rectangularBackward rectangular
For a=1, b=15, Ko=25
Forward rectangularBackward rectangular
c1 c2 c3
0.8125 -24.6875 25
0.8421 -21.0526 21.3158
EECE 413, Fall, 200699
-150
-100
-50
0
50
100
Mag
nitu
de (d
B)
101
102
103
104
-180
-170
-160
-150
Phas
e (d
eg)
Bode DiagramGm = Inf dB (at Inf rad/sec) , Pm = 29.4 deg (at 432 rad/sec)
Frequency (rad/sec)
Prob. 3.8
bsasKsD
)(
2
500)(s
sG The read arm on a computer disk drive has the transfer function
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
% Prob_3_8.m%clear *sys = tf(500,[1 0 0]);figure(1)margin(sys),hold onxin = [1000 125 1250];k = xin(1);a = xin(2);b = xin(3);sysD = tf([1 a],[1 b]);margin(sysD*sys),hold onsysD = tf(k*[1 a],[1 b]);margin(sysD*sys),hold offfigure(2)sysCL = feedback(sysD*sys,1);margin(sysCL)
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.
EECE 413, Fall, 2006100
Prob. 3.8 – optimizer code
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]
% main_optim_prob_3_8.m%xin = [1000 125 1250];xin = fminsearch('Optim_Prob_3_8',xin);
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.
-60
-40
-20
0
20
Mag
nitu
de (
dB)
101
102
103
104
-180
-135
-90
-45
0
Phas
e (d
eg)
Bode DiagramGm = Inf dB (at Inf rad/sec) , Pm = 54 deg (at 628 rad/sec)
Frequency (rad/sec)
EECE 413, Fall, 2006101
Prob 3.8 – Different Sampling Rates
0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009 0.010
0.2
0.4
0.6
0.8
1
1.2
1.4Step Response
Time (sec)
Am
plitu
de
[1000 125 1250][1.2459 0.1036 1.1]*1e3
0 1 2 3 4 5 6 7 8
x 10-3
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2Step Response
Time (sec)
Am
plitu
dexin = [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 onWs = 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 onWs = 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
800 Hz 600 Hz 500 Hz
Note: the optimized gains improve the settling time. Also, 500 Hz is unstable -> -(1-b*T) > 1.
continuous