i
OPTIMAL STABILIZATION CONTROL OF AUTONOMOUS HELICOPTER USING GENETIC ALGORITHM IN C LANGUAGE ENVIRONMENT
TAN TECK SEONG
This report is submitted in partial fulfillment of the requirements for the award of Bachelor Of Electronic Engineering (Computer Engineering) With Honors
Faculty of Electronic and Computer Engineering Universiti Teknikal Malaysia Melaka
ii
UNIVERSTI TEKNIKAL MALAYSIA MELAKA
FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER
BORANG PENGESAHAN STATUS LAPORAN
PROJEK SARJANA MUDA II
Tajuk Projek : Optimal Stabilization Control of Autonomous Helicopter using
Genetic Algorithm in C Language Environment.
Sesi Pengajian : 2009/2010
Saya TAN TECK SEONG
mengaku membenarkan Laporan Projek Sarjana Muda ini disimpan di Perpustakaan dengan syarat-syarat kegunaan seperti berikut:
1. Laporan adalah hakmilik Universiti Teknikal Malaysia Melaka.
2. Perpustakaan dibenarkan membuat salinan untuk tujuan pengajian sahaja.
3. Perpustakaan dibenarkan membuat salinan laporan ini sebagai bahan pertukaran antara institusi pengajian tinggi.
4. Sila tandakan ( √ ) :
SULIT* (Mengandungi maklumat yang berdarjah keselamatan atau kepentingan Malaysia seperti yang termaktub di dalam AKTA RAHSIA RASMI 1972)
TERHAD* (Mengandungi maklumat terhad yang telah ditentukan oleh organisasi/badan di mana penyelidikan dijalankan)
TIDAK TERHAD
Disahkan oleh:
__________________________ ___________________________________
(TANDATANGAN PENULIS) (COP DAN TANDATANGAN PENYELIA)
Alamat Tetap:
Tarikh: ……….. Tarikh: ………..
iii
“I hereby declare that this report is the result of my own work except for quotes as cited in the references.”
Signature :
iv
“I hereby declare that I have read this report and in my opinion this report is sufficient in terms of scope and quality for the award of Bachelor Degree of
Electronic Engineering (Computer Engineering) With Honors.”
Signature : ………...
v
vi
ACKNOWLEDGEMENT
First and foremost, I would like to express my deepest sense of gratitude and appreciation to my respected project supervisor, Madam Wong Yan Chiew, for her full support, useful guidance, encouragement, valuable advice and constructive comments during the time this final year project was being developed.
In addition, I am also very grateful to have all my course mates and friends, for their moral support and valuable help that they had offered my throughout my course of studies.
vii
ABSTRACT
viii
ABSTRAK
ix
TABLE OF CONTENT
CHAPTER TITLE PAGE
PROJECT TITLE i
CONFIRMATION FORM ii
DECLARATION iii
SUPERVISORS CONFIRMATION iv
DEDICATION v
ACKNOWLEDGEMENT vi
ABSTRACT vii
ABSTRAK viii
TABLE OF CONTENT ix
LIST OF TABLE xiv
LIST OF FIGURE xv
LIST OF ABBREVIATION xvii
LIST OF APPENDIX xviii
I INTRODUCTION 1
1.1 Introduction 1
1.2 Objectives 2
x
1.4 Problem Statement 2
1.5 Organization of the Report 3
1.6 Summary 4
II LITERATURE REVIEW 5
2.1 Introduction 5
2.2 Genetic Algorithm 6
2.2.1 Genes 6
2.2.2 Fitness 7
2.2.3 Population 8
2.2.4 Data Structures 9
2.2.5 Search Strategies 10
2.2.6 Encoding 10
2.2.6.1 Binary Encoding 11
2.2.7 Breeding 11
2.2.7.1 Selection 12
2.2.7.2 Crossover 14
2.2.7.2.1 Single Point Crossover 15
2.2.7.2.2 Two Point Crossover 16
2.2.7.2.3 Multi-Point Crossover 18
2.2.8 Mutation 18
2.3 Comparison of GA with Other Optimization Techniques
xi
2.4 Advantages of GA in Optimization 19
2.5 Programming Language Environment 20
2.5.1 GA Source Code 20
2.6 Strength and Weaknesses for GA to be
Programmed in C Language Compare with Other Language Environment
20
2.7 Sensors Used in Autonomous Environment 21
2.7.1 Three Axes Accelerometer – ADXL 330 21
2.7.2 Strength and Weaknesses for GA Use with Sensors
22
2.8 Microcontroller Used in Autonomous Environment
22
2.8.1 PIC18F452 23
2.8.2 Comparison of PIC18F452 with PIC16F877A
25
2.9 Programming Compiler 27
2.10 Software Tool 31
2.11 Summary 32
III METHODOLOGY 34
3.1 Introduction 34
3.2 Description of Methodology 34
3.3 Methodology Flow Chart 35
3.4 Methodology of GA Applied in Autonomous Helicopter
42
xii
IV RESULT AND DISCUSSION 45
4.1 Introduction 45
4.2 Fitness Function Used for Helicopter‟s Problems 46
4.3 Result of Output File 47
4.4 Result of Graph Plotting 53
4.5 3 – Axis Accelerometer – ADXL330 56
4.6 Experimental Study 58
4.7 Discussion 60
4.7.1 Compiling Coding 61
4.7.2 Plotting Graph in C Language Environment 62
4.8 Summary 62
V VALIDATION OF RESULT 63
5.1 Introduction 63
5.2 Validation Result 63
5.3 Summary 66
VI CONCLUSION AND SUGGESTION 67
6.1 Conclusion 67
xiii
REFERENCES 69
APPENDIX A: Source Code in CCS C Compiler 72
APPENDIX B: Schematic Circuit Layout of Prototype 95
APPENDIX C: PCB Layout of Prototype 96
xiv
LIST OF TABLES
2.1
2.2
PIC18F452 Specification
PIC16F877A Specification
23
25
4.1
5.1
Stability and Movement Control of Autonomous Helicopter
Validation Result
47
xv
LIST OF FIGURES
2.1 Representation of a Gene 7
2.2 Population 9
2.3 Binary Encoding 11
2.4 Selection 12
2.5 Single Point Crossover 16
2.6 2.7 2.8 2.9 2.10 2.11 2.12 2.13 2.14 2.15 2.16
Two - Point Crossover
Picture of PIC18F452
40 -Pin DIP Diagram of PIC18F452
Picture of PIC16F877A
40-Pin PDIP Diagram of PIC16F877A
GUI of Dev – C++ User Environment
Information of Dev – C++
GUI of Quincy 2005 User Environment
Information of Quincy 2005
GUI of CCS C Compiler User Environment
GUI of Protel 99 SE Design Explorer
17 24 24 26 27 28 29 30 30 31 32
3.1 Methodology Flow Chart 36
3.2 3.3 3.4 3.5 3.6 3.7 3.8
Excerpt Coding in Dev – C++Software
Compile Coding in Dev – C++ Software
Input Parameters of the GA
Coding Used to Plot a Graph of Fitness Value versus Generations
Excerpt Coding of the Implementation of GA
Schematic Circuit of Prototype
Operations of GA Applied in Autonomous Helicopter
37 38 39 40 41 42 43
4.1 Flow Output File 48
4.2 Excerpt Data for First Generation 49
4.3 Excerpt Data for First Generation until 20th Population 50
xvi
4.5 Excerpt Data for 99th Generation until 20th Population 52
4.6
4.7
4.8
4.9
4.10
4.11
4.12
4.13
Final Generation Obtained for the Output File
First Value of Each Generation (0 – 50)
First Value of Each Generation (51 – 100)
Graph of Fitness Value versus Generation
Measuring Tilt Angle for 3 – Axes Accelerometer Sensor
Imbalance Autonomous Helicopter under Wind Blowing Factor
Stability and Movement of Autonomous Helicopter
Example of Errors in CCS C Compiler
53
54
55
56
58
59
60
xvii
LIST OF ABBREVIATIONS
DIP - Dual In – Line
EA - Evolutionary Algorithms
GA - Genetic Algorithm
NSGA - Non-Dominated Sorting Genetic Algorithm PDIP - Plastic Dual In – Line
PIC - Programmable Interface Controller
ρ - Angle deviation from x-axis
φ - Angle deviation from y-axis
xviii
LIST OF APPENDIX
A Source Code in CCS C Compiler 72
B Schematic Circuit Layout of Prototype 95
C PCB Layout of Prototype 96
1
CHAPTER 1
INTRODUCTION
1.1 Introduction
2
1.2 Objectives
The objectives of this project are: i. To study the Genetic Algorithm concept
ii. To develop Genetic Algorithm in C language environment
iii. To implement C programming of Genetic Algorithm into microcontroller iv. To control the stability and movement of autonomous helicopter
1.3 Scope of Study
This project required to study and understands the concept of GA from the sources of reference book and internet. Through the understanding of GA, the functions of GA are then programmed in C language environment. Besides that, developments of fitness functions are required to carry out for stability and movement control. Finally, a set of sensors data will be optimized by using GA and the optimized results will be used to control the motors of autonomous helicopter in order to achieve the stability and movement control.
1.4 Problem Statement
3
1.5 Organization of the Report
The whole report is divided into six major parts, which is known as Introduction, Literature Review, Methodology, Results and Discussion, Validation Result and Conclusion.
Basically, each of the content of each chapter is;
i. Chapter 1 : Introduction
This chapter contains the background of the problem statement generally and includes the objectives and the scope of the study. Overall in this chapter, it summarized the progress of the whole project describing the how the whole project is been done.
ii. Chapter 2: Literature Review
In this chapter, any information which is related to the project is studied and summarized it, such as GA concept, C language environment, and so on. The source of the information can be from journals, books, internet, articles and etc. Base on the information from past studies and research, it will guide a correct path for the continuous project.
iii. Chapter 3 : Methodology
It describes overview of the research methods and how to conduct the research methods. It provides the details of the procedures like method of GA, the functions of GA, implementation of GA into C programming, implementation of C programming into microcontroller.
iv. Chapter 4 : Results and Discussion
4
comprehensive way. It also analyzes the results with experimental study. The explanation of results will let readers more understand on this project.
v. Chapter 5 : Validation of Result
It used the result in Chapter 4 to validate the precision and accuracy of data in achieving optimum value.
vi. Chapter 6 : Conclusion
It summarizes the main findings and how the scope is covered fully and brief recommendation for further study. Hence, alternative ways or suggestions can be recommended for improving the project in further studies.
1.6 Summary
5
CHAPTER 2
LITERATURE REVIEW
2.1 Introduction
Autonomous helicopter is an aircraft that has high mobility. It can take off and land vertically, and it can move forward, backward, and laterally. Therefore, it is expected that an autonomous helicopter will work where a human cannot work. It takes time for a human to control the autonomous helicopter manually because of the complicated flight characteristics. Hence, the stability flight control of the autonomous helicopter is important. To realize this flight, it is necessary for the autonomous helicopter to measure the position and the attitude precisely and to control the helicopter with stable [5].
6
2.2 Genetic Algorithm
Genetic Algorithms simulate natural evolution to perform function optimization and machine learning. A potential solution to the problem is encoded as a chromosome. Genetic Algorithms maintain a group of chromosomes, called the population, to explore the search space. The fitness function evaluates the performance of each chromosome to measure how close it is to the solution. The search space is explored by evolving new chromosomes into GA.
This type of algorithm is based on the Darwinian principle of evolution through natural selection: the fitter individual has higher chance of survival and tends
to pass on its favorable traits to its offspring. A „„good‟‟ parent is assumed to be able
to produce „„good‟‟ or even better offspring. Thus, chromosomes with higher fitness
scores have higher chances of producing offspring. New chromosomes are generated by applying operators that alter the underlying structure of these existing chromosomes. The process is repeated until the solution is found or the maximum number of iterations is reached [6].
The algorithm simulates the natural selection and adopts heredity thought, and can optimize in large range, also its optimizing velocity is very fast in the
forepart, meanwhile, the algorithm needn‟t search for the derivative of the object
functions which can simplify the compute greatly, so Genetic Algorithm have its special and strong excellence in solving the complex multivariate nonlinear equations whose state varies constantly [7].
GAs‟ structures can be illustrated and explained as follows.
2.2.1 Genes
Genes are the basic “instructions” for building a Generic Algorithms. A