Optimal Stabilization Control Of Autonomous Helicopter Using Genetic Algorithm in C Language Environment.

(1)

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


(2)

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: ………..


(3)

iii

“I hereby declare that this report is the result of my own work except for quotes as cited in the references.”

Signature :

Author : TAN TECK SEONG Date :


(4)

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 : ………...

Supervisor‟s Name : MADAM WONG YAN CHIEW Date :...


(5)

v

Dedicated to my family, specially to my beloved mother, brother and sisters, my lecturer and lastly my friends.


(6)

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.

Last but not the least, I would like to extend my heartiest thanks to my beloved family. They are understanding, supportive, loving and caring especially for the period during development of this project. Special appreciation to all of you.


(7)

vii

ABSTRACT

This research presents the stability control of prototype helicopter using Genetic Algorithm (GA) to obtain optimization. Since the movement of prototype helicopter is complicated, this is very difficult to control the stability of prototype helicopter with traditional methods. The design strategy is to employ the GA to search the optimized parameters of the stability control. The GA is developed in C language environment and optimized sensors data as input is implemented into microcontroller to control rotors to achieve the stability and balancing movement control. The compiler software that are used comprise of Dev – C++, which is used to compile the GA functions in C programming and analyze the results of GA functions based on the different input parameters and fitness function. Quincy 2005 software that is used to plot the graph of data that created by the GA functions in C language environment since Quincy possesses integrated Koolplot 2D plotting library, CCS C Compiler is used to program coding into microcontroller. The software that will be used to draw the schematic and PCB design is Protel 99 SE. The purpose of using Protel 99 SE is to create a prototype for validation and testing of GA program. GA is developed in C language followed by compiling and debugging. The real time testing is carried out to validate the coding programmed. A graph of fitness value versus generation is plotted in order to find optimum value. The optimum value will be used as input for controlling motors as autonomous helicopter is capable to achieve stability. The time taken for autonomous helicopter to achieve stability depends on number of generations that are executed.


(8)

viii

ABSTRAK

Kajian ini bertujuan mempersembahkan kawalan kestabilan helikopter prototaip dengan menggunakan algoritma genetik (Genetic Algorithm) untuk memperoleh pengoptimuman. Sejak pergerakan helikopter prototaip adalah rumit, keadaan ini sangat sukar untuk mengawal kestabilan helikopter prototaip dengan cara-cara tradisional. Oleh sebab itu, strategi yang digunakan ialah mengaplikasikan GA untuk mencari- parameter yang dioptimumkan untuk kawalan kestabilan. GA dibangunkan dalam persekitaran bahasa C (C Language) dan data pengesan- yang dioptimumkan sebagai input akan dilaksanakan kepada mikropengawal untuk mengawal rotor bagi mencapai pengawalan pergerakan kestabilan dan keseimbangan. Perisian penyusun yang digunakan terdiri daripada Dev - C++, yang digunakan untuk mengumpulkan fungsi GA dalam pengaturcaraan C dan analisa keputusan fungsi-fungsi GA berdasarkan parameter input yang berbeza dan fungsi-fungsi kesesuaian. Quincy 2005 perisian digunakan untuk memplotkan graf data yang dicipta oleh GA berfungsi dalam persekitaran bahasa C kerana Quincy memiliki plot perpustakaan bersepadu 2D Koolplot, CCS C Compiler adalah digunakan untuk memprogram pengekodan kepada mikropengawal. Perisian yang akan digunakan untuk melukis skematik dan reka bentuk PCB ialah Protel 99 SE. Tujuan menggunakan Protel 99 SE adalah untuk mencipta sebuah prototaip untuk pengesahan dan ujian program GA. GA dibangunkan dalam bahasa C diikuti dengan penataan dan penyahpepijatan. Ujian masa nyata dijalankan untuk mensahihkan pengekodan diprogramkan. Satu graf nilai kesesuaian lawan generasi diplotkan supaya mencari nilai optimum. Nilai optimum akan digunakan sebagai input untuk motor-motor pengawalan di mana helikopter berautonomi mampu mencapai kestabilan. Masa yang digunakan oleh helikopter berautonomi bagi mencapai kestabilan bergantung kepada jumlah generasi-generasi yang adalah dijalankan.


(9)

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


(10)

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


(11)

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


(12)

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


(13)

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


(14)

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 63


(15)

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


(16)

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 61


(17)

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


(18)

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


(19)

1

CHAPTER 1

INTRODUCTION

1.1 Introduction

Helicopter is one of the example that having control problem for a highly complex and unstable system, nonlinear, and very sensitive to external disturbance [1]. To overcome the problems, Genetic Algorithm (GA) can be applied since it is often used in optimization and search problems [2]. It is a search technique used in computing to find exact or approximate solutions to optimization and search problems. Genetic Algorithms are a particular class of evolutionary algorithms (EA) that use techniques inspired by evolutionary biology such as inheritance, mutation, selection, and crossover. This robust and flexible method can handle complex problem domains as well as noise and can be used for multi objective optimization [3]. Because of these characteristics, the microcontroller for an autonomous helicopter must be fast in computing the control response. This kind of prototype is often tuned in different operating conditions such as vehicle speed, payload, and altitude or wind speed [4]. The programming of Genetic Algorithm will be implemented into microcontroller of autonomous helicopter. The microcontroller will receive sensors data as the input, and it will be analyzed and optimized by Genetic Algorithm in microcontroller, and the output will be feedback to the motors of helicopter to achieve the stability and movement control for the helicopter.


(20)

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

Helicopter is one of the example that having control problem for a highly complex and unstable system, nonlinear, and very sensitive to external disturbance. To overcome the problems, Genetic Algorithm (GA) can be applied since it is often used in optimization and search problems. This robust and flexible method can handle complex problem domains as well as noise and can be used for multi objective optimization. Because of these characteristics, the microcontroller for an autonomous helicopter must be fast in computing the control response. This kind of autonomous is often tuned in different operating conditions such as vehicle speed, payload, altitude or wind speed.


(21)

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

It states all the results such as tables, figures and graphs when research carrying out. All the important results will be presented in a


(22)

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

It can be summarized that the whole idea of the project is all about the usage of GA for optimization and control the stability and movement of autonomous helicopter. It begins with the objective of the project, scope of study and research. During carrying out this project, problems encountered should be determined and this will lead to solve problems by studying research and information from various types of resources.


(23)

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].

This chapter comprises of study or research on methods and designs that had are applied in similar researches. The research carried out is important in guiding and identifying problems encountered and assist in leading to completion of this study.


(24)

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


(1)

CHAPTER 1

INTRODUCTION

1.1 Introduction

Helicopter is one of the example that having control problem for a highly complex and unstable system, nonlinear, and very sensitive to external disturbance [1]. To overcome the problems, Genetic Algorithm (GA) can be applied since it is often used in optimization and search problems [2]. It is a search technique used in computing to find exact or approximate solutions to optimization and search problems. Genetic Algorithms are a particular class of evolutionary algorithms (EA) that use techniques inspired by evolutionary biology such as inheritance, mutation, selection, and crossover. This robust and flexible method can handle complex problem domains as well as noise and can be used for multi objective optimization [3]. Because of these characteristics, the microcontroller for an autonomous helicopter must be fast in computing the control response. This kind of prototype is often tuned in different operating conditions such as vehicle speed, payload, and altitude or wind speed [4]. The programming of Genetic Algorithm will be implemented into microcontroller of autonomous helicopter. The microcontroller will receive sensors data as the input, and it will be analyzed and optimized by Genetic Algorithm in microcontroller, and the output will be feedback to the motors of helicopter to achieve the stability and movement control for the helicopter.


(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

Helicopter is one of the example that having control problem for a highly complex and unstable system, nonlinear, and very sensitive to external disturbance. To overcome the problems, Genetic Algorithm (GA) can be applied since it is often used in optimization and search problems. This robust and flexible method can handle complex problem domains as well as noise and can be used for multi objective optimization. Because of these characteristics, the microcontroller for an autonomous helicopter must be fast in computing the control response. This kind of autonomous is often tuned in different operating conditions such as vehicle speed, payload, altitude or wind speed.


(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

It states all the results such as tables, figures and graphs when research carrying out. All the important results will be presented in a


(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

It can be summarized that the whole idea of the project is all about the usage of GA for optimization and control the stability and movement of autonomous helicopter. It begins with the objective of the project, scope of study and research. During carrying out this project, problems encountered should be determined and this will lead to solve problems by studying research and information from various types of resources.


(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].

This chapter comprises of study or research on methods and designs that had are applied in similar researches. The research carried out is important in guiding and identifying problems encountered and assist in leading to completion of this study.


(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 chromosome is a sequence of genes. Genes may describe a possible solution to a