A Brief Introduction to Feedback Control
VO Embedded Systems Engineering Benedikt Huber
WS 2010/11
Open and Closed Loop Systems
System 1 System 2 r u y
System 1 System 2
r
u y
Example: Glucose Concentration
Pancreas
Liver, Body Cells
90 mg / dl
Glucose level too high
Glucose level too low
Beta cells emit more insulin
Alpha cells emit glucagon
Liver releases/produces glucose
Cells take glucose from blood
Glucose concentration influences pancreas cells
[Idea: AstromMurray08, Pictures: wikipedia.org]
Computer Controlled Systems
Actuators System
Controller Filter
Observed Output
Sensors Noise Noise
External Input
External disturbances
Clock
r(t)
z(t)
u(t)
y(t)
Actuation Command
Engineered Control Systems
Server Admission
Control
Simple Feedback Control
• Use control error e(t) - e(t) = r(t) – y(t)
• On/Off Control • u = umax if e > 0 • u = umin if e ≤ 0 • Dead Zone • Bang-Bang (Hysteresis)
e
u
u
e
Why Feedback Control?
Advantages of Feedback Control • Control without exact system model • Robustness: Less sensitive to disturbances • Performance: Reach setpoint more quickly • Feedback can be used to linearize system
Disadvantages • Risk of instability (e.g.: Microphone Feedback) • Additional components for providing the feedback signal
are required (measurement).
Introduction Modeling Dynamic Systems Designing PID Controllers Fuzzy Control
Simple Example Spring Mass System
– d
– p ... posi?on – m ... mass of the vehicle – c ... fric?on coeffficient – k ... spring constant – u ... applied force
System Dynamics: m p‘‘ + c p‘ + k p = u
Continous and Discrete Models
Continous • Differential Equations • Examples: Spring Mass, Cruise Control, DC Motor, ...
Discrete • Difference Equations • Example Email-Server: y[k+1] = a y[k] + b u[k] - y ... MaxUsers: deviation from operating point - u ... Remote Invocation Requests: deviation from op. Point
Linear Time-Invariant Systems
• LTI Systems • Time-Invariance: x(t-t0) → y(t-t0) • Linearity: a·x1(t) +b·x2(t) → a·y1(t) +b·y2(t) • Superposition principle: On piecewise constant input,
output is superposition of step responses • Linearity
• Most systems have non-linear behavior • LTI Systems are often a good (local) approximation • Feedback can be used to linearize systems • Beware of finite actuator ranges (clipping)
Transfer Function (1) • For Transfer Functions, the effect of a model component
is described in the Laplace Domain • Laplace Transform L: f(t) F(s) • Laplace Domain: Frequency domain (complex numbers) • Step function: u(s) = 1/s
Time Domain Transforma-on
f(t), g(t) is transformed to
F(s),G(s) is transformed to
Linear term a f(t) + b g(t) a F(t) + b G(t)
Convolu?on f(t) * g(t) = F(s) G(s)
Differenta?on f‘(t) s F(s) – f(0)
Integra?on = (u*f) t F(s) / s f (! )d!0
t
!
f (! )g(t !! )d!0
t
"
Introduc?on to Control Theory 13
The Transfer Function (2)
• The transfer func?on G(s) is defined as the ra?o of the Laplace transformed output signal Y(s) to the input signal X(s): G(s) = Y(s) / X(s)
• In the ?me domain, the transfer func?on is a map x(t) → y(t)
g(t) y(t) x(t) G(s) Y(s) X(s)
Transfer Function Building Blocks (1)
Name Transfer Func-on Modeling
Gain (Propor+onal Elem.) G(s) = k y(t) = k x(t)
Integra+ng Element G(s) = s y(t) = x‘(t)
Differien+al Element G(s) = 1/s y‘(t) = x(t)
First order delay (PT1) G(s) = KP /(1 + T0∙s) T0∙y’(t) + y(t) = KP∙x(t)
Second order delay (PT2) G(s) = KP /(a∙s2 + b∙s + 1)
a∙y’’(t) + b∙y’(t) + y(t) = KP∙x(t)
Transfer Function Building Blocks (2)
• Serial Composition
• Feedback
)()()( 21 sGsGsG ⋅=
01 2
1 2 0
G (s)G (s) G (s)G(s)
1 G (s) G (s) 1 G (s)⋅
= =+ ⋅ +
Spring Mass - System Model
Transfer Function • Second order delay • G(s)= Y(s) / U(s) = 1 / [m s^2 – k c s – m k]
[modeled using ScicosLab]
Step Response
[Image: wikipedia.org]
OVERSHOOT
Introduc?on to Control Theory 18
Step Response (2)
Proportional element y(t) = KP · x(t)
Integrating element y(t) = KI · ∫ x(t) dt
Pictures denote the response to the
standard step signal
y(t)
t
K p
y(t)
t
1
1/K I
Introduc?on to Control Theory 19
Step Response (3)
Differential element y(t) = KD · dx(t)/dt
First order delay T0·y’(t) + y(t) = KP·x(t)
Pictures denote the response to the
standard step signal
y(t)
t
inifinite amplitude not poss ible (clipping)
y(t)
t
K p
T 0
Introduc?on to Control Theory 20
Step Response (4)
Second order delay
Output depends on internal parameters
[image from wikiepdia.org]
Step Response: Spring Mass System
State Space Models
• Matrix-oriented view on LTI models • State dynamics: dx/dt = A x + B u
• x ... State vector • u ... Control vector • A ... Dynamics matrix • B ... Control matrix
• Output dynamics: y = C x + D u • y ... output vector • C .,. Sensor matrix • D ... Direct term (often 0)
LTI State Space Models
• Solve differential equation by matrix exponentiation • Given x’(t) = A x(t), x(0) = x0 • We have: y(t) = eAt x0
• Discretization • Fix sampling interval T • Given x’(t) = A x(t), x(0) = x0 • We have: x((k+1) T) = eAT x(k T) + ((eAT - I) B A -1) u(k T) • With fixed T, very simple discrete simulation (but discretization can
be expensive)
• Advantages • State Space Model directly corresponds to differential equations • Convenient to model MIMO (multiple input, multiple output) systems
(cf. SISO)
Simple Example: State Space Model Spring Mass System • State Space Equations in (p,p‘)
• For improved readbility: Variables (p,v) with v = p‘ • First row states that p‘ = v • Second row is differential equation modeling system
!x
!t=
p '
v '
"
#$$
%
&''=
0 1
(k
m(c
m
"
#
$$$
%
&
'''
p v( )+0
1
m
"
#
$$$
%
&
'''F
y =1
0
!
"#
$
%&( p v )+
0
0
!
"#
$
%&F
Introduction Modeling Dynamic Systems Designing PID Controllers Beyond PID Controllers
Goals of Effective Control
S-A-S-O • Stability
• High Accuracy (Small Steady State Error)
• Short Settle Time
• Minimize Overshoot
Proportional Control
• Idea: Amplify the error • u(t) = kp e(t) • Design Parameter: Proportional gain kp
• Steady State Error (SSE) indirect prop. to kp • Gain too small: large SSE, large settle time • Gain too high: Overshoot, oscillation
• Correcting SSE with feed forward term • u(t) = kp e(t) + uff • How to choose uff? • Requires precise system model
Proportional Control Spring Mass System
kp = 50
kp = 15
Input Amplifier
PI Controller
• Integral component eliminates SSE and attenuates disturbance
• PI Controller: kp e(t) + ip ∫e (t) • In a stable PI-controlled system, SSE becomes 0
eventually • Integrating element (ip=kp) can be used to generate uff
• Design tradeoffs for gain ip: • Larger gain attenuates disturbances effectively • Gain to large: oscillatory behavior, poor robustness,
possible instability
PI Controller
kp = 10, ki=3 (Long settlement time)
kp = 10, ki=0 (SSE)
Input Amplifier
kp = 10, ki=1
PI Control - Spring Mass System
PI Controller: Windup
• Real-world actuators have limited operating range • What happens if control point out of actuator limits? • Integrator windup: Integral term and control point can get
very large
• Solution: Anti-Windup Component • Measure Difference: actuator output - controller ouput • Feed back into integrator component
PD Controller
• Intuition: Error prediction using derivative • u = kp e + kd (de/dt) = kp ( e + Td (de/dt) ) • e + Td (de/dt): Prediction of error at time t + Td by linear
extrapolation, where Td = kd / kp
• Design Tradeoffs for derivative gain • Higher gain damps oscillations • Performance decreases if gain is too high
PID Controller
[Image: wikipedia.org]
PID Control - Spring Mass System
Input Amplifier
More PID Controller Improvements
• Low-pass filter for derivative • Problem: Derivative component sensitive to high-
frequency noise • Solution: Low-pass filter input of derivative component
• Setpoint weighting • Problem: Step in reference input causes peak of output
due to derivative term • Solution: Weight the reference input‘s influence on the PD
components
Introduc?on to Control Theory 36
Designing Control Systems using the Step Response
Step response measurement for the control path • test signal is the standard step signal:
Step response provides the characteris?c values Tu, Ta and Ks
1
t
x(t)
Introduc?on to Control Theory 37
Designing Control Systems using the Step Response (2)
y(t)
t
Ks
Tu Ta
Tu …effec?ve delay ?me Ta …effec?ve
compensa?on ?me Ks …gain
Introduc?on to Control Theory 38
Designing Control Systems using the Step Response (3) Based on the values Tu, Ta and Ks the rules by [Chien, Hrones, and Reswick] can be used to find a first se]ng of the controller: • supports P, PI, and PID controller types • se]ngs for 0% and 20% allowed overshoo?ng • depending on the control path, fine tuning may be required.
39
Rules from Chien, Hrones, and Reswick
Introduc?on to Control Theory 40
Boundary conditions of Designing a Control System by Rules using the Step Response
Requires time invariance and linearity of control path.
The described method is for analog controllers. Method gives an approximate starting configuration Possible optimizations either manually or using
sophisticated algorithms (e.g. genetic algorithm)
Introduc?on to Control Theory 41
Stability
• Most important property of controlled system • BIBO stability: Bounded Input only generates Bounded Output
• Several Methods • Frequency Domain: Nyquist Criterion, Bode Plot • State Space Model: Lyapunov Stability Theorem
Introduction Modeling Dynamic Systems Designing PID Controllers Fuzzy Control
Introduc?on to Control Theory 43
Fuzzy Logic – Fuzzy Control
Multi-valued logic Instead of true or false: degree of membership to a “Fuzzy
Set” Membership function:
]1,0[:)( →XxAµ
Introduc?on to Control Theory 44
Example: Fuzzy Variable “temp”
- 5 fuzzy sets (very cold, cold, …) - µvery cold(x) = 0 - µcold(x) = 0.14 - µmoderate(x) = 0.33 - µhot(x) = 0 - µvery hot(x) = 0
0
1
T0 T 7 T 8 T 9T 6T 5T 4T 3T 2T 1
verycold cold moderate hot very
hot
0.140.33
x
Introduc?on to Control Theory 45
Operators on Fuzzy Sets
(x)]µ (x),min[µ (x)µ BABA =∩
(x)µ1(x)µ AA −=¬
(x)]µ (x),max[µ (x)µ BABA =∪
Introduc?on to Control Theory 46
Process flow of fuzzy systems
F uzzyficationR ule
E valuation(n R ules )
Aggregation Defuzzyfication
Input Variable(s )
Output Variable(s )
‐
controller
Control Path
Introduc?on to Control Theory 47
Example: Steam Turbine
0
1
T0 T 7 T 8 T 9T 6T 5T 4T 3T 2T 1
verycold cold moderate hot very
hot
0
1
P 0 P 7 P 8 P 9P 6P 5P 4P 3P 2P 1
weak low OK strong high
Input Variables: temperature and pressure
Output Variable: throttle setting
0
1
min max0
negative zero pos itive
Introduc?on to Control Theory 48
Example: Fuzzyfication
0
1
T0 T 7 T 8 T 9T 6T 5T 4T 3T 2T 1
verycold cold moderate hot very
hot
0.6
x
1) Temperature Input x: µcold(x) = 0.6 µvery cold(x) = 0 … µvery_hot(x) = 0
2) Pressure Input y: µlow(y) = 0.37 µok(y) = 0.13 µweak(y) = 0 … µhigh(y) = 0 0
1
P 0 P 7 P 8 P 9P 6P 5P 4P 3P 2P 1
weak low OK strong high
0.13
0.37
Introduc?on to Control Theory 49
Example: Rule Base
1) IF temperature IS cold AND pressure IS low THEN
throttle IS positive
2) IF temperature IS cold AND pressure IS ok THEN throttle IS zero
3) IF temperature IS cold AND pressure IS strong THEN
throttle IS negative
4) …
Introduc?on to Control Theory 50
1) IF temperature IS cold AND pressure IS low THEN throttle IS positive
2) IF temperature IS cold AND pressure IS ok THEN throttle IS zero
3) IF temperature IS cold AND pressure IS strong THEN throttle IS negative
Example: Rule Evaluation (Max/Min)
0
1
min max0
pos itive
0.37
µcold(x) = 0.6 µlow(y) = 0.37
µcold(x) = 0.6 µok(y) = 0.13
0
1
min max0
zero
0.13
Introduc?on to Control Theory 51
Example: Aggregation (Max/Min)
0
1
min max0
pos itive
0.37
0
1
min max0
zero
0.13
0
1
min max0
zero pos itive
Introduc?on to Control Theory 52
Example: Defuzzyfication
0
1
min max0 z
• Generation of crisp output value by use of “center of gravity” method
center of gravity
References / Materials
• Exploring Classical Control (Online Material) http://www.facstaff.bucknell.edu/mastascu/eControlHTML/CourseIndex.html
• Feedback Systems: An Introduction for Scientists and Engineers.. Karl J. Åström and Richard M. Murray (2008).
• Modeling a DC motor using MATLAB/Simulink http://www.mathworks.com/help/toolbox/control/getstart/f1-1010549.html
• http://www.scicoslab.org/ • www.gnu.org/software/octave/
ENDE
Danke für die Aufmerksamkeit!
Additional / Unused Material
Laplace Transformation Designing a Digital Controller Stability criteria
Introduc?on to Control Theory 56
Laplace Transformation
Calculation in the Laplace domain (s).
∫
∫∞+
∞−
−
∞−
⋅⋅⋅
==
⋅==
+=
j
j
st
st
dsesXj
sXLtx
dtetxtxLsX
js
σ
σπ
ωσ
)(21)}({)(
)()}({)(
1
0
Introduc?on to Control Theory 57
Laplace Transformation (2)
Important Laplace Transformations
x(t) X(t) = L{x(t)}
δ(t) 1
1 or σ(t) 1 / s
t 1 / s2
sin(b t) b / (s2 + b2)
ea· t
1 / (s – a)
Introduc?on to Control Theory 58
Designing a Digital Controller (PID)
Position algorithm:
Velocity algorithm:
Sampling time Ts must be sufficiently small: Ts ≤ 0.1 · Ta Ts ≤ 0.25 · Tu
s
nnD
n
isiInPn T
eeKTeKeKu 1−−++= ∑
s
nnnDsnInnPn T
)ee(eKTeK)e(eKΔu 211
2 −−−
−−++−=
Introduc?on to Control Theory 59
Stability: Nyquist Criterion
Plo]ng the transfer func?on of the opened control system as Nyquist Plot (separate axis for real and imaginary part)
Cri?cal point of F(ω): [‐1,0i] Amplitude passage ωD1 : |F(ωD1)| = 1 Phase passage ωD2 : arc(F(ωD2)) = π Stable behavior: ωD1 < ωD2
Introduc?on to Control Theory 60
Stability: Nyquist Criterium (2)
-1
ω >
Im
Re
ω=0 ω=∞ critical point ωD1
ωD2
Introduc?on to Control Theory 61
Stability: Bode Plot |G (jω)|
ω
ω
‐90°
‐180°
‐270°
10
1
|F | > 1 … instabil|F | = 1|F | < 1 … s tabil
Φ > ‐180° … s tabilΦ = ‐180°Φ < ‐180° … instabil
Φ
Quality of Stability: • Amplitude margin
• Phase margin