Professional Documents
Culture Documents
Lecture 8: From Analog To Digital Controllers, PID Control Design Approaches
Lecture 8: From Analog To Digital Controllers, PID Control Design Approaches
Lecture 8: From Analog To Digital Controllers, PID Control Design Approaches
Design Approaches
ContinuousTime Process Model Lectures 6,7,9 Lecture 8
1 2
{u ( kh )}
Algorithm
{ y ( kh )}
y (t) D-A
State-Space Domain
Assume that the controller is given in state-space form
dx = Ax + Bu dt y = Cx + Du
Backward difference:
dx(t) dt x(t) x(t h) q1 x(t) = h qh
where x is the controller state, y is the controller output, and u is the controller input. Forward or backward approximation of the derivative
Forward difference
dx(t) dt x( k + 1) x( k) h
Backward difference
dx(t) dt x( k) x( k 1) h
leads to
x( k + 1) x( k) = Ax( k) + Bu( k) h y( k) = Cx( k) + Du( k)
rst gives
x( k) = ( I hA)1 x( k h) + ( I hA)1 hBu( k) y( k) = Cx( k) + Du( k)
which gives
x( k + 1) = ( I + hA) x( k) + hBu( k) y( k) = Cx( k) + Du( k)
Frequency Domain
Assume that the controller is given as a transfer function G (s) The discrete-time approximation H ( z) is given by
H ( z) = G (s )
Example: Discretization
Assume that the following simple controller (lter) has been designed in continuous-time:
U ( s) = 1 E ( s) s+2
where
z1 s = h s = z1 zh Forward difference Backward difference Tustins approximation
Discretize this controller using Forward Euler approximation, 1 i.e. replace s with z : h
U ( z) = U ( z) =
z1 h
1 E( z) +2
2 z1 s = h z+1
G (s)
Simulation (h = 0.1):
Amplitude
0.5
0.4
Forward differences
Backward differences
Tustin
0.3
0.2
0.1
0.5
1 Time (sec)
1.5
11
12
Frequency Distortion
Simple approximations such as Tustin introduce frequency distortion. Important for controllers or lters designed to have certain characteristics at a particular frequency, e.g., a band-pass lter or a notch (band-stop) lter. Tustin:
H ( ei h ) G 2 e 1 h ei h + 1
i h
i.e.,
=
2 tan1 h
h
2
( h)2 12
13
14
e i
Approximation
h = 0.03
10 Magnitude (abs)
10
e i
10
10
s =
tan( 1 h/2)
z1 z+1
180 90 0 90 180
15
This implies that H ei 1 h = G (i 1 ). Plain Tustin is obtained 1h 1h for small . for 1 = 0 since tan 2 2
10
10 Frequency (rad/sec)
10
10
16
10
10
10
10 Frequency (rad/sec)
10
10
17
18
Matlab
SYSD = C2D(SYSC,TS,METHOD) converts the continuous system SYSC to a discrete-time system SYSD with sample time TS. The string METHOD selects the discretization method among the following: zoh Zero-order hold on the inputs. foh Linear interpolation of inputs (triangle appx.) tustin Bilinear (Tustin) approximation. prewarp Tustin approximation with frequency prewarping. The critical frequency Wc is specified last as in C2D(SysC,Ts,prewarp,Wc) matched Matched pole-zero method (for SISO systems only).
19 20
10
10
10
90 0 90 180 270
Phase (deg)
10
10 Frequency (rad/sec)
10
10
Discretized Controller
Discretized Controller
u(t)
= K e(t) +
1 Ti
t 0
e( )d +
Td
U (s) =
K E(s) +
K E(s) sTi
+ K Td sE(s)
Much to learn! =
P
23
24
Proportional Term
u umax u0 umin e0 e0 e
1.5 1
Properties of P-Control
Set point and measured variable K=5
Proportional band
umax u = K e + u0 umin
e > e0
0 2 0 5 10
e0 < e < e0
e < e0
15
20
Stationary error
25
26
Integral Term
u = K e + u0 u=K
e
( P)
e(t)dt
Error:
e= u u0 K
1 e+ Ti
(PI)
+
t
Stationary error present e dt increases u increases y increases the error is not stationary
28
Automatic Reset
u0 K e 1 1+sT i
1.5 1
Properties of PI-Control
Set point and measured variable Ti=1 Ti=2 Ti=5
Ti= 5 10 15 20
U=
0 0
15
20
1+
Removes stationary error Smaller Ti implies faster steady-state error removal, worse stability
29
30
Prediction
Error
Derivative Part
de(t) dt
A PI-controller contains no prediction The same control signal is obtained for both these cases:
e e
e ( t)
e(t) + Td
e(t + Td)
Time
I P t Time
I P t Time
P:
u(t) = K e(t)
PD:
u(t) = K
31
e(t) + Td
de(t) dt
K e(t + Td )
32
Td = Prediction horizon
Properties of PD-Control
Set point and measured variable Td=0.1 1 0.5 0 0 6 Control variable Td=0.1 Td=0.5 4 Td=2 2 0 2 0 5 10 15 20 Td=0.5 Td=2
Alternative Forms
So far we have described the direct (position) version of the PID controller on parallel form Other forms: Series form
U = K (1 + 1 )(1 + sTd ) E sTi Td 1 = K (1 + + + sTd ) E Ti sTi
10
15
20
Td too small, no inuence Td too large, decreased performance In industrial practice the D-term is often turned off.
33 34
Practical Modications
Modications are needed to make the PID controller practically useful Limitations of derivative gain Derivative weighting Setpoint weighting Handle control signal limitations
U = K (s +
35
36
Derivative Weighting
The setpoint is often constant for long periods of time Setpoint often changed in steps D-part becomes very large. Derivative part applied on part of the setpoint or only on the measurement signal.
sTd ( Ysp(s) Y (s)) 1 + sTd / N
sTd
D ( s) =
Often, = 0 in process control (step reference changes), = 1 in servo control (smooth reference trajectories)
37 38
Setpoint Weighting
An advantage to also use weighting on the setpoint.
u = K ( ysp y)
Setpoint Weighting
1.5 Set point and measured variable beta=1 1 0.5 0 0 beta=0.5 beta=0
replaced by
u = K ( ysp y)
20
40
60
0 1
beta=1 beta=0.5
A way of introducing feedforward from the reference signal (position a closed loop zero) Improved set-point responses.
39
40
Anti-Reset Windup
Several solutions exist: controllers on velocity form ( u is set to 0 if u saturates) limit the setpoint variations (saturation never reached) conditional integration (integration is switched off when the control is far from the steady-state) tracking (back-calculation)
10
20
42
10
20
Tracking
y
Tracking
KTds Actuator e = r y K
when the control signal saturates, the integral is recomputed so that its new value gives a control signal at the saturation limit to avoid resetting the integral due to, e.g., measurement noise, the recomputation is done dynamically, i.e., through a LP-lter with a time constant Tt (Tr ).
1 s 1 Tt
K Ti
es
KT d s
Actuator model
Actuator
e = r y
K K Ti 1 s 1 Tt
+
es
44
43
Tracking
1 0.5 0 0.15 0.05 0.05 0
Discretization
r y
10 20 30
P-part:
u P( k) = K ( ysp( k) y( k))
0 10 20 30
0 0.4 0.8 0
I
10 20 30
45
46
Discretization
I-part:
I (t) = K Ti
t
Discretization
D-part (assume = 0):
sTd ( Y (s)) 1 + sTd / N Td dD dy + D = K Td N dt dt D=K
e( )d
0
dI K = e dt Ti
Forward difference
I (tk+1 ) I (tk ) K = e(tk ) h Ti
I(k+1) := I(k) + (K*h/Ti)*e(k) The I-part can be precalculated in UpdateStates Backward difference The I-part cannot be precalculated, i(k) = f(e(k))
47
48
Discretization
Tuning
Parameters: K , Ti , Td , N , , , Tr
Tracking:
Methods: empirically, rules of thumb, tuning charts model-based tuning, e.g., pole-placement automatic tuning experiment
Ziegler-Nichols method
Bumpless Transfer
Avoid bumps in control signal when changing operating mode (manual - auto - manual) changing parameters changing between different controllers Key Issue: Make sure that the controller states have the correct values, i.e., the same values before and after the change
y sp y
51
52
1 Tm
y sp y
1 s PD M 1 s
K Ti
u A
1 Tt
Switching Controllers
Controller1
More involved situation when setpoint weighting is used. The quantity P + I should be invariant to parameter changes.
Controller2 Switch
Process
Similar to changing between manual and auto Let the controllers run in parallel Let the controller that is not active track the one that is active. Alternatively, execute only the active controller and initialize the new controller to its correct value when switching (saves CPU)56
55
PID Code
PID-controller with anti-reset windup and manual and auto modes ( = 0).
y = yIn.get(); e = yref - y; D = ad * D - bd * (y - yold); v = K*(beta*yref - y) + I + D; if (mode == auto) { u = sat(v,umax,umin)} else u = sat(uman,umax,umin); uOut.put(u); I = I + (K*h/Ti)*e + (h/Tr)*(u - v); if (increment) uinc = 1; else if (decrement) uinc = -1; else uinc = 0; uman = uman + (h/Tm) * uinc + (h/Tr) * (u - uman) yold = y
Class SimplePID
public class SimplePID { private double u,e,v,y; private double K,Ti,Td,Beta,Tr,N,h; private double ad,bd; private double D,I,yOld; public SimplePID(double nK, double nTi, double NTd, double nBeta, double nTr, double nN, double nh) { updateParameters(nK,nTi,nTd,nBeta,nTr,nN,nh); } public void updateParameters(double nK, double nTi, double NTd, double nBeta, double nTr, double nN, double nh) { K = nK; Ti = nTi; Td = nTd; Beta = nBeta; Tr = nTr N = nN; h = nh; ad = Td / (Td + N*h); bd = K*ad*N; }
ad and bd are precalculated parameters given by the backward difference approximation of the D-term.
57
58
public double calculateOutput(double yref, double newY) { y = newY; e = yref - y; D = ad*D - bd*(y - yOld); v = K*(Beta*yref - y) + I + D; return v; } public void updateState(double u) { I = I + (K*h/Ti)*e + (h/Tr)*(u - v); yOld = y; } }
59
60