2nd Project 108.05450
2nd Project 108.05450
Abstract
In this project, we designed a DC motor whose speed can be controlled by a PID controller. The
proportional, integral and derivative gains (KP, KI, KD) of the PID controller are adjusted according
to Fuzzy logic.
First of all, the fuzzy logic controller is designed according to rules so that the systems is basically
robust. There are 25 rules for the auto-tuning of each parameter of the PID controller. The FLC
(fuzzy logic controller) has two inputs. The first is the motor speed error between the reference
(setpoint) and the actual speed. The second is the variation of the speed error (derivative of the
speed error). Secondly the output of the FLC is the parameters of the PID controller which are
used to control the speed of the DC motor.
The study shows that both the precise characters of PID controllers and the flexible characters of
fuzzy controllers are present in the fuzzy self-tuning PID controller. The fuzzy auto-tuning approach
implemented on a conventional PID structure was able to control the speed of the DC motor. It also
improved the dynamic and static response of the system. The comparison between the conventional
response and the fuzzy self-tuning response was performed based on the simulation result obtained by
MATLAB/SIMULINK. The simulation results show that the designed self-adaptive PID controller
achieves good dynamic behavior of the DC motor, perfect speed tracking with short rise and settling
times, zero overshoot and steady state error and thus gives better performance compared to the
conventional PID controller. We then model the fuzzy PID using simple code on Arduino IDE and
perform a practical experiment, to confirm our theorical results.
Keywords: Speed control, DC motor, PID Controller, Fuzzy logic, Fuzzy PID.
? Seniorthesis
? Nassim Messaadi :
Email address : nassim.messaadi@etu.usthb.dz
Address : Cité hospitalière Kouba, bâtiment 1, n°7, 16006 Algiers, Algeria
? Abdelkader Amroun :
It is well known that, despite the great number of new methodologies that are continuously
developed by researchers in the field of automatic control, the most adopted controllers for industrial
processes are still the Proportional-Integral-Derivative (PID) controllers.
This is motivated by the fact that, although they usually do not achieve optimal performance, they
can guarantee satisfactory results for a wide range of processes and, due to their simple structure,
they often represent the best solution from a quality/price point of view.
In this project, a new methodology for tuning PID controllers for processes with underdamped
response is proposed. It allows to determine the proportional, integral and derivative gains through
a fuzzy inference system.
The main objective of this methodology is to improve the performance of the system in terms of
setpoint tracking, i.e. to decrease the rise time, overshoot and response time.
Fuzzy logic has already been adopted in the improvement of PID control and it seems appropriate
to use it also in this context, since the design of the tuning procedure can be done in an intuitive
way, reflecting the typical experience of the operator.
In general, the torque generated by a DC motor is proportional to the armature current and the
magnetic field strength. Assume that the magnetic field is constant and therefore the motor torque
(T) is proportional to the armature current (i) alone by a constant factor (Kt) called the torque
constant, as shown in equation (1). This is called an armature-driven motor.
T = Kt × i (1)
The back electromotive force emf (e) is proportional to the angular velocity of the shaft (θ) by a
constant factor (Kb) called the electromotive force constant, as shown in Figure 1.
e = Kb × θ (2)
2
We derive the following governing equations based on Newton’s second law in equation (3) and
Kirchhoff’s mesh law in equation (4).
J θ̈ + bθ̇ = Kt × i (3)
di
La × + Ra × i = V − Kb × θ̇ × b (4)
dt
(J) is the moment of inertia of the rotor, (b) is the viscous friction constant of the motor, (La) is
the electrical inductance, (Ra) is the electrical resistance, and (V) is the voltage source. By applying
the Laplace transform, the modeling equations can be expressed in terms of Laplace variables as
follows in terms of Laplace variables, as shown in equations (5) and (6).
Θ(s) Kt rad/sec
G(s) = = [ ] (7)
V (s) (j.s + b)(La.s + Ra) + Kt × Kb V
Parameters Value
Torque constant (Kt) 0.5 N.m/A
Electromotive force constant (Kb) 1.25 V/rad/s
Electrical resistance (Ra) 5Ω
Viscous friction constant of the motor (b) 0.008 N.m/rad/s
Electrical inductance (La) 0.2 H
Moment of inertia of the rotor (J) 0.1 kg.m²
Using the parameters of our engine which are in the table above in equation (7), we obtain the
following equation:
3
2.2. Conventional controller modeling
2.2.1. PID controller
The function of the PID controller is mainly to adjust an appropriate proportional gain (KP),
integral gain (KI) and differential gain (KD) in order to achieve optimal control performance.
There are several methods for adjusting the PID parameters, in our case we will use the ”Manual
Tuning” method.
The manual Tuning of the PID controller is done by setting the reset time to its maximum value
and the rate to zero and increasing the gain until the loop oscillates at a constant amplitude.
First, we set the ki and kd values to zero. We increase kp until the loop output oscillates, then kp
should be set to about half that value for a ”quarter-amplitude decay” type response. Then ki is
increased until any offset is corrected within a sufficient time for the process. However, a value that
is too high will lead to instability.
Finally, Kd is increased, if necessary, until the loop is fast enough to reach its set point after a load
disturbance. However, increasing Kd too much will result in excessive response and overshoot. Fast
PID loop tuning usually results in a small overshoot to reach the setpoint faster; however, some
systems cannot accept overshoot, in which case an over-damped closed-loop system is required,
which will require tuning well below half the setting that was causing the oscillation.
The values obtained are: Kp = 30, ki=12 ,kd=1.
We put this controller in series with our motor, we then obtain the Simulink diagram below:
4
2.2.2. Fuzzy PID controller
Fuzzy logic is expressed using human language. Based on fuzzy logic, a fuzzy controller converts
a linguistic control strategy into a control strategy, and the fuzzy rules are constructed by the
experience of an expert or a database.
The error (e) and the change of the error (de) of the speed are the variable inputs of the fuzzy
logic controller. The variable output of the fuzzy logic controller adjusts the parameters of the PID
controller, then the PID controller calculates the control output.
All membership functions have an asymmetric form with more concentration near the origin.
This allows for greater accuracy in the steady state. Figures (6 and 7) show the input values (error
and error change) that are applied in the fuzzy PID controller.
Figures 8, 9 and 10 show the output values (Kp, ki, kd) that are applied to the PID controller.
5
Figure 8: Membership function of the gain Kp
e/de NL NS ZE PS PL
NL PVL PVL PVL PVL PVL
NS PML PML PML PL PVL
ZE PVS PVS PS PMS PMS
PS PML PML PML PL PVL
PL PVL PVL PVL PVL PVL
e/de NL NS ZE PS PL
NL PM PM PM PM PM
NS PMS PMS PMS PMS PMS
ZE PS PS PVS PS PS
PS PMS PMS PMS PMS PMS
PL PM PM PM PM PM
6
e/de NL NS ZE PS PL
NL PVS PMS PM PL PVL
NS PMS PML PL PVL PVL
ZE PM PL PL PVL PVL
PS PML PVL PVL PVL PVL
PL PVL PVL PVL PVL PVL
The Simulink diagram of our MCC in series with the fuzzy PID controller is shown in the following figure:
Figure 11: Simulink diagram of the DC motor in series with a Fuzzy PID Controller
For example, the rules applied in the PID Fuzzy as shown in Figure 12, if the error ’e’ is equal to zero (NL) and
the variation of the error ’de’ is equal to zero (PL), then Kp equal to 30 (PVL), Ki equal to 12 (PM) and kd equal to
1 (PVL).
7
2.3. Simulation
2.3.1. System without controller
Before performing the control, we must first see the motor output in rpm. In this case (figure 13), the step
response does not reach the desired value, the rise time is too high and the steady state error is very high.
8
2.3.3. System using a fuzzy PID controller
In this case (figure 15), Fuzzy Logic is used for setting the PID parameters. The response reaches the desired
value, no steady state error, zero overshoot, the settling and rise times are minimal.
Below (figure 16) we find the graphs of the error (in red) and the derivative of the error (in blue), we can see that
the error cancels out very quickly, we can also see that the derivative of the error reaches a very large negative value
from the first times which is considerably large but this is compensated very quickly.
Figure 16: The error and the derivative of the error of the DC motor in series with a Fuzzy PID controller
9
2.4. Conclusion
From the table (5) we notice that :
- None of the three setups show overshoot.
- The rise time of the DC motor without controller is considerably larger than with controller and
that the PID controller offers better performance than the fuzzy PID controller in terms of rise time.
- The steady state error without controller is very large, the simple PID controller offers negligible
error and the fuzzy PID offers no error.
- The response time without controller is quite large, the latter improves in the case of the simple
PID but remains relatively slow compared to the fuzzy PID which is 4 times faster than the PID
and 10 times faster than the DC motor without controller.
10
3. Practical experiment
Our system is controlled with an Arduino UNO which is connected to the computer to obtain
the information of the system via the Arduino IDE interface, as we can see our system is powered
in 12V, in order to be able to control the power supply we use an electronic relay module between
the power supply and the board of experimentation. To make our Arduino communicate with our
motor we use the L293D driver. The capacitor and the diode between the positive and negative
terminals are used for filtering and elimination of parasitic signals, the DC motor in this system is
included in the 4 pins fan, including a pin for the +12V, a pin for the ground, a pin linked to a
Tacheometer (Hall effect sensor, which generates two pulses per revolution) and finally a PWM pin
(pulse width modulation) which allows us to control our DC motor and vary its speed
11
3.3. The program
We modeled the Fuzzy logic controller established on matlab in a simple program on Arduino
IDE.
We modeled the membership functions of the inputs: the error and the change of the error in math-
ematical equation (We already have (e) and (de) so we project on the curves of our membership
functions to obtain the ordinate which varies between 0 and 1. This ordinate will then be projected
on the curves of the membership functions of our output (Kp,Ki,Kd).
The choice of the curves to consider will depend on condition If-Then which correspond to the rules
established previously, table (2,3,4).
In figure (19) and figure (20) we can see that the DC motor reaches the set point very quickly
(at exactly 120ms), this is confirmed by the error trace that we can see in blue which is cancelled
12
at the same time. We also notice that we have an overshoot before stabilization which is due to the
high current absorbed at startup by the MCC. These observed results have a better response time
than the fuzzy PID in theory but the latter presents a considerable overshoot at start point which
is a negative point.
4. Conclusion
Project objectives:
In this project, we designed a DC motor whose speed can be controlled by a PID controller. The
proportional, integral and derivative gains (KP, KI, KD) of the PID controller are adjusted using
the fuzzy logic method.
The study shows that both the precise characters of PID controllers and the flexible characters of
fuzzy controllers are present in the auto-tuning fuzzy PID controller.
The simulation results show that the designed self-tuning PID controller achieves the good dynamic
behavior of the DC motor, perfect speed tracking with short rise and settling times, zero overshoot,
steady state error null and thus gives better performance compared to the conventional PID con-
troller.
13
5. References
[1] Ahmed Alhussain Ali Ahmed ; Samar Mohammed Abdullah ; Mohamed Omer Babiker Mo-
hamed Ali ; Abdulmajeed Abdulmonim Abdullatif Abdulrahman.
“DC Motor Control of Speed Using FUZZY-PID Controller”- A Project Submitted in Partial Ful-
fillment for the Requirements of the Degree of B.Sc. (Honor) In Electrical Engineering. .
“FUZZY LOGIC BASED TUNING OF PID CONTROLLERS FOR PLANTS WITH UNDER-
DAMPED RESPONSE” .
14