Sei sulla pagina 1di 83

UAV QUADCOPTER

Group Members Tehseen Akhtar Muhammad Awais Chaudhry Muhammad Nahyan Mirza Muhammad Aaqib Khan Muhammad Sheryar Anjum (050498) (050480) (050475) (040265) (040281)

This project is completed in order to full fill the requirement for the degree of

BE MECHATRONICS

Project Supervisor: Dr. Shaiq A. Haq Chair Department of Mechatronics.

Project Supervisor Signature: External Examiner Signature:

DEPARTMENT OF MECHATRONICS ENGINEERING AIR UNIVERSITY, ISLAMABAD

Abstract

Unmanned aerial vehicles are aircrafts capable of flight without an on-board operator. Such vehicles can be controlled remotely by an operator on the ground, or autonomously via a pre-programmed flight path. UAVs are already being used by the military for recognizance, search and rescue operations. Our proposed design is for a lightweight, nimble craft that can be operated both indoors and out. The project poses particular challenges in terms of weight reduction, controllability and mechanical design. Quad-copter crafts generally support only a light payload, as they are required to carry the weight of the power supply, a heavy battery, onboard. Thus, weight reduction of all components is essential in order to allow for sufficient lift force. The document provides an insight on the final year project, Quad-copter UAV. The report discusses its objective, why there is a need to do this project, its working and the entire System design of the Quad-copter. It briefs the mechanical design, electronics and electrical design, software design along the project plan. The project allows one to strengthen the areas of control systems, mechanical and electronics design, embedded systems and artificial intelligence.

ii

Acknowledgment

We would like to thank our supervisors, Dr.Shaiq. A. Haq, for his patience, guidance and encouragement throughout the duration of this project and we look forward to future correspondence with him. We would also like to thank the other students and teachers who have helped in this project by any means. Special thanks to the lab assistants in the project lab, the CNC lab, and the workshop, namely Sir Abul Hassan, Sir Adnan, Sir Dawood, Sir Imtiaz and Sir Ishfaq for extending their full cooperation towards us.

iii

Table of Contents
Abstract.ii Acknowledgement....iii Table of Contents.iv List of Figures...vii Chapter 1 Introduction
1.1. What is a UAV?...................1 1.1.1 1.2 1.3 Types of UAVs ...2 Importance of helicopters & VTOL.....2 Problems associated with conventional helicopters ....3 1.3.1 1.3.2 1.4 1.5 1.6 1.7 Quadcopter ..6 History And Background Of Quadcopter7

Proposed Solution9 Complexities involved.9 Scope of this project .10 Applications...11

Chapter 2 Theory of Quadcopter


2.1 2.2 2.3 Working principle of Quadcopter..13 System of Differential Equations ......14 Simulation .17

Chapter 3 Design of Quadcopter


3.1 Mechanical Design of Quadcopter ....21

iv

3.1.1 3.1.2 3.1.3 3.2

Basic Design..22 Material Selection..22 Design Calculations...22

Prototypes .... 25 3.2.1 3.2.2 3.2.3 Quad-X-01.25 Quad-X-02.27 Quad-X-03.30 3.2.3.1 Propeller search......33 3.2.4 3.2.5 Quad-X-03-a..36 Quad-X-04.36

3.3

Control System Design .....38 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 Introduction....38 Open loop control system..38 Closed loop control system....39 Quadcopter control system....40 Quadcopter flight control software...41

Chapter 4 Features of the project


4.1 4.2 4.3 4.4 Autonomous flight.44 Path planning.44 Video surveillance.48 User interface.48

Chapter 5
Testing and Evaluation.50

Chapter 6
Conclusion.....54 References......55 Appendix ...57

List of Figures

Fig1.1: Fixed wing aircrafts (airplanes)..2 Fig1.2: Rotorcraft Eaves(Conventional Helicopters)..2 Fig1.3:BO105 helicopter's main rotor hub..4 Fig1.4: A rather complex rotor assembly of MH-53J.5 Fig1.5: Historical Tests on Quad Rotor Aircraft.7 Fig1.6: Proposed design of the Bell Boeing Quad Tilt Rotor Aircraft9 Fig2.1: Top View of Quad copter frame with moment.13 Fig2.2: Free Body Diagram of Quad copter (Side View).14 Fig2.3: Lift force transmitted through all the transformations involved...17 Fig2.4 (a): Matlab Simulation Results...18 Fig2.4 (b): Matlab Simulation Results...19 Fig2.4 (c): Matlab Simulation Results...20 Fig3.1: The basic Quad copter schematic..21 Fig3.2: Orthographic Views...23 Fig3.3: Beam Deflection24 Fig3.4: Double Rotor Dragonfly25 Fig3.5: Disintegrated Dragonfly26 Fig3.6: Rotor assembly after weight reduction..26 Fig3.7: Quad X-01...27 Fig3.8: Quad-X-02 mounted on the test bench..28 Fig3.9: Out runner 40D-05-7.0..29 Fig3.10: 18A ESC from Art-tech...29

vi

List of Figures
Fig3.11: Atml89c52 based motor driver circuit.30 Fig3.12: Test setup to determine downdraft radius. .32 Fig3.13: Quad-X-03 mounted on the test bench. .32 Fig3.14: 12x6 Art-tech adapters33 Fig3.15: 9x6 APC .34 Fig3.16: bi copter test rig...35 Fig3.17: 12x4.5 Dragon fly adapters.35 Fig3.18: Quad-X-04 before weight reduction37 Fig3.19: Weight reduction in progress on the CNC milling m/c...38 Fig3.20: Flow diagram depicting the control logic40 Fig3.21: Hardware in the loop tester schematic.41 Fig3.22: Flow Diagram of flight control software..43 Fig4.1: Flow Diagram of Path planning software..45 Fig4.2: Simulation Results of Path planning software...46 Fig4.3: Front end of the graphical user interface....49 Fig5.1: Test setup for determine lift characteristics of rotors.51 Fig5.2: Lift vs current graph for one of the motors51 Fig5.3: Test setup to determine downdraft radius.52 Fig5.4: bi copter test rig.53 Fig5.5: Test bench for mounting and testing the Quad prototypes53

vii

CHAPTER NO 1 INTRODUCTION

CHAPTER NO 1
INTRODUCTION
1.1 What is a UAV?
UAV stands for Unmanned Aerial Vehicle. A UAV is an unpiloted aircraft that can be remote controlled or fly autonomously based on pre-programmed flight plans or more complex dynamic automation systems. Most of the UAVs are currently being used in a number of military roles like reconnaissance and attack. Civil applications of UAVs are also growing rapidly. At present they are being used in applications such as firefighting when a human observer would be at risk, police observation of civil disturbances and crime scenes, and reconnaissance support in natural disasters. UAVs are often preferred for missions that are too "dull, dirty, or dangerous" for manned aircraft.

Over the years wide variety of UAV have been made with differences in shape, size, configuration, and characteristics. Most UAVs have a base station, which allows the operator to up date the flight plan of the UAV. In almost all of the applications the UAV also sends back data such as video, snapshots, sensor readings, to the base station for further processing. To represent the fact that these complex systems include base stations and other elements besides the actual aircraft, the term Unmanned Aircraft System (UAS) is used.

CHAPTER NO 1 INTRODUCTION

1.1.1

Types of UAVs:

Fig1.1: Fixed wing aircrafts (airplanes)

Fig1.2:Rotorcraft UAVs(Conventional Helicopters)

1.2

Importance of helicopters & VTOL:


Fixed wing aircrafts lack VTOL (vertical takeoff and landing ability) hence

require long runways for take off and landing. On the other hand helicopters have advantages over conventional fixed-wing aircraft on surveillance and inspection tasks,

CHAPTER NO 1 INTRODUCTION

since they possess VTOL capability which allows them to take-off and land in limited space and to hover above targets. Moreover, helicopters have the advantage of better maneuverability in limited space as compared to fixed wing aircrafts.

1.3

Problems associated with conventional helicopters:


Along with these advantages helicopters possess certain disadvantages too. In

helicopters forward and the backward movement is achieved by varying the pitch angle of the main rotor blade. This pitch angle is controlled by varying the angle of the swash plate incorporated in the main rotor assembly. The rotor size is huge and it stores a lot of kinetic energy during flight. As a result large amount of force is required to change the angle of this heavy rotating mass. All this ultimately leads to a lot of mechanical actuators and heavy assembly parts including gears, pistons and shafts resulting in a complex assembly.

CHAPTER NO 1 INTRODUCTION

Fig1.3:BO105 helicopter's main rotor hub

With increase in aircraft size and its lift capacity the rotor assembly keeps growing more and more complex.

CHAPTER NO 1 INTRODUCTION

Fig1.4: A rather complex rotor assembly of MH-53J

Another problem with conventional helicopters is the balance of the torque generated due to the main rotor. A tail rotor is incorporated to balance this torque. A separate control system is required to control the tail rotor so that it cancels out the torque induced by the main rotor at all speeds. If the tail rotor malfunctions, then the helicopter goes into a severe spin which is not controllable and ultimately results in a crash. Even with the incorporation of fly by wire systems and implementation of extensive sensors and robust control systems, the above stated problems regarding handling, safety and stability of modern day conventional helicopter still persist.

CHAPTER NO 1 INTRODUCTION

1.3.1 Quadcopter:
A Quadcopter, also called a quad rotor assembly, is an aircraft that is lifted and propelled by four static rotors. It is a dynamic hovercraft with four input forces and six degrees of freedom. Unlike regular helicopters that have variable pitch angle rotors, a Quadcopter has four fixed-pitch angle rotors. The basic motions of a Quadcopter are generated by varying the relative angular speeds of the four rotors, thereby changing the lift forces. The Quadcopter tilts towards the direction of the slow spinning rotor, which produces acceleration along that direction. Therefore angular speed of the four rotors and the motion of the Quadcopter are closely related. Spinning directions of the rotors are set to balance the moments and eliminate the need for a tail rotor. This principle is also used to produce the desired yaw motion.

1.3.2 History And Background Of Quadcopter


The Quadcopter idea is not new; in fact the first Quad-rotor helicopter was built earlier than the cyclic/collective pitch helicopter we know today. One of the first was built in France by the brothers Louis and Jacques Brguet. It was called gyroplane nr 1 and consisted of four rotors in a square. The tests flights did not end up very well; the helicopter was simply too difficult to control for the pilot.

CHAPTER NO 1 INTRODUCTION

Fig1.5: Historical Tests On Quad Rotor Aircraft

Even though the concept of the Quad-rotor helicopter is simpler than the traditional cyclic/collective pitch helicopter; it was not further developed until the introduction of a control system to control the helicopter.

Talking about quad-rotor paper work, there is a fair amount of published research with regards to quad-rotor aircraft. In fact, there are many patents for designs similar to ours. Among them are a few Four Propeller Helicopter designs and Quad Tilt rotor designs and various vertical lift aircrafts.

In the world of higher education, there are a few members of academia who have published research on quad-rotor UAVs. Among them are Joseph F. Horn and Wei Guo of Pennsylvania State University (Modeling and Simulation for the Development of a Quad-Rotor UAV Capable of Indoor Flight), Ming Chen and Mihai Huzmezan of the University of British Columbia (A Simulation Model and H Loop Shaping Control of

CHAPTER NO 1 INTRODUCTION

a Quad Rotor Unmanned Air Vehicle), and Eryk Brian Nice of Cornell University (Design of a Four Rotor Hovering Vehicle).

Furthermore, on a much larger, industrial scale, there is currently a project in development named the Bell Boeing Quad Tilt Rotor. It is a large-scale, governmentsponsored, quad-rotor aircraft currently in development as a joint venture between Bell Helicopter Textron and Boeing Integrated Defense Systems. The project is the largestscale of all the existing projects, and with a capacity of upwards of 150 passengers, far exceeds the size and span of any other similar project.

Fig1.6: Proposed design of the Bell Boeing Quad Tilt Rotor Aircraft

Today the Quad-rotor helicopter configuration is found mostly in radio controlled toy helicopters. One of the most known manufactures is RC-toys with the model Dragon flyer. An attempt to search for similar projects in the market did not yield many results.

CHAPTER NO 1 INTRODUCTION

Aside from a few overachieving hobbyists, there exist only a few commercially available products which take advantage of similar quad-rotor flight. Amongst these are the Silver lit X-UFO and the Dragon flyer.

1.4

Proposed solution:

Naturally the desire of stability and control is always there and as a result new concepts and improvements in the original design continue to emerge. The problem of torque balance and stability was partially resolved by a new concept in helicopter industry introduced as the Quadcopter. This concept was based on implementing four rotors on four positions equidistant from the center.

1.5

Complexities Involved and Assumptions Made:


The main problems encountered while designing Quadcopter in this project

include determining the lift and drag coefficients for the propellers being used. Due to lack of data, from the supplier of rotors, and lack of equipment we had to adopt practical means to cater for these deficiencies. Furthermore, since this project is a unique one of its kind in Pakistan so facilities for its testing were not available. As a result all testing and evaluation of the components used and of all prototypes was carried out on custom designed test rigs and facilities. These will be discussed in detail in the upcoming chapters. Procurement of components was another challenging task in this project. But all possible means were used to get the required components.

CHAPTER NO 1 INTRODUCTION

1.6 Scope of this project


This project is divided into two parts. The first part of the project is to design low cost UAV using commercially available parts. The designed vehicle should be feasible for testing variety of aircraft controllers designed using different technologies. As the vehicle is going to be used as a testing platform, it should be durable and at the same time easily repairable. It should also have enough flight time so that some meaningful information can be deduced from the data collected in each test. Controlling an aircraft is a very difficult task but the level of difficulty can be reduced, to some extent, by choosing an appropriate design. Therefore, selection of the design must be done carefully. In the design selection process the factors such as testing facility, safety of the operators, and life span of the components required, transportation of the vehicle must also be taken into consideration. There has been very little work on Atml89c52 based controllers especially for applications such as Unmanned Aerial Vehicle (UAV). Most of the UAV systems use DSP/microprocessor and FPGAs (field programmable gate arrays) as their processing units. The second part of this project will cover the designing and developing of a complete control system for a UAV based on Atml89c52 technology. This system will utilize ADCS (Analogue to Digital Converters) along with microcontrollers for the acquisition module and the actuator control signal module and it will utilize PID (proportional integral and derivative) control in the stabilization controller.

10

CHAPTER NO 1 INTRODUCTION

1.7

Applications:
1. The quad copter would do everything that a conventional helicopter does but with abilities to lift more payload, simpler construction and safer operation. 2. The UAV version can be used for surveillance tasks like: a. Monitoring a crowd or any activity b. Acquiring aerial views of disaster hit areas c. Military and search operations 3. The future prospect of the Quad-copter is the development of a small model hovercraft which can be used for inspection where no human can go. 4. The Quad-copter could be used to supply aerial electricity cables, into mines after accidents or into unsafe buildings. 5. The Quad-copter may be used for future TV surveillance from above by replacing the use of a full size helicopters and camera cranes.

11

CHAPTER 2 THEORY OF QUADCOPTER

CHAPTER 2
THEORY OF QUADCOPTER
2.1 Working principle of Quadcopter:

Fig2.1: Top View of Quad copter frame with moment

The working principle of the Quadcopter is depicted in the above figure. The two rotors r1 and r3 have positive or counter clockwise rotation while the two others have negative or clockwise rotation.

Altitude and velocity control is obtained by regulating the thrust of the four rotors. The thrust can be controlled by the angular velocity of the rotors.

When all rotors have same angular velocity, the quad-copter is in hover or is in vertical flight. Increased horizontal velocity in the x direction is obtained by increasing the angular velocity of r2 and r3, while increase of r3 and r4 increases velocity

12

CHAPTER 2 THEORY OF QUADCOPTER

in the horizontal y direction. Increased rotational velocity around the vertical z axis is obtained by increasing the angular velocity of r1 and r3, while negative angular velocity is obtained by increasing the velocity of r2 and r4. The following figure helps to understand and visualize the concept even further.

Fig2.2: Free Body Diagram of Quad copter (Side View)

In the above figure the vertical (cos) components of the lift force balance out the weight (mg) of the hovercraft and provide vertical acceleration while the horizontal (sine) components cause acceleration towards the right.

2.2

System of Differential Equations


The dynamics of the UAV Quad Copter are determined from a set of equations of

motion. The complexity of the equations of motion increases with the increased accuracy. We have used simplified equations which are presented in Altug, et al in Control of a Quadrotor Helicopter Using Visual Feedback. The set of equations presented, model the motion of the craft based on the amount of lift delivered by each individual motor 13

CHAPTER 2 THEORY OF QUADCOPTER

without taking into account the aerodynamics of the air craft. The amount of lift each motor provides is controlled by the amount of power delivered to each motor and the relation between them was found experimentally and was approximately linear as given in section 6.2(a).

The relationship between motion and power can be linear, parabolic or any other trigonometric function. For example referring to the figure in section 6.1(a) the air craft will move in the positive x-direction and negative y-direction by reducing the thrust from motor A (by reducing the power) and simultaneously increasing the thrust (by increasing the power) from motor C. The thrust from motor B and D must be increased so that the craft maintains constant altitude while moving along the desired path. More complex movements can be achieved by varying the power delivered to all four motors and will be studied in the following subsection. The equations of motion that govern the dynamics of the craft are listed below.

(2.1)

(2.2)

(2.3)

14

CHAPTER 2 THEORY OF QUADCOPTER

(2.4)

(2.5)

(2.6)

Here given by the given by the for simplicity.

are the pitch, roll and yaw respectively. The forces on the motors are terms. The moments of inertia of the air craft with respect to the axis are terms. The terms represent the drag coefficients, which can be ignored

is the unbalanced moment represented in terms of force (M) and

distance (L) from the centre. The centre of gravity is assumed to be at the origin.

These set of equations can easily be derived by transmitting the forces, due to the rotors, through the various transformed coordinate systems as depicted in figure below.

15

CHAPTER 2 THEORY OF QUADCOPTER

Fig2.3: Lift force transmitted through all the transformations involved.

2.3

Simulation
The craft can increase in altitude by simultaneously increasing the thrust from all

motors. Likewise, the craft can descend (if already airborne) by simultaneously decreasing the thrust from all motors. Similarly different maneuvers of the hovercraft can be achieved by altering the value of the four forces involved. In order to understand and get a physical insight into the functioning of the hovercraft we solved the system of six coupled ODEs using ode45 function of MATLAB. The code is available in Appendix A.1. Here we would show few results that we simulated which helped us in understanding the behavior of our hover craft in air.

16

CHAPTER 2 THEORY OF QUADCOPTER

X-Axis 1 0.5 0 -0.5 -1 1 0.5 0 -0.5 -1

Y-Axis 30

Z-Axis

20

10

5 Pitch Angle

10

5 Roll Angle

10

5 Yaw Angle

10

1 0.5 0 -0.5 -1

1 0.5 0 -0.5 -1

1 0.5 0 -0.5 -1

10

10

10

Fig2.4 (a): Matlab Simulation Results

The above graphs show the displacements in all the six axes if equal amount of forces are applied by each of the four motors and their sum is greater then the total weight of the frame. We can see clearly from the graphs that the air craft would only move in the z-axes and displacements in all the other axes would be zero. Similarly if we want to see the graph of the displacements if unequal forces are applied we will just change the values of those forces and simulate the behavior of the hover craft as follows:

17

CHAPTER 2 THEORY OF QUADCOPTER

X-Axis 0 -1 -2 -3 -4 -5 0 1 Pitch Angle 0 -0.2 -0.4 -0.6 -0.8 0 -0.2 -0.4 -0.6 -0.8 2 5 4 3 2 1 0 0

Y-Axis 1 0.8 0.6 0.4 0.2 1 Roll Angle 1 0.5 0 -0.5 -1 2 0 0

Z-Axis

1 Yaw Angle

Fig2.4 (b): Matlab Simulation Results

The above graphs show the displacements when F2=F4=1.3N, F1=1.32N and F3=1.28N. We noticed that after one second the altitude of the hover craft starts to fall. Now lets look at the following graphs:

18

CHAPTER 2 THEORY OF QUADCOPTER

X-Axis 0 -0.2 -0.4 -0.6 -0.8 0.8 0.6 0.4 0.2 0

Y-Axis 30

Z-Axis

20

10

5 Pitch Angle

10

5 Roll Angle

10

5 Yaw Angle

10

1 0.5

-0.005

-0.005

0 -0.5

-0.01

10

-0.01

10

-1

10

Fig2.4 (c): Matlab Simulation Results

Above graph shows the displacements and velocities of the hover craft in the respective axes from zero the ten seconds when F2 and F4 are equal to 1.3 and F1 and F3 are now 1.30001 and 1.29999 respectively. We noticed that only a small change in the relative velocities of the rotors caused it to move with approximately same velocity but in this case its altitude does not fall. Similar results can be plotted to check the behavior of our hover craft for different values of inputs.

19

CHAPTER 3 DESIGN OF QUADCOPTER

CHAPTER 3
DESIGN OF QUADCOPTER
3.1 Mechanical Design of Quadcopter:

The Mechanical Design has been categorized in the following sections: a. Basic Design b. Material Selection c. Design Calculations

3.1.1 Basic Design


The basic design consists of two links attached together in a cross formation. The links are reinforced at the center by plates. Motors are mounted at the end of the links.

Fig3.1: The basic Quad copter schematic

20

CHAPTER 3 DESIGN OF QUADCOPTER

3.1.2 Material Selection


The criterion for the selection of material was: Durability Strength Machine ability Light Weight Availability Cost

So the material selected was Aluminum

Physical Properties Density Mechanical Properties Ultimate Tensile Strength Modulus Of Elasticity

Metric System 2560kg/m3

70MPa 70GPa

Table 3.1: Properties for Aluminum Alloy 1100-H14

3.1.3 Design Calculations


Lift Calculations

As the blades have a natural twist to make the lift force constant along the length of the blade. Angle of attack =16.6 0 The formula for lift is: L=1/2(p.v2.A.C L ) (1.7)

21

CHAPTER 3 DESIGN OF QUADCOPTER

Where: L=Lift force p=Density of air V=Linear velocity of aerofoil A=Area swept by the aerofoil C L =Coefficient of lift According to the datasheet of the motors, the maximum lift force they can provide with 12X6 propeller is = 550g X 9.81 = 5.4N For the Arms we elected Square pipes of Aluminum 12.5 X 12.5 mm which are easily available in the market. The material selected for the central part (base plate) of the frame is Aluminum of 2.2mm The stress calculations for above selected material are as follows: The critical points in the frame are the joints of the arms with the base plate.

The stress calculations are as follows: Considering the arms as cantilevers, so the moment generated by the lift force is Bending stress:

Fig3.2: Orthographic Views


M = 30 * 5.40 / 100 = 1.62N.m The moment of inertia is I = [ (.0125)^4 (.0105)^4 ] / 12 = 1.0216x10^-9 m4 Centroid = y = 6.25mm Bending stress = = ( M x y ) / I = 9.92MPa << 70MPa (maximum bending stress) b

22

CHAPTER 3 DESIGN OF QUADCOPTER

Maximum Deflection:

Fig3.3: Beam Deflection


F= 5.40N L=a=20cm Elastic Modulus = E = 70GPa Deflection = Y = Fa^2 ( 3L a ) / ( 6EI ) = .201mm

As,

Bearing Stress on Bolts and base plate:

= 9.92 MPa and Area = 2.3*10^-5 m b so F= 9.92*10^6 X 2.3*10^-5 = 228.16N Bolt diameter = 3 mm Area of the bolt in contact = 3.14 ( 1.5 x 1 ) (bolt) = 228.16 / 3.14 ( 1.5 x 1 ) = 48.4 MPa << 70 MPa ,Hence its safe to use bearing the bolts On the base plate it is; (Base plate) = 228.16 / 3.14 ( 1.5 x 2.2 ) = 22 MPa << 70 MPa so safe to use. bearing

23

CHAPTER 3 DESIGN OF QUADCOPTER

3.2

Prototypes:
It is natural to expect a lot of prototypes during the development of a research

based project. The same situation applies to our case. A total of four prototypes were developed before making the final version. 3.2.1 Quad-X-01: Quad X-01 was the first prototype that we developed. This constituted of a simple cross frame made of aluminum square pipes, reinforced at the center using square plastic plates. Four rotors were mounted at the four ends of the cross. The motors used were extracted from commercially available toy helicopters (Double rotor dragonfly). These were permanent magnet dc motors rated to operate at 9V and 6A. The rotors were 18 inches in length and had an angle of attack of 16 degrees. The rotor assembly of the dragonfly was used after using all possible weight reduction tactics. The rotor-assemble weighed 150g, including propellers.

Fig3.4: Double Rotor Dragonfly

24

CHAPTER 3 DESIGN OF QUADCOPTER

Fig3.5: Disintegrated Dragonfly

Fig3.6: Rotor assembly after weight reduction

25

CHAPTER 3 DESIGN OF QUADCOPTER

Fig3.7: Quad X-01

3.2.2

Quad-X-02: Quad-X-01 was based on permanent magnet DC motors. Permanent magnets lose

their strength if the motor runs for a longer duration at peak current. With time the peak thrust of the motors started to decrease. As a result, the motors had to be changed. So, Quad-X-02 was developed.

26

CHAPTER 3 DESIGN OF QUADCOPTER

Fig3.8: Quad-X-02 mounted on the test bench

The entire design was altered. The motors selected were AC synchronous motors (out runner 40D-05-7.0). That comes with 12*6 propellers and an 18A ESC (Electric Speed Controller). Now Aluminum I beams were used instead of Aluminum square pipes.

27

CHAPTER 3 DESIGN OF QUADCOPTER

Fig3.9: Out runner 40D-05-7.0

Fig3.10: 18A ESC from Art-tech

28

CHAPTER 3 DESIGN OF QUADCOPTER

The three-phase AC servo motors are controlled via PWM supplied to the ESC. The pulse type used has a time period of 20ms, minimum high time of 1ms (motor is off) and a maximum high time of 2ms (motor running at max speed). An atml89c52 based test circuit was designed to drive the motors. A LCD was attached to display the high time in microseconds.

Fig3.11: Atml89c52 based motor driver circuit

3.2.3

Quad-X-03: Through testing it was discovered that the Quad-X-02 design required a lot of

changes. Firstly all the propellers used were designed to rotate in the same direction there by producing an unbalanced torque. Though, this was not a mechanical design flaw but the unavailability of counter pitch propellers in the local market.

29

CHAPTER 3 DESIGN OF QUADCOPTER

During the test runs, it was revealed that the distance between the two propellers was not appropriate. The interaction of the down drafts produced by neighboring propellers produced turbulence which resulted in loss of lift and instability.

To cater for these problems we had two tasks at hand: To hunt for counter pitch propellers To determine the effective radius of the rotor down draft and to change the mechanical design accordingly.

For the first task we used all possible resources to arrange the required propellers. For the second task we designed an experiment as we didnt have the facility of wind tunnel available at our university premises. The apparatus used for the experiment consisted of a simple steel ruler with thin pieces of tissue taped at equal intervals of length. The ruler was placed right next to the propeller and the motor was run. The tissue pieces were closely monitored and it was discovered that 12 propellers produce a down draft of about 9 radius.

30

CHAPTER 3 DESIGN OF QUADCOPTER

Fig3.12: Test setup to determine downdraft radius.

As a result Quad-X-3 was developed and the distance between neighboring propellers was kept safely as 6.5. The same motors were used and the propellers were not yet changed.

Fig3.13: Quad-X-03 mounted on the test bench.

31

CHAPTER 3 DESIGN OF QUADCOPTER

3.2.3.1

Propeller search: The propellers that came with the Brushless motor combo pack were 12x6

propellers. They had a good thrust to motor power ratio but they were all designed to rotate in the same direction. On the contrary our hovercraft design required two clockwise and two anticlockwise rotating propellers. Furthermore counter pitch propellers of the same size and make were not available in the market. Propellers tested: 12x6 Art-tech adapters

Fig3.14: 12x6 Art-tech adapters

These adapter type propellers came along the brushless motors but were all designed to run in the same direction. Counter pitch propellers of the same profile and make were not available so the choice was dropped.

32

CHAPTER 3 DESIGN OF QUADCOPTER

9x6 APC

Fig3.15: 9x6 APC

These propellers were smaller compared to the earlier model but come in pairs of two one clockwise rotating and the other counter clockwise. So these could serve the purpose. A pair of these propellers was ordered from Singapore and tested.

Problems encountered: These propellers didnt fit the shaft of the motors. They had a larger bore so bushings were required. Due to lack of time and resources it was decided to design custom bushings rather than ordering the same from Singapore. Hence wooden bushings were made on the CNC lathe machine and were press fit in these propellers.

33

CHAPTER 3 DESIGN OF QUADCOPTER

A bi copter test rig was designed and fabricated to check these propellers with the out runner motors selected earlier.

Fig3.16: bi copter test rig

12x4.5 Dragon fly adapters

Fig3.17: 12x4.5 Dragon fly adapters

The test results for 9x6 APC revealed that these propellers had a greater mass than the adapters. A large moment of inertia is produced when they rotate and result in greater loads on the motor shaft when the center of rotation is altered. Secondly being

34

CHAPTER 3 DESIGN OF QUADCOPTER

small in size the 9x6 APC propellers produce less lift compared to the adapter type propellers.

12x4.5 Dragon fly adapters were the next choice. These are the only large and light weight propellers available on the net (dragonfly official website). These propellers were ordered and shipped form America. These propellers come in pairs of two, one normal propeller accompanied with a counter pitch propeller. Also included in the pack are two set of fine steel bushings to fit the propellers on different sized motor shafts.

3.2.4

Quad-X-03-a: This prototype was a mere upgrade of the Quad-X-03. The only change in the

design was the implementation of the new propellers (12x4.5 dragonfly adapters).

3.2.5

Quad-X-04: Quad-X-03 scored high in all the test runs but was rated low over its looks.

Therefore the design was altered by replacing the 0.5x0.5 aluminum links with 1x1 links. This did increase the weight of the craft but other weight reduction techniques were adapted to cater this new problem. This new design was termed as Qua-X-04. High density Styrofoam was used as the rotor guards. The spring steel strips were selected to make the landing gear. Due to lack of availability of the desired gauge of steel strips in the market we had to go for a custom solution. Steel blades for hack saws were altered to serve the purpose.

35

CHAPTER 3 DESIGN OF QUADCOPTER

Fig3.18: Quad-X-04 before weight reduction

Steel was heavy for the landing gear and so were the new links. The weight of the links was reduced by drilling holes through them to remove material. This task was accomplished on the CNC milling at our university. The landing gear design was altered by replacing the spring steel strips with static low density Styrofoam packing material.

36

CHAPTER 3 DESIGN OF QUADCOPTER

Fig3.19: Weight reduction in progress on the CNC milling m/c

3.3
3.3.1

Control System Design:


Introduction
A control system is a device or a set of devices, which manages, commands, direct or

regulates the behavior of another device or set of devices. There are mainly two types of control systems: 1. Open loop control system 2. Closed loop control system

3.3.2

Open loop control system


In an open loop control system there is no feedback loop. That means the task is done

by following a set of predetermined sequential steps. The parameters for these steps of the control loop are calculated from the parameters of the device being controlled. For example the device being controlled is a motor and the speed of the motor is directly proportional to the currant through its armature. The task is to maintain a certain

37

CHAPTER 3 DESIGN OF QUADCOPTER

speed. Know the controller can control the motor and perform this task by calculating the amount of currant needed by using the relationship between the currant and speed parameters of the motor. As the controller is an open loop control system that means there is no information of the output getting back to the controller and the accuracy of control is dependent on the current and speed relationship of the motor. This relationship in turn depends on a lot of other parameters like temperature, humidity wear and tear of the mechanical parts etc. Therefore, prior to designing the control system, the effect of all these parameters on the currant-speed relationship must be studied. Also the controller will need sensors to determine the environment of the motor and because of the added parameters it will take longer to calculate the answer.

3.3.3

Closed loop control system


The closed loop control system has a feedback loop. The feedback loop consists of a

sensor, which takes the reading of the output of the device being controlled, and converts it in to a form that can be inputted in to the controller. The controller uses this information in combination with the information of the parameters of the device being controlled to decide the next step. Taking the same example, as before, of the electric motor. The feedback for this system will comprise of a sensor, which can take the reading of the speed of the motor. Considering the same task of maintaining a certain speed, the controller, by using the currentspeed relationship of the motor, will decide on the currant required for the task. Now as it is a closed loop system it gets the reading of the output and by using this information the controller can improve on its calculations, for example, by increasing the

38

CHAPTER 3 DESIGN OF QUADCOPTER

currant if the actual speed is slower then the required speed and vice versa. There by, increasing the overall accuracy of the system.

3.3.4

Quadcopter control system: The following flow diagram represents the logic behind the electronic circuit for

controlling one of the four motors.

Fig3.20: Flow diagram depicting the control logic

The controller implements proportional control logic. A default position is fed in to the control system. This default value is then compared with the feed back from the accelerometer. An error signal is generated multiplied with a correction factor and the pwm supplied to the ESC is modified accordingly. A hard ware in the loop tester was developed to implement the above logic. The circuit diagram is as follows:

39

CHAPTER 3 DESIGN OF QUADCOPTER

Fig3.21: Hardware in the loop tester schematic

Here the LCD is added to show the duty cycle of the wave supplied to the ESC by the controller. In this circuit only one out of the two concerned axes is catered. The circuit was simulated using Proteus 7.2 before making the hardware. Similar circuits are used to control the rest of the three motors and the remaining axes except that each axes will employ a separate ADC. Therefore each individual motor will have its own controller and ADCs. 3.3.5 Quadcopter flight control software:

The objective is to balance the Quadcopter while hovering. The four motors installed on the Quadcopter are identical but they still may not run at the same rpm for the same applied voltage. This may result in slight unbalance force, thrust at any rotor, 40

CHAPTER 3 DESIGN OF QUADCOPTER

which can result in a crash. To work on this problem we will need to develop a feedback system that monitors the orientation of the Quadcopter in the hover mode, and aligns it to the reference horizontal position every time a change is sensed. The orientation will be adjusted by altering the rpm of the four motors. Firstly, initializing the motors and gradually increasing the rotor speed until the weight of the Quadcopter is counter balanced by the lift force (thrust). Furthermore, taking input from the user. If there is no input then consider the angle as zero and balance the Quadcopter at zero position. The next step involves taking the input from accelerometer and calculating the error (i.e error=input-feedback). The error is catered by multiplying it with Kp for proportional control. This correction factor so generated, is then used to generate the new pulse width that will correct the out put.

41

CHAPTER 3 DESIGN OF QUADCOPTER

The Flow Diagram for the program logic is as follows:

Fig3.22: Flow Diagram of flight control software

42

CHAPTER 4 Features of the project

CHAPTER 4
Features of the project
Broadly the features of the project are: Autonomous flight Path planning Video surveillance

4.1

Autonomous flight: Due to lack of time, resources and man power, this task has been achieved to the

extent that the hover craft is able to take off, hover for some time and then land. In a Quadcopter design, this is the most difficult task which has been achieved successfully. 4.2 Path planning: In the path planning software the basic idea was image recognition, reading map and identifying obstacles in path. Matlab was used as the programming tool. The software allows loading a map. The user is then allowed to enter two points as the input, the start point and end point. The software then generates two trajectories. First one is the shortest distance between the starting and end point on the principle of crow flying distance. On the other hand, the second trajectory represents the shortest path avoiding the obstacles between the starting and end point. This path is produced by employing the A* algorithm. Edge detection techniques, using Roberts Model, are employed prior to applying the A*algorithm to identify obstacles.

43

CHAPTER 4 Features of the project

The following Flow Diagram represents the logic behind this intelligent software:

Fig4.1: Flow Diagram of Path planning software

44

CHAPTER 4 Features of the project

A short demo of the software functionality is given below:

Displaying the map.

Taking first point.

Taking second point.

Displaying graphical results.

Fig4.2: Simulation Results of Path planning software

45

CHAPTER 4 Features of the project

Useful information displayed on the matlab command window:

Here it represents the input points i.e. the start and the end points entered by the user. P represents the intermediate points or rally points i.e. the points that define the shortest path

46

CHAPTER 4 Features of the project

4.3

Video surveillance: Surveillance cameras are a key feature of most UAVs. The Quadcopter is also

equipped with a wireless camera. The software was developed in Matlab that allows the facility of live streaming of the video from the wire less camera. It provides the added function of taking and saving snapshots just by a single mouse click.

4.4

User interface: The artificial intelligence part and the surveillance part were linked together by

incorporating them in a single Graphical User Interface. The Graphical User Interface was designed in Matlab and runs off a PC based embedded system running on Windows XP embedded. The graphical user interface allows the operator to load a map from a set of maps saved in the system. The user may then indicate the start and end point of his journey by a simple click of the right mouse button. The shortest feasible path is then displayed. The same graphical user interface also provides buttons for switching the camera display on or off. Another button allows the user to take snapshots at desired moment while the camera is turned on and the video is being previewed.

47

CHAPTER 4 Features of the project

Fig4.3: Front end of the graphical user interface

48

CHAPTER 5 Testing and Evaluation

CHAPTER 5
Testing and Evaluation
While developing any project, it remains incomplete without the testing phase. Testing basically involves exposing the product to the environment it is designed for and to operate it there in to find its response. For air crafts extensive tests through practical flights prove to be very expensive. So instead of real flights the flight environment is simulated in a wind tunnel. Wind tunnel facility was not available in our university premises. Further more, since tests are extensively used while developing a new project. So it was decided to find an alternative to wind tunnel testing and to setup our own testing equipment. The journey started with the design of a simple setup to measure the lift produced by the rotor assemblies. This setup constituted of a digital weighing balance, a motor base, a power supply and a motor drive circuit. The main idea was to put some predefined weight on the weighing balance along with the motor assembly and to set the initial weight to zero (a function called tare on most digital weighing machines). When the motor is run it pulls off weight from the weighing scale and the scale displays the weight reduced due to the motor uplift. The values displayed on the machine are equal to the thrust at that point.

49

CHAPTER 5 Testing and Evaluation

Fig5.1: Test setup for determine lift characteristics of rotors

The lift VS current graph was developed using this apparatus. The test was carried out for each rotor assembly separately and graphs between the two variables were plotted.

600

500

400

lift force (g)

300

200

100

4 current I (A)

Fig5.2: Lift vs current graph for one of the motors

50

CHAPTER 5 Testing and Evaluation

Similarly different testing methods were devised to check different parameters. The span of the downdraft too was determined experimentally using a simple experimental setup. The setup is pictured bellow.

Fig5.3: Test setup to determine downdraft radius.

Here the disturbance of the tissue strips determined how wide the down draft is spread. Similarly different other tests were conducted. A bi copter test bench was designed to study the behavior of two counter rotating propellers. A large test bench was also developed to show that the prototypes could be mounted on it and then run to calculate different parameters.

51

CHAPTER 5 Testing and Evaluation

Fig5.4: bi copter test rig

Fig5.5: Test bench for mounting and testing the Quad prototypes

52

CHAPTER 6 Conclusion

CHAPTER 6
Conclusion
We started off the project with aim to accomplish the simple looking task of designing a UAV capable of autonomous operations. But with time and experience it was learnt that this wasnt at all an easy job, especially if the mechanism is in the air and has six degrees of freedom. Though we couldnt achieve all the goals of our project that we had in mind at the start, we had a great learning experience. A platform is ready for any one interested to work on this project. With a little more time, slight alteration on the control system and system integration a marvel can be produced. Since this is a research oriented project it requires a lot of iterations of design. This in turn demands for a lot of time, money and hard work. Nevertheless this project has been a success as far as learning and practical implementation of engineering concepts is concerned. The basic design proposed in this project works well and can be implemented on commercial aircrafts. Having VTOL capability and static rotors the production of such aircrafts will save from construction of runways and from the complex rotor mechanism of conventional helicopters.

53

References

References:
1) Altug, et al Control of a Quadrotor Helicopter Using Visual Feedback

2) http://diydrones.com/profiles/blogs/quadcopter-platform-for-uav

3) http://www.draganfly.com/uav-helicopter/draganflyer-x6/?gclid=CPjlhZFuZsCFRUwpAodbFnUBA

4) http://www.dreamincode.net/forums/showtopic83856.htm

5) http://amir.ch/weblog/2007/03/quadcopter.html

6) http://www.helifreak.com/showthread.php?t=100612

7) http://www.aerospy.at/en/products_demonstrators.html

8) http://bridgeportquadcopter.blogspot.com/

9) http://en.wikipedia.org/wiki/Quadrotor

10) http://www.robotspodcast.com/forum/viewtopic.php?f=13&t=302

11) http://diydrones.ning.com/profiles/blogs/705844:BlogPost:12672

12) http://video.asterpix.com/v/366640161/x-bl-rc-hd-test/

13) http://www.youtube.com/watch?v=ZtPLgp4q0qY

14) http://www.google.com.pk/search?q=uav+quadcopter&hl=en&start=40&sa=N

54

References

15) http://www.isprs.org/congresses/beijing2008/proceedings/1_pdf/204.pdf

16) http://www.leechvideo.com/tag/QUADCOPTER/

17) http://groups.yahoo.com/group/Quadcopter/summary

18) http://iphone4.tw/forums/archive/index.php/t-13238.html

19) http://www.top54u.com/videos/?tag=microdrones

20) http://www.vidchili.com/video/AiCiHF-SnFU/MicroDrone/

21) http://cosmosurf.net/search.php?phrase=quadcopter

22) http://www.sandroses.com/video/Quadroufo/

55

Appendix

Appendix
1) Code for Graphical User Interface
function varargout = My_GUI(varargin) % MY_GUI M-file for My_GUI.fig % MY_GUI, by itself, creates a new MY_GUI or raises the existing % singleton*. % % H = MY_GUI returns the handle to a new MY_GUI or the handle to % the existing singleton*. % % MY_GUI('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in MY_GUI.M with the given input arguments. % % MY_GUI('Property','Value',...) creates a new MY_GUI or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before My_GUI_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to My_GUI_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Copyright 2002-2003 The MathWorks, Inc. % Edit the above text to modify the response to help My_GUI % Last Modified by GUIDE v2.5 02-Jul-2009 06:00:17 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @My_GUI_OpeningFcn, ... 'gui_OutputFcn', @My_GUI_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout

56

Appendix

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT

% --- Executes just before My_GUI is made visible. function My_GUI_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to My_GUI (see VARARGIN) rgb_img11= imread('H:\Home Stuff\fyp softwares\MAtlab GUI\naruto-wallpaper1024x768-124.jpg'); imshow(rgb_img11);

% Choose default command line output for My_GUI handles.output = hObject;

% Update handles structure guidata(hObject, handles); % UIWAIT makes My_GUI wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line. function varargout = My_GUI_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output;

% --- Executes on button press in grayscale. function grayscale_Callback(hObject, eventdata, handles) % hObject handle to grayscale (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

57

Appendix

image=handles.current_data; I = .2989*image(:,:,1)... +.5870*image(:,:,2)... +.1140*image(:,:,3); imshow(I);

% --- Executes on button press in edgedetection. function edgedetection_Callback(hObject, eventdata, handles) % hObject handle to edgedetection (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) image=handles.current_data; I = .2989*image(:,:,1)... +.5870*image(:,:,2)... +.1140*image(:,:,3); BW = edge(I,'roberts'); imshow(BW); handles.BW=BW; handles.current_data=handles.BW; % Update handles structure guidata(hObject, handles);

% See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

% --- Executes on button press in generatetrijectory. function generatetrijectory_Callback(hObject, eventdata, handles) % hObject handle to generatetrijectory (see GCBO)

58

Appendix

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) BW=handles.current_data; [x,y] = ginput(2); %imshow(BW); %pixval on line(x,y,'Color','r','LineStyle',':'); shortest_distance =sqrt((x(2,1)-x(1,1))^2+(y(2,1)-y(1,1))^2); n=1; travelling_distance=0; while(n==1) shortest_distance1 =sqrt((x(2,1)-x(1,1))^2+(y(2,1)-y(1,1))^2); %%%Now to create first pixel matrix... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %routein for creating equal x & y column matrix for line pixels %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %for steap horizontal line %%%%%%%%%%%%%%%%%%%%%%%%%% if abs(x(2,1)-x(1,1))>abs(y(2,1)-y(1,1)) if x(1,1)<x(2,1) a=x(2,1)-x(1,1); for t=1:1:a+1 u(t,1)=x(1,1)+t-1; end elseif x(1,1)>x(2,1) a=x(1,1)-x(2,1); for t=1:1:a+1 u(t,1)=x(1,1)-t+1; end end if y(1,1)<y(2,1) b=y(2,1)-y(1,1); w=b/a; p=1; for t=1:w:b+1 v(p,1)=y(1,1)+t-1; p=p+1; end elseif y(1,1)>y(2,1) b=y(1,1)-y(2,1); w=b/a; p=1; for t=1:w:b+1 v(p,1)=y(1,1)-t+1;

59

Appendix

p=p+1; end elseif y(2,1)==y(1,1) for t=1:1:a+1 v(t,1)=y(1,1); end end c=a; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %for steap virtical line %%%%%%%%%%%%%%%%%%%%%%%%%% elseif abs(x(2,1)-x(1,1))<abs(y(2,1)-y(1,1)) if (y(1,1)<y(2,1)) b=y(2,1)-y(1,1); for t=1:1:b+1 v(t,1)=y(1,1)+t-1; end elseif y(1,1)>y(2,1) b=y(1,1)-y(2,1); for t=1:1:b+1 v(t,1)=y(1,1)-t+1; end end if x(1,1)<x(2,1) a=x(2,1)-x(1,1); w=a/b; p=1; for t=1:w:a+1 u(p,1)=x(1,1)+t-1; p=p+1; end elseif x(1,1)>x(2,1) a=x(1,1)-x(2,1); w=a/b; p=1; for t=1:w:a+1 u(p,1)=x(1,1)-t+1; p=p+1; end elseif x(2,1)==x(1,1) for t=1:1:b+1 u(t,1)=x(1,1); end end c=b;

60

Appendix

end %generating martix of line pixels = impixel(BW,u,v); %drawing line form starting pt to 1st edge n=0; for m=1:1:c+1 e=pixels(m,1); if e==1 if n==0 x1=u(m,1); y1=v(m,1); n=n+1; end end end if n==0 travelling_distance = travelling_distance + shortest_distance1; elseif n==1 %travelling_distance = travelling_distance + sqrt((x1-x(1,1))^2+(y1-y(1,1))^2); l0(1,1)=x(1,1); %l0(2,1)=x1; l1(1,1)=y(1,1); %l1(2,1)=y1; %Filters for determining type of edge........ P1 = impixel(BW,x1+1,y1);%right pixel P2 = impixel(BW,x1-1,y1);%left pixel P3 = impixel(BW,x1,y1+1);%pixel below P4 = impixel(BW,x1,y1-1);%pixel above %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$ %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %For horizontal edge............. if P1(1,1)>0 && P2(1,1)>0 %For right corner.......... rc=x1+2; for rp=3:1:250 P5 = impixel(BW,rc,y1); if P5==1 rc=x1+rp; end end rc=rc-1; h1 = sqrt((x(2,1)-(rc))^2+(y(2,1)-(y1))^2);%remaining distance g1 = abs(x1-rc);%distance covered

61

Appendix

f1 = g1 + h1%total distance %For left corner............... lc=x1-2; for lp=3:1:250 P6 = impixel(BW,lc,y1); if P6==1 lc=x1-lp; end end lc=lc+1; h2 = sqrt((x(2,1)-(lc))^2+(y(2,1)-(y1))^2);%remaining distance g2 = abs(x1-lc);%distance covered f2 = g2 + h2%total distance if f1<f2 l0(2,1)=rc; l1(2,1)=y1; travelling_distance = travelling_distance + sqrt((l0(2,1)-x(1,1))^2+(l1(2,1)y(1,1))^2); P7 = impixel(BW,rc,y1-1);%pixel above right corner P8 = impixel(BW,rc,y1+1);%pixel below right corner elseif f2<f1 l0(2,1)=lc; l1(2,1)=y1; travelling_distance = travelling_distance + sqrt((l0(2,1)-x(1,1))^2+(l1(2,1)y(1,1))^2); P7 = impixel(BW,lc,y1-1);%%pixel above left corner P8 = impixel(BW,lc,y1+1);%pixel below left corner end if (l0(2,1)==lc && x(2,1)<lc) || (l0(2,1)==rc && x(2,1)>rc) if f1<f2 x(1,1)=l0(2,1)+1; elseif f2<f1 x(1,1)=l0(2,1)-1; end y(1,1)=y1; elseif (l0(2,1)==lc && x(2,1)>lc) || (l0(2,1)==rc && x(2,1)<rc) %%%%MASK for corner for either going up or down.......... %%%%%%%%%%%%%%%%%%%%%%%%%%%%% if P7(1,1)==1 && P8(1,1)==0 uc=y1-2; for up=3:1:250 P9 = impixel(BW,l0(2,1),uc); if P9==1 uc=y1-up; end end

62

Appendix

uc=uc+1; l0(3,1)=l0(2,1); l1(3,1)=uc; x(1,1)=l0(2,1); y(1,1)=uc-1; travelling_distance = travelling_distance + abs(uc - y1); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%% if P7(1,1)==0 && P8(1,1)==1 loc=y1+2; for lop=3:1:250 P10 = impixel(BW,l0(2,1),loc); if P10==1 loc=y1+lop; end end loc=loc-1; l0(3,1)=l0(2,1); l1(3,1)=loc; x(1,1)=l0(2,1); y(1,1)=loc+1; travelling_distance = travelling_distance + abs(loc - y1); end%$4444444444444444444444444444444444444444444444444444444 end %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$ %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %For vertical edge............. elseif P3(1,1)>0 && P4(1,1)>0 %For upper corner.......... uc=y1-2; for up=3:1:250 P5 = impixel(BW,x1,uc); if P5==1 uc=y1-up; end end uc=uc+1; h1 = sqrt((x(2,1)-x1)^2+(y(2,1)-uc)^2);%remaining distance g1 = abs(y1-uc);%distance covered f1 = g1 + h1%total distance %For lower corner............... loc=y1+2; for lop=3:1:250 P6 = impixel(BW,x1,loc);

63

Appendix

if P6==1 loc=y1+lop; end end loc=loc-1; h2 = sqrt((x(2,1)-x1)^2+(y(2,1)-(loc))^2);%remaining distance g2 = abs(y1-loc);%distance covered f2 = g2 + h2%total distance if f1<f2 l0(2,1)=x1; l1(2,1)=uc; travelling_distance = travelling_distance + sqrt((l0(2,1)-x(1,1))^2+(l1(2,1)y(1,1))^2); P7 = impixel(BW,x1-1,uc);%pixel left of upper corner P8 = impixel(BW,x1+1,uc);%pixel right of upper corner elseif f2<f1 l0(2,1)=x1; l1(2,1)=loc; travelling_distance = travelling_distance + sqrt((l0(2,1)-x(1,1))^2+(l1(2,1)y(1,1))^2); P7 = impixel(BW,x1-1,loc);%pixel left of lower corner P8 = impixel(BW,x1+1,loc);%pixel right of lower corner end if (l1(2,1)==loc && y(2,1)>loc) || (l1(2,1)==uc && y(2,1)<uc) x(1,1)=x1; if f1<f2 y(1,1)=l1(2,1)-1; elseif f2<f1 y(1,1)=l1(2,1)+1; end elseif (l1(2,1)==loc && y(2,1)<loc) || (l1(2,1)==uc && y(2,1)>uc) %%%%MASK for corner for either going right or left.......... %%%%%%%%%%%%%%%%%%%%%%%%%%%%% if P7(1,1)==1 && P8(1,1)==0 lc=x1-2; for lp=3:1:100 P9 = impixel(BW,lc,l1(2,1)); if P9==1 lc=x1-lp; end end lc=lc+1; l0(3,1)=lc; l1(3,1)=l1(2,1); x(1,1)=l0(3,1)-1; y(1,1)=l1(3,1);

64

Appendix

travelling_distance = travelling_distance + abs(lc - x1); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%% if P7(1,1)==0 && P8(1,1)==1 rc=x1+2; for rp=3:1:100 P10 = impixel(BW,rc,l1(2,1)); if P10==1 rc=x1+rp; end end rc=rc-1; l0(3,1)=rc; l1(3,1)=l1(2,1); x(1,1)=l0(3,1)+1; y(1,1)=l1(3,1); travelling_distance = travelling_distance + abs(rc - x1); end%$4444444444444444444444444444444444444444444444444444444 end end %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$ %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ line(l0,l1,'Color','g','LineStyle',':'); end end line(x,y,'Color','g','LineStyle',':'); shortest_distance travelling_distance

% --- Executes on button press in firstimage. function firstimage_Callback(hObject, eventdata, handles) % hObject handle to firstimage (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) rgb_img1= imread('H:\Home Stuff\fyp softwares\MAtlab GUI\Map_01.bmp'); imshow(rgb_img1); handles.rgb_img1 = rgb_img1; handles.current_data=handles.rgb_img1; % Update handles structure guidata(hObject, handles);

65

Appendix

% --- Executes on button press in secondimage. function secondimage_Callback(hObject, eventdata, handles) % hObject handle to secondimage (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) rgb_img2= imread('H:\Home Stuff\fyp softwares\MAtlab GUI\Map_02.bmp'); imshow(rgb_img2); handles.rgb_img2 = rgb_img2; handles.current_data=handles.rgb_img2; % Update handles structure guidata(hObject, handles); % --- Executes on button press in thirdimage. function thirdimage_Callback(hObject, eventdata, handles) % hObject handle to thirdimage (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) rgb_img3= imread('H:\Home Stuff\fyp softwares\MAtlab GUI\Map_03.bmp'); imshow(rgb_img3); handles.rgb_img3 = rgb_img3; handles.current_data=handles.rgb_img3; % Update handles structure guidata(hObject, handles);

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

% --- Executes on button press in cameraon. function cameraon_Callback(hObject, eventdata, handles) % hObject handle to cameraon (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Access an image acquisition device. vidobj = videoinput('winvideo', 1);

66

Appendix

% Open the preview window. preview(vidobj); handles.vidobj=vidobj; handles.current_data=handles.vidobj; % Update handles structure guidata(hObject, handles);

% --- Executes on button press in cameraoff. function cameraoff_Callback(hObject, eventdata, handles) % hObject handle to cameraoff (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Close the preview window. vidobj=handles.current_data; closepreview(vidobj); delete(vidobj) clear vidobj

% --- Executes on button press in takesnap. function takesnap_Callback(hObject, eventdata, handles) % hObject handle to takesnap (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) vidobj=handles.current_data; %Taking the snapshot and storing it.. snapshot = getsnapshot(vidobj); % Display the frame in a figure window. imagesc(snapshot);

67

Appendix

2) 89c52 Based Code For Flight Control of Quad copter


//Loading libraries... #include<reg52.h> //******************** #include <stdio.h> #include <string.h> #include <stdlib.h> //******************** //Prototypes for lcd subroutiens... void lcdcmd(unsigned char value0); void lcddata(unsigned char value1); void lcddata2(unsigned char value2); void clr(); void out(unsigned char p[]); void msdelay(unsigned int itime); //******************** //Prototypes for adc subroutien... float adc(float h, float l); //******************** //initilizing control pins for adc sbit read = P3^0;//read bit of adc sbit write = P3^1;//write bit of adc sbit INTR = P3^2;//interupt bit of adc sfr MYDATA = 0x90;//p1 address //******************** //initilizing control pins for lcd sfr ldata = 0xa0;//p2 address sbit rs = P3^3;//register select bit of lcd sbit rw = P3^4;//read/write bit of lcd sbit en = P3^5;//enable bit of lcd //********************

68

Appendix

//initilizing the output pin for PWM... sbit WAVE = P3^6; //******************** //initilizing variables float x; float y; unsigned char z; //******************** void main() { unsigned char message1[] = "QUAD X"; unsigned char text1[] = "DUTY CYCLE"; x=0; TMOD = 0x11; //Initilizing both the timers in 16-bit timer mode... //***************** TH0 = 0xfc; //Initilizing timer0 for 1ms... TL0 = 0x17; //****************** TH1 = 0xb1; //Initilizing timer1 for 20ms... TL1 = 0xdf; //*****************

//Displaying the initial mesages on lcd... //**************** //First message... clr(); //clearing the screen lcdcmd(0x84); //force cursor to 1st row 4th column for(z=0;z<6;z++) //diaplay "QUAD X" on lcd {

69

Appendix

lcddata(message1[z]); } //end msdelay(80);//short delay //Second message... clr();//clr screen lcdcmd(0x80);//force cursor to 1st row 1st column for(z=0;z<10;z++) { lcddata(text1[z]); } //end lcdcmd(0xca);//force cursor to 2nd row 10th column msdelay(80);//short delay //Main PWM Loop... while(1) { TR0 = 1; //Run timer0... TR1 = 1; //Run timer1 for 20ms... WAVE = 1; //output high until the flag of timer0... while (TF0==0); //Stay here until timer0 overflows... WAVE = 0; //output low for rest of the time... TR0 = 0; //stoping timer0... TF0 = 0; //Forcing the flag bit of timer0 to zero after an overflow... while (TF1==0); //Stay here until flag bit of timer1 goes high... TR1 = 0; //stoping timer1... TF1 = 0; //Forcing the flag bit of timer1 to zero after an overflow... adc(x,y); //calling the adc subroutiene... //Reinitilizing timer0 according to adc value... TH0 = (y);

70

Appendix

TL0 = (x); //********************* //Reinitilizing timer1 TH1 = 0xb1; //for 20ms... TL1 = 0xdf; //********************* } } //Subroutienes for lcd... void lcdcmd(unsigned char value0)//function for sending commands to lcd { ldata=value0; rs = 0; rw = 0; en = 1; msdelay(1); en = 0; return; } void lcddata(unsigned char value1)//function for displaying notes on lcd { ldata=value1; rs = 1; rw = 0; en = 1; msdelay(1); en = 0; msdelay(8); return; } void lcddata2(unsigned char value2)//function for displaying the %dutycycle on lcd { ldata=value2; rs = 1; rw = 0; en = 1; msdelay(1);

71

Appendix

en = 0; //msdelay(1); return; } void msdelay(unsigned int itime)//short delay function { unsigned int i , j; for ( i=0 ; i<itime; i++) for ( j=0 ; j<1275; j++) ; } void clr()//function for clearing lcd screen { lcdcmd(0x38);//2 lines and 5x7 matrix lcdcmd(0x0c);//display on cursor off lcdcmd(0x01);//clear screen display return; } void out(unsigned char p[])//function to display the ' % ' sign on lcd { for(z=0;z<2;z++) { lcddata2(p[z]); } } //********************* //Subroutiene for adc... float adc(float h, float l)//function for activating adc { float value; //********************* unsigned char mystring[4]; int a; //********************* MYDATA = 0xFF; //Maling port 1 input port INTR = 1; //Making pin 3.2 input pin read = 1; //Making pin 3.0 input pin write = 1; //Making pin 3.1 input pin

72

Appendix

//********************* //Reading value from adc... write = 0; write = 1; while (INTR == 1); read = 0; value = MYDATA; read = 1; //********************** //Dividing the value accordingly... if(value>=0 && value<54) { y = 0xf8; x = (((208*value)/53)+47); } else if(value>=54 && value<119) { y = 0xf9; x = (((255*value)/64)-215.156); } else if(value>=119 && value<184) { y = 0xfa; x = (((255*value)/64)-474.14); } else if(value>=184 && value<249) { y = 0xfb; x = (((255*value)/64)-733.125); } else if(value>=249 && value<256) { y = 0xfc; x = (((23*value)/6)-954.5); } //********************** //Displaying the value on lcd after converting in into string... a = (((-200*value)/51)+2000);

73

Appendix

sprintf(mystring, "%d", a);// Convert int to string... for(z=0;z<4;z++) { lcddata2(mystring[z]); } h=x; l=y; out("s"); lcdcmd(0xca);//force cursor to 2nd row 10th column return(h,l); }

74

Appendix

3a) Code for flight simulation


function [tdot] = Flight_Simulation(time,t) global F; %C=1; % Whatever values you want to choose %g=1; %L=1; %m=1; %J1=1; %J2=1; %J3=1; W=0.1;%width of hub D=W;%depth of hub H=0.02;%height of hub Q=0.09;%mass of motor P=0.1;%mass of hub r=0.012;%radius of motor h=0.036;%height of motor R=0.25;%distance from motor to hub F1=1.3; F2=1.3; F3=1.3; F4=1.3; F=[F1;F2;F3;F4] K1=0; K2=0; K3=0; K4=0; K5=0; K6=0; C=1; g=9.8; L=0.2; m=.5; J1=(1/3)*Q*(3*r^2+h^2)+4*Q*R^2+(1/12)*P*(H^2+D^2) J2=J1; J3=2*Q*r^2+4*Q*R^2+(1/12)*P*(W^2+D^2) tdot(1) = t(2);%x dot tdot(2) = ((F1+F2+F3+F4)/m)*(cos(t(11))*sin(t(7))*cos(t(9))+sin(t(11))*sin(t(9)))K1*t(2);%x double dot tdot(3) = t(4);%y dot tdot(4) = ((F1+F2+F3+F4)/m)*(sin(t(11))*sin(t(7))*cos(t(9))-cos(t(11))*sin(t(9)))K2*t(4);%y double dot tdot(5) = t(6);%z dot tdot(6) = ((F1+F2+F3+F4)/m)*(cos(t(11))*cos(t(9)))-g-K3*t(6);%z double dot tdot(7) = t(8);%theta dot

75

Appendix

tdot(8) = ((-F1-F2+F3+F4)/J1)*L-K4*t(8);%theta double dot tdot(9) = t(10);%omega dot tdot(10) = ((-F1+F2+F3-F4)/J2)*L-K5*t(10);%omega double dot tdot(11) = t(12);%phi dot tdot(12) = C*(F1-F2+F3-F4)/J3-K6*t(12);%phi double dot tdot = tdot'; % This makes Ydot into a column vector

3b) code to run flight simulation


clc; clear all; close all; global F; [T,t]=ode45('Flight_Simulation',[0 10],[5 5 0 0 0 0 0 0 0 0 0 0]); %Ploting the displacement and velocity curves in X-direction.. subplot(2,3,1) plot(T,t(:,1),'-',T,t(:,2),'--'); title('X-Axis') %Plotiong the displacement and velocity curves in Y-direction.. subplot(2,3,2) plot(T,t(:,3),'-',T,t(:,4),'--'); title('Y-Axis') %Plotiong the displacement and velocity curves in Z-direction.. subplot(2,3,3) plot(T,t(:,5),'-',T,t(:,6),'--'); title('Z-Axis') %Plotiong the displacement and velocity curves of theta(Pitch angle).. subplot(2,3,4) plot(T,t(:,7),'-',T,t(:,8),'--'); title('Pitch Angle') %Plotiong the displacement and velocity curves of omega(Roll angle).. subplot(2,3,5) plot(T,t(:,9),'-',T,t(:,10),'--'); title('Roll Angle') %Plotiong the displacement and velocity curves Phy(Yaw angle).. subplot(2,3,6) plot(T,t(:,11),'-',T,t(:,12),'--'); title('Yaw Angle')

76

Potrebbero piacerti anche