1 Sabancı University Faculty of Engineering and Natural Sciences Fall 2014 ME 303 CONTROL SYSTEM DESIGN LAB REPORT # 3 (Group Number1 & B) PID Controller Design Submitted by Alp Gabay-15369 Doğukan Er-15509 K. Selim Engin–16429 on 19.11.2014
Nov 19, 2015
1
Sabanc University
Faculty of Engineering and Natural Sciences
Fall 2014
ME 303
CONTROL SYSTEM
DESIGN
LAB REPORT # 3
(Group Number1 & B)
PID Controller Design
Submitted by
Alp Gabay-15369
Doukan Er-15509
K. Selim Engin16429
on
19.11.2014
2
INTRODUCTION The main aim of this lab is to see the effects of control parameters on a real system. Our
equipment consisted of a D-space device, DC motor with an encoder and a computer for
software. First of all, whole devices connected to each other properly and software configuration
took place. After that MATLAB project is created for simulation purposes. We were giving a
constant as an input and we were multiplying it with our transfer function and gain. By changing
the control parameters we tried to observe the effects of these parameters on our system. We
drew some graphs from the data we collected from our encoder that is attached to our motor and
the results of the graphs and the experiment is discussed below.
PROCEDURE In this lab our task was doing some experiments on D-space in order to understand what is effect
of control parameters on the output. At first we installed our D-space device and made the
configurations accordingly. After that, we created a MATLAB project in order to download into
D-space for our experimental purposes. Creating another windows for our observations was
another part of our task. We drew 3 graph for input, output and error values. Finally, we
changed the control parameters' values in a specific order to see their effect on the system,
output.
RESULTS
Figure 1. The results with parameters Kp=4
0 5 10 15 20 2511
12
13Kp = 4
Outp
ut
0 1 2 3 4 5 6 7 8 9 10-5
0
5
Err
or
0 1 2 3 4 5 6 7 8 9 10-20
0
20
Contr
ol In
put
3
Figure 2. The results with parameters Kp=100
Figure 3. The results with parameters Ki=0.1
0 1 2 3 4 5 6 7 8 9 100
1
2Kp = 100
Outp
ut
0 1 2 3 4 5 6 7 8 9-5
0
5
Err
or
0 1 2 3 4 5 6 7 8 9-500
0
500
Contr
ol In
put
0 10 20 30 40 50 60-50
0
50Ki = 0.1
Outp
ut
0 10 20 30 40 50 60-50
0
50
Err
or
0 10 20 30 40 50 60-20
0
20
Contr
ol In
put
4
Figure 4. The results with parameters Ki=1
Figure 5. The results with parameters Kp=3 Ki=0.1
0 10 20 30 40 50 60-20
0
20Ki = 1
Outp
ut
0 10 20 30 40 50 60-20
0
20
Err
or
0 10 20 30 40 50 60-100
0
100
Contr
ol In
put
50 60 70 80 90 100 110 1205
5.5
6Kp = 3 Ki = 0.1
Outp
ut
50 60 70 80 90 100 110 120-1
-0.5
0Error
50 60 70 80 90 100 110 120-0.15
-0.1
-0.05Control Input
5
Figure 6. The results with parameters Kp=5 Ki=0.1
Figure 7. The results with parameters Kd=1
380 390 400 410 420 430 440 4500
0.01
0.02
Err
or
380 390 400 410 420 430 440 4500.06
0.08
0.1
Contr
ol In
put
380 390 400 410 420 430 440 450
4.985
4.99
4.995
5Kp = 5 Ki = 0.1
Outp
ut
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.5
1Kd = 1
Outp
ut
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.5
1
Err
or
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.5
1
Contr
ol In
put
6
Figure 8. The results with parameters Kp=3 Kd=1
Figure 9. The results with parameters Kp=3 Kd=2
0 1 2 3 4 5 6 7 8 90
5
10Kp = 3 Kd = 1
Outp
ut
0 1 2 3 4 5 6 7 8 9-5
0
5
Err
or
0 1 2 3 4 5 6 7 8 9-20
0
20
Contr
ol In
put
0 2 4 6 8 10 12 14 16 18 200
5
10Kp = 3 Kd = 2
Outp
ut
0 2 4 6 8 10 12 14 16 18 20-5
0
5
Err
or
0 2 4 6 8 10 12 14 16 18 20-20
0
20
Contr
ol In
put
7
Figure 10. The results with parameters Kp=3 Kd=5
Figure 11. Comparing the results of the output as the parameter Kd changes
0 2 4 6 8 10 12 14 16 180
5
10Kp = 3 Kd = 5
Outp
ut
0 2 4 6 8 10 12 14 16 18-5
0
5
Err
or
0 2 4 6 8 10 12 14 16 18-20
0
20
Contr
ol In
put
0 2 4 6 8 10 12 14 16 18 200
1
2
3
4
5
6Comparing PD Controllers (Output) Kp=3
R:
Kd=
1,
G:
Kd=
2 B
: K
d=
5
8
Figure 12. Comparing the results of the error as the parameter Kd changes
Figure 13. Comparing the results of the control input as the parameter Kd changes
0 2 4 6 8 10 12 14 16 18 20-1
0
1
2
3
4
5Comparing PD Controllers (Error) Kp=3
R:
Kd=
1,
G:
Kd=
2 B
: K
d=
5
0 2 4 6 8 10 12 14 16 18 20-2
0
2
4
6
8
10
12
14
16Comparing PD Controllers (Control Input) Kp=3
R:
Kd=
1,
G:
Kd=
2 B
: K
d=
5
9
Figure 14. The results with parameters Kp=1.5 Ki=0.02 Kd=0.15
Figure 15. The results with parameters Kp=1 Ki=0.01 Kd=0.1
0 5 10 15 20 25 30 350
10
20Kp = 1.5 Ki = 0.02 Kd = 0.15
Outp
ut
0 5 10 15 20 25 30 35-20
0
20
Err
or
0 5 10 15 20 25 30 35-50
0
50
Contr
ol In
put
0 5 10 15 20 25 30 35 400
5
10Kp = 1 Ki = 0.01 Kd = 0.01
Outp
ut
0 5 10 15 20 25 30 35 40-5
0
5
Err
or
0 5 10 15 20 25 30 35 40-10
0
10
Contr
ol In
put
10
Kp=4 Kp=100 Ki=0.1 Ki=1 Kp=3
Ki=0.1
Kp=5
Ki=0.1
Kd=1 Kp=3
Kd=1
Kp=3
Kd=2
Kp=3
Kd=5
Kp=1.5
Ki=0.02
Kd=0.15
Kp=1
Ki=0.01
Kd=0.1
5 5 23.42 15.3 -0.08 0.02 [] 5 5 5 5 5
2.76 2.85 12.65 8.2 0.28 0.006 [] 2.45 2.12 1.73 7.93 2.37
20 500 14.44 58.3 -0.08 0.07 [] 15 15 15 23.05 7.56
11.04 285.05 10.31 43.9 0.08 0.06 [] 6.82 5.85 3.9 8.31 1.58
tr 389 570 7721 929 41297 39833 - 1962 2201 3742 5034 2697
MP% 68 128 39 485 9 0 - 0 0 0 17 10
ts 5181 4481 56693 50891 54583 48970 - 4013 6042 7823 25806 30893
DISCUSSION
K. Selim Engin:
In the first case, we have used a low Kp value. There was a little overshoot at the
beginning. As we increased the Kp the response got worse. When Kp was between 2-4 the
system was not satisfactory since there were overshoots and undershoots. However,
interestingly, when we increased the Kp value more, the transient response became better.
There was almost no OS when Kp was larger than 4.
Then, we removed the proportional controller and added pure integral control. We
started with a low Ki value. The response to it was not satisfactory, because the system was
unstable and there were oscillations. We kept increasing the Ki however the response did not
change too much and the results were similar when we used a high Ki in pure integral control.
When we added Kp, the system became stable again. However, the settling time was
large and the transient response was not fine enough. The steady-state error and the control
input were zero.
Later, we used pure derivative controller. Pure derivative control is impractical due to
the undesirable noise amplification. In the layout the system was unstable. Because of the
amplified noise, we cannot see anything in the plots of Figure 7.
Afterwards, we added proportional controller to pure derivative control. The response of
it was quite satisfactory. As we increased Kd the settling time also increased.
At the end, we used PID controller. The responses were similar to the results in the pre-
lab. Thats why we picked parameter values that are close to the ones in the pre-lab. The
response of this controller was not the best. When we used PD control there was no OS. The
steady-state response was aloes satisfactory.
11
Alp Gabay:
As it was given in the lab task we started with a very small Kp value and increased it
slowly. From our observations, I can say that small Kp creates some under and overshoot but
as we increase it the percentage of these under and overshoots increased and the quality of the
system got worse.(when Kp is between 2 and 4). Surprisingly, when we exceeded 4 for the Kp
value we did not observe any overshoot.
After that we were asked to remove Kp and add some pure integral control. As we
expected regardless of the Ki value system was unstable. Increasing or decreasing the Ki value
did not affect the output drastically.
As the third task, we added some Kp value to the system and it simply became a PI
controller. That actions stabilized the system however it increased the settling time and we are
having a bad transient response.
Afterwards, we just put some pure derivative control to the system and it amplified our
noises in the system and we could not read any output and could not draw any graph from the
data. As a conclusion, I think it is useless to use pure derivative controller.
Then, we inserted a PD controller to our system. Results were okay and increasing Kd
allowed us to have smaller settling time and by changing Kp according to Kd values it was
possible to decrease the overshoot percentage.
Lastly, we put PID controller to the system. This should be the best of all systems that
we simulated but we encountered something different. In PD controller we managed to have
almost zero percent overshoot but in PID we could not reach that.
Doukan Er:
First of all, we started to observe the effect of Kp value as it was mentioned. We gave
small values of Kp to the system and continued to increase it. In a specific interval (2 and 4)
our system had some over and undershoot. When we reach to 4, overshoot of the system was
gone.
Secondly, we use pure integral control instead of Kp. Our observation was that the
system was very unstable does not matter which Ki value we insert.
Thirdly, we were asked to insert a PI controller. Adding Kp to our Ki, system became
stable but due to the integral gain we had very long settling time.
Later, we only inserted pure derivative controller to our system. That Kd increased our
noise in the output dramatically. That is why we could not observe anything on the output. For
that reason using a pure derivative controller is not logical.
Afterwards, we used a PD controller for our system. It had a very short settling time
with some overshoot. However, we can control the settling time as we desire and decrease the
overshoot to some extent.
At last, we put a PID controller for our system. In PID controller we managed to
control both settling time and overshoot percentage at the same time. However, we could
decrease the overshoot in PD controller more than PID.
12
CONCLUSION Using pure derivative or pure integral control for any kind of system is useless because it
makes our system unstable and impossible to control. However, PI and PD controllers did a
great job. PI controller had a longer settling time than PD that is why PD controller is the most
suitable one for this system. In our experiments we could not make overshoot equal to zero in
PID controller. However maybe spending more time on the decision of the control parameters'
values can lead to zero overshoot.
APPENDIX
% %% Low Kp
figure(1)
subplot(3,1,1)
plot(kp4_output.X.Data, kp4_output.Y.Data)
title('Kp = 4');
ylabel('Output');
subplot(3,1,2)
plot(kp4_error.X.Data, kp4_error.Y.Data)
ylabel('Error');
subplot(3,1,3)
plot(kp4_input.X.Data, kp4_input.Y.Data)
ylabel('Control Input');
%% High Kp
figure(2)
subplot(3,1,1)
plot(kp100_output.X.Data, kp100_output.Y.Data)
title('Kp = 100');
ylabel('Output');
subplot(3,1,2)
plot(kp100_error.X.Data, kp100_error.Y.Data)
ylabel('Error');
subplot(3,1,3)
plot(kp100_input.X.Data, kp100_input.Y.Data)
ylabel('Control Input');
%% Low Ki
figure(3)
subplot(3,1,1)
plot(ki01_output.X.Data, ki01_output.Y.Data)
title('Ki = 0.1');
ylabel('Output');
subplot(3,1,2)
plot(ki01_error.X.Data, ki01_error.Y.Data)
ylabel('Error');
subplot(3,1,3)
plot(ki01_input.X.Data, ki01_input.Y.Data)
ylabel('Control Input');
%% High Ki
figure(4)
subplot(3,1,1)
plot(ki1_output.X.Data, ki1_output.Y.Data)
title('Ki = 1');
ylabel('Output');
subplot(3,1,2)
plot(ki1_error.X.Data, ki1_error.Y.Data)
ylabel('Error');
subplot(3,1,3)
13
plot(ki1_input.X.Data, ki1_input.Y.Data)
ylabel('Control Input');
%% Low Kp + Low Ki
figure(5)
subplot(3,1,1)
plot(kp3_ki01_output.X.Data, kp3_ki01_output.Y.Data)
title('Kp = 3 Ki = 0.1');
ylabel('Output');
subplot(3,1,2)
plot(kp3_ki01_error.X.Data, kp3_ki01_error.Y.Data)
title('Error');
subplot(3,1,3)
plot(kp3_ki01_input.X.Data, kp3_ki01_input.Y.Data)
title('Control Input');
%% Higher Kp + Low Ki
figure(6)
subplot(3,1,1)
plot(kp5_ki01_output.X.Data, kp5_ki01_output.Y.Data)
title('Kp = 5 Ki = 0.1');
ylabel('Output');
subplot(3,1,2)
plot(kp5_ki01_error.X.Data, kp5_ki01_error.Y.Data)
ylabel('Error');
subplot(3,1,3)
plot(kp5_ki01_input.X.Data, kp5_ki01_input.Y.Data)
ylabel('Control Input');
%% Pure Kd (NO GRAPH)
figure(7)
subplot(3,1,1)
plot(kd1_output.X.Data, kd1_output.Y.Data)
title('Kd = 1');
ylabel('Output');
subplot(3,1,2)
plot(kd1_error.X.Data, kd1_error.Y.Data)
ylabel('Error');
subplot(3,1,3)
plot(kd1_input.X.Data, kd1_input.Y.Data)
ylabel('Control Input');
%% Kp(3) + Kd(1)
figure(8)
subplot(3,1,1)
plot(kp3_kd1_output.X.Data, kp3_kd1_output.Y.Data)
title('Kp = 3 Kd = 1');
ylabel('Output');
subplot(3,1,2)
plot(kp3_kd1_error.X.Data, kp3_kd1_error.Y.Data)
ylabel('Error');
subplot(3,1,3)
plot(kp3_kd1_input.X.Data, kp3_kd1_input.Y.Data)
ylabel('Control Input');
%% Kp(3) + Kd(2)
figure(9)
subplot(3,1,1)
plot(kp3_kd2_output.X.Data, kp3_kd2_output.Y.Data)
title('Kp = 3 Kd = 2');
ylabel('Output');
subplot(3,1,2)
plot(kp3_kd2_error.X.Data, kp3_kd2_error.Y.Data)
ylabel('Error');
subplot(3,1,3)
plot(kp3_kd2_input.X.Data, kp3_kd2_input.Y.Data)
ylabel('Control Input');
14
%% Kp(3) + Kd(5)
figure(10)
subplot(3,1,1)
plot(kp3_kd5_output.X.Data, kp3_kd5_output.Y.Data)
title('Kp = 3 Kd = 5');
ylabel('Output');
subplot(3,1,2)
plot(kp3_kd5_error.X.Data, kp3_kd5_error.Y.Data)
ylabel('Error');
subplot(3,1,3)
plot(kp3_kd5_input.X.Data, kp3_kd5_input.Y.Data)
ylabel('Control Input');
%% Comparing PD Controllers
figure(11)
hold on;
title('Comparing PD Controllers (Output) Kp=3');
ylabel('R: Kd=1, G: Kd=2 B: Kd=5')
plot(kp3_kd1_output.X.Data, kp3_kd1_output.Y.Data,'r')
plot(kp3_kd2_output.X.Data, kp3_kd2_output.Y.Data,'g')
plot(kp3_kd5_output.X.Data, kp3_kd5_output.Y.Data)
figure(12)
hold on;
title('Comparing PD Controllers (Error) Kp=3');
ylabel('R: Kd=1, G: Kd=2 B: Kd=5')
plot(kp3_kd1_error.X.Data, kp3_kd1_error.Y.Data,'r')
plot(kp3_kd2_error.X.Data, kp3_kd2_error.Y.Data,'g')
plot(kp3_kd5_error.X.Data, kp3_kd5_error.Y.Data)
figure(13)
hold on;
title('Comparing PD Controllers (Control Input) Kp=3');
ylabel('R: Kd=1, G: Kd=2 B: Kd=5')
plot(kp3_kd1_input.X.Data, kp3_kd1_input.Y.Data,'r')
plot(kp3_kd2_input.X.Data, kp3_kd2_input.Y.Data,'g')
plot(kp3_kd5_input.X.Data, kp3_kd5_input.Y.Data)
%% Kp(1) + Ki(0.02) + Kd(0.15)
figure(14)
subplot(3,1,1)
plot(kp1bucuk_kd015_ki002_o.X.Data, kp1bucuk_kd015_ki002_o.Y.Data)
title('Kp = 1.5 Ki = 0.02 Kd = 0.15');
ylabel('Output');
subplot(3,1,2)
plot(kp1bucuk_kd015_ki002_er.X.Data, kp1bucuk_kd015_ki002_er.Y.Data)
ylabel('Error');
subplot(3,1,3)
plot(kp1bucuk_kd015_ki002_i.X.Data, kp1bucuk_kd015_ki002_i.Y.Data)
ylabel('Control Input');
%% Prelab PID
figure(15)
subplot(3,1,1)
plot(prelab_o.X.Data, prelab_o.Y.Data)
title('Kp = 1 Ki = 0.01 Kd = 0.01');
ylabel('Output');
subplot(3,1,2)
plot(prelab_e.X.Data, prelab_e.Y.Data)
ylabel('Error');
subplot(3,1,3)
plot(prelab_i.X.Data, prelab_i.Y.Data)
ylabel('Control Input');
%% System Responses to Step Input
stepinfo(kp4_output.Y.Data)
stepinfo(kp100_output.Y.Data)
stepinfo(ki01_output.Y.Data)
stepinfo(ki1_output.Y.Data)
stepinfo(kp3_ki01_output.Y.Data)
15
stepinfo(kp5_ki01_output.Y.Data)
stepinfo(kd1_output.Y.Data)
stepinfo(kp3_kd1_output.Y.Data)
stepinfo(kp3_kd2_output.Y.Data)
stepinfo(kp3_kd5_output.Y.Data)
stepinfo(kp1bucuk_kd015_ki002_o.Y.Data)
stepinfo(prelab_o.Y.Data)
%% MAX Values Of Errors
max(kp4_error.Y.Data)
max(kp100_error.Y.Data)
max(ki01_error.Y.Data)
max(ki1_error.Y.Data)
max(kp3_ki01_error.Y.Data)
max(kp5_ki01_error.Y.Data)
max(kd1_error.Y.Data)
max(kp3_kd1_error.Y.Data)
max(kp3_kd2_error.Y.Data)
max(kp3_kd5_error.Y.Data)
max(kp1bucuk_kd015_ki002_er.Y.Data)
max(prelab_e.Y.Data)
%% RMS Values Of Errors
rms(kp4_error.Y.Data)
rms(kp100_error.Y.Data)
rms(ki01_error.Y.Data)
rms(ki1_error.Y.Data)
rms(kp3_ki01_error.Y.Data)
rms(kp5_ki01_error.Y.Data)
rms(kd1_error.Y.Data)
rms(kp3_kd1_error.Y.Data)
rms(kp3_kd2_error.Y.Data)
rms(kp3_kd5_error.Y.Data)
rms(kp1bucuk_kd015_ki002_er.Y.Data)
rms(prelab_e.Y.Data)
%% MAX Values Of Control Inputs
max(kp4_input.Y.Data)
max(kp100_input.Y.Data)
max(ki01_input.Y.Data)
max(ki1_input.Y.Data)
max(kp3_ki01_input.Y.Data)
max(kp5_ki01_input.Y.Data)
max(kd1_input.Y.Data)
max(kp3_kd1_input.Y.Data)
max(kp3_kd2_input.Y.Data)
max(kp3_kd5_input.Y.Data)
max(kp1bucuk_kd015_ki002_i.Y.Data)
max(prelab_i.Y.Data)
%% RMS Values Of Control Inputs
rms(kp4_input.Y.Data)
rms(kp100_input.Y.Data)
rms(ki01_input.Y.Data)
rms(ki1_input.Y.Data)
rms(kp3_ki01_input.Y.Data)
rms(kp5_ki01_input.Y.Data)
rms(kd1_input.Y.Data)
rms(kp3_kd1_input.Y.Data)
rms(kp3_kd2_input.Y.Data)
rms(kp3_kd5_input.Y.Data)
rms(kp1bucuk_kd015_ki002_i.Y.Data)
rms(prelab_i.Y.Data)