Professional Documents
Culture Documents
Faculty of Engineering
Department of Electrical and Computer
Engineering
EC3501: Control Systems
Lab 02: DC Motor Control and PID Control
Name
Index Number
De Silva O.R.M.
EN14536458
Kaushalya S.A.D.T.P.
EN14535468
Kehelalla P.H.
EN14522802
Group
: Group 03
Contents
List of Figures ................................................................................................................................. 2
Introduction ..................................................................................................................................... 4
Modeling a DC Motor..................................................................................................................... 5
Model a DC Motor using the physical model Approach ............................................................ 5
Modelling the Mechanical Portion of the System....................................................................... 5
Modified Mechanical Portion of the System .............................................................................. 6
Modified Mechanical Portion of the System for a Translation Motion ...................................... 6
Proportional Control ....................................................................................................................... 8
PD Control ................................................................................................................................ 11
PI Control .................................................................................................................................. 13
PID Control ............................................................................................................................... 15
Tuning Kp .................................................................................................................................. 16
Tuning Ki .................................................................................................................................. 17
Tuning Kd .................................................................................................................................. 18
Tuned PID Controller ............................................................................................................... 19
PID Control Design with Control System Toolbox ...................................................................... 20
Proportional controller .............................................................................................................. 20
PI Controller.............................................................................................................................. 21
PID controller............................................................................................................................ 22
Tune PID controller for a DC Motor in MATLAB SIMULINK .................................................. 23
Conclusion .................................................................................................................................... 27
Bibliography ................................................................................................................................. 27
Page | 1
List of Figures
Figure 1: Current Scope in DC Motor ............................................................................................ 5
Figure 2: Physical Model of a DC Motor ....................................................................................... 5
Figure 3: Current Scope of the mechanical portion ........................................................................ 5
Figure 4: DC Motor with Mechanical portion ................................................................................ 5
Figure 5: Modified Mechanical Portion of the System ................................................................... 6
Figure 6: Scope 1 Output ................................................................................................................ 6
Figure 7: System for a Translation Motion ..................................................................................... 6
Figure 8: Scope 1 ............................................................................................................................ 6
Figure 9: Scope of translational motion .......................................................................................... 7
Figure 11: Scope of Translational spring rate 100 .......................................................................... 7
Figure 10: Scope of Translational spring rate 10 ............................................................................ 7
Figure 1 - Variation of Overshoot for different Kp values ............................................................. 8
Figure 2 - Overshoot vs Kp ............................................................................................................. 9
Figure 3 - Variation of Settling Time for different Kp values ...................................................... 10
Figure 4 - Settling Time vs. Kp .................................................................................................... 10
Figure 5 - Step Response of the system with PD controller for various Kd values ...................... 11
Figure 6 - Overshoot vs Kd ........................................................................................................... 12
Figure 7 - Step Response for the system with PI controller ......................................................... 13
Figure 8 - Settling time vs Ki ........................................................................................................ 14
Figure 9 - Step Response with PID controller .............................................................................. 15
Figure 10 - Tuning for Kp ............................................................................................................. 16
Figure 11 - Tuning for Ki.............................................................................................................. 17
Figure 12 - Tuning for Kd ............................................................................................................. 18
Figure 13 Step Response Before Tuning and After Tuning of PID ........................................... 19
Figure 1: Variation of the system response with increasing response time .................................. 20
Figure 2: Effect of the variation of response time on the response. ............................................. 22
Figure 1: System model ................................................................................................................ 23
Figure 2: Initial parameters given for the PID controller ............................................................. 24
Figure 3: System response for the given parameters .................................................................... 24
Figure 4: Initial tuned response..................................................................................................... 25
Page | 2
Page | 3
Introduction
Proportional-Integral-Derivative (PID) control is the most common control algorithm used in
industry and has been universally accepted in industrial control. The popularity of PID
controllers can be attributed partly to their robust performance in a wide range of operating
conditions and partly to their functional simplicity, which allows engineers to operate them in a
simple, straightforward manner. PID algorithm consists of three basic coefficients proportional,
integral and derivative which are varied to get optimal response.
The basic idea behind a PID controller is to read a sensor, then compute the desired actuator
output by calculating proportional, integral, and derivative responses and summing those three
components to compute the output. The proportional term produces an output value that is
proportional to the current error value, the contribution from the integral term is proportional to
both the magnitude of the error and the duration of the error and in the derivative of the process
error is calculated by determining the slope of the error over time and multiplying this rate of
change by the derivative gain. [1]
The process of setting the optimal gains for P, I and D to get an ideal response from a control
system is called tuning. PID controller tuning appears easy, but finding the set of gains that
ensures the best performance of your control system is a complex task. Traditionally, PID
controllers are tuned either manually or using rule-based methods. Manual tuning methods are
iterative and time-consuming. But MATLAB can automatically tune PID controllers to achieve
the optimal system design and to meet design requirements, even for plant models that traditional
rule-based methods cannot handle well.
DC motors are widely used in industrial control systems because they are well understood and
easy to control. Usually, the cogging torque, commutation torque, and friction exist in DC
motors, causing torque ripples in the motor output torque. For cost reduction reasons, cheaper
DC motors are used more in a lot of commercial products such as scanners. For cheap DC
motors, these disturbance torques can be quite large, causing performance issues like speed
ripples. Usually, the closed and/or open-loop control are used to suppress the disturbances. The
main objective of this laboratory is to understand and familiarize with the Simulink function of
the MATLAB software as well as getting the results of DC motor controls and PID controls
Page | 4
Modeling a DC Motor
Model a DC Motor using the physical model Approach
Here in the scope current value is a constant of 1A since there is no current decaying and
a DC Voltage source is used
Here the current is flowing through rotational electromechanical converter so the current
is decaying. The resulting torque is positive because the current flowing from the positive
to negative terminal is positive
Page | 5
Figure 4: DC Motor with Mechanical portion
The Ideal Rotational Motion Sensor block represents an ideal mechanical rotational
motion sensor. Here ideal rotational motion sensor controls current signal proportional to
angular velocity or angle. Initially it will take some time then becomes a constant value.
The sensor is ideal since it does not account for inertia, friction, delays, energy
consumption, and so on. It starts from zero because DC offset is zero.
The Wheel and axle block represents wheel and axle mechanism as an ideal converter
between mechanical rotational and mechanical translational motions. Here Port A is the
mechanical rotational conserving port associated with the axle and Figure 6: Scope 1 Output
port P is the mechanical translational conserving port associated
with the wheel periphery. The wheel and the axle have the same axis, and the axis is
assumed to be rigidly connected to the frame making this mechanism it converts
mechanical rotational into mechanical translational motion.
Initially it oscillates with a larger amplitude an it drops with time so that finally it reaches
an oscillation with a uniform amplitude.
Page | 6
Figure 8: Scope 1
A springs Spring Rate is the amount of weight required to deflect a spring one inch. The
lower the Spring Rate, the softer the spring. The softer the spring, the smoother the ride.
The magnitude of the spring force is equal to the product of physical signal input and the
relative displacement between two translational conserving ports.
A minimal spring rate prevents non-physical values. When Translational spring rate is at
100 this Oscillate faster than the Translational spring rate is at 10.
Page | 7
Proportional Control
The below closed loop transfer function was analyzed using MATLAB.
KP was varied to observe the behavior of overshoot and settling time. Below figure shows the
variation of overshoot for the step responses of above system at different values of KP.
The characteristics of each of the above step responses were obtained from MATLAB
stepinfo() function and tabulated as below.
Table 1 - Step Response Characteristics for various Kp Values
Kp
4
8
12
16
20
24
28
32
36
40
Overshoot
0
0.0038
0.2640
0.8772
1.7322
2.7221
3.7803
4.8642
5.9523
7.0269
Settling Time
1.2383
0.9833
0.8004
0.6727
0.5824
0.8603
0.8538
0.8308
0.8033
0.7752
It is evident from the figure 2 that the peak overshoot increases with the increasing of KP.
Page | 8
Figure 13 - Overshoot vs Kp
It should also be noted that the step response moves from an over damped response to an under
damped response with the increase of KP. This variation is justified by the below calculation.
(
(
)
)(
Below figure shows the variation of settling time for the step responses of above described
system at different values of KP.
Page | 9
The settling time of the above responses are varied as shown in figure 4.
The settling time decreases with the increase of KP in the range of 4 to 20. However, during the
transition of of 20 to 24, settling time increases by a small amount. This could be explained by
using the definition of the settling time: the maximum time taken to reach 98% of the steady
state value. Overshoot is less than 2% in 4 to 20 range, hence settling time comes before the
overshoot take place. But the overshot is greater than 2% from 24 onward. Therefore, the time
taken by the system to reach 98% of its steady state value comes after the overshoot. Considering
the overall variation in figure 4, it could be concluded that the settling time decreases with the
increase of KP.
Page | 10
PD Control
The below closed loop transfer function with a PD controller was analyzed using MATLAB.
The KP value was fixed at 300 and Kd was changes from 10 to 50. The step response for each
case is shown in figure.
Figure 16 - Step Response of the system with PD controller for various Kd values
The characteristics of each of the above step responses were obtained from MATLAB
stepinfo() function and tabulated as below.
Table 2 - Step Response Characteristics for various Kd Values
Kd
10
20
30
40
50
Overshoot
15.3418
5.7909
1.7723
0.0662
0
Settling Time
0.2897
0.2723
0.0920
0.0890
0.0839
Even though the settling time is decreased with the increase of Kd, it is not much significant. The
overshoot is significantly reduced with the increase of Kd. The variation of overshoot with the
derivative gain is plotted in figure 6.
Page | 11
Figure 17 - Overshoot vs Kd
The overshoot exponentially decreases with the increase of Kd. This could be mathematically
represented with below proof. In the above closed loop transfer function,
Since the damping constant is increased with the increase of Kd, overshoot will eventually get
decreased.
The increasing of the overshoot was the major drawback in the proportional controller, even
though it significantly reduces the settling time. The increasing of overshoot could be addressed
by using the PD controller where the derivative gain helps to reduce the overshoot while keeping
the properties of the proportional gain unchanged. Combining both the properties, PD controller
is an efficient way to reduce both the settling time and overshoot.
Page | 12
PI Control
The below closed loop transfer function with a PI controller was analyzed using MATLAB.
The KP value was fixed at 30 and Ki was changes from 0 to 90. The step response for each case
is shown in figure 7.
The characteristics of each of the above step responses were obtained from MATLAB
stepinfo() function and tabulated as below.
Table 3 - Step Response Characteristics for different Ki values
Ki
0
10
20
30
40
50
60
70
80
90
Settling Time
0.8433
14.2547
6.7359
4.2037
2.9101
2.0976
1.5607
0.6182
1.0613
1.1472
Overshoot
4.3210
0
0
0
0
0
0
1.2588
5.1966
8.9141
Settling Max
0.6259
0.9977
0.9973
0.9999
0.9970
0.9977
0.9985
1.0126
1.0520
1.0891
Page | 13
Below figure shows the variation of settling time with the variation of Ki.
Page | 14
PID Control
The closed loop transfer function of the system with PID controller is given below.
Step response for this system was obtained by setting Kp = 350, Ki = 300 and Kd = 50.
The characteristics of the step response were obtained from the stepinfo() function of MATLAB.
RiseTime
: 0.0548
SettlingTime : 0.8308
SettlingMin
: 0.9006
SettlingMax
: 0.9959
Overshoot
:0
Undershoot
:0
Peak
: 0.9959
PeakTime
: 2.4775
These characteristics could be optimized by tuning the proportional, integral and derivative
gains.
Page | 15
Tuning Kp
KP is varied while keeping the Ki = 300 and Kd = 50.
The original response is shown by the red color graph. It could be identified that the KP = 450
(light blue) graph gives a better settling time. Hence the proportional gain was tuned to value
450. The characteristics of the step response were obtained from the stepinfo() function of
MATLAB.
RiseTime
: 0.0473
SettlingTime : 0.7898
SettlingMin
: 0.9015
SettlingMax
: 0.9837
Overshoot
:0
Undershoot
:0
Peak
: 0.9837
PeakTime
: 1.0853
Page | 16
Tuning Ki
Ki is varied while keeping the Kp = 450 and Kd = 50.
The KP tuned response is shown by the green color graph. It could be identified that the
Ki = 1100 (yellow) graph gives a better settling time and a good steady state value. Hence the
integral gain was tuned to value 1100. The characteristics of the step response were obtained
from the stepinfo() function of MATLAB.
RiseTime
: 0.0462
SettlingTime : 0.0911
SettlingMin
: 0.9010
SettlingMax
: 1.0010
Overshoot
: 0.0984
Undershoot
:0
Peak
: 1.0010
PeakTime
: 0.2139
Page | 17
Tuning Kd
Kd is varied while keeping the Kp = 450 and Ki = 1300.
The KP and Ki tuned response is shown by the blue color graph. The increment of Kd decreases
the rise time and increases settling time. Therefore, the derivative gain was kept at the value 50.
The characteristics of the step response were obtained from the stepinfo() function of MATLAB.
RiseTime
: 0.0462
SettlingTime : 0.0911
SettlingMin
: 0.9010
SettlingMax
: 1.0010
Overshoot
: 0.0984
Undershoot
:0
Peak
: 1.0010
PeakTime
: 0.2139
Page | 18
Below table can be used to compare the characteristics of the response before and after tuning
the PID controller.
Table 4 - PID Tuning Comparison
KP
Ki
Kd
Rise Time
Settling Time
Settling Min
Settling Max
Overshoot
Undershoot
Peak
Peak Time
Before Tuning
350
300
50
0.0548
0.8308
0.9006
0.9959
0
0
0.9959
2.4775
After Tuning
450
1300
50
0.0462
0.0911
0.9010
1.0010
0.0984
0
1.0010
0.2139
PID control could be used to obtain a fast response at the expected steady state value. The
proportional term of the PID controller accounts for decreasing of the settling time and
increasing of the overshoot. Settling time decreases with the increasing of KP. To overcome the
Page | 19
increasing of overshoot, derivative term of PID controller could be used. Overshoot decreases
with the increasing of Kd. The integral term of the PID controller removes the permanent error
induced in the response and it also decreases the rise time and settling time of the response. The
combination of these three terms produces a faster response for the step input.
Proportional controller
Figure 25: Variation of the system response with increasing response time
Plot
1
2
3
4
Rise time(s)
1.86
1.73
0.914
NaN
Settling time(s)
8.42
8.51
20.7
NaN
Overshoot %
14.1
17
58.9
NaN
Peak
0.573
0.634
1.3
Inf
Page | 20
Variation of the response for with response time for a proportional controller is pretty straight
forward. It is evident that the response starts from a stable response and after a certain point it
becomes unstable with rising response time. At the 4th plot it can be seen that the almost all the
parameters are NaN(Not a Number). This is because these quantities cannot be computed for an
unstable response. And the peak of the 4th plot is infinity. This also shows that the response is
unstable. And at this point the pidtool is unable to find a stabilizing controller.
PI Controller
Plot
1
2
3
4
Rise time(s)
19.2
3.33
1.35
NaN
Settling time(s)
36
10.1
167
NaN
Overshoot %
0
7.89
13.5
NaN
Peak
0.999
1.08
1.14
Inf
In the PI controller it can be seen that with increasing response time the overshoot of the
response starts to increase and become unstable at some point. It can be also seen that the rise
time of the response gets decreased with the increasing response time. Both of these behavior are
because of the involvement of the Integration controller in the PI controller.
Page | 21
PID controller
Plot
1
2
3
4
5
Rise time(s)
19.2
4.89
1.68
0.678
0.15
Settling time(s)
36
13.5
4.26
285
14.5
Overshoot %
0
4.48
4.29
0
53
Peak
0.999
1.04
1.04
0.999
1.53
Page | 22
By observing figure it can be seen that as the response time is increased the overshoot is also
increased. This is because for a faster response time it is required to increase the ki. And the ki
increses the overshoot also increases. It can also be seen that as the response time increases the
settling time also increases. But this increase is not a gradual one. But by tuning the other
controller variables kd and kp it is possible to get the best response for the desired response time
using the pidtool. It should be also noted that the response never gets unstable in PID controllers
as in Proportional and PI controllers.
A model of a dc motor was created in simulink and a PID controller was designed for it.
Initially following parameters were given to the PID controller and the output effect was
observed.
Page | 23
Afterwards the simulation was run and the following output was obtained. It can be seen that the
measured speed of the motor is far from the desired speed. This is due to the inappropriate
choosing of the value for kp, ki and kd.
But Matlab provides automatic tuning for PID controllers which linearizes the model at the
default operating point and automatically determines the values for kp, ki and kd to achieve better
Page | 24
response which is robust. When the tune button is pressed the pidtool opens up and presents a
enhanced system reponse. When the update button is pressed the kp, ki and kd values are updated
in the Function block parameters dialog box for PID controllers.
Page | 25
Page | 26
Conclusion
Analyzing the system control for a particular system and designing it for a particular application
is the objective of this laboratory test. So by the above set of models we can conclude that
proportional controller (KP) will have the effect of reducing the rise time and will reduce but
never eliminate the steady-state error. An integral control (KI) will have the effect of eliminating
the steady-state error for a constant or step input, but it may make the transient response slower.
A derivative control (KD) will have the effect of increasing the stability of the system, reducing
the overshoot, and improving the transient response. [2] PID Controller block generates a voltage
signal driving the dc motor to track desired shaft rotation speed. In addition to voltage, the dc
motor subsystem takes torque disturbance as an input, allowing us to simulate how well the
controller rejects disturbances.
Bibliography
[1] [Online]. https://en.wikipedia.org/wiki/PID_controller
[2] PID Control. [Online]. http://in.mathworks.com/discovery/pid-control.html
Page | 27