Lecture 10
Lecture 10
K. J. Åström
1. Introduction
2. The PID Algorithm
3. Set Point Weighting
4. Integrator Windup
5. Tuning
6. Computer Control Control actions are based on
&
c K. J. Åström August, 2000 1
A PID Algorithm The Problem with Derivatives
dy(t)
Inn spite of the widespread use of PID it is not given much at- The signal y(t) = sin t + an sin ω t has the derivative dt
=
tention in education. Much information among the manufactur- cos t + anω cos ω t
ers.
Example ω = 100, an = 0.01
PID control is more than
y( t) = sin t + 0.01 sin ω t
ki d y( t)
G c ( s) = k + + kd s = cos t + ω cos ω t
s dt
We have to consider Approximate Differentiation: replace sT by
• Set point weighting • Computer implementation
sT
G d ( s) =
• Derivative filter • Mode switches 1 + sT / N
• Integrator Windup • Bumpless parameter changes What does it mean? The system Gd (s) has the output T d y/dt
A good introduction to practical implementation of algorithms. for low frequency signals. The gain of Gd is less than N .
Bode Diagrams
−20
−2 −2
−40 0 5 10 15 0 5 10 15
100 Brusig signal sb Derivatan av sb
2 2
80
−2 −2
60
0 5 10 15 0 5 10 15
40
Brusig signal sb Fuskderivatan av sb
2 2
20
0 −2 −2
−1 0 1 2
10 10 10 10
0 5 10 15 0 5 10 15
Frequency (rad/sec)
&
c K. J. Åström August, 2000 2
The PID Controller Different Parameterizations
The basic equation Parallel form:
Z
t d y f ( t) 1 k
u( t) = k bysp( t) − y( t) + ki ysp(τ ) − y(τ ) dτ + kd (− ), G ( s) = k 1 + + sTd = (1 + sTi + s2 Ti Td )
dt sTi sTi
0
Derivative filter Td dy f
+ yf = y Series form:
N dt
1 k̃
Feedback Gc (s) = k + ki
+ kd 1+ssTf G̃ ( s) = k̃ 1 + (1 + sT̃d ) = 1 + s( T̃i + T̃d ) + s2 T̃i T̃d
s sT̃i sT̃i
Feedforward G f f (s) = bk + ki
s
Relations between coefficients
Set point weighting b T̃i + T̃d T̃i T̃d
k = k̃ , Ti = T̃i + T̃d, Td =
T̃i T̃i + T̃d
Sometimes also high frequency roll-off
Parallel form is more general. Equivalence possible only if
Ti ≥ 4Td. Essential for tuning to know which form is used.
l n
−0.5
−1
0 10 20 30 40
&
c K. J. Åström August, 2000 3
Integrator Windup One Way to Avoid Windup
2 y –y
KT d s
1 Actuator
ysp model Actuator
0 e = r− y
0 20 40 60 80 K Σ
0.1
u K – +
1
Ti
Σ Σ
−0.1 s
0 20 40 60 80
1 es
I Tt
2
−2 Cherchez l’erreur!
0 20 40 60 80
0.5
y Tt = 3
ysp
Tt = 2
0 1
0 10 20 30 Tt = 0.1, Tt = 1
0.15
0
u 0 10 20 30
0.05
−0.05 0.1 Tt = 3
0 10 20 30 Tt = 0.1 Tt = 2
0 Tt = 1
0
I −0.1
−0.4
0 10 20 30
−0.8
0 10 20 30
&
c K. J. Åström August, 2000 4
Rules of Thumb Tracking
• Fast resetting time not good because errors may reset the Protection against windup is often built into controllers. This
integral. can be done in many ways. Here is one version where the
• Long resetting time gives poor windup protection controller has a tracking input. This can be used in many
different ways, e.g. when selectors are used.
• Rules of thumb
Tt = 0.5Ti for PI control
√
Tt = Ti Td for PID control
• Simulations made with Ti = 1.
• Rundqvist’s dissertation
&
c K. J. Åström August, 2000 5
Ziegler-Nichols’ Step Response Method Ziegler-Nichols’ Step Response Method
• Switch controller to manual. Parameters a and L from normalized step response
• Make a step in the control variable.
• Log process output. Don’t wait for steady state. Normalize
the curve so that it corresponds to a unit step. Controller k Ti Td Tp
• Determine parameters a and L from initial part of step P 1/a 4L
response. Controller parameters are give by a table. PI 0.9/a 3L 5.7L
PID 1.2/a 2L L/2 3.4L
−1 ϕ Re G(iω )
a
Parameter Tp is an estimate of the response time of the closed
ω
loop system.
&
c K. J. Åström August, 2000 6
Process Suitable for PID Control Properties of Ziegler Nichols Rules
Enkapacitiv Flerkapacitiv
Properties
+ Easy to explain and use
+ Very common
Integrerande Oscillativ
- The closed loop system obtained too oscillatory ζ 0.2.
Part of the criterion (quarter amplitude damping)
- Too large overshoot
- Sensitive to process variations
- Can only be used on a restricted class of processes
Dödtid Omvänt svar
0
−1 0
10 10
−1
0 5 10 15 20
−2 −1
10 10
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Gives ω 180 and k180
&
c K. J. Åström August, 2000 7
Some Properties Automatic Tuning of a Level Controller
• Safe for stable systems
• Close to industrial practice
Compare manual Ziegler-Nichols tuning
Easy to explain
• Little prior information. Relay amplitude
• One-button tuning
• Automatic generation of test signal
– Injects automatically much energy at ω 180 without need
for knowing ω 180 beforehand
• Good for pretuning
• Good industrial experience
&
c K. J. Åström August, 2000 8
A Basic Algorithm Sampling, Aliasing and Anti-aliasing Filters
The following operations are executed by the computer.
1. Wait for clock interrupt 1
sa
2. Convert setpoint ysp and process output y to numbers
3. Compute control signal u 0 s
4. Convert control signal to analog value
5. Update variables in control algorithm −1
0 1 2 3 4 5
6. Go to step 1
Aliasing means that high frequencies appear like low frequen-
Desirable to make time between 1 and 4 as short as possible. cies when sampled. High frequencies must be eliminated be-
Defer as much as possible of the computations to step 5. fore sampling.
fs
No high frequencies above the Nyquist frequency f n = .
2
&
c K. J. Åström August, 2000 9
Integral Part Derivative Part
Z t sTd
k D ( s) = − k Y ( s)
i( t) = e( s) ds 1 + sTd/ N
Ti
Differentiate Hence
di k (1 + sTd/ N ) D ( s) = − ksTd Y ( s)
= e( t)
dt Ti
In time domain
Approximate the derivative by a difference
Td dd dy
d( t) + = − kTd
i( tk+1 ) − i( tk ) ke( tk) N dt dt
=
h Ti
Approximate derivative by backward difference
This equation can be written as Td d( tk ) − d( tk−1) y( tk) − y( tk−1)
d( t k) + = − kTd
kh N h h
i( tk+1 ) = i( tk ) + e( t k )
Ti
&
c K. J. Åström August, 2000 10
Add Protection Against Windup Wordlength Issues
Consider updating of the integral part
p( tk) = k ∗ b( ysp( tk ) − y( tk))
e( tk) = ysp( tk ) − y( tk) i( tk+1) = i( tk ) +
kh
e( t k )
Td Ti
d( t k ) = d( tk−1) − kN y( tk) − y( tk−1)
Td + Nh Example
v= p( tk) + i( tk ) + d( tk)
u( tk )= sat(v) • h=0.05 s
kh kh • Ti=5000 s
i( tk+1 ) = i( tk ) + e( t k ) + u−v
Ti Tr
• k=1
• Useful to precompute parameters kh
• = 10−5
• Make sure updating is done safely Ti
• Organize the code right If the error has 3 digits the integral need to be updated with 8
digits (28 bits) to avoid rounding off the errors!
• More sophisticated controllers have more modes The basic issue is that multiplication with a time function does
not commute with differentiation or integration.
&
c K. J. Åström August, 2000 11
Compute controller coefficients Summary
bi=K*h/Ti integral gain
ad=(2*Td-N*h)/(2*Td+N*h) • Automatic control fundamentals
bd=2*K*N*Td/(2*Td+N*h) derivative gain • Assessment of control systems
a0=h/Tt
Bumpless parameter changes – Often poorly done in literature
I=I+Kold*(bold*ysp-y)-Knew*(bnew*ysp-y) – Six responses are needed
Control algorithm – The importance of load disturbances
r=adin(ch1) read setpoint • Many practical and operational issues
y=adin(ch2) read process variable
P=K*(b*ysp-y) compute proportional – Derivative filter
D=ad*D-bd*(y-yold) update derivative – Set point weighting (2DOF)
v=P+I+D compute temporary output – Integrator windup
u=sat(v,ulow,uhigh) actuator saturation – Digital control
daout(ch1) set analog output – Mode switching
I=I+bi*(ysp-y)+ao*(u-v) update integral
yold=y update process output • Relevant for all systems
&
c K. J. Åström August, 2000 12