Professional Documents
Culture Documents
INTRODUCTION
The digital control systems have been introduced in control system to improve the tracking
performance for complex systems. This is due to the price of devices that have been improved
dramatically during past decade. Figure below shows a block diagram of a single-loop digital
control system.
The digital computer (or micro-Controller, microprocessor) receives the error or only the
reference signal and performs calculations (program) in order to provide an output near or
equals the desired signal.
Advantages of digital computers: The use of digital computers in the control systems yields
the following advantages over analog control systems:
1. Reduced cost,
1|Page
2. Flexibility in response to design changes,
3. Noise immunity
4. Digital control systems are more suitable for Modern control systems.
From the tracking performance side, the analog control system exhibits good performances than
digital control system. Indeed, the digital control system will introduce a delay in the loop.
The loop (forward and feedback) contains both analog and digital signals must provide a means
for conversion from one form to other to be used by each subsystem. A device that converts
analog signal to digital signal is called Analog-to-Digital Converter (ADC). Conversely, a
device that converts digital signals to analog signals is called a Digital Analog Converter
(DAC).
Digital-To-Analog Conversion:
From the binary number each bit is
properly weighted voltages and are
summed together to yield analogue
output.
Analog-To-Digital Conversion:
ADC is not instantaneous and needs two-step process. There is a delay between the analog input
voltage and the output digital word. In ADC, the analog signal is first converted to a sampled
signal and then converted to a sequence of binary numbers, the digital signal.
The sampling rate must be at least twice the bandwidth of the signal. In figures below we see
the analog signal sampled at periodic intervals and held over the sampling interval by a device
called a zero-order-hold (Z-O-H) that yields a staircase approximation to the analog signal.
2|Page
After sampling and holding, the ADC converts the sample to a digital number (see figure c).
From figure b, we deduce that the difference between two levels is and for n bits where
23 2
M is the maximum voltage of the signal to be converted. Also from figure b, we can see that
there will be an error for each digitized analog value. We call this error the quantization error.
The quantization error is bounded by: || where n is the number of bits and M is the
2
maximum voltage. Note to reduce this quantization error, we have to increase the number of
bits used in word.
3|Page
Digital Control System
G(z)
We have already
the controller D(s)
Design Using Root
Locus
Euler-
Approximation
D(z)
Difference equation
Difference equation
Simulation
Simulation
Real-time
Real-time
implementation
implementation
4|Page
For the approximation methods, used to convert the continuous controller to digital controller,
are: Euler method, Trapezoidal method etc and we can use forward or backward
approximation.
(+1)()
= this is a forward approximation,
()(1)
= this is a backward approximation. T is the sampling time.
Afterwards, the differential equation of the controller can be transformed to difference equation
where this difference equation can be easily programmed as a control algorithm.
Its assumed that we have already designed a continuous PID controller and we want to
implement it using a digital controller.
( )(1) ( )(1)
= ; =
and
() ( 1) ( 1) ( 2)
=
() 2 ( 1) + ( 2)
=
2
The difference equation of the controller is:
( ) = ( 1) + 1 + + ( ) 1 + 2 ( 1) + ( 2)
5|Page
Or
() = ( 1) + () ( 1) + ( 2)
Where = 1 + + ; = 1 + 2 and =
+2
Example: Find the digital controller to implement the compensator () = 70 for the
+10
1
plant () = using sample rate of 20Hz and 40Hz.
(+1)
MATLAB Code:
clear
% plant definition
numG=1;
denG=[1 1 0];
% continuous compensation
Ko=70;
a=2; % D(s) zero
b=10; % D(s) pole
numD=Ko*[1 a];
denD=[1 b];
num=conv(numG,numD);
den=conv(denG,denD);
[numcl,dencl]=feedback(num,den,1,1);
tf=1;
t=0:.01:tf;
yc=step(numcl,dencl,t);
subplot(2,1,1)
plot(t,yc,'-'),grid
axis([0 1 0 1.5])
hold on
N=tf*Ws;
yd=dstep(numcld,dencld,N);
td=0:T:(N-1)*T;
plot(td,yd,'*')
plot(td,yd,'-')
ylabel('output y')
title('Fig. 3.2 Continuous and digital response
using Eulers method')
text(.25,.1,'*-----*-----* digital control')
text(.25,.3,'------------- analog control')
text(.35,.6,' (a) 20 Hz')
6|Page
hold off
Ws= 40; % Hz
T=1/Ws;
[numGd,denGd]=c2dm(numG,denG,T,'zoh');
numDd=Ko*[1 -(1-a*T)];
denDd=[1 -(1-b*T)];
numd=conv(numGd,numDd);
dend=conv(denGd,denDd);
[numcld,dencld]=feedback(numd,dend,1,1);
N=tf*Ws;
subplot(2,1,2)
plot(t,yc,'-'),grid
hold on
yd=dstep(numcld,dencld,N);
td=0:T:(N-1)*T;
plot(td,yd,'*')
plot(td,yd,'-')
xlabel('time (sec)')
ylabel('output y')
text(.25,.1,'*-----*-----* digital control')
text(.25,.3,'------------- analog control')
text(.35,.6,' (a) 40 Hz')
hold off
The step response of the process closed by a continuous controller and discrete controller for
different sampling rate.
1
output y
(a) 20 Hz
0.5
1.5
1
output y
(a) 40 Hz
0.5
7|Page
Modeling the sampler:
Consider the models for sampling shown in figure below. The model is a switch turning on and
off at a uniform sampling rate.
In figure b sampling can also be considered to be a product of the time waveform to be sampled
() and a sampling function ().
8|Page
().
The time equation of the sampled waveform, Using the model shown above, we have:
= ()() = () ( ) ( )
=
Where k is an integer, T is the period of the pulse train and is the pulse width.
9|Page
() = () ( )
=
To find the transfer function of the Z-O-H, just we send an impulse in the input and from the
output response; we can deduce the transfer function.
10 | P a g e
impulse
0 T
1 1 1
() = () = =
The Z-Transform:
Laplace transform of a sampled signal r*(t) is:
() =
= () ( ) () = = () ( )
() = = () ( )
=
= ()
its nonlinear. To overcome
the nonlinearity problem, we transform S-domain to another domain where the operator is
linear: Z- domain by setting: = .
() = ()
=
Solution: () = with || 1
(1)2
11 | P a g e
1+1
Hint: use
=0 = .
1
If = then () = .
12 | P a g e
Some Properties:
13 | P a g e
Z-transform from s-Domain:
1
1. Partial fraction: Knowing that Z-Transform of: ,
+
Thus,
0 1
() = + + () = 0 + 1 +
+0 +1 0 1
2
Example: Find the Z-transform of () =
2 +5 6
2. Using Residue:
() = () ()
=1
() =
=1
14 | P a g e
1
Example: Find the Z-transform of () =
2 (+1)
K1=
K2=
K3=
Thus,
() = + +
0.5
Example: Find the inverse z-transform of: () = (0.5)(0.7)
15 | P a g e
The ideal sampled time function is:
() = () 1 () 1
=1
() =
=1
Example:
(1 )
Find the inverse Z-transform of () = (1)( )
16 | P a g e
b. If z= is a multiple pole of order q, then the jth residue is:
1 1
= (1)!
lim 1 {( ) () 1 } , for j=1,2,..
Example:
2 2
1 () = and 2 () =
(1)2 ( ) (1 1 )3
Solution:
17 | P a g e
Transfer function of discrete System:
18 | P a g e
() = () () = ()()
=0 =0
How to use MATLAB to write a transfer function
Transfer function:
1
-------------
s^2 + 2 s + 1
Transfer function:
0.004679 z + 0.004377
---------------------
z^2 - 1.81 z + 0.8187
19 | P a g e
Y(s)
E(s) E*(s)
T
Zero Order Hold
Z.O.H G(s)
G(z)
1
We have () = () () = ().
1
Solution: 2 () = .
1
Example 3: Let 3 () = , find 3 () ?
2
2 +1
Solution: 3 () = .
2 (1)2
MATLAB Code :
>> T=1;Num=1;Den=[1 0 0];
>> sysc=tf(Num,Den);
>> sysd=c2d(sysc,T,'zoh')
Transfer function:
0.5 z + 0.5
-------------
z^2 - 2 z + 1
Sampling time (seconds): 1
20 | P a g e
Block Diagram Reduction
The rule is: {1 ()2 ()} 1 ()2 ()
Or {1 ()2 ()} 1 () 2 ()
and
{1 ()2 () } = 1 () 2 ()
21 | P a g e
Stability:
In this part, we will see the stability of the digital system and the effect of the
sampling time on the stability. The stability of digital system can be analyzed in Z-
Domain or in S-Domain.
We know that in S-plane, the stability region is in the left-Plane of the S-Domain. If
the transfer function G(s) is transformed into a digital transfer function G(z), the
region of stability on the z-plane can be evaluated from the definition: =
Letting = + , we obtain:
From the above equation, we can deduce that the stable domain that corresponds to
<0, lies inside the unity circle, the jw (=0) axis lies on the unity circle, and the
unstable domain >0 lies outside the unity circle.
Thus, a digital system is stable if and only if all poles of the closed-loop
transfer function T(z) are inside the unity circle.
22 | P a g e
The digital system is unstable if any pole of the closed-loop transfer
function T(z) is outside the unity circle.
The digital system is marginally stable if poles of multiplicity one of the
closed-loop transfer function T(z) are on the unity circle and other are
inside the unity circle.
1
Where () = +2 and T=0.5s.
() 0.316
() = (1 1 ) =
0.368
() 0.316
() = 1+() = 0.05 since the pole is inside the unity circle then the
system is stable.
MATLAB Code:
>> T=1;Num=1;Den=[1 2]; >> sysclD=feedback(sysd,1)
>> T=0.5;Num=1;Den=[1 2];
>> sysc=tf(Num,Den); Transfer function:
>> sysd=c2d(sysc,T,'zoh') 0.3161
-----------
Transfer function: z - 0.05182
0.3161
---------- Sampling time (seconds): 0.5
z - 0.3679
Sampling time (seconds): 0.5
23 | P a g e
We can check the stability with regards to the sampling period T:
0.5 1 2
() = The system is stable for all T >0.
(1.5 2 0.5)
10 1 10 1
Let () = +1 () = 10 and () =
(11 10)
24 | P a g e
Thus system is unstable and
has 1 pole outside the unity
circle. No pole on the unity
circle and two poles inside
the unity circle.
Jurys Stability test: In this course, we will use this test only for second
order system (For more general system see Ogatas book).
Let the characteristic equation given by: () = 2 2 + 1 + 0
The system is stable if:
1. Q(1) >0;
2. Q(-1) > 0;
3. |0 | < |2 |
0.368 +0.264
Example: Let the digital system defined by: () = 2 1.368 +0.368
Determine the range of K that ensures the stability of the system K G(z)
closed by unity feedback.
() = 1 + () = 2 + (0.368 1.368) + 0.368 + 0.64=0
(1) = 1 + 0.632 > 0
|0 | < |2 | |0.368 + 0.264 | < 1
25 | P a g e
Steady state error:
We now examine the effect of sampling upon the steady state error.
Consider the digital system given below:
()
From the figure, we have: () = () (), or: () = 1+().
1
The steady state error for this case is: = () =
26 | P a g e
1
where = lim1 ( 1)()
(+)
Unit Parabolic Input: () = ()
1
The steady state error for this case is: = () =
1
where = 2 lim1 ( 1)2 ()
10
Example: Let the open-loop transfer function 1 () = (+1) for the
system shown previously
1
With the ZOH, we obtain: 1 () = 10 1 1 + ;
Thus:
1. For a step input: = lim1 1 () = ess=
1
2. For a ramp input: = ( 1)1 () = 10 ess=
1
3. For a parabolic input: = 2 lim1 ( 1)2 1 () = 0 ess=
Results are:
= 0.27; = 0.924; = 1.43; = 16; = 3.53; % =
41%; = 0.
System: sysdcl
Peak amplitude: 1.4
Overshoot (%): 40
At time (seconds): 3 Step Response
1.4
System: sys
Peak amplitude: 1.16
Overshoot (%): 16.3
At time (seconds): 3.59
1.2
System: sysdcl
Settling time (seconds): 15.3
System: sys 1
Rise time (seconds): 1.64
System: sys
Settling time (seconds): 8.08
System: sysdcl
0.8 Rise time (seconds): 1.57
Amplitude
0.6
0.4
0.2
0
0 5 10 15 20 25 30 35
Time (seconds)
Ts Tr Tp %OS Ts ess
0 0.5 1 1.638 3.62 16 8 0
1s 0.27 0.92 1.43s 3.54 41 16 0
0.1s 0.473 0.9951 1.6 3.58 18.51 8.5 0
Determine the gain K that leads to =0.5 (%OS=16) for the system:
1
() =
( + 1)
The easiest solution is to use MATLAB:
31 | P a g e
>> sys=tf(1,[1 1 0])
Root Locus
Transfer function:
1 2
-------
s^2 + s
1
Imaginary Axis
>> Gz=c2d(sys,0.1,'zoh')
0.5
Transfer function:
0
0.004837 z + 0.004679
----------------------
z^2 - 1.905 z + 0.9048
-1
Sampling time (seconds): 0.1
>> rlocus(Gz)
>> zgrid(0.5,0) -2
-6 -4 -2 0 2
Real Axis
Root Locus
0.2 System: Gz
Gain: 0.921
0.15 Pole: 0.95 + 0.0793i
Damping: 0.499
Imaginary Axis
0.05
-0.05
32 | P a g e
>> K=0.921; System: sysdcl
>> sysdcl=feedback(K*Gz,1) 1.4 Step amplitude:
Peak Response 1.17
Overshoot (%): 16.6
Transfer function: At time (seconds): 3.8
1.2
0.004455 z + 0.004309
---------------------
1
z^2 - 1.9 z + 0.9091
System: sysdcl
Amplitude
Sampling time (seconds): 0.1 0.8 Settling Time (seco
>> step(sysdcl)
0.6
0.4
0.2
0
0 2 4 6 8 10 12
Time (seconds)
33 | P a g e
>> rlocus(Gz) Root Locus
The system is stable:
1
0 < K< 22.3 System: Gz
Gain: 22.3
0.8
Pole: 0.894 + 0.448i
Imaginary Axis
Damping: 0.000296
0.6 Overshoot (%): 99.9
Frequency (rad/s): 4.65
0.4
0.2
0 0.5 1 1.5
Real Axis
Digital PD Controller:
1
Given a system (double integrator) modeled by: () = . We want to achieve the following
2
performances: Ts=0.5s, %OS=25% and zero steady state error.
System: syscl
0.8
0.2
Tr=0.0732s
Digital Controller:
34 | P a g e
MATLAB Code: System: sysdcl
>> sysd=c2d(sys, 0.1) Peak amplitude: 1.26 Step Response
1.4 Overshoot (%): 25.8
sysd = At time (seconds): 0.2
HOW to calculate
() ?
() ()
()()
= = () =
we have = ;
() 1+()() () ()
1+ 1+(())() 1+ ()
35 | P a g e
() =
For our case we will obtain: () () =
and
+ (+)
MATLAB Code:
>>Kp=400; Kd=16;Ps=tf(Kp,[1 Kd Step Response
1.4
0]);
>>syscl=feedback(Ps,1)
System: syscl
1.2 Peak amplitude: 1.25
Overshoot (%): 25.4
Same results At time (seconds): 0.17
System: syscl
Time (seconds): 0.425
Amplitude: 0.983
1
System: syscl
Rise time (seconds): 0.0734
0.8
Amplitude
0.6
0.4
0.2
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
Time (seconds)
For better Comparison use SIMULINK or MATLAB (command line with Sim wher the system
is represented by a Simulink file).
36 | P a g e