DLSU ResCon 2017 Paper 110

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Presented at the DLSU Research Congress 2017

De La Salle University, Manila, Philippines


June 20-22, 2017
Design, Development and Implementation of a PID Fuzzy Logic Based
Flight Controller of an Unmanned Aerial Vehicle (Quadcopter) Using
Arduino Microcontroller
Jerwin M. Bautista1, Ariel S. Motas1, Ralph Laurence G. Visaya2
1Undergraduate Students, College of Engineering and Computer Studies
2Laboratory Custodian, College of Engineering and Computer Studies
Lyceum of the Philippines University-Laguna (LPU-L), Laguna, Philippines

Abstract: So many researchers proposed control systems for quadcopter in these past
few years. In this research paper, the proponent presented the design, development
and implementation of a PID Tuning with Fuzzy Logic based flight controller for an
unmanned aerial vehicle quadcopter using Arduino microcontroller. The proponents
introduce the brief introduction of the quadcopter, its significance and applications.
After that, it also introduces the detailed hardware for the quadcopter. The proponent
makes use of Arduino IDE for the programming platform of the Arduino and for the
simulation of the flight controller. The proponent also makes use of MATLAB Simulink
for the PID Tuning; it has been used to test, analyze and compare the performance of
the controllers in simulations and the MATLAB Fuzzy Logic toolbox for the trial and
error of the PID tuned controller. The Sugeno style of fuzzy inference system was used
in the system. Triangular membership functions were used in the control system. Two
Fuzzy inputs are constructed namely: the error, and change in error. The proponents
also constructed FAM matrix for the rules in the fuzzy logic. The output of the fuzzy
logic is normalized in the Dev C++ for fine tuning and getting the accurate and precise
outputs. The proponents used the experimentations to validate the functionality and
applicability of the designed and developed controller The results of the experiments
were satisfactory and it is concluded that it is possible to alleviate quadcopter with
PID tuned fuzzy logic based controller.

Key Words: unmanned aerial vehicle, quadcopter, Simulink, Sugeno style, Arduino
IDE, Fuzzy Logic

1. INTRODUCTION parameters tuning etc. Skilled, practiced and expert


knowledge is vital in tuning the controller’s
parameter to get the optimal performances.
1.1 Background of the Study
In the last few decades, small-scale unmanned 1.1 Objectives of the Study
aerial vehicles have been used for many
applications. The need for aircraft with greater The general objective of this study is to design,
maneuverability and hovering ability has led to a develop and implement a PID tuned fuzzy logic
rise in quadcopter research. The four-rotor design based flight controller for a quadcopter using
allows quadcopters to be relatively simple in design arduino microcontroller. Specifically, the proponent
yet highly reliable and maneuverable. Research is makes a program for the simulation of the PID
continuing to increase the abilities of quadcopters by tuning. The proponent also makes a fuzzy logic
making advances in multi-craft communication, algorithm for the fuzzy logic tuning for the PID. The
environment exploration, and maneuverability. proponent test and experiment the functionality of
Quadcopters are useful tool for university the sensors needed for the flight controller.
researchers to test and evaluate new ideas in a
number of different fields, including flight control 1.2 Scope and Limitation of the Study
theory, navigation, real time systems, and robotics.
The studies for an unmanned aerial vehicle (UAV) In this study, the proponents will use fuzzy logic
quadcopter modeling and controls have been for tuning the PID tuned which was simulated in the
increased quickly in the recent years. In the MATLAB and it will be implemented in Arduino
quadcopter, it mainly involves complex method Atmega 2560. The proponents will make use of
such as modeling, control, simulation and
Presented at the DLSU Research Congress 2017
De La Salle University, Manila, Philippines
June 20-22, 2017
Sugeno style of fuzzy inference system to fine tune controllers, can control the system properly, the
constants for desirable crisp output. In this study, second controller performed better than the classical
the proponents will be performing experiments and PID controller. A research entitled, “Wireless
simulations for the different sensors and modules. Control Quadcopter with Stereo Camera and Self-
These experiments and simulations will be Balancing System” was proposed by Mongkhun
integrated to produce the full fuzzy system for the Qetkeaw A/L Vechian, in able to give more focus on
flight control system of the quadcopter. In the fuzzy the development of a remotely operated Quadcopter
logic algorithm, the triangular membership system. The Quadcopter is controlled through
functions of the FLC will be constructed with seven graphical user interface (GUI). Communication
(7) classifications such as “NB”, “NM”, “NS”, “ZO”, between GUI and Quadcopter is done by using
“PS”, “PM”, “PB”. The proponents considered only wireless communication system. Sensors such as
two input variables namely: error (e) and change in IMU 5DOF and ultrasonic sensor has been used in
error (de). The Fuzzy Associative Memory (FAM) this research which is being controlled through
matrix of two-dimensional (2- D) space will be Arduino Uno microcontroller. GUI is designed using
constructed. The three (3) ouputs namely: Ki, Kp Visual Basic 2008 Express as interface between
and Kd, served as the crisp output. This will be control base and Quadcopter. The experiment shows
optimized using trial and error method using that Quadcopter can hover with maintain it
DevCpp and Matlab fuzzy logic toolbox will be fed balancing and stability. A research entitled, “See-
to the input of the Microcontroller Unit (MPU), and-Avoid Quadcopter using Fuzzy Control
which will be used in the flight controller. The code Optimized by Cross-Entropy” was proposed by
will be uploaded to Arduino IDE (Arduino Atmega Miguel A. Olivares-Mendez, et al, in order to present
2560) and based on the sensed external an optimized fuzzy visual servoing system for
temperature condition; the MPU will classify and obstacle avoidance using an unmanned aerial
make decision. vehicle. The optimization process was made using
the ROS-Gazebo 3D simulation with purposeful
2. REVIEW OF RELATED extensions developed for experiments. Visual
servoing is achieved through an image processing
LITERATURE front-end that uses the Camshift algorithm to detect
and track objects in the scene.
A research entitled, “Quadrotor control:
modeling, nonlinear control design, and simulation” 3. METHODOLOGY
was proposed by Francesco Sabatino, to present the
derivation of the mathematical model of a
3.1 PID Controller
quadrotor’s dynamics with the use of Newton’s and
Euler’s laws. The research intended to obtain a
Proportional, integral and derivative Controller
linearized version of the model, hence the linear
(PID), are the most common controllers in the control
quadratic regulator has been derived. In line with
this, two feedback linearization control schemes are of industrial processes which has the mathematical
designed. First is the dynamic inversion with zero development of control theory Proportional
dynamics stabilization and the second one is the controller (P): The P proportional part of the PID
exact linearization and non-interacting control controller has the task of reducing the rising time. If
through dynamic feedback. Comparison of only a proportional controller is used to control the
performance has been made between these system, permanent fault occurs in the system.
nonlinear control strategies and linear quadratic Proportional-integral controller (PI): By adding the L
regulator. The behavior in virtual reality was Integrator section to the controller P, Permanent fault
observed completely with the help of Simulink 3D of the system is deleted. It could also lead to the
Animation toolbox. A research entitled, “Controlling creation of fluctuations in the system, these
of Qaudrotor UAV Using a Fuzzy System for Tuning fluctuations may be mortal or immortal. So to
the PID Gains in Hovering Mode” was proposed by correct the controller, derivative part is added to it.
E. Abbasi and M.J. Mahjoob, to improve the Proportional-integral-derivative controller (PID):
modeling and control system of the unmanned air Addition of the derivative section enables the
vehicle known as quadrotor aircraft. In terms of controller to predict a kind of system behavior, and
modeling the quadrotor , Euler – Newton equation before the error rate is increased highly, it corrects
has been used, and in terms of stabilizing the the control input.
quadrotor and contollong its attitude, classical PID
controller and a fuzzy system that adjusts the PID
3.2 Fuzzy Logic Controller
controller gains have been designed. In line with
this, the research showed that although, both of the
The first step in designing Fuzzy Logic System is
classical PID and the fuzzy self-tuning PID
to describe fuzzy sets, the information in terms of
Presented at the DLSU Research Congress 2017
De La Salle University, Manila, Philippines
June 20-22, 2017
fuzzy linguistic terms or can be regarded as values In the figure above, it shows the block diagram
equal to 0 or 1 and values within them. The fuzzy of the full system of the quadcopter. The receiver
membership function is used to assign values with signal is being transmitted to the RC controller in
respect to fuzzy sets and its degrees of membership. order to control the quadcopter then the input will
be decided on the PID Fuzzy Logic controller after
3.3 PID Fuzzy Logic Structure that after the output of the controller are to be fed to
the Arduino Microcontroller. The Barometric Sensor
can be able to sense and tell about the altitude of the
quadcopter, the accelerometer can be able to tell
about the angle, the acceleration and the speed, the
x,y and z channel of the quadcopter. The
Magnetometer tells the direction and the magnitude
of the quadcopter. The servo motor helps to roate the
camera in 180 degrees. Then the motor reacts
depending on the input.

4. DESIGN CONSDERATIONS
Fig. 1. PID Fuzzy Logic Structure Block Diagram
4.1 The Prototype
In the figure 1, it shows the block diagram of the
PID fuzzy logic structure. The fuzzy logic controller
takes the system error denoted by “e” and the change
in error denoted by “Δe”. The output of the fuzzy logic
will goes to the PID controller namely: Kp, Ki and
Kd. The output of the PID will goes to the flight
controller of the quadcopter.

3.4 Arduino IDE


Figure 3: The Quadcopter
The software for this project was developed using
a simple high level language in C++. It also used In figure 3, it shows the actual prototype of the
ARDUINO IDE sketchbook for PC to system system. The flight controller of the quadcopter is an
interface. The software controls the input display of Arduino Microcontroller based. The connection in
the device and manipulates its polarity depending the controller comprises of the Triple Axis
on the parameters of the equipment engaged Accelerometer and Gyroscope, Magnetometer,
through it. The Arduino IDE is an open-source Barometric Pressure Sensor, Servo motor for
Arduino Software it provides an easy way to write a controlling the rotation of the camera, it has also 6-
code and upload it to the board.The environment is ch transceiver just for recognizing by the 2.4GHz RC
written based on Processing, Java, and other open- Toy Remote Controller. The frame of the quadcopter
source software’s. The software can be used with any is made of wood. The motor of this prototype is a
Arduino board. Brushed DC motor.

3.5 Hardware Block Digram 4.2 System Sensors:


4.2.1 MPU6050 (Triple Axis Accelerometer and
Gyroscope)

Fig.4. MPU6050
In this research, the proponents make use of the
Fig. 2. Hardware Block Diagram the MPU6050 Triple Axis Acclerometer and
Gyroscope in the system. The following reasons why
use this sensor:
Presented at the DLSU Research Congress 2017
De La Salle University, Manila, Philippines
June 20-22, 2017
a. Averaging the data that comes from system, the proponents used the Sugeno Style FIS
accelerometers and gyroscopes can produce System.
a better estimate of orientation than
obtained using accelerometer data alone.
b. Also has Digital Motion Processor (DMP)
c. Economical and cheaper than the separate
modules for the accelerometer and
gyroscope.
d. It is compatible to Arduino
Microcontroller.

4.2.2 BMP180 (Barometric Pressure Sensor) Fig. 8. Error (Input 1)


In the above figure shows the Input error of the
fuzzy logic. It also shows the Membership functions.
In the FIS, the proponents make use of the
triangular membership function and comprises of 7
parameters namely: “NB, NM, NS, ZO, PB, PM, PS”.

Fig. 5. BMP180
This precision sensor is the best low-cost sensing
solution for measuring barometric pressure and
temperature. Because pressure changes with
altitude you can also use it as an altimeter! The
sensor is soldered onto a PCB with a 3.3V regulator,
I2C level shifter and pull-up resistors on the I2C
pins. It is also
Fig. 9. The Output (Kp)
4.2.3 HCM5883L (Magnetometer) The figure shows the Kp output. It also shows the
output of the sugeno style fuzzy interference system
and the membership functions and its parameters
namely: P, Z and N. This is only for the Kp and the
others (Ki and Kd) are in the below part of the Kp.

Fig. 6. HCM5883L
HMC5883L is a triple axis magnetometer.
Magnetometers have a wide range of uses. The axes
are labeled as X, Y, and Z. An output is provided for
each of these axes that describe the position of these
axes relative to the earth’s magnetic field.

4.3 Fuzzy Logic Simulation:


Fig. 10. Rule Editor
This is the part where rules can be add and
deleted. This is also where rules are constructed.
The rules comprise about 49 rules.

Fig. 7. FIS EDITOR


In the figure, it shows the Fuzz Logic Toolbox. It
comprises of the 2 inputs and 3 outputs for the
tuning the PID. In the center box, it appears the
name of the file and the type of fuzzy logic Fig. 11. Rule Viewer
interference system used in the system. In the
Presented at the DLSU Research Congress 2017
De La Salle University, Manila, Philippines
June 20-22, 2017
This figure shows the rule viewer. The values of the inputs taken over time is some form of random variation.
can be changed and see what values would be the output. There are two distinct groups of smoothing
methods : a.)Averaging Methods b)Exponential
5. EXPERIMENTS AND ANALYSIS Smoothing Methods. The proponents used the
Averaging Method in observing and proving the the
OF RESULTS PID Fuzzy Logic is much more accurate than PID.
The point of this chapter is to show the analysis
and interpretation of data for series of experiments. Tab. 1. Settling Time Measured in Altitude Control
The proponents simulated the tuning of PID in
MATLAB through the use of Simulink. Then after the
tuning, The output of the simulation had been the
input for another tuning in the fuzzy logic toolbox also
in MATLAB.

In the table, it shows the comparison of the


settling time between those two controllers. The
proponents tested the time by using a stopwatch
and mesasured the time response of the quadcopter
in the part of altitude control. The altitude control
is the time the quadcopter responded in lifting or
flying upward direction.

Fig. 12. Surface View Kp

Fig. 13. Surface View Ki Fig. 15. Graphical Representation of the Setting Time of
PID and Fuzzy Logic

In this figure, show the graphical comparison of


the two controllers. Fuzzy PID has the faster time
response than PID alone. The proponents estimated
1 sec time response for the controller and the fuzz
Fig. 14. Surface View Kd PID the only one matches the estimated time
In figures 12 – 14, it shows the surface view of response in the quadcopter.
the PID Gains, Ki, Kd and Kp. The colors changes
according to the output values. In the picture, the Tab. 2. Percentage Error
highest value is color yellow and the lowest value is
color blue. In the evelation map, it will help to see
what is the highest and lowest.

5.1 Statistical Tool


5.1.1 Smoothing Technique

When data collected over time displays random


variation, smoothing techniques can be used to The table shows that the PID controller has
reduce or cancel the effect of these variations. When the highest percentage error while the Fuzzy Logic
properly applied, these techniques smooth out the PID has the lowest percentage error. Thus, it is
random variation in the time series data to reveal being resulted that the fuzzy logic is reliable.
underlying trends. Inherent in the collection of data
Presented at the DLSU Research Congress 2017
De La Salle University, Manila, Philippines
June 20-22, 2017
5.2 Statistical Analysis Using Moving Fuzzy PID is faster than the PID so it must be used
Average Smoothing Technique in the quadcopter specially when the quadcopter
used for racing, for surveillance, etc.
Tab. 3. Using Smoothing Technique / Moving Average
7. ACKNOWLEDGEMENT
The proponent acknowledge Jesus Christ, who
always give them knowledge, wisdom and strength
in this research. He would like to thank Engr. Rionel
B. Caldo for his continuous support and advices as
the preferred thesis adviser.

8. REFERENCES
Ralph Laurence G. VIsaya, et al, DESIGN AND
DEVELOPMENT OF FUZZY LOGIC
ALGORITHM WITH VARYING SETPOINTS
FOR FAN SPEED CONTROL SYSTEM USING
ARDUINO MICROCONTROLLER, 2014

Mustafa R Abuzeid, Ramadan AElmoude, Nasr E


Shtawa. A novel Strategy for Synchronizing of
Fig. 16. Graphical Representation for the Statistcal
Analysis for PID and Fuzzy Logic.
Two DC Motors, Al-azhar Engineering Ninth
International Conference, April 12-14, 2007.
In the figure and the table show the analysis for
using the moving average smoothing technique. https://en.wikipedia.org/wiki/Quadcopter
The proponents used this to find and to see that the
data is more accurate than taking down the time Jitender Kaushal, Comparative Performance Study
response in 10 trials. It shows that the PID also is of ACO & ABC Optimization based PID
slower than Fuzzy PID. Controller Tuning for Speed Control of DC Motor
Drives, Issue JUNE, 2012.
6. CONCLUSION
Bin Adzmi K .A, Motor Speed Controller Using
After the series of experimentation for the Fuzzy Logic Method for PCB Drilling Operation,
hardware parts and the software parts for the flight Issue 4 November, 2008.
controller of the quadcopter. the results were
carefully studied and interpreted accordingly. Based S.Z. He. S. Tan, F.L.Xu, ''Fuzzy self-tuning of PID
on the data analysis and reports, the output of the controllers‟‟, fuzzy set and Systems, 56(1993),
controller was favorable and satisfactory because 37-46.
that fuzzy pid can be implemented on arduino
microcontroller and at the same time the time
response for different controls the atltitude, yaw,
throttle, the experimentation and results, it is
evident and proof that the time measured in PID and
Fuzzy PID, which prove that the research is reliable
and accurate because of the difference in their time
responses. The PID is slower than of the Fuzzy PID.
It also convenient to use because of its minimal delay
time of the controller.. Fuzzy PID Based Controller
responds in a very least possible time. Thus, the
time response is strong and almost in the , the
system is reliable. The research is properly and
accurately working which satisfied the objectives of
this study.pitch of the quadcopter meets the
expected time response ranging from 0.89 to 0.98
secs with the maximum requirement of 1 secs.
Analyzing the tables and graphs in using the
Smoothing Technique, it can see clearer that the

You might also like