0% found this document useful (0 votes)
14 views

Lecture 10

Uploaded by

Veljko
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Lecture 10

Uploaded by

Veljko
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Lecture 10 - PID Control PID Control

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

7. Summary • The error e(t)


Rt
• Past errors I = e(s)ds
Theme: A closer look at the most common control law. Prac-
tical issues such as windup, windup protection, computer im- • Predicted future error ep = e + Td de
dt
plementation More complex controllers use other methods for prediction.

How the PID Controller Emerged Integral Action or Reset


• The most common form (PI) of control all categories It was noticed early that proportional control gives steady state
• Widely used in all areas error. A bias term called reset was introduced to eliminate
steady state errors. The following clever method of making the
• Invented and reinvented many times reset automatically was then invented.
• Proportional action gives steady state error
e u
• Can be removed by integral action K Σ
I
Average past errors!
1
• Reset and automatic reset 1+ sTi
• Derivative action  1 
Preact Taylor Instruments A simple calculation gives U (s) = k 1 + . Voilá a PI
sT
controller!

&
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

Simulation of Approximate Derivative


40

Signal y(t) = sin t + an sin ω t, approximate derivative


Gd (s) = 1+ss/5
20

0 Brusfri signal Brusfri derivata


2 2
Phase (deg); Magnitude (dB)

−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.

Set Point Weighting - Poor Man’s DOF Effects of Saturation


Setpoint ysp and process output y • Practically all systems have saturations in actuators
1
• The feedback loop is broken when saturation occurs
0.5 b=1
b = 0.5 • Unstable parts of system or controller will drift
0 b=0
0 10 20 30 40 • An integrator in a controller is an unstable part
Control signal u
• Instabilities are real limitations!
2 b=1
b = 0.5 G. Stein First Bode Lecture Respect the Unstable
0 b=0 • Windup protection is needed in all controllers with integral
0 10 20 30 40
Load disturbance l and measurement noise n action

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

Control with Anti-Windup Effect of Time Tracking Time Constant Tt


Influence of the reset time constantTt.
ysp
1

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

PID Controller with Tracking Input Controller Tuning


Two approaches
y sp P
b Σ K
• Direct
y sKTd D Start with controller that gives stable system
−1 Σ
1+ sTd / N Perturb process
e I
Observe behavior
K 1 v
Σ Σ
Ti s Adjust parameters
1
• Indirect (Model based)
Tt
Perturb the process
w + – Develop a model
Σ
Determine the parameters based on the model
y sp
SP v
y MV PID
w TR

&
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

K Parameter Tp is an estimate of the response time of the closed


A0 loop system.

Ziegler-Nichols’ Frequency Response Method Ziegler-Nichols’ Frequency Response Method


• Switch the controller to pure proportional. Parameters ku and Tu are obtained from a special experiment
• Adjust the gain so that the closed loop system is at the
stability boundary.
• Determine the gain ku (the ultimate gain) and the period Reg. k Ti Td Tp
Tu (the ultimate period) of the oscillation. P 0.5ku Tu
• Suitable controller parameters are obtained from a table. PI 0.4ku 0.8Tu 1.4Tu
Im G(iω )
PID 0.6ku 0.5Tu 0.125Tu 0.85Tu
Ultimate point

−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

A good idea to base tuning on simple process experiments.


Large scope for improvements.
More process information needed.

A Ziegler Nichols Replacement Relay Auto-tuning


• ZN is basically a sound method, BUT
Damping specified is too low QAD < ζ = 0.2 y sp
Σ
u
Process
y

Too little process information (Two parameters ku, Tu )


PID
• An additional parameter give a big improvement
−1
κ = e G (ω 180 )/ G (0)e
K/Ku vs kappa Ti/Tu vs kappa
0
10 10
1 1

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

Automatic Tuning of a Temperature Controller Computer Control


Practically all control systems are today implemented using
computers. We will briefly discuss some aspects of this.
AD and DA converters are needed to connect sensors and ac-
tuators to the computer. A clock is also needed to synchronize
the operations. We will discuss
• Sampling and aliasing
• A basic algorithm
• Converting differential equations to difference equations
• Word-length issues
• Bumpless parameter changes

&
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

The PID Algorithm The Proportional Part


The PID controller is described by:
p( tk) = k ∗ ( bysp( tk ) − y( tk))
U ( s ) = P( s ) + I ( s ) + D ( s )
 
P( s) = k bYsp( s) − Y ( s)
1
I ( s) = k ( Ysp( s) − Y ( s))
sTi
sTd
D ( s) = − k Y ( s)
1 + sTd/ N

Computers can only add and multiply, it cannot integrate or


take derivatives. To obtain a programmable algorithm we must
approximate. There are many ways to do this.
Introduce the times tk when the clock ticks, assume that
tk − tk−1 = h, ,where h is the sampling period.

&
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

Derivative Part Continued The Discrete PID Algorithm


Td d( tk) − d( tk−1) y( tk) − y( tk−1) Summarizing we find
d( t k ) + = − kTd
N h h p( tk) = k ∗ ( bysp( tk ) − y( tk))
Hence e( tk) = ysp( tk ) − y( tk)
  
Td  Td kTd 
d( t k ) =
Td
d( tk−1) − kN y( tk) − y( tk−1)
1+ d( t k) = d( t k− 1) − y( tk) − y( tk−1)
Nh Nh h Td + Nh
or u( tk ) = p( tk) + i( tk ) + d( tk)
kh
Td kTd N  i( tk+1) = i( tk ) + e( t k )
d( t k) = d( tk−1) − y( tk) − y( tk−1) Ti
Td + Nh Td + Nh

Notice that the algorithm works well even if Td is small, this is


not the case if forward approximations are used.

&
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!

Mode Changes Bumpless Parameter Changes


• A controller can operate in several modes A PID controller is often switched between between manual
• Simple controllers such as PID have at least three modes and automatic control. It is important that there will not be
switching transients.
– Off - Constant safe value of control signal
– Manual - Control signal can be changed manually It is also important that parameter changes do not generate
transients. This can be avoided by proper coding.
– Automatic - Set point can be changed manually
– Parameter changes Example:
• Important to make sure that there are no transients when This implementation gives This implementation gives
modes are changed bumps no bump
Z Z
• Some commercial controller allow parameter changes only k t t
k
i= e( s) ds i= e( s) ds
in manual mode! Ti Ti

• 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

You might also like