A Fast Realization Method of Fuzzy PID Control For DC Motor
A Fast Realization Method of Fuzzy PID Control For DC Motor
1. School of Industrial Automation, Beijing Institute of Technology, Zhuhai, Guangdong 519088, China
E-mail: [email protected]
Abstract: DC motor is widely used in various fields for its good starting and speed regulating characteristics. In many cases, it is
necessary to control the speed of the motor accurately. Although the conventional PID control algorithm can solve most of the control
problems, the conventional PID control algorithm also has many defects, for example, parameters cannot adapt to the change of the
model. The fuzzy control does not rely on the mathematical model of the control system, and simulates the control experience of
human control, which has high robustness. In this paper, the fuzzy control is combined with the conventional PID control to control
the speed of the DC motor. PID parameters are adaptively obtained by fuzzy control rules. The control system model is set up in
Simulink, and the control algorithm is deployed on the hardware platform through the automatic code generation. Through the
hardware-in-the-loop (HIL) experiment, the algorithm is quickly verified.
Key Words: DC motor, Fuzzy PID, HIL Experiment, Automatic Code Generation
5131
2 System Structure 1) Not included in the fuzzy set A if ߤ ሺݔሻ ൌ Ͳ (no
member).
The control system consists of a DC motor with an 2) Fully included if ߤ ሺݔሻ ൌ ͳ (full member).
encoder and a Raspberry Pi 3 controller as well as a DC 3) Partially included if Ͳ ൏ ߤ ሺݔሻ ൏ ͳ (fuzzy member).
motor drive and the power supply, as shown in Fig. 1.
3.2 Control System Model
Raspberry Pi is a popular, low-cost, credit card sized single-
board computer that supports embedded Linux operating In the process of control signals and the evaluation index is
systems. The combination of MATLAB and Raspberry Pi not easy to quantify, the effective way to solve this problem
can easily and quickly verify and deploy control algorithms. is fuzzy theory, using the basic theory and method of fuzzy
mathematics, the conditions of the rules and the operation of
the representation of fuzzy sets, and the fuzzy control rules
and evaluation index, initial PID parameters as the
Power supply knowledge stored in the knowledge base and according to
Battery the actual response of the control system, the optimal
Fuzzy PID
DC motor driver
adjustment of PID parameters automatically.
Power
supply The fuzzy PID control combines the conventional PID
WiFi wireless
communication
External mode control signal control with the fuzzy control. The overall concept of the
control scheme can be explained in the block diagram as
shown in Fig. 2.
The error e and the error change ec are used as the input of
Encoder signal the fuzzy PID controller. In operation, e and ec are
Raspberry PI 3
DC motor with encoder continuously checked. According to fuzzy control theory,
Fig. 1: System Structure three parameters are modified online to meet different
requirements of control parameters for different e and ec, so
A fuzzy PID control system model is designed in that the controlled object has good dynamic and static
Simulink. The model uses the I/O port of Raspberry Pi to performance.
collect the encoder signal of the DC motor and calculates the
ec
actual speed of the motor, and then compares it with the FUZZY
e
speed command to get the error signal and the rate of error CONTROLLER
change. The fuzzy PID control system model generates d/dt dKp dKi dKd
PWM control signal, and outputs it to the DC motor driver
through the I/O of Raspberry Pi, so that the motor speed can Ref Speed PID
DC MOTOR
Actual Speed
CONTROLLER
be controlled by controlling the voltage of the motor. The
data transmission between PC and Raspberry Pi by WiFi
wireless communication. Through the hardware-in-the-loop
experiment, the real speed of the motor can be viewed in real
Fig. 2: Control System Model
time.
Considering the stability, rapidity, overshoot and steady
3 Design of Fuzzy PID Controller state accuracy of the control system, the functions of Kp, Ki,
and Kd are as follows.
3.1 Concept of Fuzzy Set The role of Kp is to speed up the response of the system
and improve the precision of the system. The greater the Kp
The concept of fuzzy sets corresponds to the concept of the
value, the faster the response speed of the system, the higher
classical set. For a classical set A, the arbitrary element x on
the precision of the system, but it is easy to overshoot and
the domain E belongs to it or does not belong to it, as Eq. (1).
ͳǡ ܣ א ݔ even lead to the instability of the system. The smaller the Kp
ܺ ሺݔሻ ൌ ቄ (1) value, the adjustment accuracy will be reduced, the response
Ͳǡ ܣ ב ݔ
E is the domain, ك, ك, ܺ ሺݔሻ is the characteristic speed of the system is slow, the adjustment time becomes
function of A. longer, and the dynamic and static characteristics of the
In classical sets, there are only two possible relationships system deteriorate.
between the element x and the set A, belonging to or not. The effect of Ki is to eliminate the steady-state error of the
There is no other case, but the fuzzy set extends the classical system. The larger the Ki is, the faster the static error is
set. eliminated. But if Ki is too large, the integral saturation
Fuzzy set is used to describe a set that does not clearly phenomenon will occur in the early stage of the response
define the boundary, that is, the element it contains can be process, which will lead to a larger overshoot. If the Ki is too
partially subordinate to this set. small, the static error of the system cannot be eliminated, and
The characteristics function of the classical set can only be the adjustment precision of the system is reduced.
{0, 1}, Zadeh expanded the scope, characteristics function The effect of Kd is to improve the dynamic characteristics
can be any number of [0, 1]. This type of characteristics of the system, mainly to predict the variation trend of the
function is called membership function, marked by ߤ ሺݔሻ deviation in advance. If the Kd is too large, the response
ߤ ሺݔሻ אሾͲǡͳሿ process will be braking in advance, thus prolonging the
The set A determined by ߤ ሺݔሻ is called a fuzzy set on E. adjustment time and reducing the anti-interference ability of
the system.
Let ܣ א ݔ. Then x is called
5132
The output of the fuzzy controller is dKp, dKi, and dKd.
These three parameters change dynamically with the e and
ec according to the above rules.
The three parameters of the PID controller consist of the
initial value and the dynamic value, as follow
ܭ ൌ ܭᇱ ݀ܭ
ܭ ൌ ܭᇱ ݀ܭ
ܭௗ ൌ ܭௗᇱ ݀ܭௗ
ᇱ ᇱ ᇱ
ܭ ,ܭ andܭௗ are the initial value of the PID controller.
They can be automatically tuned by the method used in
paper [8]. In this paper, ܭᇱ ൌ0.489, ܭᇱ ൌ ͳʹǤͲͳ, ܭௗᇱ ൌ Ͳ.
Fig. 6: Membership Function for dKp
3.3 Fuzzy Controller
The fuzzy controller is designed by fuzzy logic designer
in MATLAB, as shown in Fig. 3. When the design is
completed, a file named *.fis is generated, which contains
the designed fuzzy control rules. [9,10]
5133
NM NB NB NM NM NS ZO ZO Create WiFi hotspot, connect Raspberry Pi and PC, keep
the data communication well. What needs to be noted is to
NS NM NM NS NS ZO PS PS
remember the IP address of the Raspberry Pi. In this paper,
ZO NM NS NS ZO PS PS PM the IP address of the Raspberry Pi is 192.168.8.100. Modify
PS NS NS ZO PS PS PM PM the run mode for external mode. When the control algorithm
PM ZO ZO PS PM PM PB PB
is deployed offline to the hardware, the run mode is normal
mode. By button Deployed to Hardware, the control model
PB ZO ZO PS PM PB PB PB automatically generates embedded code.
5134
PID algorithm." Transactions of the Institute of Measurement
& Control 37.2(2015):164-176.
[5] Ma, Yongbin, Y. Liu, and C. Wang. "Design of Parameters
Self-tuning Fuzzy PID Control for DC Motor." International
Conference on Industrial Mechatronics and Automation IEEE,
2010:345-348.
[6] Abhinav, Rishabh, and S. Sheel. "An adaptive, robust control
of DC motor using fuzzy-PID controller." IEEE International
Conference on Power Electronics, Drives and Energy
Systems IEEE, 2013:1-5.
[7] Meza-Sanchez, I. M., et al. "Performance of a Simple Tuned
Fuzzy Controller and a PID Controller on a DC Motor
Application." Nonlinear Studies 14(2007):531 - 537.
[8] Wei-Jie Tang, Zhen-Tao Liu, Qian Wang. DC Motor Speed
Control Based on System Identification and PID Auto Tuning.
The 36th Chinese Control Conference, 2017: 6420-6423.
[9] MathWorks, MATLAB user’s guide, [Online], Available:
http://www.mathworks.com, The MathWorks, 2017.
[10] MathWorks,ĀFuzzy Logic Toolbox,āUser’s Guide, Version
2.3, 2017.
Fig. 12: Result of the HIL experiment (Ref Speed from 150r/min
to 50r/min)
5 Conclusion
Although the conventional PID control is a very efficient
control method, it still has some defects. Fuzzy control is not
dependent on the mathematical model of the control system,
which can be used to simulate human experience.
Combining the conventional PID controller and the fuzzy
controller, the fuzzy PID controller is obtained, which has
the advantages of both.
This article presents a fast realization method of fuzzy
PID control for DC motor. The definition and principle of
fuzzy control are described, and a DC motor speed control
system based on fuzzy PID is designed in
MATLAB/Simulink. And using Raspberry Pi 3 as the
controller, a hardware control system is set up. Through the
hardware-in-the-loop experiment, the designed control
algorithm is verifying very quickly. The experimental results
show that the fuzzy PID controller has good performance.
The mode of development of this control system is very
efficient and can greatly promote the research work.
In future research, it is necessary to analyze the fuzzy PID
controller deeply, and use different control systems to test it,
and study its robustness.
References
[1] Zadeh, L. A. "Fuzzy sets." Fuzzy Sets, Fuzzy Logic, & Fuzzy
Systems World Scientific Publishing Co. Inc. 1996:394-432.
[2] Zadeh, Lotfi A. "Fuzzy Logic." Computer 21.4(1988):83-93.
[3] Geering, Hans P. "Introduction to Fuzzy Control." Springer
Berlin 7(1998).
[4] Akbari-Hasanjani, Reza, S. Javadi, and R. Sabbaghi-
Nadooshan. "DC motor speed control by self-tuning fuzzy
5135