Download as pdf or txt
Download as pdf or txt
You are on page 1of 68

Digital Controller Design

& Discrete Implementation

(Chapter 8)
Main Focus:
9.1 Phase-Lead and Phase Lag -
(w-transformation)
9.2 PI, PD and PID - (Integration
and Differentiation)
Learning Objectives
• Perform digital implementation of the Lead, Lag, PID and
Lead-Lag controllers and develop block diagrams for
implementation.
• Realize the implementation of digital controllers through direct
decomposition of the transfer function.
• Design a discrete-data control system using the w-
transformation in the frequency domain and the z-plane.
• Design a digital controller transfer function (difference equation)
using phase-lead, phase-lag compensation and w-domain root-
locus techniques that will satisfy design specifications for a
given discrete control system.
• Design a digital controller transfer function (difference equation)
using PI, PD compensation and z-domain root-locus
techniques that will satisfy design specifications for a given
discrete control system.
Specification of System Desired
Characteristics

• Steady State Accuracy


• Transient Response
• Relative Stability
• Sensitivity
• Disturbance Rejection
• Control Effort
Summary
Continuous to Discrete using Matlab

C2D Conversion of continuous-time models to discrete time.

SYSD = C2D(SYSC,Ts,METHOD) converts the continuous-time LTI


model SYSC to a discrete-time model 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.)
'impulse' Impulse-invariant discretization
'tustin' Bilinear (Tustin) approximation.
'matched' Matched pole-zero method (for SISO systems only).
Summary
Continuous to Discrete using Matlab
Plant to G(z) using Impulse

e(t) 1/(s)
e(kT) f(kT)

gz1=c2d(gs,1,'imp')

Transfer function:
ds= 1/s z
-----
z-1

Sampling time: 1

Impulse used to transform a plant into z-domain without ZOH, this will give the same
result as the ZT Table.
Summary
Continuous to Discrete using Matlab
Plant to G(z) using ‘zoh’

f(t) f(kT)* f(kT)


1 - e -Ts 1
Sampler s
F(s) F*(s) s Y(s)

G(z)

gz1=c2d(gs,1,'zoh')

Transfer function:
1
-----
z-1

Sampling time: 1
Summary
Continuous to Discrete using Matlab
Controller to D(z) using Tustin
Trapezoidal Integration: Make use of trapezoidal-
integration rule in conjuntion with the difference
equation

F(s) M(s) Y(s)


A/D Digital Filter D/A Plant
f(t) f(kT) f(t)
m(kT) m(t)

D(z)=c2d(ds,1,'tustin')

Transfer function:
2 z -1 0.5 z + 0.5
ds= 1/s s= -----------
T z +1 z-1

Sampling time: 1
Tustin, Bilinear Transformation and Trapezoidal Rule
Summary
Continuous to Discrete using Matlab
Controller to GC(z) using Matched Pole Zero Method
Digital Differentiation/Integration using Backward-Rectangular

e(t) 1/(s)
e(kT) f(kT)
gz1=c2d(gs,1,'matched')

Transfer function:
1.001
-----
z-1
ds= 1/s 1 z -1
s=
T 1 Sampling time: 1
>> gz1=c2d(gs,2,'matched')

Transfer function:
2.001
-----
z-1

Sampling time: 2
Designing Discrete Controllers
• Methodology 1 (9.1): Frequency Domain Design (using
controlSystemDesigner)
Given or determine GP(z) that include zoh, find w-transformation used to
design lead/lag/pid controllers, using Tustin. Hence transfer back to GC(z),
again using Tustin. 2
2 z -1 2+T ×w T
+w
w= z= =
T z +1 2 -T ×w 2 - w
T
• Methodology 2 (9.2): PID controller design, use z-domain Root Locus
(using controlSystemDesigner and/or simulink –Trapeziodal/Tustin &
Forward-Rectangular/Matched)

T é z + 1ù é z - 1ù
D( z ) = K P + K I ê ú + K Dê ú
2 ë z - 1û ë Tz û
9.1 Digital controller design (a) phase lag
dB
G ( jw w )

G ( jw w ) D( jw w )

Gain margin
0
w wp w w0 Logw w
a0w wp
20 log
w w0

ÐG ( jw w ) D( jw w )
Phase
w wp w w0
0
Logw w

ÐG ( jw w )

- 180

fm
9.2 Digital controller design (b) Phase-Lead
dB

Gain margin
w wp

w w0 Logw w

G ( jw w )D( jw w )

Phase Figure 8-12 (299)

w w0 w wp

Logw w

ÐG ( jw w )D( jw w )

-180°
Fm

ÐG ( jw w )
Phase-Lead controller (p.297-306) – same as before
For phase-lead compensators, w w 0 < w wp . A typical frequency response
is shown in the following illustration:

dB

1
20 log
a 0 w wp
w w0
wm =
aT
20 log a 0

w w0 w wp Logw w
a -1
sin fm =
Phase
a +1
QM
1 + sin fm
a=
w w0 w wm w wp Log w w
1 - sin fm
General Design Outline/Guideline for Phase-
1. Find G(z), including ZOH.
Lead/phase-lag remain same !!
T 2
2. Substitute z = 1+ w +w
z= 2 = 2+T ×w = T
T 2
3. Obtain Bode Diagram of Uncompensated 1- w 2 - T × w -w
Process. Adjust the value of K need to be 2 T
adjusted upward once the value of a is
determined. 1
wm =
4. Determine the phase and gain margin of the aT
uncompensated system, determine the amount of
phase lead needed to realize the phase margin. a -1
Determine a and hence T. sin fm =
a +1
5. Place corner frequencies eg ωzero=1/aT and
ωpole= 1/T such that phase Φm is located at the 1 + sin fm
new gain-crossover frequency. From the bode a=
diagram of phase-lead controller the Gain in dB at
this point is -10 log a. Record ωm. 1 - sin fm
6. Adding the controller gain will cause the 1 + aTw
magnitude curve of the compensated system to
go through 0dB at ωm.
a >1
1 + Tw
Problem 1: Design a Phase-Lead
Digital Controller GC(z) that yields
a phase margin of 60o
Given the plant, determine the forward-path
transfer function, Gp(z) =ZOH+G(z), @
some sampling frequency T=0.1sec
r(t) + e(t) y(t)
GC(s) ZOH 4
- T T S 2

GC(z)
Forward Path Transfer

! 4 $ 0.02 z + 1 ( )
(
G(z) = GhoG p (z) = 1− z Z # 3 & =
−1
)
" s % z z −1
2

( )
2
+ w 20 + w
gz1=c2d(g1,0.1,'zoh') z=T =
2
g1=tf(n,d) - w 20 - w
Transfer function: T
Transfer function: 0.02 z + 0.02
gw=d2c(gz1,'tustin')
4 -------------
--- z^2 - 2 z + 1
Transfer function:
s^2 -1.11e-018 s^2 - 0.2 s + 4
Sampling time: 0.1
--------------------------
s^2
Aside, Evaluate Closed Loop
(stability??) of discrete system

Y ( z) Gho G p ( z ) 0.02 ( z + 1)
= =
1 + Gho G p ( z ) z - 1.98 z + 1.02
2
R( z )

Determine the closed loop pole position in


z-plane. System Stable or Unstable?
Back to Forward Path Transfer
Function
W-transformation
2 EXAMPLE(z to w) Using
+ w 20 + w Matlab:

z= T = n1=[0.02 0.02];
2 20 - w d1=[1 -2 1]
-w gz=tf(n1,d1,0.1)
T Transfer function:
0.02 z + 0.02
-------------

4 (1 - 0.05w )
z^2 - 2 z + 1
>> gw=d2c(gz,'tustin')
Transfer function:
G ( w) = 2
-0.2s + 4
-----------
w s^2
4 (1 - 0.05w )
Bode Plot G ( w) = 2
w
Unstable
select fm = 75, hence
1 + sin 75
a= = 57
1 - sin 75
then, select freq at :
gain = -10 log 57 = -17.62
use :
1
wm =
aT
1 1
5.65 = = ...hence
aT 57.8T
T = 0.0233 and aT = 1.347
1 + aTw 1 + 1.347w
Gc ( w) = =
1 + Tw 1 + 0.023w
n_controller = [1.347 1]

n_controller =

1.3470 1.0000

>> d_controller = [0.023 1]

d_controller =

0.0230 1.0000

>> gs_controller=tf(n_controller, d_controller)


Transfer function:
1.347 s + 1
-----------
0.023 s + 1

>> gz_controller=c2d(gs_controller,0.1,'tustin')

Transfer function:
19.14 z - 17.77
---------------
z + 0.3699
Implementation in Simulink
Discrete Systems Toolbox
Example 2:
Design a Phase-Lead Digital
Controller GC(z) that yields a
phase margin of 45o
Given the plant, determine the forward-path
transfer function, Gp(z) =ZOH+G(z), @
some sampling frequency T=0.01sec
r(t) + e(t) y(t)
GC(s) ZOH 1
- T T 0.1* S 2

GC(z)
Phase-Lead Design

1 Determine Forward 0.05( z + 1)


G( z ) =
Path Transfer
Function
( z - 1) 2

2
+w
T 200 + w
z= = n1=[0.05 0.05];
2
2 Bilinear - w 200 - w d1=[1 -2 1]
T gz=tf(n1,d1,0.01)
transformation w = Transfer function:
0.05 z + 0.05
-------------

3 G(w) = 5(200 - w) z^2 - 2 z + 1


>> gw=d2c(gz,'tustin')
2 Transfer function:
w -5 s + 1000
-----------
s^2
Determine a, gain, read ωm
1 + sin( 45 + 5 + 10)
4 a= = 14
1 - sin( 45 + 5 + 10)
gain = - - 10 log10 14 = -11.5 hence
1 1
wm = = 63.6 = .....T = 0.0042
aT 14T
hence :
1 + aTw 1 + 0.0588w
D( w) = =
1 + Tw 1 + 0.0042 w
2 z -1
Finally Re - arrange for : w =
0.01 z + 1
9.2 PI, PD and PID in z-Domain - Discrete System Modelling and
Controller Design (Using controlSystemDesigner or Simulink)

• Methodology 2 (9.2): PID controller design, use z-domain Root


Locus (using controlSystemDesigner and/or simulink –
Trapeziodal/Tustin & Forward-Rectangular/Matched)

T é z + 1ù é z - 1ù
D( z ) = K P + K I ê ú + K Dê ú
2 ë z - 1û ë Tz û
Design a Discrete PD Controller to meet Specification

1.6 Enter the transfer function into ACSYS and create a z-domain root locus and design a
PD controller to meet the following performance requirement, overshoot < 30%:

K D ( z - 1)
GC ( z ) = K ( K P + )
T
Show the uncompensated and compensated root locus and step response.
(10)
R(z)
+ Gc(z) G P _ Hold ( z )
Y(z)

-
Integrated Exam Question –
PD Design using z-Domain Rootlocus
Shown in Figure 4(a) and 4(b) is the model and
the block diagram of one joint of a robot arm,
respectively. The input U(s) is the controlling
signal, Ea(s) is the servomotor input voltage, is
the motor shaft angle (degrees), and the output
is the angle (degrees) of the arm. The
inductance of the armature of the servomotor
has been neglected such that the servomotor
transfer function is of second order. The
servomotor transfer function includes the inertia
of both the gears and the robot arm.
Figure 4: Industrial Robot Arm Discrete Control System
Determine Closed Loop System Performance
without the D(z):
Consider the addition of the A/D (sampler, T=0.1), D(z)
(controller, D(z)=1), Gain (K = 1.0) and D/A converter
(ZOH):
3.1 Determine the pulse transfer function for a
sampling period of T=0.1 sec. Find the roots of the
transfer function. (3)
3.2 Develop the discrete state space model for the
pulse transfer function in Question 3.1. (2)
3.3 Derive the closed-loop system transfer function.
Determine the characteristic equation and its roots in
the z-domain. Determine ζ, τ and ωn. (5)
3.4 Make use of the Jury Test to determine the range
of K that will keep the system stable. (5)
3.1 Pulse Transfer Function
> n1=[20]

>> d1=[1 5 0]

>> gs1=tf(n1,d1)
Transfer function:
20
---------
s^2 + 5 s

>> ghz=c2d(gs1,0.1,'zoh')

Transfer function:
0.08522 z + 0.07216
----------------------
z^2 - 1.607 z + 0.6065

Sampling time: 0.1


>> roots([1 -1.607 0.6065])
ans =
1.0013
0.6057 (3)
3.2 State Space Model
ghzss=ss(ghz)
a=
x1 x2
x1 1.607 -0.6065
x2 1 0
b=
u1
x1 0.5
x2 0

c=
x1 x2
y1 0.1704 0.1443

d=
u1
y1 0
3.4 Perform Stability Test using Jury Test
PD Controller Design

Uncompensated
(From 3.1, include
ZOH,
Select T = 0.1) then
RHS rootlocus and
response will appear !!
PD Controller Design

Uncompensated
(From 3.1, include ZOH,
Select T = 0.1) then RHS
rootlocus and response will
appear !!
Compensated
K D (z −1)
GC (z) = K(K P + )
T
0.1(z −1)
= 0.369(1+ )
0.1
Discrete Implementation of
Integration and Differentiation

PID Control
(p.310 – 327)

In Particular Section 8.11:


Design by z-domain Root
Locus
Digital controller design
PID IMPLEMENTATION STRATEGY / ALGORITHM

T é z + 1ù é z - 1ù
D( z ) = K P + K I ê ú + K Dê ú
2 ë z - 1û ë Tz û
Digital controller design T é z + 1ù é z - 1ù
P( z ) = K P + K I + K
2 êë z - 1 úû
Dê ú
ë Tz û
Integration and Differentiation filters: Section 8.8 p.311
The following illustration shows a numerical integration method.

Replace a
1/w with:

m(kT) shall be the numerical integral of e(t). Then we can write:


T
m[(k + 1)T ] = m(kT ) + {e[(k + 1)T ] + e(kT )}
2
After applying the z-Transform, we receive discrete integration:

T é z + 1ù
M ( z) = ê z - 1ú E ( z)
2 ë û
T é z + 1ù é z - 1ù
Digital controller design P( z ) = K P + K I
2 êë z - 1 úû
+ K Dê ú
ë Tz û
M ( w) T é z + 1ù 1
DI ( w) = = ê z - 1 ú 2 +T × w = w
E ( w) 2 ë û z=
2 -T ×w
....used Tustin
The following illustration shows a numerical differentiation method.
e(t )

e(kT )

Replace a
e[(k - 1)T ]
w with:

(k - 1)T kT t

e(kT ) - e[(k - 1)T ]


m(kT ) =
T
é z - 1ù
M ( z) = ê ú E( z)
ëT × z û
NumericalDifferntiation and Integration
T é z + 1ù é z - 1ù
P( z ) = K P + K I ê z - 1 ú + K D ê Tz ú
2 ë û ë û

Used Matched Pole - Zero :


Ts é 1 ù é z - 1ù
P( z ) = K P + K I ê ú + KD ê ú
1 ë z - 1û ë Ts û
PID Discrete Time Control Systems Design
1
1.Given the transfer function: GP ( s) =
s 2 + 1.1s + 11
Determine G(z) using C2D. Use Ts=0.1 sec and assume model is connected to a
ZOH. Draw the discrete unit step response (Use Simulink)
(4)
2. Given: NumericalDifferntiation and Integration
T é z + 1ù é z - 1ù
P( z ) = K P + K I ê z - 1ú + K D ê Tz ú
2 ë û ë û

Used Matched Pole - Zero :


Ts é 1 ù é z - 1ù
P( z ) = K P + K I + K
1 êë z - 1 úû
Dê ú
ë Ts û

Include GPID(z)= KP controller only. R(z)


+ G (z) G ( z)
Y(z)

PID P _ Hold
Tune controller to satisfy: -
Tsettling < xx sec
%OS < 5%
ess < 1%
What is the best this controller can achieve? Note: Create Z-Domain Root Locus.
(4)
Method 1: Enter into ACSYS Unit Step Response
1 Continuous to Discrete,
GP ( s ) =
s 2 + 1.1s + 11 Ts=0.1

Place Pole and Zero’s to “Manipulate” Root-Locus, Think of s-


domain, and “place” roots at a response that you desire. The
final controller is within w-domain
Continue Method 2: Alter Root locus for z-domain, use pole placement to alter root
locus
If PD Control :
GC ( w) = K ( K P + K D w) w= ( z -1)
Ts
K D ( z - 1)
GC ( z ) = K ( K P + )
T
(1+3.8w)

GzPD=1+3.8(z-1)
0.1
Also,
integral
control:
(1+0.25w)
w
= 1/w + 0.25 and

GzPI= 0.1 + 0.25


(z-1)
C2D Conversion of continuous-time models to discrete time.
SYSD = C2D(SYSC,Ts,METHOD) 'matched' Matched pole-zero method (for SISO
z-plane pole Position & Time-Response
z-plane
wn2
G (s) = 2 .........s = -zw ± j w 1 - z 2

s + 2zw n s + wn2
1, 2 n n

Equivalent z - plane poles :


z = e sT = e -zw nT Ð ± wnT 1 - z 2 = rÐ ± q
s1, 2

- ln r = zw nT also wnT 1 - z 2 = q
Taking ..Ratio :
- ln r
z =
ln 2 r + q 2
1
wn = ln 2 r + q 2
T
1 -T
t = time cons tan t = =
zw n ln r
r = e -T /t
Method 2: Enter into Simulink Unit Step Response
T é z + 1ù é z - 1ù
P( z ) = K P + K I ê z - 1 ú + K D ê Tz ú
2 ë û ë û

Also, in Simulink: PID Optimization


PID Digital controller design
z-domain Root-Locus

Section 8.11

Example is an Integrated Question


Figure below shows the block diagram of a system controlled by a digital controller
GC(z).

r(t) + e(t) 100 y(t)


GC(s) ZOH K
T T 0 .05 s 2 + s
-
GC (z)

1.0 Determine the pulse transfer function for a sampling period of T=0.01 sec. (2)
2.0 With GC(z) = 1.0 and K = 1.0, derive the closed-loop system transfer function. Determine
the characteristic equation and its roots in the z-domain. Determine ζ and ωn. (7)
3.0 With GC(z) = 1.0. Make use of the w-transformation to create a Bode plot and hence
determine the system gain and phase margin. Determine what value of loop gain K
would make the system marginally stable-unstable. (11)
Determine the pulse transfer function for a sampling period of T=0.01 sec

n=[100];
>> d=[0.04 1.0 0.0];
>> gs=tf(n,d)

Transfer function:
100
------------
0.04 s^2 + s

>> gzoh=c2d(gs,0.01,'zoh')

Transfer function:
0.1152 z + 0.106
----------------------
z^2 - 1.779 z + 0.7788

Sampling time: 0.01


With GC(z) = 1.0 and K = 1.0, derive the closed-loop system transfer function.
Determine the characteristic equation and its roots in the z-domain. Determine ζ and
ωn.
gz_cl=feedback(gzoh,1)

Transfer function:
0.1152 z + 0.106
----------------------
z^2 - 1.664 z + 0.8848

Sampling time: 0.01

roots([1 -1.664 0.8848])

ans =

0.8320 + 0.4388i
0.8320 - 0.4388i
Select K=1.0
ωn= 49 rads/sec
ζ=0.125
%OS=0.73
With GC(z) = 1.0. Make use of the w-transformation to create a Bode plot and hence
determine the system gain and phase margin. Determine what value of loop gain K
would make the system marginally stable-unstable
2
+w
T 200 + w
z= =( )
2 200 - w
-w
T
200 + w
0.1152( ) + 0.106
G ( w) = 200 - w
200 + w 2 200 + w
( ) - 1.779( ) + 0.7788
200 - w 200 - w
- 0.0092w2 - 42.4 w + 8848
G ( w) =
3.558w2 + 88.4w

In order for system to become


marginally stable-unstable,
increase loop gain K to gain:

20logK=6.36dB, then crossover


point is at 180o phase shift,
hence K= 2.079.
Design Discrete PD Controller:
4.0 Let K=1.0, and hence make use of the root-contour method (varying KD) to design
a digital PD-controller described by the transfer function (T=0.01 sec):
K D ( z - 1)
GC ( z ) = K P +
Tz
K D ( z - 1)
GC ( z ) = K P +
Tz
K PTz + K D ( z - 1)
GC ( z ) =
Tz
z + 100 K D ( z - 1)
GC ( z ) =
z
hence
z + 100 K D ( z - 1) 0.1152 z + 0.106
* 2
z z - 1.7788 z + 0.7788

Note: In order not to influence the steady state error of the system, we set KP = 1. Vary
KD to achieve the minimum amount of overshoot. ALSO, NOTE CL Transfer Function !!!
hence, from characteristic equation, 1 + GH = 0
K D (11.52 z 2 - 0.92 z - 10.6)
1+
z 3 - 1.6636 z 2 + 0.8848 z

Use rlocus(gz) from


Matlab commandline
to create a rootlocus:

Vary Gain, hence KD,


until minimum
overshoot is found.
Design State Feedback Controller:
5.0 Determine the state space equations for the open loop transfer function (pulse
transfer function, K=1.0). Design a state feedback controller so that the characteristic
equation roots of the closed loop system are at z= 0.5 and 0.5.

State Feedback Control


Phase 1
(variable setpoint)
z1,2 = 0.5, 0.5

Desired Equation
gz=tf(nz,dz, 0.01)

Transfer function:
0.1152 z + 0.106
----------------------
z^2 - 1.779 z + 0.7788
Sampling time: 0.01

>> [A,B,C,D]=tf2ss(nz,dz)
A = 1.7790 -0.7788
1.0000 0
B= 1
0
C = 0.1152 0.1060
D= 0
>> K=acker(A,B,[0.5 0.5])
K=
0.7790 -0.5288
Fin

You might also like