Digital Control Systems
(SS2023)
Computer Lab 2
Report on
Digital Control
(PID CONTROL & DIRECT SYNTHESIS METHOD)
Prepared by:
Madhuri Salluri
Adeyemi Mayowa
Date: 09-05-2023
1
Table of Contents:
Part I: PID Control
3
Task I.1
1.1.1 Introduction
3
1.1.2 Task 3
a. Building and testing in Simulink the continuous control system
3
b. Selecting the appropriate sampling time
4
c. Determine the transfer function of the digital PID
6
d. Simulation of the digital control loop
6
e. Comparing the response
8
Task I.2
10
a. Identifying the process as a first order with dead time
10
b. Calculating the parameters of the PID Using ITAE criterion
11
c. Determining an appropriate sampling period for the system
12
d. Closed-loop system response
13
e. Analyzing the effect of changing the sampling time
15
f. Selecting a different tuning criterion and compare the results.
17
Part II: Direct Synthesis Method
20
2.1 Introduction
20
2.2 Dead Beat Control
20
a. Select an adequate Sampling Time
20
b. Design and Implementation of the control in a Discrete Filter block.
21
c. Testing the system
22
2.3: Dahlin control.
23
a. Selection of sampling time
23
b. Implementation of the Dahlin control in a Discrete Filter block
23
2
c. Testing the system 24
d. Results and Conclusion
25
2.4: Kalman Control 25
a. Selection of sampling time. 25
b. Implementation of the Kalman control in a Discrete Filter block
25
Part I: PID Control
Task I.1
1.1.1 Introduction:
3
A PID controller, which stands for Proportional-Integral-Derivative controller, is a commonly
used feedback control algorithm in the field of engineering and automation.
The PID controller consists of three main components:
Proportional (P) term: The proportional term provides a control action that is directly
proportional to the error signal. It scales the error by a gain factor known as the proportional gain
(Kp).
Integral (I) term: The integral term accounts for the accumulation of past errors over time. It
integrates the error signal and multiplies it by the integral gain (Ki).
Derivative (D) term: The derivative term considers the rate of change of the error signal. It
calculates the derivative of the error with respect to time and multiplies it by the derivative gain
(Kd).
1.1.2 Task:
The relationship between the input voltage (in volts) and the output speed (rad/sec) of a micro
servo motor is given by the following transfer function:
360000
𝐺(𝑠) = ------------ (1)
( s+60)(s+ 600)
For the continuous-time case, it has been determined that a PID controller with proportional gain
Kc=2, integral time Ti=0.02 sec and Td=0.0002 sec results in acceptable performance.
If it is desired to change this control loop to a digital version:
a) Build and test in Simulink the continuous control system.
For the given transfer function Equation (1), the designed simulink model of the PID
controller is shown in figure (1) & is constructed using the given values of proportional
gain Kc=2, integral time Ti=0.02 sec and Td=0.0002 sec shown in figure (2) and the
simulation results is also seen in figure (3) respectively.
Figure 1: Simulink model of PID Controller for the given transfer function.
4
Figure 2: Block Parameters of PID Controller
Figure 3: Simulation results for the PID Controller.
b) Select the appropriate sampling time. Justify.
The appropriate sampling time selected was 0.001 because, the sampling time should be
small enough to capture the quick changes in the controlled system. If the system changes
rapidly, a smaller sampling time is needed. If it changes slowly, a larger sampling time
5
can be used and also by selecting a smaller sampling time can help reduce the impact of
noise on measurements and improve control accuracy.
Figure 4: Simulink Model of PID Controller using Zero Hold block.
The figure (4) & (5), shows the designed PID controller with zero hold block using
simulink for the selected sampling time of 0.002 and simulation results respectively.
Figure 5: Simulation Results of PID controller using Zero Hold block.
6
c) Determine the transfer function of the digital PID (ideal structure without filter for the
derivative term) using the method of a backward Euler difference.
1 de (t)
u ( t )=k c e ( t ) +
Ti
∫ e (t)dt +Td
dt
---------- (2)
1
T i−−−K i=
T
Applying Laplace transform for equation (2), we get
1 e (s ) k
u ( s )=k c e ( s ) + +T d e ( s ) s p
Ti s Ti
[
u ( s )=k c 1+
1 e (s )
Ti s ]
+ T d s e ( s )−−−−−ideal form ------ (4)
In terms of Ki, Kp and Kd for continuous time PID. To discretize the PID controller, to convert the integral
and derivative terms to their discrete time counterpart by using backward Euler method. Given the
sampling period Ts, the integral term Ki/s can be represented Backward Euler,
In discrete form by the derivative term can be discretised as
−1
(1−Z )
s= ------- (4)
T
By substituting the equation (4) in equation (3), the resulting discrete-time PID controller using
backward Euler methods for both integral & derivative terms are given by,
U (s) Ts Td ( 1−Z −1)
=Kc[1+ + ] --------- (5)
E(s) Ti(1−Z −1 ) Ts
(or)
U (s) Ts . Z Td ( Z−1 )
=Kc[1+ + ] ----------- (6)
E(s) Ti(Z−1) Ts. Z
d) Perform a simulation of the digital control loop (using Simulink). Don’t use the PID
block from Simulink, you should implement the controller in a discrete-transfer function
block or in a digital filter block.
To design the PID controller without using the PID block from the simulink library, involves
creating the components of the controller individually such as, Proportional gain (Kc),
Integral gain (Ki) & Derivative gain (Kd) and implementing their functions.
In the lab Script, the values given for PID controller are proportional gain Kc=2, integral
time Ti=0.02 sec and Td=0.0002 sec.
Now using the above values, calculating the Integral gain (Ki) & Derivative gain (Kd) gives
the below values.
7
Kc 2
Ki = = = 100 (since, Kc = 2 & Ti = 0.02)
Ti 0.02
Kd = Kc * Td = 2 * 0.0002 = 0.0004
Substituting the above values of Ki, Kc, Kd & Ts = 0.002, in the transfer function equation
(6),
U (s) Ts . Z Td ( Z−1 )
=Kc[1+ + ]
E(s) Ti(Z−1) Ts. Z
we get,
U ( s) Ts. Z 0.0002 ( Z−1 )
=2[1+ + ]
E(s) 0.02(Z−1) Ts . Z
U ( s) Ts . Z ( Z −1 )
=2[1+(50) +(0.0002) ] ----- (7)
E(s) ( Z−1 ) Ts . Z
Now, the designed PID controller using the above equation (7) in Simulink is shown in figure
(6) and the simulation results in figure (7) respectively.
Figure 6: Simulink Model of PID Controller without using the PID block
8
Figure 7: Simulation results of PID Controller without using the PID block
e) Compare the response of the digital control system against the continuous one.
Increasing the proportional gain (Kc) has the effect of proportionally increasing the control
signal for the same level of error. Another effect of increasing Kc is that it tends to reduce, but
not eliminate, the steady-state error. The addition of a derivative term, however, has no effect on
the steady-state error.
The general effects of each controller parameter (Kc, Kp, Kd) on a closed-loop system are
summarized in the below table:
CL RESPONSE RISE TIME OVERSHOOT SETTLING TIME Steady-State ERROR
Kc Decrease Increase Small Change Decrease
Ki Decrease Increase Increase Decrease
Kd Small Change Decrease Decrease No Change
9
Figure 8: Simulink model of PID controller with and without PID block
Figure 9: Simulation results of PID controller to compare the response.
10
Task I.2
[2] The rotational velocity 𝜔 of the satellite shown in Figure 1 is adjusted by changing the
length of the beam L. The transfer function between 𝜔(𝑠) and the incremental change in
beam length Δ𝐿(𝑠) is:
ω(s) 2.5(s+ 2)
= ----- (8)
ΔL(s) (s+5)(s+1)2
Perform the following steps with the help of MATLAB/Simulink:
a. Identify the process as a first order with dead time.
By using the using Taylor method, we can identify the given 3 rd order system to a first
order system as below,
−t s
ω(s)
= Ke ------ (9)
o
ΔL(s) τs+ 1
To calculate the gain K, substitute s=0 in the equation (8)
ω(s) 2.5(0+2)
= =1
ΔL(s) ( 0+5 ) ( 0+1 )2
K= 1; τ = 1 & t o=1+1=2
−2 s
ω(s) 1e
Now, substitute the values in equation (9), we get =
ΔL(s) s+1
Using the Taylor method, the simulink model is shown in figure (10) with deadtime,
t o=¿ 2 and the simulation results are shown in figure (11).
Figure 10: Simulink Model of the system using Taylor method
11
Figure 11: Simulation results of the system using Taylor Method with deadbeat 2.
b. Calculate the parameters of the PID (non-interactive with filter for the derivative
term). Use ITAE criterion.
To calculate the parameters of the PID, we have different forms, but here we are
considering the non-interactive form of PID for setpoint change equations from the
script and is shown in table1.
Table 1: Integral criteria for non-interactive form of PID (Setpoint Change)
Substituting the values of deadtime t o=2 , K=1∧τ=1∈the above equations, we get
0.983 2 −0.4985
Kc = ( ¿¿ = 0.694
1 1
1 2 2.2977
Ti = ( ¿¿ = 1.811
2.7134 1
12
2 0.1676
Td = 0.214 * 1( ¿¿ = 0.240
1
Substituting all the above values in the transfer function, we get
U (s) Ts 0.24 ( 1−Z −1 )
=0.694 [1+ + ]
E(s) 1.811(1−Z −1 ) Ts
c. Determine an appropriate sampling period for the system. Justify.
For control purposes, to discretize a continuous transfer function (expressed in the
Laplace domain), the criterion taken is the step response time, in particular the rise time.
Recall that the rise time is typically described as the time required for the system
response to increase from 0 to 90%.
It is proposed that the sampling time (or sampling period) be chosen such that there are 4
to 10 samples of the step response of a transfer function in terms of the rise time, i.e., that
𝑡𝑟 /10 < 𝑇 < 𝑡𝑟/ 4 where 𝑡𝑟 is the rise time of the system (described by the transfer
function) when a step is applied at the input.
We can verify, this type of systems with a step input, have a rise time that ranges between
3 and 4 time-constants,
𝑡𝑟 = 3𝜏 = 3(1) = 3
Therefore, the sampling time 𝑇 can be chosen as:
3/10 < 𝑇 < 3/ 4 = 0.3 < 𝑇 < 0.75
Figure 12: Simulink model of the system with sampling period, 0.4
The figure 12 & 13 shows the simulink model and simulation results of the system using
the calculated parameters of Kc, Kd, Ki, Ti & Td along with sampling period of 0.4
(selected between the range 0.3 < 𝑇 < 0.75)
13
Figure 13: Simulation results of the system
d. Check the closed-loop system response by a change in the setpoint.
With PID control the critical issue is that the sampling period must be so short that the
phase lead is not adversely affected by the sampling. This implies that the sampling
period should be chosen so that the number
𝑇 𝑁/𝑇𝑑 is in the range of 0.2 to 0.6
Figure 14: Simulation results of the system with sampling period = 0.2
14
Figure 15: Simulation results of the system with sampling period = 0.5
Figure 16: Simulation results of the system with sampling period = 0.6
From the above figures 14, 15 & 16, we can observe that the
15
e. Analyze the effect of changing the sampling time: First propose a sampling period 4
times longer than the original one and then one 4 times shorter. Write down your
conclusions.
For the selected sampling period 0.4 (used the value from calculation in point c),
proposing a sampling period 4 times longer than the original one gives the value
0.4*4=1.6 and is shown in figure 17.
Figure 17: Simulink model with sampling period 1.6
Figure 18: Simulation results with sampling period 1.6
16
Similarly, proposing a sampling period 4 times shorter than the original one gives, 0.4/4 =
0.1 and is shown in figure 19.
Figure 19: Simulink model with sampling period 0.1
Figure 20: Simulation results with sampling period 0.1
17
f. Select a different tuning criterion and compare the results.
Figure 21: Simulink model along with calculated parameters
18
Figure 22: Simulation results with the response time 1.537 and transient behaviour 0.6
During the tuning process of the PID controller, an overshoot in the system was observed
in the graph shown below. The system exhibited a response time of 1.5, indicating the
time it takes to reach a stable state. Additionally, the transient behavior of 0.6 indicates
the oscillatory nature of the system before settling. The presence of overshoot in the
system response suggests that the PID controller's parameters need further adjustment to
minimize this overshooting effect.
19
Figure 23: Simulation results with the response time 0.243and transient behaviour 0.243
While tuning the PID controller, the system response exhibited a response time of 0.243
units. This response time indicates the time required for the system to reach a stable state.
Additionally, a transient behavior of 0.243 was observed, suggesting oscillatory motion
before settling. The graph below depicts the presence of overshoot in the system,
highlighting the need for further adjustment of the PID controller's parameters to
minimize overshooting effects.
20
2. Part II: Direct Synthesis Method
2.1 Introduction
Direct synthesis methods are commonly employed in control systems utilizing discrete
controllers. These methods rely on the utilization of the Z-transform to design discrete
controllers. By employing the c2d command in MATLAB, a discrete transfer function
can be derived, taking into consideration the desired sampling frequency and utilizing the
Zero-Order Hold (ZOH) method.
In a recent laboratory experiment, PI and D controllers were implemented, and their
performance was deemed satisfactory. However, it is possible to attain optimal system
behavior by employing direct synthesis methods. Therefore, the following direct
synthesis controllers were investigated:
1. Dead-Beat Control: Dead-beat control is a technique that aims to bring the system to its
desired state in the shortest possible time, eliminating any transient response. By utilizing
this method, the controller attempts to achieve zero error in a finite number of time steps.
2. Dahlin Control: Dahlin control is a type of predictive control that incorporates a model
of the process dynamics. This controller calculates control actions based on predictions of
the future behavior of the system, allowing for better disturbance rejection and enhanced
performance.
3. Kalman Control: Kalman control utilizes the Kalman filter to estimate the current state
of the system. This estimated state information is then used in the control algorithm to
generate optimal control actions, taking into account uncertainties and noise in the
system.
2.1: Dead-Beat Control
The first option of the system given above was used for the direct synthesis method.
The relationship between the input voltage (in volts) and the output speed (rad/sec) of a
micro servo motor is given by the following transfer function:
360000
𝐺(𝑠) =
( s+60)(s+ 600)
a. Select an adequate Sampling Time
The sampling time for Dead-Beat Control can be obtained by considering the desired
settling time of the system. Since Dead-Beat Control aims to eliminate transient response
and achieve zero error in a finite number of time steps, the sampling time can be
approximated to ensure that the system reaches steady state within the desired settling
time. However, there is no explicit sampling time in Dead-Beat Control as it depends on
various factors such as system dynamics, desired performance, and hardware limitations.
The dead-beat control sampling time was obtained using the formula that was available in
the class script which is below:
θ=NT∗f
21
In this case, the sampling time (T) is determined as a parameter. The variable N
represents an integer value. Additionally, with a value of zero for f, the output does not
exhibit any oscillations or ringing. The selected continuous transfer function does not
possess any dead time, resulting in a theta value of zero. Consequently, the sampling time
is chosen to align with the desired settling time of the plant as 0.01.
b. Design and Implementation of the control in a Discrete Filter block.
To design the discrete filter block, calculations are performed using a MATLAB script.
The formula utilized is derived from the lecture script that was provided.
Matlab Script for converting continuous to discrete transfer function
% Define the transfer function
num = 360000;
den = [1 660 36000];
G = tf(num, den);
% Define the sampling time
Ts = 0.01;
Gz = c2d(G, Ts)
The generated z transform,
Gz =
3.905 z + 0.5959
------------------------
z^2 - 0.5513 z + 0.00136
Sample time: 0.01 seconds
Once the discrete transfer function is acquired, the Simulink model incorporates the dead-
beat control by utilizing the discrete filter block.
−1
Z 1
D(Z) = −1 =
1−Z Z−1
22
Figure 24: Design and Implementation of the control in a Discrete Filter block
The output of the system is observed below as shown in the figure 25.
Figure 25: Simulation results with D(Z) and Gp(Z) with sampling time 0.01
c. Testing the system for changes in the set-point as well as for disturbances.
At different values of set points and the sampling time of 0.1, we test the system to see
the output and the disturbance acted on the system.
Figure 25: Simulation result when the system was tested with sampling time 0.1
d. Results and Conclusions.
The transfer function for the dead-beat controller has been successfully derived and
applied through direct synthesis to the designated plant. Moreover, the controller has been
subjected to various conditions, and the results confirm the effectiveness of the dead-beat
controller.
23
Task 2.3: Dahlin control.
The relationship between the input voltage (in volts) and the output speed (rad/sec) of a
micro servo motor is given by the following transfer function:
360000
𝐺(𝑠) =
( s+60)(s+ 600)
To implement the Dahlin control, the above system is considered
a. Selection of sampling time
The sampling time was obtained using the formula that was available in the class script
which is below:
θ=NT∗f
In this case, the sampling time (T) is determined as a parameter. The variable N
represents an integer value. Additionally, with a value of zero for f, the output does not
exhibit any oscillations or ringing. The selected continuous transfer function does not
possess any dead time, resulting in a theta value of zero. Consequently, the sampling time
is chosen to align with the desired settling time of the plant as 0.01.
b. Implementation of the Dahlin control in a Discrete Filter block
To design the discrete filter block, calculations are performed using the formula derived
from the lecture script that was provided.
1 −1
∗Z
D(Z) = HGp (Z )
−1
1−Z
Figure 27: Design and Implementation of the Dahlin control
The graph below illustrates the results of the applied Dahlin controller. It combines the
step input, desired output, and output of the Dahlin controller onto a single graph.
24
Figure 28: The Output Design and Implementation of the Dahlin control
c. Testing the system for changes in the set-point as well as for disturbances and at least
two different values of lambda.
The Figure below represents the output of the system when the Dahlin Controller was
implemented with different lambda values. It combines the step input, desired output, and
output of the Dahlin controller onto a single graph. The values of the lambda used is 0.05.
Figure 29: The Output of the system with Different Lambda Values
25
d. Results and Conclusions.
The transfer function for the Dahlin controller is successfully derived and employed
through direct synthesis for the designated plant. Moreover, the controller undergoes
testing under various conditions, including changes in set points, lambda value, and the
introduction of disturbances in the system. The Dahlin controller demonstrates its
effectiveness by delivering results that meet the specified requirements.
Task 2.4: Kalman Control
The relationship between the input voltage (in volts) and the output speed (rad/sec) of a
micro servo motor is given by the following transfer function:
𝐺(𝑠) = (360000 )/((s + 60) (s + 600))
To implement the Kalman control, the above transfer function is used
a. Selection of sampling time.
The sampling time was obtained using the formula that was available in the class script
which is below:
θ=NT∗f
In this case, the sampling time (T) is determined as a parameter. The variable N
represents an integer value. Additionally, with a value of zero for f, the output does not
exhibit any oscillations or ringing. The selected continuous transfer function does not
possess any dead time, resulting in a theta value of zero. Consequently, the sampling time
is chosen to align with the desired settling time of the plant as 0.01.
b. Implementation of the Kalman control in a Discrete Filter block
In order to design the discrete filter block, calculations are performed using a MATLAB
script. The formula utilized is derived from the lecture script that was provided. Below is
the MATLAB Script below
param1 = tf('s');
param2 = tf('z', 0.01);
param3 = 0.03; % time constant
param4 = [0.20];
param5 = 0.5;
num = 360000;
den = [1 660 36000];
G = tf(num, den);
stepplot(G);
S = stepinfo(G);
sys = c2d(G, param4, 'zoh');
sysr = 1 / sys;
T = param5*param2^-1 * (1-param5)*param2^-2;
D = sysr * T / (1 - T);
[param6, param7, param8] = tfdata(D);
Dd = tf(param6, param7, param8, 'variable', 'z^-1');
26
[param9, param10, param11] = tfdata(Dd);
n = cell2mat(param9);
d = cell2mat(param10);
The Matlab Script for the transfer function calculation
3 Software Directory:
Software used Matlab R2021a
4 Date and Signature
(11-06-2023) (11-06-2023)
27