P. 1
BE - Thesis of UAV-Quad Copter

BE - Thesis of UAV-Quad Copter

|Views: 2,533|Likes:
Published by Tehseenakhtar

More info:

Published by: Tehseenakhtar on Jul 27, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

05/05/2013

pdf

text

original

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

i

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 Quadcopter…………………………………………7

Proposed Solution…………………………………………………………………………9 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.3 4.3 3.3 Quad-X-01……………………………………………………………………….3.1 3.48 User interface…………………………………………………………………………….2 3.....2 3.38 3..1 4.22 Design Calculations…………………………………………………………….2 4..3.54 References…………………………………………………………………………………..25 Quad-X-02……………………………………………….…………………...2.…………………….…………………57 v .………………………36 3.2.2..1..36 Quad-X-04………………………………………………..5 Quad-X-03-a…………………………………………………………………….33 3..4 3.1 3..…50 Chapter 6 Conclusion……………………………………………………………………………………..48 Chapter 5 Testing and Evaluation……………………………………………………………………….2 Basic Design…………………………………………………………………….1.3.…………………….5 Introduction…………………………………………….22 Material Selection……………………………………………………………….………………….……44 Path planning……………………………………………………………………………...………………………30 3.3.3 Control System Design …………………………………………..…..………………..38 Closed loop control system…………………………………….4 3.44 Video surveillance……………………………………………………………………….1 Propeller search………………………………….40 Quadcopter flight control software………………………….………………………27 Quad-X-03……………………………………………….4 Autonomous flight………………………………………………………………….3.55 Appendix ……………………………………………………………………..…………………….1 3..2.……………………….41 Chapter 4 Features of the project 4.2...2 3.2.3. 25 3..22 Prototypes ………………………………………………………...38 Open loop control system……………………………………………………….3 3.1.....39 Quadcopter control system………………………………….

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

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

to the base station for further processing. In almost all of the applications the UAV also sends back data such as video. Civil applications of UAVs are also growing rapidly. sensor readings. To represent the fact that these complex systems include base stations and other elements besides the actual aircraft. which allows the operator to up date the flight plan of the UAV. 1 . Over the year’s wide variety of UAV have been made with differences in shape.1 What is a UAV? UAV stands for Unmanned Aerial Vehicle. the term Unmanned Aircraft System (UAS) is used. police observation of civil disturbances and crime scenes. At present they are being used in applications such as firefighting when a human observer would be at risk. UAVs are often preferred for missions that are too "dull. size. or dangerous" for manned aircraft. Most of the UAVs are currently being used in a number of military roles like reconnaissance and attack. and reconnaissance support in natural disasters. dirty. snapshots. and characteristics. Most UAVs have a base station.CHAPTER NO 1 INTRODUCTION CHAPTER NO 1 INTRODUCTION 1. 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. configuration.

1: Fixed wing aircrafts (airplanes) Fig1.CHAPTER NO 1 INTRODUCTION 1.2:Rotorcraft UAVs(Conventional Helicopters) 1.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. 2 .1 Types of UAVs: Fig1.

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. 1. pistons and shafts resulting in a complex assembly. This pitch angle is controlled by varying the angle of the swash plate incorporated in the main rotor assembly. Moreover. All this ultimately leads to a lot of mechanical actuators and heavy assembly parts including gears. In helicopters forward and the backward movement is achieved by varying the pitch angle of the main rotor blade. helicopters have the advantage of better maneuverability in limited space as compared to fixed wing aircrafts. As a result large amount of force is required to change the angle of this heavy rotating mass.3 Problems associated with conventional helicopters: Along with these advantages helicopters possess certain disadvantages too. The rotor size is huge and it stores a lot of kinetic energy during flight. 3 .

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

A tail rotor is incorporated to balance this torque. then the helicopter goes into a severe spin which is not controllable and ultimately results in a crash.CHAPTER NO 1 INTRODUCTION Fig1. safety and stability of modern day conventional helicopter still persist. 5 . the above stated problems regarding handling. Even with the incorporation of fly by wire systems and implementation of extensive sensors and robust control systems. If the tail rotor malfunctions.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 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.

3. also called a quad rotor assembly. thereby changing the lift forces. a Quadcopter has four fixed-pitch angle rotors.3. The tests flights did not end up very well. 6 . One of the first was built in France by the brothers Louis and Jacques Bréguet.2 History And Background Of Quadcopter The Quadcopter idea is not new. This principle is also used to produce the desired yaw motion.1 Quadcopter: A Quadcopter. It was called “gyroplane nr 1” and consisted of four rotors in a square. The basic motions of a Quadcopter are generated by varying the relative angular speeds of the four rotors. is an aircraft that is lifted and propelled by four static rotors. the helicopter was simply too difficult to control for the pilot.CHAPTER NO 1 INTRODUCTION 1. Unlike regular helicopters that have variable pitch angle rotors. It is a dynamic hovercraft with four input forces and six degrees of freedom. The Quadcopter tilts towards the direction of the slow spinning rotor. in fact the first Quad-rotor helicopter was built earlier than the cyclic/collective pitch helicopter we know today. Therefore angular speed of the four rotors and the motion of the Quadcopter are closely related. which produces acceleration along that direction. Spinning directions of the rotors are set to balance the moments and eliminate the need for a tail rotor. 1.

Horn and Wei Guo of Pennsylvania State University (“Modeling and Simulation for the Development of a Quad-Rotor UAV Capable of Indoor Flight”). In the world of higher education. Ming Chen and Mihai Huzmezan of the University of British Columbia (“A Simulation Model and H Loop Shaping Control of ∞ 7 . Among them are a few “Four Propeller Helicopter” designs and “Quad Tilt rotor” designs and various “vertical lift aircrafts”.CHAPTER NO 1 INTRODUCTION Fig1. there are many patents for designs similar to ours. Among them are Joseph F. In fact. there is a fair amount of published research with regards to quad-rotor aircraft. there are a few members of academia who have published research on quad-rotor UAVs.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.

far exceeds the size and span of any other similar project. An attempt to search for similar projects in the market did not yield many results. Fig1. quad-rotor aircraft currently in development as a joint venture between Bell Helicopter Textron and Boeing Integrated Defense Systems. there is currently a project in development named the Bell Boeing Quad Tilt Rotor. One of the most known manufactures is RC-toys with the model Dragon flyer. and with a capacity of upwards of 150 passengers. industrial scale.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. governmentsponsored. Furthermore. and Eryk Brian Nice of Cornell University (“Design of a Four Rotor Hovering Vehicle”). It is a large-scale. The project is the largestscale of all the existing projects.CHAPTER NO 1 INTRODUCTION a Quad Rotor Unmanned Air Vehicle”). on a much larger. 8 .

These will be discussed in detail in the upcoming chapters. 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. and lack of equipment we had to adopt practical means to cater for these deficiencies. Furthermore. from the supplier of rotors. 1. Procurement of components was another challenging task in this project. The problem of torque balance and stability was partially resolved by a new concept in helicopter industry introduced as the “Quadcopter”. there exist only a few commercially available products which take advantage of similar quad-rotor flight.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. since this project is a unique one of its kind in Pakistan so facilities for its testing were not available. But all possible means were used to get the required components.CHAPTER NO 1 INTRODUCTION Aside from a few overachieving hobbyists. This concept was based on implementing four rotors on four positions equidistant from the center. Due to lack of data. 9 . Amongst these are the Silver lit X-UFO and the Dragon flyer.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. 1.

and life span of the components required. As the vehicle is going to be used as a testing platform. The second part of this project will cover the designing and developing of a complete control system for a UAV based on Atml89c52 technology.6 Scope of this project This project is divided into two parts. selection of the design must be done carefully. 10 . The designed vehicle should be feasible for testing variety of aircraft controllers designed using different technologies. by choosing an appropriate design. to some extent. It should also have enough flight time so that some meaningful information can be deduced from the data collected in each test. it should be durable and at the same time easily repairable. Controlling an aircraft is a very difficult task but the level of difficulty can be reduced. The first part of the project is to design low cost UAV using commercially available parts. In the design selection process the factors such as testing facility. safety of the operators. 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. 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. Therefore.CHAPTER NO 1 INTRODUCTION 1. transportation of the vehicle must also be taken into consideration.

The Quad-copter could be used to supply aerial electricity cables.7 Applications: 1. Military and search operations 3. 2. The Quad-copter may be used for future TV surveillance from above by replacing the use of a full size helicopters and camera cranes. The quad copter would do everything that a conventional helicopter does but with abilities to lift more payload. Acquiring aerial views of disaster hit areas c.CHAPTER NO 1 INTRODUCTION 1. 5. The UAV version can be used for surveillance tasks like: a. 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. 11 . 4. Monitoring a crowd or any activity b. simpler construction and safer operation. into mines after accidents or into unsafe buildings.

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.CHAPTER 2 THEORY OF QUADCOPTER CHAPTER 2 THEORY OF QUADCOPTER 2. Altitude and velocity control is obtained by regulating the thrust of the four rotors. 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 . the quad-copter is in hover or is in vertical flight. The thrust can be controlled by the angular velocity of the rotors. When all rotors have same angular velocity.1 Working principle of Quadcopter: Fig2.

2. The set of equations presented. et al in “Control of a Quadrotor Helicopter Using Visual Feedback”.2 System of Differential Equations The dynamics of the UAV Quad Copter are determined from a set of equations of motion.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. The complexity of the equations of motion increases with the increased accuracy. The following figure helps to understand and visualize the concept even further. while negative angular velocity is obtained by increasing the velocity of r2 and r4. We have used simplified equations which are presented in Altug. model the motion of the craft based on the amount of lift delivered by each individual motor 13 . 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(a). The relationship between motion and power can be linear. parabolic or any other trigonometric function. The thrust from motor B and D must be increased so that the craft maintains constant altitude while moving along the desired path.2) (2. More complex movements can be achieved by varying the power delivered to all four motors and will be studied in the following subsection. (2.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. For example referring to the figure in section 6. The equations of motion that govern the dynamics of the craft are listed below. 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.3) 14 .1) (2.CHAPTER 2 THEORY OF QUADCOPTER without taking into account the aerodynamics of the air craft.

CHAPTER 2 THEORY OF QUADCOPTER (2. The forces on the motors are terms. The centre of gravity is assumed to be at the origin. which can be ignored is the unbalanced moment represented in terms of force (M) and distance (L) from the centre. are the pitch. The terms represent the drag coefficients. 15 . roll and yaw respectively. through the various transformed coordinate systems as depicted in figure below.6) Here given by the given by the for simplicity. due to the rotors. The moments of inertia of the air craft with respect to the axis are terms. These set of equations can easily be derived by transmitting the forces.4) (2.5) (2.

Similarly different maneuvers of the hovercraft can be achieved by altering the value of the four forces involved. Likewise.3: Lift force transmitted through all the transformations involved. the craft can descend (if already airborne) by simultaneously decreasing the thrust from all motors.CHAPTER 2 THEORY OF QUADCOPTER Fig2.1. In order to understand and get a physical insight into the functioning of the hovercraft we solved the system of six coupled ODE’s using “ode45” function of MATLAB. The code is available in Appendix A. 16 . Here we would show few results that we simulated which helped us in understanding the behavior of our hover craft in air. 2.3 Simulation The craft can increase in altitude by simultaneously increasing the thrust from all motors.

5 -1 1 0.5 0 -0. 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 .5 -1 1 0.5 -1 1 0.5 -1 Y-Axis 30 Z-Axis 20 10 0 5 Pitch Angle 10 0 5 Roll Angle 10 0 0 5 Yaw Angle 10 1 0.5 0 -0.5 0 -0.5 -1 0 5 10 0 5 10 0 5 10 Fig2.5 0 -0.5 0 -0.CHAPTER 2 THEORY OF QUADCOPTER X-Axis 1 0. 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.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.

4 0.6 0.32N and F3=1.8 2 5 4 3 2 1 0 0 Y-Axis 1 0.5 -1 2 0 0 Z-Axis 1 Yaw Angle 2 0 1 2 0 1 2 0 1 2 Fig2.6 -0.5 0 -0.2 1 Roll Angle 1 0.2 -0.4 -0. F1=1.4 (b): Matlab Simulation Results The above graphs show the displacements when F2=F4=1. Now let’s look at the following graphs: 18 .CHAPTER 2 THEORY OF QUADCOPTER X-Axis 0 -1 -2 -3 -4 -5 0 1 Pitch Angle 0 -0.8 0 -0.3N.8 0.4 -0.28N.6 -0.2 -0. We noticed that after one second the altitude of the hover craft starts to fall.

5 -0.4 -0.005 -0.3 and F1 and F3 are now 1. 19 .01 0 5 10 -1 0 5 10 Fig2.4 0.8 0. 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.005 0 -0.2 0 Y-Axis 30 Z-Axis 20 10 0 5 Pitch Angle 10 0 5 Roll Angle 10 0 0 5 Yaw Angle 10 0 0 1 0.30001 and 1.2 -0. Similar results can be plotted to check the behavior of our hover craft for different values of inputs.8 0.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.CHAPTER 2 THEORY OF QUADCOPTER X-Axis 0 -0.6 0.29999 respectively.5 -0.6 -0.01 0 5 10 -0.

Motors are mounted at the end of the links. Fig3.1 Mechanical Design of Quadcopter: The Mechanical Design has been categorized in the following sections: a. Basic Design b.CHAPTER 3 DESIGN OF QUADCOPTER CHAPTER 3 DESIGN OF QUADCOPTER 3.1: The basic Quad copter schematic 20 .1. Design Calculations 3. Material Selection c. The links are reinforced at the center by plates.1 Basic Design The basic design consists of two links attached together in a cross formation.

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 it’s 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

6: Rotor assembly after weight reduction 25 .CHAPTER 3 DESIGN OF QUADCOPTER Fig3.5: Disintegrated Dragonfly Fig3.

CHAPTER 3 DESIGN OF QUADCOPTER Fig3.2. As a result. the motors had to be changed.2 Quad-X-02: Quad-X-01 was based on permanent magnet DC motors. So.7: Quad –X-01 3. Quad-X-02 was developed. Permanent magnets lose their strength if the motor runs for a longer duration at peak current. 26 . With time the peak thrust of the motors started to decrease.

The motors selected were AC synchronous motors (out runner 40D-05-7. 27 .CHAPTER 3 DESIGN OF QUADCOPTER Fig3.8: Quad-X-02 mounted on the test bench The entire design was altered. That comes with 12*6 propellers and an 18A ESC (Electric Speed Controller).0). Now Aluminum I beams were used instead of Aluminum square pipes.

CHAPTER 3 DESIGN OF QUADCOPTER Fig3.10: 18A ESC from Art-tech 28 .9: Out runner 40D-05-7.0 Fig3.

Firstly all the propellers used were designed to rotate in the same direction there by producing an unbalanced torque.CHAPTER 3 DESIGN OF QUADCOPTER The three-phase AC servo motors are controlled via PWM supplied to the ESC. minimum high time of 1ms (motor is off) and a maximum high time of 2ms (motor running at max speed). Though. The pulse type used has a time period of 20ms. A LCD was attached to display the high time in microseconds. this was not a mechanical design flaw but the unavailability of counter pitch propellers in the local market.3 Quad-X-03: Through testing it was discovered that the Quad-X-02 design required a lot of changes. 29 . An atml89c52 based test circuit was designed to drive the motors.11: Atml89c52 based motor driver circuit 3. Fig3.2.

30 . The interaction of the down drafts produced by neighboring propellers produced turbulence which resulted in loss of lift and instability.CHAPTER 3 DESIGN OF QUADCOPTER During the test runs. 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. it was revealed that the distance between the two propellers was not appropriate. For the second task we designed an experiment as we didn’t have the facility of wind tunnel available at our university premises. The tissue pieces were closely monitored and it was discovered that 12” propellers produce a down draft of about 9” radius. The ruler was placed right next to the propeller and the motor was run. For the first task we used all possible resources to arrange the required propellers. The apparatus used for the experiment consisted of a simple steel ruler with thin pieces of tissue taped at equal intervals of length.

The same motors were used and the propellers were not yet changed.13: Quad-X-03 mounted on the test bench.CHAPTER 3 DESIGN OF QUADCOPTER Fig3. 31 . As a result Quad-X-3 was developed and the distance between neighboring propellers was kept safely as 6.5”.12: Test setup to determine downdraft radius. 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. 32 . Propellers tested: • 12x6 Art-tech adapters Fig3.2.1 Propeller search: The propellers that came with the Brushless motor combo pack were 12x6 propellers. Counter pitch propellers of the same profile and make were not available so the choice was dropped. 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.3.CHAPTER 3 DESIGN OF QUADCOPTER 3. They had a good thrust to motor power ratio but they were all designed to rotate in the same direction.

A pair of these propellers was ordered from Singapore and tested.CHAPTER 3 DESIGN OF QUADCOPTER • 9x6 APC Fig3. So these could serve the purpose. Hence wooden bushings were made on the CNC lathe machine and were press fit in these propellers. They had a larger bore so bushings were required. 33 .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. Due to lack of time and resources it was decided to design custom bushings rather than ordering the same from Singapore. Problems encountered: These propellers didn’t fit the shaft of the motors.

17: 12x4.5 Dragon fly adapters Fig3.16: bi copter test rig • 12x4.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. Secondly being 34 . 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.5 Dragon fly adapters The test results for 9x6 APC revealed that these propellers had a greater mass than the adapters. Fig3.

one normal propeller accompanied with a counter pitch propeller. This new design was termed as Qua-X-04. These are the only large and light weight propellers available on the net (dragonfly official website). 3. Therefore the design was altered by replacing the 0. 12x4. This did increase the weight of the craft but other weight reduction techniques were adapted to cater this new problem. The only change in the design was the implementation of the new propellers (12x4.5 dragonfly adapters).5” aluminum links with 1”x1” links. 3.5”x0.2. Due to lack of availability of the desired gauge of steel strips in the market we had to go for a custom solution. These propellers were ordered and shipped form America.5 Dragon fly adapters were the next choice. 35 . Steel blades for hack saws were altered to serve the purpose.5 Quad-X-04: Quad-X-03 scored high in all the test runs but was rated low over its looks. High density Styrofoam was used as the rotor guards. These propellers come in pairs of two.4 Quad-X-03-a: This prototype was a mere upgrade of the Quad-X-03. The spring steel strips were selected to make the landing gear.CHAPTER 3 DESIGN OF QUADCOPTER small in size the 9x6 APC propellers produce less lift compared to the adapter type propellers. Also included in the pack are two set of fine steel bushings to fit the propellers on different sized motor shafts.2.

The weight of the links was reduced by drilling holes through them to remove material. 36 .18: Quad-X-04 before weight reduction Steel was heavy for the landing gear and so were the new links.CHAPTER 3 DESIGN OF QUADCOPTER Fig3. 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.

The parameters for these steps of the control loop are calculated from the parameters of the device being controlled. There are mainly two types of control systems: 1. commands.3.3 3. For example the device being controlled is a motor and the speed of the motor is directly proportional to the currant through its armature. Closed loop control system 3. which manages.2 Open loop control system In an open loop control system there is no feedback loop.1 Control System Design: Introduction A control system is a device or a set of devices.19: Weight reduction in progress on the CNC milling m/c 3.3. direct or regulates the behavior of another device or set of devices. That means the task is done by following a set of predetermined sequential steps.CHAPTER 3 DESIGN OF QUADCOPTER Fig3. The task is to maintain a certain 37 . Open loop control system 2.

humidity wear and tear of the mechanical parts etc. Considering the same task of maintaining a certain speed. The feedback loop consists of a sensor. for example. The feedback for this system will comprise of a sensor. The controller uses this information in combination with the information of the parameters of the device being controlled to decide the next step. which can take the reading of the speed of the motor. 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. prior to designing the control system. as before. the controller. which takes the reading of the output of the device being controlled. This relationship in turn depends on a lot of other parameters like temperature. Taking the same example. of the electric motor.CHAPTER 3 DESIGN OF QUADCOPTER speed. and converts it in to a form that can be inputted in to the controller. 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. Therefore. by using the currentspeed relationship of the motor.3 Closed loop control system The closed loop control system has a feedback loop.3. 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. by increasing the 38 . the effect of all these parameters on the currant-speed relationship must be studied. will decide on the currant required for the task. 3. 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.

3.CHAPTER 3 DESIGN OF QUADCOPTER currant if the actual speed is slower then the required speed and vice versa. This default value is then compared with the feed back from the accelerometer. The circuit diagram is as follows: 39 . Fig3.20: Flow diagram depicting the control logic The controller implements proportional control logic. 3. increasing the overall accuracy of the system. 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. There by. A default position is fed in to the control system.4 Quadcopter control system: The following flow diagram represents the logic behind the electronic circuit for controlling one of the four motors.

Therefore each individual motor will have its own controller and ADCs.5 Quadcopter flight control software: The objective is to balance the Quadcopter while hovering. 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. 40 .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. The circuit was simulated using Proteus 7.3. 3. thrust at any rotor. The four motors installed on the Quadcopter are identical but they still may not run at the same rpm for the same applied voltage. In this circuit only one out of the two concerned axes is catered. This may result in slight unbalance force.2 before making the hardware.CHAPTER 3 DESIGN OF QUADCOPTER Fig3.

and aligns it to the reference horizontal position every time a change is sensed. Firstly. 41 . To work on this problem we will need to develop a feedback system that monitors the orientation of the Quadcopter in the hover mode. The orientation will be adjusted by altering the rpm of the four motors.e error=input-feedback). is then used to generate the new pulse width that will correct the out put. If there is no input then consider the angle as zero and balance the Quadcopter at zero position. This correction factor so generated. 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. The error is catered by multiplying it with Kp for proportional control.CHAPTER 3 DESIGN OF QUADCOPTER which can result in a crash. The next step involves taking the input from accelerometer and calculating the error (i.

22: Flow Diagram of flight control software 42 .CHAPTER 3 DESIGN OF QUADCOPTER The Flow Diagram for the program logic is as follows: Fig3.

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

1: Flow Diagram of Path planning software 44 .CHAPTER 4 Features of the project The following Flow Diagram represents the logic behind this intelligent software: Fig4.

Taking second point.CHAPTER 4 Features of the project A short demo of the software functionality is given below: Displaying the map. Fig4. Taking first point.2: Simulation Results of Path planning software 45 . Displaying graphical results.

P represents the intermediate points or rally points i.CHAPTER 4 Features of the project Useful information displayed on the matlab command window: Here it represents the input points i.e. the points that define the shortest path 46 . the start and the end points entered by the user.e.

The same graphical user interface also provides buttons for switching the camera display “on” or “off”. The software was developed in Matlab that allows the facility of live streaming of the video from the wire less camera. The Quadcopter is also equipped with a wireless camera. It provides the added function of taking and saving snapshots just by a single mouse click.3 Video surveillance: Surveillance cameras are a key feature of most UAV’s.4 User interface: The artificial intelligence part and the surveillance part were linked together by incorporating them in a single Graphical User Interface. The user may then indicate the start and end point of his journey by a simple click of the right mouse button.CHAPTER 4 Features of the project 4. 47 . The shortest feasible path is then displayed. The graphical user interface allows the operator to load a map from a set of maps saved in the system. The Graphical User Interface was designed in Matlab and runs off a PC based embedded system running on Windows XP embedded. 4. Another button allows the user to take snapshots at desired moment while the camera is turned “on” and the video is being previewed.

3: Front end of the graphical user interface 48 .CHAPTER 4 Features of the project Fig4.

So instead of real flights the flight environment is simulated in a wind tunnel. Wind tunnel facility was not available in our university premises. The journey started with the design of a simple setup to measure the lift produced by the rotor assemblies. 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. 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.CHAPTER 5 Testing and Evaluation CHAPTER 5 Testing and Evaluation While developing any project. For air crafts extensive tests through practical flights prove to be very expensive. a power supply and a motor drive circuit. Further more. 49 . it remains incomplete without the testing phase. a motor base. 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). This setup constituted of a digital weighing balance. Testing basically involves exposing the product to the environment it is designed for and to operate it there in to find its response. The values displayed on the machine are equal to the thrust at that point.

2: Lift vs current graph for one of the motors 50 .CHAPTER 5 Testing and Evaluation Fig5. 600 500 400 lift force (g) 300 200 100 0 0 1 2 3 4 current I (A) 5 6 7 8 9 Fig5. The test was carried out for each rotor assembly separately and graphs between the two variables were plotted.1: Test setup for determine lift characteristics of rotors The lift VS current graph was developed using this apparatus.

Fig5.3: Test setup to determine downdraft radius. Similarly different other tests were conducted. 51 . Here the disturbance of the tissue strips determined how wide the down draft is spread. The span of the downdraft too was determined experimentally using a simple experimental setup. A large test bench was also developed to show that the prototypes could be mounted on it and then run to calculate different parameters. A bi copter test bench was designed to study the behavior of two counter rotating propellers.CHAPTER 5 Testing and Evaluation Similarly different testing methods were devised to check different parameters. The setup is pictured bellow.

CHAPTER 5 Testing and Evaluation Fig5.4: bi copter test rig Fig5.5: Test bench for mounting and testing the Quad prototypes 52 .

money and hard work. slight alteration on the control system and system integration a marvel can be produced. But with time and experience it was learnt that this wasn’t at all an easy job. A platform is ready for any one interested to work on this project. Though we couldn’t achieve all the goals of our project that we had in mind at the start. 53 . Nevertheless this project has been a success as far as learning and practical implementation of engineering concepts is concerned. especially if the mechanism is in the air and has six degrees of freedom. 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. This in turn demands for a lot of time. With a little more time. Since this is a research oriented project it requires a lot of iterations of design.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. we had a great learning experience. The basic design proposed in this project works well and can be implemented on commercial aircrafts.

pk/search?q=uav+quadcopter&hl=en&start=40&sa=N 54 .helifreak.net/forums/showtopic83856.com.htm 5) http://amir. et al “Control of a Quadrotor Helicopter Using Visual Feedback” 2) http://diydrones.References References: 1) Altug.wikipedia.blogspot.html 8) http://bridgeportquadcopter.com/v/366640161/x-bl-rc-hd-test/ 13) http://www.dreamincode.com/showthread.ch/weblog/2007/03/quadcopter.com/watch?v=ZtPLgp4q0qY 14) http://www.google.com/forum/viewtopic.html 6) http://www.robotspodcast.com/profiles/blogs/quadcopter-platform-for-uav 3) http://www.draganfly.at/en/products_demonstrators.asterpix.ning.org/wiki/Quadrotor 10) http://www.com/uav-helicopter/draganflyer-x6/?gclid=CPjlhZFuZsCFRUwpAodbFnUBA 4) http://www.php?t=100612 7) http://www.aerospy.com/profiles/blogs/705844:BlogPost:12672 12) http://video.youtube.com/ 9) http://en.php?f=13&t=302 11) http://diydrones.

vidchili.tw/forums/archive/index.leechvideo.References 15) http://www.html 19) http://www.com/tag/QUADCOPTER/ 17) http://groups.com/videos/?tag=microdrones 20) http://www.yahoo.sandroses.php?phrase=quadcopter 22) http://www.isprs.top54u.com/video/AiCiHF-SnFU/MicroDrone/ 21) http://cosmosurf.pdf 16) http://www.net/search.com/video/Quadroufo/ 55 .php/t-13238.com/group/Quadcopter/summary 18) http://iphone4.org/congresses/beijing2008/proceedings/1_pdf/204.

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

% UIWAIT makes My_GUI wait for user response (see UIRESUME) % uiwait(handles. handles) % varargout cell array for returning output args (see VARARGOUT).Executes just before My_GUI is made visible. imshow(rgb_img11).output = hObject. % Choose default command line output for My_GUI handles. else gui_mainfcn(gui_State. eventdata. % hObject handle to figure % eventdata reserved . eventdata.Executes on button press in grayscale. end % End initialization code . handles) % hObject handle to grayscale (see GCBO) % eventdata reserved .output. varargin{:}). % --. function varargout = My_GUI_OutputFcn(hObject. % --. % Update handles structure guidata(hObject. see OutputFcn. function My_GUI_OpeningFcn(hObject.Outputs from this function are returned to the command line. varargin) % This function has no output args. function grayscale_Callback(hObject.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.Appendix [varargout{1:nargout}] = gui_mainfcn(gui_State.DO NOT EDIT % --.jpg').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.figure1). eventdata.to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) 57 . handles. varargin{:}). % hObject handle to figure % eventdata reserved . handles).

function edgedetection_Callback(hObject. +.to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) image=handles. if ispc set(hObject.Appendix image=handles..5870*image(:.'defaultUicontrolBackgroundColor')).:.3).1). I = . % --. % Update handles structure guidata(hObject.BW. function generatetrijectory_Callback(hObject.:.3). +.'BackgroundColor'.:.Executes on button press in edgedetection. handles. end % --. eventdata. I = ..2989*image(:.:.'roberts'). +. else set(hObject.current_data.:. handles) % hObject handle to edgedetection (see GCBO) % eventdata reserved . imshow(I). % See ISPC and COMPUTER. handles. handles).Executes on button press in generatetrijectory..BW=BW. handles) % hObject handle to generatetrijectory (see GCBO) 58 .2).current_data.'white')..:.'BackgroundColor'.current_data=handles.. eventdata.2989*image(:. imshow(BW).1140*image(:.2). +.get(0.5870*image(:. BW = edge(I...1)..1140*image(:.

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

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

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

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

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

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

handles. end end line(x. l1(3.Appendix travelling_distance = travelling_distance + abs(lc . function firstimage_Callback(hObject.current_data=handles.rgb_img1.x1).1).1)==0 && P8(1.'g'.1). end%$4444444444444444444444444444444444444444444444444444444 end end %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$ %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ line(l0. l0(3. end %%%%%%%%%%%%%%%%%%%%%%%%%%%%% if P7(1.1)+1.1)=l1(2.'g'.Executes on button press in firstimage.':').'LineStyle'.1)==1 rc=x1+2.':').1)).bmp').1)=l0(3.l1.rc. for rp=3:1:100 P10 = impixel(BW.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. x(1.x1).'Color'.1)=l1(3.y.l1(2.'LineStyle'. travelling_distance = travelling_distance + abs(rc .'Color'. 65 . y(1. imshow(rgb_img1). eventdata. end end rc=rc-1. handles. if P10==1 rc=x1+rp.rgb_img1 = rgb_img1. handles) % hObject handle to firstimage (see GCBO) % eventdata reserved . handles). shortest_distance travelling_distance % --. % Update handles structure guidata(hObject.1)=rc.

rgb_img3. handles) % hObject handle to secondimage (see GCBO) % eventdata reserved . eventdata.'BackgroundColor'. % See ISPC and COMPUTER.current_data=handles.bmp'). function thirdimage_Callback(hObject.rgb_img2.'white'). 66 . handles. % --. imshow(rgb_img3). handles.to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Access an image acquisition device. eventdata.'defaultUicontrolBackgroundColor')).'BackgroundColor'. handles. % Update handles structure guidata(hObject. vidobj = videoinput('winvideo'.Executes on button press in thirdimage. % Update handles structure guidata(hObject.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.current_data=handles. eventdata.Executes on button press in secondimage.get(0.Executes on button press in cameraon. 1). else set(hObject. handles).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. end % --. handles) % hObject handle to thirdimage (see GCBO) % eventdata reserved . function secondimage_Callback(hObject. handles).Appendix % --. function cameraon_Callback(hObject. if ispc set(hObject.bmp').rgb_img2 = rgb_img2. % Hint: edit controls usually have a white background on Windows.rgb_img3 = rgb_img3. handles) % hObject handle to cameraon (see GCBO) % eventdata reserved . imshow(rgb_img2). handles.

preview(vidobj). delete(vidobj) clear vidobj % --. handles) % hObject handle to takesnap (see GCBO) % eventdata reserved .current_data=handles. function takesnap_Callback(hObject.vidobj. handles.to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) vidobj=handles. eventdata.Executes on button press in takesnap.. ………………………………………………………………………………………… 67 . snapshot = getsnapshot(vidobj). vidobj=handles. function cameraoff_Callback(hObject. handles.vidobj=vidobj. % Display the frame in a figure window. handles) % hObject handle to cameraoff (see GCBO) % eventdata reserved . %Taking the snapshot and storing it.current_data. imagesc(snapshot).Executes on button press in cameraoff.to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Close the preview window.current_data. % Update handles structure guidata(hObject.Appendix % Open the preview window. eventdata. handles). closepreview(vidobj). % --.

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

//Initilizing timer0 for 1ms. unsigned char text1[] = "DUTY CYCLE".Appendix //initilizing the output pin for PWM. //****************** TH1 = 0xb1... float y..z++) //diaplay "QUAD X" on lcd { 69 . //force cursor to 1st row 4th column for(z=0. x=0.. unsigned char z.z<6. sbit WAVE = P3^6.. //******************** //initilizing variables float x. //clearing the screen lcdcmd(0x84)... TL1 = 0xdf.. //**************** //First message. //Initilizing timer1 for 20ms. TMOD = 0x11. clr(). //Initilizing both the timers in 16-bit timer mode.. //***************** //Displaying the initial mesages on lcd.. TL0 = 0x17... //******************** void main() { unsigned char message1[] = "QUAD X". //***************** TH0 = 0xfc.

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

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

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

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

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

K6=0. % Whatever values you want to choose %g=1. g=9.%mass of hub r=0.%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). W=0.25.09. F2=1.%x double dot tdot(3) = t(4). K2=0.%height of hub Q=0. m=.%height of motor R=0.%y double dot tdot(5) = t(6).Appendix 3a) Code for flight simulation ………………………………………………………………………………………… function [tdot] = Flight_Simulation(time.3. K5=0. L=0.1. F=[F1. J3=2*Q*r^2+4*Q*R^2+(1/12)*P*(W^2+D^2) tdot(1) = t(2).F3.%width of hub D=W.%z dot tdot(6) = ((F1+F2+F3+F4)/m)*(cos(t(11))*cos(t(9)))-g-K3*t(6). %J3=1.%depth of hub H=0.t) global F.F2.1.036. %J2=1. F3=1.%radius of motor h=0. %J1=1.3. J1=(1/3)*Q*(3*r^2+h^2)+4*Q*R^2+(1/12)*P*(H^2+D^2) J2=J1.%theta dot 75 .%mass of motor P=0. K4=0.%distance from motor to hub F1=1.%z double dot tdot(7) = t(8).F4] K1=0.5.8. F4=1.3.012.%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).3. C=1. K3=0. %C=1.02.2. %m=1. %L=1.

.10).%phi double dot tdot = tdot'.3) plot(T.t(:.t(:. title('Y-Axis') %Plotiong the displacement and velocity curves in Z-direction.t(:.[0 10]. global F. subplot(2.%phi dot tdot(12) = C*(F1-F2+F3-F4)/J3-K6*t(12).3.[5 5 0 0 0 0 0 0 0 0 0 0]).3). title('Z-Axis') %Plotiong the displacement and velocity curves of theta(Pitch angle).t(:.T.'--').T.t(:.8).t(:.3.'--').t]=ode45('Flight_Simulation'.4).%omega double dot tdot(11) = t(12).%theta double dot tdot(9) = t(10).Appendix tdot(8) = ((-F1-F2+F3+F4)/J1)*L-K4*t(8).'--').'--').3.1).'-'.9).'-'.2).5) plot(T.3.6).'-'.t(:.1) plot(T.4) plot(T.12).6) plot(T. title('Roll Angle') %Plotiong the displacement and velocity curves Phy(Yaw angle).'-'. title('Yaw Angle') ………………………………………………………………………………………… 76 ..3.t(:.'--').11). subplot(2.3.T.t(:. % This makes Ydot into a column vector ………………………………………………………………………………………… 3b) code to run flight simulation ………………………………………………………………………………………… clc. title('X-Axis') %Plotiong the displacement and velocity curves in Y-direction..T.T. close all. subplot(2.t(:..%omega dot tdot(10) = ((-F1+F2+F3-F4)/J2)*L-K5*t(10). clear all.'-'.2) plot(T. title('Pitch Angle') %Plotiong the displacement and velocity curves of omega(Roll angle)...5).t(:.t(:. subplot(2. %Ploting the displacement and velocity curves in X-direction.'-'.7). subplot(2. subplot(2.T.'--'). [T.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->