IEEE Paper

amarafie
Capstone.docx

Self-Charging Drone

ELEG/CPEG 480- Capstone Design Project II

Project Members

Ahmed Marafie (S00032764)

Ammar Shaban (S00036111)

Sayed Salman AlMosawi (S00032471)

Sayed Mohammed AlMosawi (S00032470)

Project Supervisor(s)

Dr. Seyed E Esmaeili

Department of Electrical & Computer Engineering

AMERICAN UNIVERSITY of KUWAIT

May 15, 2019

Self-Charging Drone

Project Members

Ahmed Marafie (S00032764)

Ammar Shaban (S00036111)

Sayed Mohammed AlMosawi (S00032470)

Sayed Mohammed AlMosawi (S00032470)

The capstone project report is being submitted in partial fulfillment of the requirements for the degree of

Bachelor of Engineering in Electrical Engineering

Project Supervisor(s):

Dr. Seyed E Esmaeili

Supervisor’s Signature: ____________________________

Department of Electrical & Computer Engineering

AMERICAN UNIVERSITY of KUWAIT

May 15, 2019

Abstract

Drones are a very useful piece of technology. They have many functionalities and they are used in different fields. For example, surveillance, medical assistance or even as a hobby. However, a major limitation to drones is their battery life. The average battery life of a drone is 20 minutes. With this battery life, a surveillance drone for example, can only cover a certain area before needing to go back to the owner for a battery change or to charge. Our solution is to create charging stations, where drones can self-charge whenever it is required and then continue with their task. These charging stations will be placed high enough so that the drones are un-interrupted, and they will always be charging the batteries, so they are available whenever needed.

Key Words: Battery, Charging, Drone, Station, Swap

vi

Table of Contents

Abstract iii Table of Contents iv List of Figures vi List of Tables 1 CHAPTER 1: INTRODUCTION 2 1.1 Background 2 1.2 Problem Statement 2 1.2.1 Problem 2 1.2.2 Solution 3 1.3 Aims and Objectives of the Project 3 1.3.1 Aims 3 1.3.2 Objectives 3 1.4 Significance, Scope and Definitions 4 1.4.1 SWOT Analysis 4 1.4.2 Project Development 5 1.5 Report Outline 5 CHAPTER 2: LITERATURE REVIEW 6 2.1 Historical Background 6 2.2 University of Connecticut’s autonomous battery charging of Quadcopter [1] 6 2.3 A Study on Drone Charging System Using Wireless Power Transmission [2] 8 2.4 Automated Battery Swap and Recharge to Enable Resistant UAV Missions [3] 9 2.5 Autonomous Recharging and Flight Mission Planning for Battery-Operated Autonomous Drones [4] 10 2.6 Solar UAV Design [5] 11 2.7 Eagle Eye Drone by Francois Baptista and Stephane Pietroiusti [6] 12 2.8 Summary and Implications 13 CHAPTER 3: METHODOLOGY, DESIGN AND ANALYSIS 15 3.1 Requirements 15 3.1.1 Functional Requirements 15 3.1.2 Non-Functional Requirements 15 3.2 Research Design 16 3.2.1 System Design 16 3.2.2 System Architecture 18 3.3 Hardware 19 3.3.1 Motor 19 3.3.2 Sensor 25 3.3.3 Microcontroller 26 3.3.4 Bluetooth [20] 28 3.3.5 Battery Charger [21] 29 3.3.6 Battery [22] 29 3.3.7 Flight Controller [23] 29 3.3.8 GPS Module [24] 29 3.4 Software 30 3.4.1 Arduino IDE [25] 30 3.5 Budget 31 3.6 Analysis and Calculations 31 3.7 Ethics and Limitations 34 3.7.1 Ethics 34 3.7.2 Limitations 35 CHAPTER 4: IMPLEMENTATION 36 4.1 Hardware Implementation 36 4.2 Software Implementation 38 4.3 Problems Faced 39 CHAPTER 5: EVALUATION 40 5.1 Economic Impact 40 5.2 Safety Impact 40 5.3 Social Impact 41 5.4 Ethical Impact 41 5.5 Survey 42 CHAPTER 6: CONCLUSION AND FUTURE WORK 45 6.1 Conclusion 45 6.2 Future Work 45 6.2.1 Charging Station 45 REFERENCES 47 APPENDIX A 49 i. Drone Code: 49 ii. Station Code: 55

List of Figures

Figure 2.1. Image Tracking System [1] 7

Figure 2. 2. Drone in Operation [2] 8

Figure 2.3. Drone Charging on Station [2] 8

Figure 2. 4. CAD Design of Battery Carrier [3] 9

Figure 2.5. CAD Design of Landing Station [3] 10

Figure 2.6. Geographical Locations of Charging Stations [4] 10

Figure 2.7. Weight Division of the UAV with Nano Sensor System [5] 12

Figure 2. 8. Power Utilization Division of the UAV [5] 12

Figure 2.9. Eagle Eye Drone [6] 13

Figure 3.1. Flowchart 18

Figure 3.2. System Architecture 19

Figure 3.3. AC Motor [7] 20

Figure 3.4. Brushed DC Motor [9] 21

Figure 3.5. Brushless DC Motor [10] 22

Figure 3.6. Geared DC Motor [11] 22

Figure 3.7. Stepper Motor [12] 23

Figure 3.8. Servo Motor [13] 24

Figure 3.9. Ultrasonic Sensor [15] 26

Figure 3.10. Arduino Uno [17] 27

Figure 3.11. Arduino Due [18] 28

Figure 3.12. Arduino Mega [19] 28

Figure 3.13. The three segments of GPS 30

Figure 3.14. The Recharge System Model 32

Figure 3.15. Replace System Model 33

Figure 4.1. UAV Landing on Charging Station 36

Figure 4.2. Wheel Motors 37

Figure 4.3. Topical View of UAV 38

Figure 5.1. “Why do you use Drones?” 42

Figure 5.2. “Is Drone Battery Life a Problem to you?” 43

Figure 5.3. “Would you use a Public Charging Station for a Fee?” 43

Figure 5.4. “Where would you like to see Charging Stations?” 44

List of Tables

Table 1.1 SWOT Analysis 4

Table 2. 1 Comparative Analysis 14

Table 3.1 Functional Requirements 15

Table 3.2 Non-Functional Requirements 16

Table 3.3. Table of Components 31

CHAPTER 1: INTRODUCTION

Background

Drones or unmanned aerial vehicles (UAVs) attract the attention of business, military and civilian divisions throughout the world for being a source of observation and meets their requirements. For instance, an examination performed by British Petroleum on drones to observe the pipelines and employment by the government of Nepal to investigate the damaged regions caused by an earthquake of 2015 (Kima, Lima & Chob, 2018). Such examples demonstrate that UAVs or drones can be operated at any time and any temperature.

Monitoring and inspection are essential in specific large regions for road watching, livestock investigation, and home safety. Drones can execute the like missions as they can travel independently in inspection regions without being stopped by the earthly hindrances. The timespan of flight of these drones is the real issue. It has been observed that a usual drone can fly for 10 minutes with the latest battery, Li-Po batteries. This battery timing makes the usage of a UAV impractical specifically in the fields of medicine and surveillance.

This chapter includes a problem statement, solution to the problem and the idea generation. The goals and objectives of the project are enlisted in this chapter. Also, SWOT analyses have been performed for the project as well as for the project team.

Problem Statement

Problem

Drones are commonly used in medicine and observation. The most frequent uses of drones in medicine include the supply of crisis evaluations in the unavailability of other sources of reach; distributing medicines, help packages, blood, vaccines and other kinds of clinical stuff (Balasubramaniam, Reshma & Janardanan, et al. 2018). In addition, drones offer many advantages concerning surveillance — for example, offense prosecutions, traffic monitoring, and border monitoring, etc. Nevertheless, in the current times, even the most developed drones have a flight duration ranging from 20 to 25 minutes. The short battery life of drones creates problems during surveillance and make the usage of these drones as impracticable in all fields. Due to the extensive usage of drones in surveillance and medicine, it is essential to look for a way by which the flight duration of these drones can be increased without interrupting the flights. Usually, drones operate through onboard batteries which have restricted capacities (Tseng, Chau, Elbassioni & Khonji, 2017). Nonetheless, these drones are anticipated to accomplish vital and longer missions. Therefore, there is a need for an autonomous mechanism by which the flight time of drones can be enhanced, and the missions can be completed without any effect. It aids in extending the working duration of drones.

Solution

Self –charging drones are the solution to the short battery timing of drones. A grid of fully charged batteries can offer maximum flight duration to the drones by taking the place of consumed batteries. For instance, when the battery of a drone gets exhausted, the drone can replace this exhausted batter with a completely charged battery from a nearby pole and continue its mission without being affected by the depletion of the battery.

Aims and Objectives of the Project

Aims

· To design a drone charging station

· To arm the station with a battery swap functionality

· To maintain high drone uptime

Objectives

I. To encourage the implementation of mounted batteries for enhancing flight duration of drones.

II. To develop charging stations for drones where they can charge themselves and execute the tasks without being disturbed.

III. To make efficient use of solar energy to charge the batteries.

Significance, Scope and Definitions

SWOT Analysis

SWOT analysis refers to strengths, weaknesses, opportunities, and threats. It is a helpful way to identify strengths and weaknesses and determining the opportunities that are available to a business. The threats are identified which a business or a project may endure (Mindtools. n.d.). A SWOT analysis of the project is presented in Error! Reference source not found..

Table 0.1 SWOT Analysis

Strengths

Weaknesses

· A revolutionary drone charging plan for persistent drone functions

· Waypoints at a distance of every 25 minutes

· Drones can be charged without the need to land

· Unique energy storage structure

· Reduction in asset upgrading costs

· Wireless charging of drones will require upgrading of infrastructure

· Requires hard work and time

· Batteries need to be replaced after every 25 minutes

Opportunities

Threats

· A distinctive solution for the battery issue of drones.

· Can be executed to examine the probability of successfulness of such solutions.

· Persistent operations of drones can lead to an air war

Project Development

The subject matter of Self-charging drones has been selected for our capstone project. The idea development resulted from the brainstorming and the research conducted by the project team concerning the issues faced in the utilization of drones for various missions. It was examined after conducting vast research that there is a need for a new and practical solution to this problem and it can be resolved by no other than the mounted batteries. This project entails extensive research about how this solution can be executed successfully and what are the costs involved and the resulting advantages.

Report Outline

Chapter 1: The problem statement, proposed solution, objectives and project analysis.

Chapter 2: Literature review about the recently developed solutions for the drone self-charging system.

Chapter 3: System architecture, system design, and the required components to implement the system.

Chapter 4: The implementation details of the self-charging drone.

Chapter 5: The safety and economic impacts of the system.

Chapter 6: The conclusion and the proposed future work.

CHAPTER 2: LITERATURE REVIEW

1

Historical Background

There has been a rapid growth in drones with the advancement in the technology and their incorporation in consumer electronics. These are the aircrafts which were built for fulfilling limitary purposes originally. In the start, they were used as weapons such as missiles so that they could be controlled with the remote controls through radio waves. There are a lot of applications in which these drones can be used now as their functions now also include monitoring of the change in climate and delivering items for the search operations. The origin of these drones took place in the year 1894 when Venice was attacked by Austria using explosives. However, they were in the form of balloons which do not meet with the current standards of drones that work in the form of piloted aircraft for shooting missiles.

University of Connecticut’s autonomous battery charging of Quadcopter [1]

The quadcopter is identical to a drone. However, the flight timing of a quadcopter is restricted because of the drawbacks of the new battery supply. Including additional batteries is not a permanent solution to the issue. Because adding batteries will utilize extra power, resulting in a decrease in battery timing and flying duration. In this project, the design team of the University of Connecticut decided to build a UAV structure that can charge autonomously without requiring human involvement. The design team developed an autonomous structure which can navigate the unmanned aerial vehicle to the charging location, thus, charging the quadcopter's battery without needing a human engagement Error! Reference source not found..

Figure 2.1. Image Tracking System [1]

The design team of the University of Connecticut used an image processing mechanism to search the charging station. The design team believed that it is the most suitable option because the drone is designed for flying indoors. Moreover, the team will experiment on the inside. Therefore, there will be no need for GPS. This image processing method involves pointing out towards a tag or a color close to the charging station. The drone will fly near to the color or tag till the time it reaches the charging station.

When the drone identifies the charging station, it should rest on the top of the charging station to charge itself. To dock at the charging station, the camera that is installed under the drone will persistently monitor for color or tag. As soon as the bottom camera identifies a tag, the drone will dock in the charging station and initiates charging. The other function of the drone will monitor the battery persistently until it is complete. After complete charging, the drone will take-off.

A Study on Drone Charging System Using Wireless Power Transmission [2]

This drone charging system based, which is on wireless power transmission, is developed by Chang W. P. et al.. In this system, radio frequency energy harvesting using circular spiral indicator antenna is used to charge the drone wirelessly. The distance between the drone charging circuit and the energy harvesting circuit is kept at a value such that maximum power is transferred from the harvesting system to the drone battery. The system design is shown below in Error! Reference source not found. and operation is shown in Error! Reference source not found..

Figure 2.02. Drone in Operation [2]

Figure 0.3. Drone Charging on Station [2]

The station is powered by solar power, which is then supplied to the station. The station is placed in a high location, which allows easy access to the drone without interruption; and it allows the solar panels to take in the most amount of power.

Automated Battery Swap and Recharge to Enable Resistant UAV Missions [3]

Tuna Tokosoz et al. proposed an automated battery swap and recharge to enable persistent UAV missions. The authors presented a hardware platform for the proposed system. The proposed system uses a buffer of 8 batteries arranged in a novel dual-drum structure that enables a hot battery swap. Because of the high capability of the developed drone which uses 8 large batteries, it's possible to use the system to refuel multiple UAV's for long duration and persistent missions. The hardware implementation of the system is shown in the below Figure 2.04 and Figure 2.5.

Figure 2.04. CAD Design of Battery Carrier [3]

Figure 2.5. CAD Design of Landing Station [3]

Autonomous Recharging and Flight Mission Planning for Battery-Operated Autonomous Drones [4]

Many researchers worked on the management of the automated drone system. The phase of the drone management system is imported for many applications. An algorithm was developed to allow the accessibility of the drone to the nearest charging station. The developed algorithm minimizes the time to access the charging station by the drone. The geographical location of the sites of these charging stations and the base station of the drone is shown in the Figure 2.6. While flying, the drone targets the closest charging station at the current time, then flies to it when the battery is at low power. The closest station keeps changing as the drone moves around.

Figure 2.6. Geographical Locations of Charging Stations [4]

Solar UAV Design [5]

The unmanned aerial vehicle (UAV) developed in this project was founded on the Green Falcon UAV that was built at the Australian Research Centre for Aerospace and Automation (ARCAA) and QUT. The main sub-systems include navigation structure. The elements of this navigation structure are a gyro sensor, accelerometer, GPS, airspeed sensor, autopilot, barometer pressure, and fail-safe structure. The autopilot utilized in the development of the UAV was the ArduPilot Mega 2.5. It is a comprehensive autopilot structure with a higher proportion of benefit to cost and lower weight. The autopilot structure functions in three ways, i.e., self-governing way, to ultimately execute the mission that does not need crew by preprogramming the computer checked coordinates of each phase of a flight from the ground control stations (GCS). The second component is stabilization mode. It helps the earthly captain in regulating and maintaining the flight of the aerial vehicle. However, in this manner, the captain has incomplete command on the aerial vehicle, and when the input is absent, autopilot becomes able to manage the smooth flying of the aerial vehicle. The third component is manual mode. This mode is helpful in executing a pre-flight check. Through this mode, the pilot can independently execute manual takeoffs and landings operations when the autopilot is not preprogrammed.

All these modes allow the autopilot to convey significant flying details like pitch, roll, yaw, GPS position, battery position and airspeed to ground control station by employing a telemetry module. The airframe of the UAV is smooth to transfer quick deployment and manually take off. The wingspan of the airframe is 2.52m; length is 960mm and wing aspect proportion is 13. The original weight was 960g however, after including the SSC panels, the weight elevated to 1610g. So, the ultimate weight of the unmanned aerial vehicle was 3285g as shown in Error! Reference source not found. and Figure 2.6. The overall power utilization of the UAV or the drone was 42.52 Wh. The telemetry model was RFD900.

The suggested drone is appropriate to execute observation on the old cases where earthly sensors can elevate a timely alarm that introduces a UAV to observe the growth of CO2 Cloud.

Figure 0.7. Weight Division of the UAV with Nano Sensor System [5]

Figure 2.08. Power Utilization Division of the UAV [5]

Eagle Eye Drone by Francois Baptista and Stephane Pietroiusti [6]

One of the critical problems with drones is that they need to charge the batteries after a brief flight duration. However, the Eagle Eye Drone designed by Baptista and Pietroiusti is created with a different aim Figure 2.7. It is structured with solar panels at the top surface. Thus, it recharges itself while flying in the air and does not require to land. This drone is structured for the areas with hidden dangers in distant places. These drones offer information about the way the land has changed and the trees that might have perished. This drone was developed by French engineers and they aimed to keep people secured during wild experiences. Because of its super characteristics, it has become a mandatory device for the rescuers.

Figure 0.9. Eagle Eye Drone [6]

Summary and Implications

The projects listed above touch on all aspects that relate to our project. All projects that have been discussed and analyzed above are listed in Table 2.801. The table emphasizes on comparing the features and components of the drones that have been designed in these different projects. The Mechanical portion considers the physical features like wheel and appearance while the electrical part considers the battery timing and recharging mechanism of the drones.

Table 2.801 Comparative Analysis

Project

# of Batteries

Battery Swap

Fast Charging

Autonomous Charging

Cost

Quadcopter [1]

1

≈ $3700

Wireless Charged Drone [2]

1

≈ $4300

Automated Swap-Recharge [3]

2

≈ $3870

Autonomous Recharging [4]

2

≈ $5030

Solar UAV [5]

1

≈ $4230

Eagle Eye Drone [6]

1

≈ $4670

Self-Charging Drone

4

≈ $2500

As we can see in Table 2.801, we have compared all the projects we researched to our project. The compared aspects are key to a charging station. These aspects allow the station to function in the most viable way, with the highest uptime. Our project meets all the standards, with the highest amount of carried batteries and is also the cheapest out of all the projects.

CHAPTER 3: METHODOLOGY, DESIGN AND ANALYSIS

2

Requirements

Functional Requirements

Functional requirements are what a system is supposed to accomplish, in other words the main parts of the system. They are things that the user expects from the system to do, with minimal failure. Without these requirements, the system will not perform according to the standards that were specified, because these are considered crucial and vital features of it. Error! Reference source not found. shows the functional requirements of our project.

Table 03.1 Functional Requirements

Functional Requirment

Priority

Accurate Drone Landing

High

Battery Percentage Detection

High

Station Carries Several Batteries

Low

Battery Swapping Capability

High

Autonomous Drone

High

Non-Functional Requirements

The non-functional requirements are the requirements that show how the system functions and executes the tasks instead of showing what the system should accomplish. These features do not affect the main functions of the project, such as time taken, efficiency, the power consumption, and portability. Error! Reference source not found. includes the non-functional requirements of our project and their priorities.

Table 3.2 Non-Functional Requirements

Non-Functional Requirement

Description

Performance

The measure of efficiency the system develops and for our

project we are expecting performance to be a high priority.

Reliability

It is a measure of how robust the system and it measure its

endurance.

Availability

It is a high priority requirement as the system should be

available whenever needed.

Safety

It is a high priority requirement as it is the measure of how well the system functions without causing minimal failure or system crash.

Research Design

System Design

Error! Reference source not found. shows the flow chart of both our systems; the drone and the charging station. For the Station, firstly, the system checks if a drone has arrived or not, in case of “Not Landed” it will wait until a drone arrives. While waiting, it will check the stored batteries’ percentage. If the batteries are not charged, they are moved to the charging bay and will charge. Otherwise they are moved to the receiving bay, ready to be inserted into the drone. In case of "Landed" the system will position the drone in the center of the platform, then moving it to the right orientation to extract and insert battery correctly and easily, then the system will lock the drone to prevent any movement for the drone during extracting and inserting the battery. Then the system will extract the exhausted battery from the drone. The system will replace the exhausted battery with the charged one, and then the system will do two operations concurrently, the first one is inserting the charged battery back to the drone, then unlocking the drone, and informing the control unit that the drone is ready for departing. The second is placing the weak battery into a charger for charging it and then placing the next charged battery in a position for next drone.

As for the drone, the system checks it the battery is charged or not. In case of “Not Charged” it will remain at the station until a new battery is placed. In the case of “Charged” the drone will fly until the sensor detects low battery, which will then lead it to the charging station, and charge.

Figure 0.1. Flowchart

System Architecture

Our system’s Architecture shown in Error! Reference source not found. consists of two main processes. These processes are connected through two Arduinos, whether is it a command from or to the Arduinos. Each of the processes is connected to an Arduino; and both Arduinos are connected to each other. Process one is the Battery Station. Process two is connected to the drone.

Figure 0.2. System Architecture

Hardware

Motor

The most important part of planning a robotic project is to choose the right motor. Electric motor is an electric machine in which electrical energy is converted into mechanical energy. There are many types of motors and each one of them has different specifications that we should consider depending on the need of our project like torque, speed, precision and accuracy. In the case of our design, we are most interested in delicate precision movement. The team managed to compare between several types of motors to choose the motor that best suits our needs.

AC Motor [7]

AC motor is the motor that converts the AC current into mechanical power by using an electromagnetic induction phenomenon. This motor is driven by an alternating current. The most important parts of the AC motor are the stator and the rotor. The stator is the stationary part of the motor, and the rotor is the rotating part of the motor shown below in Error! Reference source not found..

Figure 0.3. AC Motor [7]

DC Motor [8]

DC motor uses the DC current to convert electrical energy into mechanical energy. When the electric current passes through a coil in a magnetic field, a magnetic force will be generated, which produces a torque in the DC motor.

Brushed DC Motor [9]

The most common type of DC motors is the Brushed DC motor. This motor can be found in everything like hand-held fans, cordless drills, cell phone buzzers and steel mills. As shown in Error! Reference source not found., a brushed DC motor has two brushes to conduct current from source to armature. The permanent magnet DC motor (PMDC) is one kind of many brushes DC motors, which is used extensively in robotics. That is because brushed DC (BDC) motors have served advantages, as they are inexpensive, easy to drive and are readily available in all sizes and shapes, they are widely used in applications ranging from toys to push-button adjustable car seats.

Figure 0.4. Brushed DC Motor [9]

Brushless DC Motor [10]

Brushless DC (BLDC) Motors are mechanically less complicated than brushed motors, which replace the brushes and associated sparks and noise with electronic commutation to silently switch the current flow to drive the motor. Brushless DC motors can be found in computer fans and disk drives, as well as in quadcopters, electric vehicles and high-precision servomechanisms where quietness is important. Comparing brushless DC motors to brush DC motors, the advantages of the brushless DC motor is higher efficiencies than the brush DC motor, high reliability, low electrical noise, good speed control and more importantly, no brushes or commutator to wear out producing a much higher speed. However, their disadvantage is that they are more expensive and more complicated to control.

Figure 0.5. Brushless DC Motor [10]

Geared DC Motor [11]

We can define geared DC motors to be an extension of DC motors. It has a gear assembly attached to the motor. And the rotations of the shaft per minute (RPM) counted as the motor speed. The gear assembly helps in increasing the torque and reducing the speed. Using the correct combination of gears in a gear motor, its speed can be reduced as desired. Error! Reference source not found. represents a geared DC motor.

Figure 0.6. Geared DC Motor [11]

Stepper Motor [12]

A stepper motor is an electromechanical device, which converts electrical pulses into discrete mechanical movements. Error! Reference source not found. below shows the shaft of a stepper motor rotates in discrete step increments when electrical command pulses are applied to it in the proper sequence. There are several direct relationships between the motor’s rotations and the applied input pulses. Such as, the sequence of the applied pulses is directly related to the direction of motor shafts rotation. The speed of the motor shafts rotation is directly related to the frequency of the input pulses and the length of rotation is directly related to the number of input pulses applied. Whenever controlled movement is required the stepper motor can be a good choice. They can be in applications where you need to control rotational angle, speed, position and synchronism. So, in all sorts of applications ranging from clocks to robots and CNC machines stepper motors can be found.

Figure 03.7. Stepper Motor [12]

Servo Motor [13]

A servomotor is a motor that allows for a precise control in terms of angular position. Servomotor is a good choice if you want to rotate and object at some specific angles or place with great precision. It is made up of simple motor, which run through servo mechanism. Servomotors have two types, which are DC servomotor and AC servomotor. The servomotor can give us very high torque in a lightweight and small package. For these features they are being used in many applications like toy car, RC helicopters and planes, robotics, machines etc. The motor electrical pulse determines the position of a servomotor and its circuit is places beside the motor. It has an option, which provides angular precision, i.e. it will only rotate as much you as decide and then stop till the next signal to take further action. Which is unlike a normal electrical motor that starts rotating as and when power is applies to it until we switch off the power. The servo system has huge industrial applications nowadays. Servo motors applications are commonly seen in remote controlled toy cars for controlling direction of motion and it is also very commonly used as the motor which movers the tray of a CD and DVD player.

Servo Mechanism consists of three main parts:

· Controlled device

· Output sensor

· Feedback system

It is a closed loop system where it uses positive feedback system to control motion and final position of the shaft. Here the device is controlled by a feedback signal generated by comparing output signal and reference input signal.

Figure 0.8. Servo Motor [13]

Illustrated in Error! Reference source not found., the reference input signal is compared to reference output signal and the third signal is produces by feedback system. And this third signal acts as input signal to control device. This signal is present as long as feedback signal is generated or there is difference between reference input signal and reference output signal. So, the main task of servomechanism is to maintain output of a system at desired value at presence of noises.

Decision:

For our project we are going to use a DC motor, as it is the best fit to our desired requirements. The primary advantage of the DC motor is that it can develop constant torque over a wide speed application. We are also going to use a servo motor accurately land the drone on the station.

Sensor

A sensor is a sophisticated device that measures a physical quantity like speed or pressure and converts it into a signal that can be measured electrically. To select the right sensor is not a hard process. In the design of our project, sensors are used for measuring the distance from two objects.

IR Sensor [14]

An infrared sensor, also known as an IR sensor, is a device, which is used to sense certain characteristics of its surroundings by either emitting or detecting select light wavelength infrared spectrum. The IR sensor sends a light wave that is equal to selected light wave the sensor is looking for which is LED. How it works is that if there is no object the light will not reflect. The closer the object is the higher the intensity of the light wave reflecting into the light sensor.

Ultrasonic Sensor

These sensors shown in Figure 3.3.29 are designed to receive the echo reflected high frequency sound waves by the target, which generated by the sensor itself. These sensors are used in a wide range of applications and are very useful. Ultrasonic Sensors measure the distance to the target by measuring the time between the transmission and reception. The distance can be calculated with the following formula:

(3.1)

Where L is the distance, T is the time between the transmission and reception, and C is the ultrasonic sound waves speed. (The value is multiplied by 1/2 because T is the time for go-and-return distance.)

Figure 0.9. Ultrasonic Sensor [15]

Voltage Sensor [16]

Voltage sensors measure and monitor the voltage in in a targeted device. They are used in many safety mechanisms to alert if the voltage reaches a dangerous level. They are also used to measure the levels of voltage in devices such as batteries in automatic charging situations.

Decision

Our team agreed on using the ultrasonic sensor, as it is the most suitable for our project due to its high accuracy detection. This sensor can work in critical conditions such as dirt and dust. Our design will also require a voltage sensor to identify the voltage level in the batteries, and in the drones battery.

Microcontroller

Arduino Uno [17]

Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. Arduino Uno: is a microcontroller board based on the ATmega328P. As shown below in Figure 0.10, it has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analogy inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. You can tinker with your UNO without worrying too much about doing something wrong, worst case scenario you can replace the chip for a few dollars and start over again.

Figure 0.10. Arduino Uno [17]

Arduino Due [18]

The Arduino Due in Figure 0.10 is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU. It is the first Arduino board based on a 32-bit ARM core microcontroller. It has 54 digital input/output pins (of which 12 can be used as PWM outputs), 12 analog inputs, 4 UARTs (hardware serial ports), a 84 MHz clock, an USB OTG capable connection, 2 DAC (digital to analog), 2 TWI, a power jack, an SPI header, a JTAG header, a reset button and an erase button. Unlike most Arduino boards, the Arduino Due board runs at 3.3V. The maximum voltage that the I/O pins can tolerate is 3.3V. Applying voltages higher than 3.3V to any I/O pin could damage the board. The board contains everything needed to support the microcontroller; simply connect it to a computer with a micro-USB cable or power it with a AC-to-DC adapter or battery to get started. The Due is compatible with all Arduino shields that work at 3.3V and are compliant with the 1.0 Arduino pinout.

Figure 0.11. Arduino Due [18]

Arduino Mega [19]

The Mega 2560 is a microcontroller board based on the ATmega2560. It has 54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with an AC to DC adapter or battery to get started. Figure 0.10 below represents Arduino Mega.

Figure 0.12. Arduino Mega [19]

Decision

Despite the common features of the different types of Arduino mentioned above, the team’s decision is to use Arduino Mega as it contains many inputs and outputs necessarily needed in our design.

Bluetooth [20]

Bluetooth is used to control devices at long distances. These devices can be connected to the phones or any other device which contains Bluetooth functionality. However, the issue with the Bluetooth is a range as the Bluetooth can only reach out to a specific range. The chances of losing signals are more with the use of Bluetooth in drones.

Battery Charger [21]

Having a multifunctional charger for the battery can perform better because this investment can pay off by giving better health to the battery over the longer run. These chargers have some of the easily adaptable features which include the charging of battery virtually and other forms of maintenance tasks. Most commonly used battery is Lithium - polymer as it offers a better life and working with less maintenance requirement.

Battery [22]

Batteries offer the most reliable form of power. They are consistent and allow easy replacement. The battery is used to control power supply. The charging time of the drone , is a part of the chargers specs. However, to calculate battery drainage:

(3.2)

Flight Controller [23]

There is a small circuit which has various levels of complexity and this is used for controlling the flight. The function of this unit is to offer direct instructions towards the motor after it gets the instructions. When the command is received from the pilot, the information is fed in the flight controller and then it takes forward the flight while determining all the important tasks to meet the given command.

GPS Module [24]

GPS stands for Global Positioning System by which anyone can always obtain the position information anywhere in the world. GPS consists of the following three segments:

· Space segment (GPS satellites): Many GPS satellites are deployed on six orbits around the earth at the altitude of approximately 20,000 km (four GPS satellites per one orbit) and move around the earth at 12-hour-intervals.

· Control segment (Ground control stations): Ground control stations play roles of monitoring, controlling and maintaining satellite orbit to make sure that the deviation of the satellites from the orbit, as well as GPS timing, are within the tolerance level.

· User segment (GPS receivers): User segment (GPS receivers).

This is demonstrated in Figure 0.13

C:\Users\Lord\Desktop\13.JPG

Figure 0.13. The three segments of GPS

Software

Arduino IDE [25]

The open-source Arduino Software (IDE) makes it easy to write code and upload it to the board. It runs on Windows, Mac OS X, and Linux. The environment is written in Java and based on Processing and other open-source software. This software can be used with any Arduino board. The Arduino compiler/IDE accepts C and C++ as-is. In fact, many of the libraries are written in C++. Much of the underlying system is not object oriented, but it could be. Thus, "The Arduino language" is C++ or C.

Budget

These are the components that have been used during our project research. Table 0.3. Table of Components below gives the exact estimate of what we used, availability, quantity and the prices.

Table 0.3. Table of Components

Components

Availability

Quantity

Price

Drone

Yes

1

970 USD

GPS module

Yes

2

39.50 USD

Battery

Yes

4

644.50 USD

DC Motors

Yes

6

108.50 USD

DuPont wires

Yes

1

16.50 USD

Flight Controller Board

Yes

1

26.50 USD

Battery Charger

Yes

2

37 USD

Wheels Motors

Yes

3

20 USD

Limit Switch

Yes

3

4 USD

Arduino Mega

Yes

2

50 USD

Voltage Sensor

Yes

2

20 USD

Bluetooth

Yes

2

53 USD

Servo Motor

Yes

2

26.50 USD

Ultrasonic sensor

Yes

4

316 USD

Total

2,332 USD

Analysis and Calculations

We will use Petri net model in our system analysis. Petri net also known as a place/transition (PT) net, can be considered a graphical tool that may be used to describe distributed, concurrent, parallel, asynchronous, deterministic and/or stochastic stepwise processes. It is a bipartite graph, in which the nodes are divided into transitions (T, represented by bars) and places (P, represented by circles). The connection between nodes is made by directed arcs, which connect only a T to a P, or a P to a T, never P to P or T to T. There is an essential term in Petri net called token (usually represented by dots) travel through the net. Whenever there is a token at the input of all arcs leading to a transition, the transition "fires," the tokens at the input are consumed, and a token is created at the output of each of the outgoing arcs. The location and number of tokens at the start of the Petri net evolution is called the initial marking.

C:\Users\Lord\Desktop\11.JPG

Figure 0.14. The Recharge System Model

C:\Users\Lord\Desktop\11.JPG

Figure 0.15. Replace System Model

Figure 0.15 and Figure 0.15 show Petri net models for a recharge and a replacement system, where TF stands for the time a UAV spends in the air, TR is the time it spends at the service station, TC is the charging time a battery requires to achieve full charge when fully depleted and TI is the idle time allocated to each UAV in one operation cycle. In the Petri net for the recharge platform on Figure 0.15, the duration TR should be at least if a battery charging time; the UAV remains with the platform until its battery is fully charged. In the Petri net for the replacement platform on Figure 0.15, TR will be small relative to TC, since only a battery swap is required during the TR duration.

In the initial marking of the replacement Petri net, there are NUAV, NPLAT, (NBATT − NUAV) and NCGR tokens in the places labeled "Ready to fly," "Platform ready for UAV," "Battery charged," and "Chargers waiting for batteries" respectively. These represent the number of UAVs (each with a battery), exchange platforms, backup charged batteries, and battery chargers, respectively.

If there is only one output arc and one input arc at any of the places of a given Petri net, the network is called "decision-free." The system cycle time for a decision free Petri net can be obtained as max ( TiNi ), where i ranges over all loops in the net, Ti is the sum of durations along these loops and Ni is the number of tokens in places in the initial loop marking.

There are four simple loops in the replacement net: UAV loop (LUAV), platform loop (LPLAT), battery loop (LBATT), and charger loop (LCGR). Defining:

(3.3)

(3.4)

(3.5)

(3.6)

where NUAV, NPLAT, NBATT, and NCGR are the number of UAVs, platforms, batteries (total including those on UAVs and those on the platforms) and chargers, respectively. The minimum cycle time (maximum performance) of the system is:

) (3.7)

Ethics and Limitations

Ethics

These are the unmanned vehicles which should work with some of the ethical ramifications. It is necessary to keep in view some of the important implications of drones in routine life so that ethics can be given importance. The ethics about the use of drones in Kuwait are broken down into rules and then they are encoded in the form of programs so that the ethical behaviour can be ensured. As drones work with a completely autonomous system, they should have some of the important ethical constraints for the betterment of humans. The process of using drones is automated so that the decision making can be taken ethically with the replacement of humans. These drones conduct proper ethical analysis for making target decisions by having complete information about how ethical rules are operated.

Limitations

Some of the important limitations which must be followed to work with the drones include that these drones can be a hazard when flying over large crowds or people. This can be dangerous. These drones are also limited to respect the privacy of others while flying. These drones are not allowed to fly over the aircraft operating areas or airports. Also, our calculations do not consider weather conditions, which is sometimes unpredictable. These drones are also limited to fly in the sensitive areas as in the government as well as military areas.

CHAPTER 4: IMPLEMENTATION

3

Hardware Implementation

The hardware components integrated in this part will be broken down, viewing the functionality of each system, and how the movements and reactions of the machine are built.

As mentioned in the flowchart the station is made of three zone: a receiving zone, charging zone and a charged zone as shown in Figure 0.1. The drone lands on the receiving zone and on the left of it is the charging zone and on the right is where the charged batteries go to. The moment the drone lands the battery goes to the charging zone and when it is fully charged the wheel motors turns and drops the battery in the station where it sends it to the charged zone ready to be used. Also, we have the option to move the batteries horizontally where it moves from the charging zone in a reverse movement back to receiving zone and all the way to the charged zone.

Figure 0.1. UAV Landing on Charging Station

We have three motor wheels (Figure 0.1) that controls the battery movement from one zone to another by basically turning counterclockwise and we can reverse this mechanism as previously mentioned.

Figure 0.2. Wheel Motors

The drone operates normally and the instant the battery runs out it will land on the station, there is a connectivity between the drone and the station through a Bluetooth module. When it lands safely the station recognizes that and a voltage sensor measures the battery status.

Basically, the drone has three different types of sensors, an ultrasonic sensor which sets the path of the battery from on zone to another. A voltage sensor that measures the battery and checks its status and finally we used a Bluetooth module for connectivity between the drone and the station. Lastly, on the station, there is an Arduino connected to it three limit switches situated in every zone where it identifies the location of the batteries onboard the station. We can see some of these in Figure 0.1.

Figure 0.3. Topical View of UAV

Software Implementation

The software Application of our design is applied through the coding process for our autonomous station. After many options to consider, the team decided to use C language using Arduino platform. Our code description is shown below as follows: Power supply is provided.

First, we have the code for the drone. The first step is setting up the drone and we give it time for calibrations and establishing a start/end point using the GPS onboard. The drone rises in the air and fly in a specific coordinate given to it. When it senses that the battery onboard is low the drone stops and return to the same exact position it started from.

Here, the second part is the station. When the drone lands on the station first the voltage sensor test the battery if its full or not and if not, the wheel motor rotates the battery to the charging zone and plug in the fully charged battery in the drone.

Problems Faced

During the process of building our design, we have come across a few problems in the phase of choosing the ideal components and while assembling them together.

Our team plan started by purchasing the main components for our design online and it took more time than expected. The first and most important component was the drone. After several tests on the first drone we ended up breaking it. So, we had to buy another one and that is our final prototype. The most painful part was synchronizing all motors to work simultaneously while forgetting a blade on the motor and winding up with a cut on the hand. Also, setting up the gyroscope and balancing the drone was the biggest challenge we faced. We had to use a controller until we finally balanced the drone. We had to replace the sensors several time until we found the best sensor that the market can offer. We also had a difficult time with the batteries; a couple were damaged in the process of setting them up, even creating minor flames once.

Concerning the station, our team faced problems with the battery swap mechanism for the station. After deep discussions and many meetings, we decided to approach the choice of using a wheel motors to move the batteries from and to the drone. During that process we broke the station many times until we finally got it to operate properly.

It was challenging to create two different systems, at different times, and them learn how to integrate them together.

CHAPTER 5: EVALUATION

4

Economic Impact

The cost of this prototype of drone is cheaper compared to other prototypes because it uses low-priced components and it is reasonable. However, our prototype achieves the task of replacing the battery in a short time therefore, no need to spend a lot of money for more expensive components to shorten the time of the replacement process because time is not critical. It also uses market-available components such as ultrasonic sensor, GPS module and Arduino. So, it is possible for any company to design and implement such a drone easily and station effortlessly.

Safety Impact

Implementing a safe system is a vital factor during our brainstorming process for the project, thus our project must be assessed of how safe it is to the public use on every angle. After the assembly of our project, it is tested to show if it is working properly. The project will be for the public use so we must test it accurately to obtain a safe certified project.

Most importantly during the building of our station we noted down all the key points concerning the safety standards we looked up. The quality of the station and the assembling of the parts have to be correct and firmly positioned in place. The main focus in our testing is long term functionality; we aim to prevent any malfunction during its task.

Our prototype drone is safe because the batteries we used has a housing to be plugged in. It is based on a switching key which attach the battery securely to the drone. The case of the battery is attached firmly to the drone without the fear of falling down during flight. Also, the drone has an electronic system which relays the battery status to the user so the user of such drone knows where is the position of the battery in the station and that it is connected safely before departure of the drone.

Social Impact

Our project is very useful for drone user’s community specially the professionals and has many benefits such as enabling easy and safe battering swapping. People around the world use drones for many different reasons such as capturing memorable photos and videos and some of them struggle with the battery life specially when you mostly need it. A lot of people also struggle with carrying many items with them during outdoor activities. Therefore, our project gives them the opportunity to extend the flight duration while charging his own battery for extra time in-hand without the need of carrying extra batteries or chargers.

Amazon is a well-known delivery company started using autonomous drones for delivering small items within 30 minutes, our project will help extending this time line to increase the range of delivery as well. TU Delft is a company in the Netherlands that uses an ambulance drone as a first-response measure for any emergency that happens. Our project will defiantly make certain that all these drones are ready and fully operational during a crisis and that their batteries are fully charged. Thus, our project can be used in many aspects in our society, it is very useful and safe to our community.

Ethical Impact

The ethical impact is one of the most critical parts to be discussed and forms the principle of any project. When ethical impact exists and is not taken into consideration, health and safety is a concern, people could be hurt severely or god prohibit even leads to death. The ethics and guidelines we discuss to aim are safety, pollution, pre preparation and manpower.

“Safety comes first”. As project management comes, safety is the first aspect to be discussed. The risk of our project is considered relatively low to a zero as the station will be factory-made under safe environment and fixed in position where it is not reachable and cannot be tampered with. Second point to be taken into consideration is pollution. In the case of our station the first threat of pollution would be the material it is made from where we will make it environmentally friendly. The second threat of pollution would be the noise of the station operating. Since the design implementation focuses on using electric motors, there will be no noise.

The final most important point we should take into account is manpower. We aim for our project to be fully autonomous. We require only one worker to manage maintenance of the station; testing the machine and maintain a clean and accurate function of the station. This will help save manpower, reduction of effort, and also maintain a professional output to the user.

Survey

For this project we decided to conduct a survey to understand the market better, to see the people’s demand, and to get an unbiased opinion about the project. We picked specific questions to target some important details, which could help uss further improve our project, and develop future plans for it.

Figure 0.1. “Why do you use Drones?”

Figure 0.2. “Is Drone Battery Life a Problem to you?”

Figure 0.3. “Would you use a Public Charging Station for a Fee?”

Figure 0.4. “Where would you like to see Charging Stations?”

From the results of the survey we conducted, we can see that the majority of people use their drones for either entertainment or videography. This may suggest why most people would like the stations to be placed in public stations. Even though the results of the drone battery life being an issue is split in half, many people were fine with paying a fee to have access to our charging stations, if it means longer battery life and more drone uptime.

CHAPTER 6: CONCLUSION AND FUTURE WORK

5

Conclusion

In conclusion, we decide to build self-charging drone’s system as a solution for the short battery timing of drone problem. After a deep research by team members, we found that such an issue is serious problem for drones because it results to the possibility of failing the mission that the drone would do and also affects the utilization of drones for various missions. The idea of our Project to solve this issue resulted from brainstorming and deep research. This project entails extensive research about how this solution can be executed successfully and what are the costs involved and the resulting advantages.

Firstly, we surveyed a lot of projects, research paper and articles related to drones to gain more knowledge and recognize different issues in the design and implementation of drones and we made a literature review (chapter 2). After a deep discussion about the system architecture by team members, we have reached to the block diagram of the system and drew it (as shown in chapter 3), then we used petri-net tool to make analysis of the system, and then we selected the appropriate components for our prototype (in chapter 3). We made the design and implementation of the system (chapter 4) and finally we evaluated the project based on different aspects: economic, safety and social impacts (chapter 5).

Future Work

Although our charging station will fulfill our customer’s needs, there can be extra features that would improve the overall functionality of our station depending on where you use it. Some of which are as follows:

Charging Station

· Charging stations might be implemented in countries with a high temperature atmosphere; therefore, we might install a cooling system for the batteries in the station.

· We can use solar panels to power up the station and charge the batteries fitted in it and that will give us the freedom of choosing a location for our station, provided you get a constant exposure to direct sunlight.

· After studying the market for all type drones used worldwide, we design an application for the station where the costumer can choose the type of battery, he requires from it while providing a location for nearest available station.

REFERENCES

[1] Kima, S. J., Lima, G. J. & Chob, J. (2018). Drone Flight Scheduling Under Uncertainty on Battery Duration and Air Temperature

[2] Balasingam, M. (2017).Drones in medicine—the rise of the machine. The International Journal of Clinical Practice, 71 (9)

[3] Balasubramaniam, A., Reshma, S. & Janardanan, et al. (2018). Enhancing the Proficiency of the Drone with an Application of Ocean Farming. Procedia Computer Science 133.p.725–732.

[4] Microdrones. (n.d.). Subtle Monitoring with UAVs.

[5] TSENG, C. M., CHAU, C. K., ELBASSIONI, K. & KHONJI, M. (2017). Autonomous Recharging and Flight Mission Planning for Battery-operated Autonomous Drones.

[6] Edronic. (n.d.). The Sky is the limit, no the Autonomy.

[7] Mindtools. (n.d.). SWOT Analysis.

[8] Malaver, N. Motta, P. Corke and F. Gonzalez. “Development and Integration of a Solar Powered Unmanned Aerial Vehicle and a Wireless Sensor Network to Monitor Greenhouse Gases” Sensors, 15, 2015, 4072-4096

[9] Royal Literary Fund. (n.d.). What is a literature review?

[10] T. Baietto, G. Bautista, R. Oldham & Y. Song. “Autonomous Battery Charging of Quadcopter” University of Connecticut, 2016, pp 1-13.

[11] M. Hemsworth. “The Eagle Eye Drone Has Solar Panels to Charge during Flight”, 2017.

[12] designboom. “francois baptista + stéphane pietroiusti create EAGLE EYE as a rescue drone”, 2018

[13] P. Luca., A. Benedetto, B. Enrico., G. Francesco., M. Marco., M. Tomnaso. Integrated Design and Testing of an Anemometer for Autonomous Sail Drones (2018) Journal of Dynamic Systems, Measurement and Control, Transactions of the ASME, 140 (5)

[14] Park, C. W., & Chung, H. T. A Study on Drone Charging System Using Wireless Power Transmission

[15] Tseng, C. M., Chau, C. K., Elbassioni, K., & Khonji, M. (2017). Autonomous Recharging and Flight Mission Planning for Battery-operated Autonomous Drones.

[16] Tseng, C. M., Chau, C. K., Elbassioni, K., & Khonji, M. (2017). Autonomous Recharging and Flight Mission Planning for Battery-operated Autonomous Drones.

APPENDIX A

i. Drone Code:

#define chanel_number 6 //set the number of chanels

#define default_servo_value 1510 //set the default servo value

#define PPM_FrLen 22500 //set the PPM frame length in microseconds (1ms = 1000µs)

#define PPM_PulseLen 300 //set the pulse length

#define onState 1 //set polarity of the pulses: 1 is positive, 0 is negative

#define sigPin 10 //set PPM signal output pin on the arduino

//////////////////////////////////////////////////////////////////

#include <Wire.h>

int val11;

int val2;

/*this array holds the servo values for the ppm signal

change theese values in your code (usually servo values move between 1000 and 2000)*/

int ppm[chanel_number];

int phase1 = 0;

int phase2 = 0;

int phase3 = 0;

int batteryPercentage = 0;

int FrontSensor = 0;

int backSensor = 0;

int rightSensor = 0;

int leftSensor = 0;

const int trigPin = 14;

const int echoPin = 15;

const int trigPin2 = 16;

const int echoPin2 = 17;

const int trigPin3 = 18;

const int echoPin3 = 19;

const int trigPin4 = 20;

const int echoPin4 = 11;

long duration;

int distance;

long duration2;

int distance2;

long duration3;

int distance3;

long duration4;

int distance4;

void setup(){

ppm[0]= 1510;

ppm[1]= 1510;

ppm[2]= 1560;

ppm[3]= 1510;

ppm[4]= 1510;

ppm[5]= 1510;

pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin, INPUT); // Sets the echoPin as an Input

pinMode(trigPin2, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin2, INPUT); // Sets the echoPin as an Input

pinMode(trigPin3, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin3, INPUT); // Sets the echoPin as an Input

pinMode(trigPin4, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin4, INPUT); // Sets the echoPin as an Input

pinMode(sigPin, OUTPUT);

digitalWrite(sigPin, !onState); //set the PPM signal pin to the default state (off)

cli();

TCCR1A = 0; // set entire TCCR1 register to 0

TCCR1B = 0;

OCR1A = 100; // compare match register, change this

TCCR1B |= (1 << WGM12); // turn on CTC mode

TCCR1B |= (1 << CS11); // 8 prescaler: 0,5 microseconds at 16mhz

TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt

sei();

}

int phase1 = 0;

void loop(){

//---------------------------------voltage sensor -----------------------------------

float temp;

val11=analogRead(1);

temp=val11/4.092;

val11=(int)temp;

val2=((val11%100)/10);

batteryPercentage = val2;

//---------------------------------voltage sensor -----------------------------------

//---------------------------------ultra sonic-----------------------------------

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration = pulseIn(echoPin, HIGH);

// Calculating the distance

distance= duration*0.034/2;

digitalWrite(trigPin2, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin2, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin2, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration2 = pulseIn(echoPin2, HIGH);

// Calculating the distance

distance2= duration2*0.034/2;

digitalWrite(trigPin3, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin3, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin3, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration3 = pulseIn(echoPin3, HIGH);

// Calculating the distance

distance3= duration3*0.034/2;

digitalWrite(trigPin4, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin4, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin4, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration4 = pulseIn(echoPin4, HIGH);

// Calculating the distance

distance4= duration4*0.034/2;

FrontSensor = distance;

rightSensor = distance2;

backSensor = distance3;

leftSensor = distance4;

//---------------------------------ultra sonic-----------------------------------

//---------------------------------flight-----------------------------------

if( phase1 == 0)

{

delay(3000);

ppm[0] = 1010;

ppm[1] = 1010;

ppm[2] = 1010;

ppm[3] = 1990;

delay(4000);

phase1 = 1;

}

if ( phase1 == 1)

{

ppm[0] = 1510;

ppm[1] = 1510;

ppm[2] = 1900;

ppm[3] = 1510;

delay(400);

phase2 = 1;

}

if(phase2 == 1)

{

ppm[1] = 1610;

ppm[3] = 1510;

if(FrontSensor < 15)

{

ppm[3] = 1610;

}

if(leftSensor < 15)

{

ppm[3] = 1510;

ppm[1] = 1410;

}

if(backSensor < 15)

{

ppm[3] = 1410;

ppm[1] = 1510;

}

if(rightSensor <15)

{

ppm[3] = 1510;

ppm[1] = 1610;

}

if(batteryPercentage <40)

{

phase3 = 1;

}

}

if(phase3 == 1)

{

if(rightSensor <15 && backSensor <15)

{

phase2 = 0;

ppm[0] = 1510;

ppm[1] = 1510;

ppm[2] = 1400;

ppm[3] = 1510;

}

if(batteryPercentage>55)

{

phase1 = 0;

phase2 = 0;

phase3 = 0;

}

}

//---------------------------------flight----------------------------------

delay(10);

}

ISR(TIMER1_COMPA_vect){ //leave this alone

static boolean state = true;

TCNT1 = 0;

if(state) { //start pulse

digitalWrite(sigPin, onState);

OCR1A = PPM_PulseLen * 2;

state = false;

}

else{ //end pulse and calculate when to start the next pulse

static byte cur_chan_numb;

static unsigned int calc_rest;

digitalWrite(sigPin, !onState);

state = true;

if(cur_chan_numb >= chanel_number){

cur_chan_numb = 0;

calc_rest = calc_rest + PPM_PulseLen;//

OCR1A = (PPM_FrLen - calc_rest) * 2;

calc_rest = 0;

}

else{

OCR1A = (ppm[cur_chan_numb] - PPM_PulseLen) * 2;

calc_rest = calc_rest + ppm[cur_chan_numb];

cur_chan_numb++;

}

}

}

ii. Station Code:

int limitswitch = 2;

int limitswitch2 = 3;

int limitswitch3 = 4;

#include <Servo.h>

Servo myservo; // create servo object to control a servo

Servo myservo2; // create servo object to control a servo

// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

int pos2 = 0; // variable to store the servo position

void setup() {

// put your setup code here, to run once:

myservo.attach(4); // attaches the servo on pin 9 to the servo object

myservo.attach(5); // attaches the servo on pin 9 to the servo object

pinmode(limitswitch, INPUT_PULLUP);

pinmode(limitswitch2, INPUT_PULLUP);

pinmode(limitswitch3, INPUT_PULLUP);

//Setup Channel A

pinMode(12, OUTPUT); //Initiates Motor Channel A pin

pinMode(9, OUTPUT); //Initiates Brake Channel A pin

//Setup Channel B

pinMode(10, OUTPUT); //Initiates Motor Channel A pin

pinMode(11, OUTPUT); //Initiates Brake Channel A pin

//Setup Channel C

pinMode(7, OUTPUT); //Initiates Motor Channel A pin

pinMode(6, OUTPUT); //Initiates Brake Channel A pin

}

void loop() {

// put your main code here, to run repeatedly:

if ( limitswitch2 === HIGH)

{

digitalWrite(12, HIGH); //Establishes forward direction of Channel A

}

else

{

digitalWrite(12, LOW); //Stop Motor

}

if ( limitswitch3 === HIGH)

{

digitalWrite(7, HIGH); //Establishes forward direction of Channel A

}

if( limitswitch2 == HIGH)

{

digitalWrite(7, LOW); //Stop Motor

}

if(limitswitch2 == HIGH)

{

myservo.write(90);

myservo2.write(90);

}

else

{

myservo.write(0);

myservo2.write(0);

}

}

36