You are on page 1of 36

Chapter 13: PID Controllers

May 8, 2017

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 1 / 36


Introduction

Outline

1 Introduction

2 Analog and Digital formulations

3 Implementations
Analog Implementation
Digital Implementation

4 PID Tuning
Manual Tuning
Heuristic Methods
Numerical Optimization Methods

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 2 / 36


Introduction

What is a PID controller?

Definition
A Proportional-Integral-Deriviative (PID) controller is a control-loop feedback
mechanism (controller) widely used in process industry.

Continuous-time text book equation:


Z t
de(t)
u(t) = Kp e(t) + Ki e( )d + Kd
0 dt
| {z } | {z } | {z }
Proportional Action Integral Action Derivative Action

Note: 90% (or more) of control-loops in process industry are PID.

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 3 / 36


Introduction

What is a PID controller?

Proportional action up (t) = Kp e(t): it depends on the instantaneous value of the


error.
+ Reduces rise time
+ Reduces but does not eliminate the steady-state error: Only when
K , error 0 (unless the plant has pole(s) at s = 0)
Rt
Integral action ui (t) = Ki 0
e( )d : it is proportional to the accumulated error.
+ Eliminates the steady-state error for a constant or step input (e.g.,
in plants of type 0)
Makes transient response slower
Derivative action ud (t) = Kd de(t)
dt
: it is proportional to the rate of change of the
error.
+ Increases the stability of the system, reduces overshoot, improves the
transient response
Amplifies the noise present in the error signal

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 4 / 36


Analog and Digital formulations

Outline

1 Introduction

2 Analog and Digital formulations

3 Implementations
Analog Implementation
Digital Implementation

4 PID Tuning
Manual Tuning
Heuristic Methods
Numerical Optimization Methods

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 5 / 36


Analog and Digital formulations

Proportional Control

The continuous-time and discrete-time implementations are identical.

For the continuous-time case we have:


Up (s)
up (t) = Kp e(t) = Kp
E(s)

and for the discrete-time case:


Up (z)
up [k] = Kp e[k] = Kp
E(z)

where e(t) or e[k] is the error signal.

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 6 / 36


Analog and Digital formulations

Derivative Control

In continuous-time it is given by:

de(t) Ud (s)
ud (t) = Kd = Kd s
dt E(s)

and in discrete-time by (using backward Euler):

e[k] e[k 1] Ud (z) z1


ud [k] = Kd = Kd
Ts E(z) Ts z

with Ts the sampling time.

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 7 / 36


Analog and Digital formulations

Integral Control

In continuous-time it is given by:


Z t
Ui (s) Ki
ui (t) = Ki e( )d ui (t) = Ki e(t) =
0 E(s) s

and in discrete-time by (using backward Euler)

Ui (z) zTs
ui [k] = ui [k 1] + Ki Ts e[k] = Ki
E(z) z1

with Ts the sampling time.

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 8 / 36


Analog and Digital formulations

Digital formulation (conventional version)


Digital PID controller (conventional version)
Kd
u[k] = Kp e[k] + (e[k] e[k 1]) + ui [k]
Ts
with ui [k] = ui [k 1] + Ki Ts e[k]

In the Z-domain:
U (z) z Kd z 1
= Kp + Ki Ts +
E(z) z1 Ts z
Kd
where Ki Ts and Ts are the new derivative and gains.

Digital PI controller Digital PD controller


U (z) z U (z) Kd z 1
= Kp + Ki Ts = Kp +
E(z) z1 E(z) Ts z

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 9 / 36


Analog and Digital formulations

Alternative Digital PID controller

If we discretize the continuous-time (analog) PID controller using the


bilinear transformation,

U (z) Ki
= Kp + + Kd s
E(z) s s= 2 ( z1 ) Ts z+1

we obtain an alternative form for a digital PID controller

U (z) Ki Ts (z + 1) 2Kd (z 1)
= Kp + +
E(z) 2(z 1) Ts (z + 1)
2
2 z + 1 z + 0
=
(z 1)(z + 1)

where 2 , 1 , 0 are design parameters.

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 10 / 36


Analog and Digital formulations

PID Math Demystified

https://www.youtube.com/watch?v=JEpWlTl95Tw
Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 11 / 36
Analog and Digital formulations

Alternative Derivative Action (Continuous-time)

r(t)

Imagine a step change in reference signal r(t). This


results in a theoretically infinite, practically very
large response of the derivative term.
t

Add a low-pass filter to the derivative term:

Ud (s) Kd s
=
E(s) 1 + s

With s = j, breakpoint at = 1/ . This prevents amplification of high


frequencies.

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 12 / 36


Analog and Digital formulations

Alternative Derivative Action (Continuous-time)

Ud (s) Kd s
=
E(s) 1 + s
Further e(t) is replaced by c r(t) y(t) with c the setpoint weighting,
which is often set to zero to further reduce immediate influence of a
sudden set-point jump.

In the time-domain:
dud d
ud (t) = + Kd (c r(t) y(t))
dt dt

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 13 / 36


Implementations

Outline

1 Introduction

2 Analog and Digital formulations

3 Implementations
Analog Implementation
Digital Implementation

4 PID Tuning
Manual Tuning
Heuristic Methods
Numerical Optimization Methods

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 14 / 36


Implementations Analog Implementation

Analog Implementation
The key building block is the operational amplifier (op-amp).

PV - Process Variable y(t)


SP - Setpoint r(t)
Output - Control action u(t)

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 15 / 36


Implementations Analog Implementation

Analog Implementation

Analog PID controller: FOXBORO 62H-4E-OH M/62H

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 16 / 36


Implementations Analog Implementation

Analog PI Motor Speed Control

https://youtu.be/6W3PLiVIcmE
Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 17 / 36
Implementations Digital Implementation

Digital Implementation
The difference equations are typically implemented in a microcontroller or in an
FPGA (field-programmable gate array) device:
Kd
u[k] = Kp e[k] + (e[k] e[k 1]) + ui [k]
Ts
with ui [k] = ui [k 1] + Ki Ts e[k]

Pseudocode
previous error = 0
integral = 0
Start :
e r r o r = setpoint measured value
p r o p o r t i o n a l = KP e r r o r
i n t e g r a l = i n t e g r a l + Ki s a m p l i n g t i m e e r r o r
d e r i v a t i v e = Kd ( e r r o r p r e v i o u s e r r o r ) / s a m p l i n g t i m e
output = p r o p o r t i o n a l + i n t e g r a l + d e r i v a t i v e
previous error = error
wait ( s a m p l i n g t i m e )
goto S t a r t

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 18 / 36


Implementations Digital Implementation

Digital Implementation
PLC with a digital PID module: Digital PID:

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 19 / 36


Implementations Digital Implementation

PLC

A Programmable Logic Controller (PLC) is a digital computer used for


automation in process industry.

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 20 / 36


Implementations Digital Implementation

What is a PLC? Basics of PLCs

https://youtu.be/iWgHqqunsyE

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 21 / 36


PID Tuning

Outline

1 Introduction

2 Analog and Digital formulations

3 Implementations
Analog Implementation
Digital Implementation

4 PID Tuning
Manual Tuning
Heuristic Methods
Numerical Optimization Methods

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 22 / 36


PID Tuning Manual Tuning

Manual Tuning

The effects of each of the controller parameters Kp , Ki , and Kd on the


closed-loop system are summarized in the table below.

Closed-loop response
PID gains
Rise Time Overshoot Settling time Steady-State error
Kp Decrease Increase Small Change Decrease
Ki Decrease Increase Increase Eliminate
Kd Small change Decrease Decrease No change

Important note
Changing one parameter can influence the effect of the other two.
Therefore, use this table only as a reference.

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 23 / 36


PID Tuning Manual Tuning

Manual Tuning

One possible way is as follows (the controller is connected to the plant):


1 Set Ki and Kd equal to 0.
2 Increase Kp until you observe that the step response is fast enough
and the steady-state error is small.
3 Start adding some integral action in order to get rid of the
steady-state error. Keep in mind that too much Ki can cause
instability!
4 Add some derivative action in order to quickly react to disturbances
and/or dampen the response.

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 24 / 36


PID Tuning Heuristic Methods

Heuristic Methods

When the mathematical model of a plant is unknown or it is too com-


plicated to obtain, an analytical approach to design a PID controller is not
possible. Therefore in these cases we have to use an experimental approach
to tune the PID controller. Among the existing experimental approaches we
can mention:
Ziegler-Nichols tuning rule based on step response (First method)
Ziegler-Nichols tuning rule based on critical gain and critical period
(Second method)

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 25 / 36


PID Tuning Heuristic Methods

Ziegler-Nichols tuning rule: First Method

In this method, the response of the plant to a unit-step input is obtained ex-
perimentally. If the plant involves neither integrators nor dominant complex-
conjugate poles, then such a unit-step response curve may look S-shaped
as shown in the figure on the next slide. This S-shaped curve may be char-
acterized by two constants: delay time L and time constant T . The delay
time and the time constant are determined by drawing a tangent line at the
inflection point of the S-shaped curve and determining the intersections of
the tangent line with the time axis and a horizontal line crossing the y-axis
at point (0,K).

If the response to a step input does not exhibit an S-shaped curve, the
first method does not apply.

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 26 / 36


PID Tuning Heuristic Methods

Ziegler-Nichols tuning rule: First Method


Step Response

K
Amplitude

L T

0
0
Time (seconds)

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 27 / 36


PID Tuning Heuristic Methods

Ziegler-Nichols tuning rule: First Method

Ziegler and Nichols suggested to set the values of Kp , Ki , and Kd


according to the formulas shown in the following table:

Control Type Kp Ki Kd
P T /L 0 0
PI 0.9 TL Kp 0.3
L 0
Kp
PID 1.2 TL 2L 0.5LKp

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 28 / 36


PID Tuning Heuristic Methods

Ziegler-Nichols tuning rule: First Method

The PID controller tuned by the first method gives:


U (s) Ki
= Kp + + Kd s
E(s) s
T 1 
= 1.2 1 + + 0.5Ls
L 2Ls
1 2

s+ L
= 0.6T
s
with a pole at the origin and a double zero at s = L1 .

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 29 / 36


PID Tuning Heuristic Methods

Ziegler-Nichols tuning rule: Second Method

This method is based on the value of Kp that results in marginal stability


when only proportional control action is used.
1 Set the integral and derivative gains to zero (Kp = Kd = 0);
2 Increase the proportional gain Kp until the output of the control loop
starts oscillating with a constant amplitude. The value of Kp at this
point is referred to as ultimate gain (Ku , Kp );
3 Measure the period of the oscillations Tu at the output of the
closed-loop system;
4 Use Ku and Tu to determine the gains of the PID controller
according to the tuning rule table shown in the next slide.

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 30 / 36


PID Tuning Heuristic Methods

Ziegler-Nichols tuning rule: Second Method

Control Type Kp Ki Kd
P 0.5Ku - -
PI 0.45Ku 1.2Kp /Tu -
PD 0.8Ku - Kp Tu /8
PID 0.6Ku 2Kp /Tu Kp Tu /8
Pessen Integral Rule 0.7Ku 2.5Kp /Tu 3Kp Tu /20
Some overshoot 0.33Ku 2Kp /Tu Kp Tu /3
No overshoot 0.2Ku 2Kp /Tu Kp Tu /3

If the output does not exhibit sustained oscillations for whatever value Kp
may take, then the second method does not apply.
Keep in mind that we are working with heuristic tuning rules, and therefore some
additional fine tuning might be necessary.

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 31 / 36


PID Tuning Heuristic Methods

Ziegler-Nichols tuning rule: Second Method (example)


Example
Consider a plant with a given model:
1
P (s) =
(s + 1)3
We compute the critical gain Ku .
This is the value of Kp for which (Kp P (s)) = 180 . On the Nyquist plot this
is the value of Kp for which Kp P (s) passes through (1, 0).

Ku P (ju ) = 1
Ku = (ju + 1)3
= (3u2 1) + j(u3 3u )

u3 3u = 0 u = 3
2
Ku = 8, Tu = = 3.628
u
Kp = 4.8, Ki = 2.6448, Kd = 2.16

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 32 / 36


PID Tuning Numerical Optimization Methods

Numerical Optimization Methods


The tuning of a PID controller is posed as a constrained optimization problem.
For a given set of parameters Kp , Ki and Kd run a simulation of the closed-loop
system, and compute some performance parameters (e.g. settling time, rise time,
etc.) and a performance index.
Optimize the performance index over the three PID gains.

Optimizer
, , Performance Index

Simulation

PID Plant Model

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 33 / 36


PID Tuning Numerical Optimization Methods

Some Software Tools

Software Tool Brief Description


pidtool/pidTuner It is a Matlab tool to interactively design a SISO
PID controller in the feed-forward path of single-
loop, unity-feedback control configuration
Pidpy It is a modular PID control library for python
that supports PID auto tuning. https://pypi.
python.org/pypi/pypid/
INCA PID Tuner It is a commercial tuning tool developed by
IPCOS. It has a vast library of PID structures
for DCS and PLC Systems including Siemens,
ABB, Honeywell, Emerson, etc. http://www.
ipcos.com/advancedprocesscontrol/
advanced-process-control/
pid-tuning-software/inca-pid-tuning/

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 34 / 36


PID Tuning Numerical Optimization Methods

pidtool/pidTuner - Demo

https://www.youtube.com/watch?v=2tKe0caUv1I

Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 35 / 36


PID Tuning Numerical Optimization Methods

INCA PID Tuner - Demo

https://www.youtube.com/watch?v=XH2bkq1URSg
Prof. Bart De Moor (KUL) Chapter 13: PID Controllers 36 / 36