Upload
rohithmv1
View
227
Download
0
Embed Size (px)
Citation preview
7/31/2019 prjt nikhil
1/47
1
Design of an unmanned aerial vehicle based on the AUTOPILOTING
NIKHIL G MADHU
VISHNU S V
ANISH J
SAJIN
GUIDE : SAGAI FRANCIS BRITTO
7/31/2019 prjt nikhil
2/47
2
ABSTRACT
This project focuses on the design, modeling, implementation and testing of an autonomous unmanned aerialvehicle. The controller is based on an Ardupilot board which is a custom PCB with an embedded processor
(ATMega168) combined with circuitry to switch control between the RC control and the autopilot control. It
controls navigation (following GPS waypoints) and altitude by controlling the rudder and throttle. It uses flight
stabilization system (co-pilot), a sensor pack, Global Positioning System (GPS) and an RF transceiver to monitor
and report crucial parameters such as altitude, speed, pitch, roll, and position. An embedded software algorithm
has been developed to enable the aerial vehicle accomplish the required autonomy and maintain satisfactory fligh
operation. The autopilot features an advanced, highly autonomous flight control system with an auto-launch and
auto landing algorithms.
7/31/2019 prjt nikhil
3/47
3
TABLE OF CONTENT
SL TITLE PAGE
NO. NO.
ABSTRACT
1. 1.1 INTRODUCTION1.2 Description of UAV1.3 Classification of UAV1.4 General functions of UAV
2. DESIGN2.1 Top View
2.2 Bottom View
2.3 Design parameters
2.4 NACA Airfoil
2.4.1 Airfoil Terminology
2.4.2 Airfoil Types
2.4.3 Four Digit Series
2.4.4 Equation for Four Series Symmetrical Airfoil
2.4.5 Characteristics of NACA 4415 Airfoil
2.4.6 Characteristics of NACA 0012 Airfoil
7/31/2019 prjt nikhil
4/47
4
2.5 Twin Boom
3. POWERPLANT
3.1 Key Features
3.2 Specifications
3.3 Working
3.4 Propeller
3.4.1 Pusher Type Propeller
4. REFERENCE
7/31/2019 prjt nikhil
5/47
5
CHAPTER-1
INTRODUCTION
A growing area in aerospace engineering is the use and development of unmanned aerial vehicles (UAV)
for military and civilian applications .There are difficulties in the design of these vehicles due to the varied andnon intuitive nature of the configurations and missions that can be performed . Currently there has been a huge
demand for UAVs and services for real time and remote sensing. Unmanned aerial vehicles can be deployed to
solve a number of civilian tasks. It can be used as an effective means of search, detection and identifying of
objects or subjects of interest as well as their precise coordinates. UAVs are also very useful in disaster
management. In the occurrence of a forest fire, for instance, it is very difficult to have a precise data on the
development of the situation. But with the deployment of a UAV which is capable of flying at low altitudes and
able to navigate with GPS waypoints and machine vision, the situation can be controlled very efficiently.
We named this UAV as NAVS. NAVS is a light weight low altitude short/ medium-range surveillanc
and intelligence gathering UAV.NAVS have a wing span of 1600mm and length of 1200mm.The propeller usin
is a puller type one. Power-plant is an air-cooled glow engine seated at the rear of the fuselage with a pulle
propeller. Undercarriage is tricycle type landing gear. Solid spring shock absorbers are employed to reduce th
impact during landing.
The entire structure of NAVS is made up of light weight balsa wood, which has high strength to weight ratio
Vinyl sheet forms the skin. The avionics includes a six channel radio controller and receiver, seven servos and
7.4 volt lithium battery. The NAVS can facilitate a shock-resistant camera along with its transmitter and receiver
an autopilot system with Global Positioning System (GPS) navigation. The merits of NAVS are that it offer
minimum drag and hence good fuel economy. Its light weight makes it portable and can be easily disassemble
and reassembled. It can serve both civil and military purposes. It is also of great use in emergency rescu
operations and in disaster management.
1.1 DESCRIPTION OF THE UAV NAVS
The entire aircraft (wings and fuselage) can be constructed using light weight balsa wood. Its fuselage
designed to house fuel, a glow engine and a rear pusher propeller unit. Effectively, there are five control surface
on the UAV. These are the left and right ailerons on the wings, single elevator and two rudders on the boom
mounted tail unit. These control the pitching, rolling and yawing on this UAV.
The aircrafts small, single-cylinder, 120mm bore ASP S^! engine sits at the rear of the craft with a pulle
propeller .The craft can be maneuvered easily via a joystick on the ground control unit. An aircraft constructe
7/31/2019 prjt nikhil
6/47
6
with a pusher configuration has the engine mounted forward of the propeller - which faces in a rearwards directio
- giving an appearance that the aircraft is pushed.
1.2 UAV CLASSIFICATION:
UAVs typically fall into one of six functional categories (although multi-role airframe platforms are becomin
more prevalent):
Target and decoy - providing ground and aerial gunnery a target that simulates an enemy aircraft or missile Reconnaissance - providing battlefield intelligence Combat - providing attack capability for high-risk missions (see Unmanned combat air vehicle) Logistics - UAVs specifically designed for cargo and logistics operation Research and development - used to further develop UAV technologies to be integrated into field deploye
UAV aircraft
Civil and Commercial UAVs - UAVs specifically designed for civil and commercial applications. Handheld 2,000 ft (600 m) altitude, about 2 km range Close 5,000 ft (1,500 m) altitude, up to 10 km range
1.3 GENERAL UAV FUNCTIONS:
1.3.1 REMOTE SENSING:
UAV remote sensing functions include electromagnetic spectrum sensors, biological sensors, an
chemical sensors. A UAV's electromagnetic sensors typically include visual spectrum, infrared, or near infrare
cameras as well as radar systems. Biological sensors are sensors capable of detecting the airborne presence o
various microorganisms and other biological factors. Chemical sensors use laser spectroscopy to analyze th
concentrations of each element in the air.
1.3.2 TRANSPORT:
UAVs can transport goods using various means based on the configuration of the UAV itself. Mo
payloads are stored in an internal payload bay somewhere in the airframe. With fixed wing UAVs, payloads ca
also be attached to the airframe, but aerodynamics of the aircraft with the payload must be assessed. For suc
situations, payloads are often enclosed in aerodynamic pods for transport.
http://en.wikipedia.org/wiki/Unmanned_combat_air_vehiclehttp://en.wikipedia.org/wiki/Infraredhttp://en.wikipedia.org/wiki/Near_infraredhttp://en.wikipedia.org/wiki/Laser-induced_breakdown_spectroscopyhttp://en.wikipedia.org/wiki/Chemical_elementhttp://en.wikipedia.org/wiki/Fixed-wing_aircrafthttp://en.wikipedia.org/wiki/Aerodynamicshttp://en.wikipedia.org/wiki/Aerodynamicshttp://en.wikipedia.org/wiki/Fixed-wing_aircrafthttp://en.wikipedia.org/wiki/Chemical_elementhttp://en.wikipedia.org/wiki/Laser-induced_breakdown_spectroscopyhttp://en.wikipedia.org/wiki/Near_infraredhttp://en.wikipedia.org/wiki/Infraredhttp://en.wikipedia.org/wiki/Unmanned_combat_air_vehicle7/31/2019 prjt nikhil
7/47
7
1.3.3 SCIENTIFIC RESEARCH:
Unmanned aircraft are uniquely capable of penetrating areas which may be too dangerous for piloted craft
1.3.4 ARMED ATTACKS:
UAVs armed with missiles are now used as platforms for hitting ground targets in sensitive areas. Th
advantage of using an unmanned vehicle, rather than a manned aircraft in such cases is to avoid a diplomati
embarrassment when the aircraft is shot down and the pilots captured.
1.3.5 SEARCH AND RESCUE:
UAVs will likely play an increased role in search and rescue operations in regions inaccessible to humans.
1.3.6 ARDUPILOT (PCB):
ArduPilot is a full-featured autopilot based on the open-source Arduinoplatform . The Ardupilot is a
custom PCB with an embedded processor (ATMega 168) combined with circuitry to switch between RC control
and the autopilot control (i.e., the multiplexer/failsafe; otherwise known as a MUX). This controls navigation
(following GPS waypoints) and altitude by controlling the rudder and throttle. These components are all open
source. This autopilot is fully programmable and can have any number of GPS waypoints (including altitude) and
trigger camera or other sensors. Features of the ArduPilot .It can be used for an autonomous aircraft. The built-inhardware failsafe uses a separate circuit to transfer control from the RC system to the autopilot and back again. It
includes the ability to reboot the main processor in mid-flight. It makes provision for the use of multiple
waypoints. It also provides a 6-pin GPS connector for the 1hz EM406 GPS module.
http://en.wikipedia.org/wiki/Hellfire_missilehttp://en.wikipedia.org/wiki/Hellfire_missile7/31/2019 prjt nikhil
8/47
8
CHAPTER 2
DESIGN
UAV NAVS has a blended wing design with a twin boom attached to the rear of the aircraft. Th
empennage is mounted on the booms. The wings blend smoothly with the fuselage; hence it offers minimum dra
and improves fuel efficiency. Twin boom ensures better longitudinal stability and better field of view for camer
mounted in front. The airfoil used is Symmetrical airfoil for the main plane and NACA 0012 for the tail unit. Th
control surfaces include two ailerons on wing, two rudders and a single elevator which performs rolling, yawin
and pitching movements respectively. Engine is mounted at the rear of the fuselage with a pusher propelle
attached. Undercarriage is tricycle type landing gear. Solid spring shock absorbers are employed to reduce th
impact during landing. The design was finalized after a number of iterations.
7/31/2019 prjt nikhil
9/47
9
2.1TOP VIEW
Fig1 Top View of NAVS
2.2 BOTTOM VIEW
Fig 2 Bottom View of NAVS
7/31/2019 prjt nikhil
10/47
10
2.3 DESIGN PARAMETERS
Wing span 1600 mm
Length 1200 mm
Height 580 mm
Mean aerodynamic chord 270mm
Wing area 2.667 m2
Wheelbase (long) 576 mm
Wheelbase (lat) 247 mm
Aerofoil wing Symmetrical aerofoil
Aerofoil horizontal stabiliser NACA 0012
Table 1 Design Parameters
2.4 AEROFOIL :
UAV NAVS uses Symmetrical airfoil for wings and NACA 0012 airfoil for its tail unit. An airfoil is th
shape of a wing or blade as seen in cross-section. An airfoil-shaped body moving through a fluid produces a forc
perpendicular to the motion called lift. Subsonic flight airfoils have a characteristic shape with a rounded leadin
edge, followed by a sharp trailing edge, often with asymmetric camber.
Airfoils design is a major facet of aerodynamics. Various airfoils serve different flight regime
Asymmetric airfoils can generate lift at zero angle of attack, while asymmetric airfoil may better suit frequen
inverted flight as in as aerobatic aero plane.
As a wing moves through the air, the air spilt and passes above and below the wing. The wings uppe
surface is shaped so the air rushing over the top speeds up and stretches out. This decreases the air pressure abov
the wing. The air flowing below the wing moves in a straight line, so its speed and air pressure, the air below th
wing pushes upward toward the air above the wing. The wing is in middle, and wing is lifted. The faster a
airplane moves, the more lift there is. And when the force of lift is greater than the force of gravity, the airplane i
able to fly.
7/31/2019 prjt nikhil
11/47
11
2.4.1 AIRFOIL TERMINOLOGY:
The various terms related to airfoil are defined below:
2.4.1.1MEAN CAMBER LINE:
The mean camber line is a line drawn between the upper and lower surfaces.
2.4.1.2CHORD LINE:
The chord line is a straight line connecting the leading and trailing edges of the airfoil, at the ends of the
mean camber line.
2.4.1.3 CHORD:
The chord is the length of the chord line and is the characteristic dimension of airfoil section.
2.4.1.4 MAXIMUM THICKNESS:
The maximum thickness and the location of maximum thickness are expressed as a percentage of the chord
2.4.1.5 AERODYNAMIC CENTER:
The aerodynamic center is the chord wise length about which the pitching moment is independent of th
lift coefficient and the angle of attack.
2.4.1.6 CENTRE OF PRESSUREThe center of pressure is the chord wise location about which pitching moment is zero.
2.4.2 AIRFOIL TYPES:
2.4.2.1 SUBSONIC AIRFOIL:
Subsonic airfoils have a round edge which is naturally insensitive to the angle of attack. In subsoni
airfoil, the leading edge is more towards the shape of a cylinder and the trailing edge is more towards the shape o
a sharp edged knife.
7/31/2019 prjt nikhil
12/47
12
Fig 3 Subsonic airfoil
Profile geometry1: Zero lift line; 2: Leading edge; 3: Nose circle; 4: Camber; 5: Maximum thickness; 6: Uppe
surface; 7: Trailing edge; 8: Main camber line; 9: Lower surface
Fig 4 Airfoil Parameters
A: blue line=chord, green line = camber, B: leading edge radius, C: x-y-coordinates for the profile geometr(Chord = x-Axis; y-Axis line on that leading edge)
The NACA airfoils are airfoil shapes for aircraft wings developed by the National Advisory Committee fo
Aeronautics (NACA). The shape of the NACA airfoils is described using a series of digits following the wor
"NACA." The parameters in the numerical code can be entered into equations to precisely generate the cross
section of the airfoil and calculate its properties.
http://en.wikipedia.org/wiki/Airfoilhttp://en.wikipedia.org/wiki/National_Advisory_Committee_for_Aeronauticshttp://en.wikipedia.org/wiki/National_Advisory_Committee_for_Aeronauticshttp://en.wikipedia.org/wiki/File:NACA_Profil_0.svghttp://en.wikipedia.org/wiki/File:Airfoil_geometry.svghttp://en.wikipedia.org/wiki/File:NACA_Profil_0.svghttp://en.wikipedia.org/wiki/File:Airfoil_geometry.svghttp://en.wikipedia.org/wiki/National_Advisory_Committee_for_Aeronauticshttp://en.wikipedia.org/wiki/National_Advisory_Committee_for_Aeronauticshttp://en.wikipedia.org/wiki/Airfoil7/31/2019 prjt nikhil
13/47
13
2.4.3 FOUR-DIGIT SERIES:
The NACA four-digit wing sections define the profile by:
1. One digit describing maximum camber as percentage of the chord.2. One digit describing the distance of maximum camber from the airfoil leading edge in tens of percents o
the chord.
3. Two digits describing maximum thickness of the airfoil as percent of the chord.For example, the NACA 2408 airfoil has a maximum camber of 2% located 40% (0.4 chords) from the leadin
edge with a maximum thickness of 8% of the chord. Four-digit series airfoils by default have maximum thicknes
at 30% of the chord (0.3 chords) from the leading edge.
The NACA 0012 airfoil is symmetrical, the 00 indicating that it has no camber. The 15 indicates that the airfo
has a 12% thickness to chord length ratio: it is 12% as thick as it is long.
2.4.4 EQUATION FOR A SYMMETRICAL 4-DIGIT NACA AIRFOIL:
The formula for the shape of a NACA 00xx foil, with "xx" being replaced by the percentage of thickness t
chord, is:
Where:
c is the chord length, x is the position along the chord from 0 to c, y is the half thickness at a given value ofx (centerline to surface), and tis the maximum thickness as a fraction of the chord (so 100 tgives the last two digits in the NACA 4
digit denomination).
The two different types of airfoils used in this model are NACA 0012 and NACA 2408.
http://en.wikipedia.org/wiki/Camber_%28aerodynamics%29http://en.wikipedia.org/wiki/Chord_%28aircraft%29http://en.wikipedia.org/wiki/Chord_%28aircraft%29http://en.wikipedia.org/wiki/Chord_%28aircraft%29http://en.wikipedia.org/wiki/Chord_%28aircraft%29http://en.wikipedia.org/wiki/Camber_%28aerodynamics%297/31/2019 prjt nikhil
14/47
14
2.4.5 AIRFOIL PARAMETERS:
Thickness: 9.0%
Camber: .40%
Trailing edge angle: 9.7o
Lower flatness: 72.9%
Leading edge radius: 0.8%
Max CL: 0.928
Max CL angle: 12.5
Max L/D: 48.121
Max L/D angle: 4.0
Max L/D CL: 0.724
Stall angle: 4.5
Zero-lift angle: -2.0
Table 2 Symmetrical aerofoil Parameters
2.4.6 CHARACTERISTICS OF 0012:
Fig 5 NACA 0012 airfoil
7/31/2019 prjt nikhil
15/47
15
CHAPTER 3
POWERPLANT
The NAVS use S61 nitro engine.The fuel used is the misture of 80%methanol and 20%caster oil.
Nitro engines use a carburetor to mix the nitro and air together. The carburetor can either be sliding or
rotary. On a rotary carburetor, the slide is opened as the arm is turned by the servo. On a slide carburetor
the slide is opened by sliding the arm out by the servo. Both are held open slightly by an idle screw which
allows the engine to receive a very small amount of fuel to keep the engine running when the vehicle is at
stop. The carburetors usually feature 2 needles used to tune the mixture. A high speed needle tunes how
much fuel is allowed into the carburetor at mid to high RPM, and a low speed needle determines how
much fuel is allowed into the carburetor at low to mid range RPM. Turning either needle in a clockwise
motion will lean the engine out. Lean describes the amount of fuel in the fuel / air mixture. To a point this
will make the engine run faster with better performance, but once too lean the engine will overheat, andwear out prematurely due to not receiving enough lubrication. Turning either needle counterclockwise wil
richen the engine. Rich is the opposite of lean, it means more oil is entering the engine. If the engine is too
rich, it will run poorly, and fuel that has not yet been burnt may start to spit out of the exhaust. The engine
will run very slow and seem to have no power and possibly cut out from being flooded with fuel.
Although, being too rich is better than being too lean, because being too rich just means the engine is
getting too much oil which is perfectly fine, although performance may not be as good as if the engine
were lean. A properly tuned engine will last a long time with good performance throughout its life.
7/31/2019 prjt nikhil
16/47
16
3.1 KEY FEATURES
2-stroke nitro engine from one of RC's top brands 9.95cc displacement rivals similarly sized 2 strokes Includes: Ignition, Muffler, carburetor and Motor Mount Built for the utmost in reliability and performance RPM ranges from 2000-18000 Power 1.85bhp Available in traditional silver case
Fig 6 ASP S61 Nitro Engine
3.2 SPECIFICATION
Type: 2 stroke gasoline engine Displacement: 9.95 cc Bore: 24 mm Stroke: 22 mm Total weight: 602g for Motor + Mount + Muffler + Ignition Prop range:12*6,11*7 RPM range: 2000 - 18000 rpm
7/31/2019 prjt nikhil
17/47
17
Fuel: 20% caster oil and 80% methanol Mounting dimensions: 124mm x 85mm x 173mm Muffler type: Cast Power: 1.85 kWatts
3.3 WORKING:
To start a glow engine, a direct current (around 3 amps and 1.25 to 2 volts, often provided by a single, higcurrent capacity rechargeable Nickel Cadmium, Nickel metal hydride or lead-acid battery cell, or
purpose-built "power panel" running on a 12VDC source is applied to the glow plug, initially heating th
filament. The name 'glow plug' comes from the fact that the plug's filament glows red hot. The engine i
then spun from the outside using a manual crank, built-in rope-based recoil starter, spring-loaded motor o
purpose-built electric motor, or by hand, to introduce fuel to the chamber
Once the fuel has ignited and the engine is running, the electrical connection is no longer needed and cabe removed. Each time combustion keeps the glow plug filament glowing red hot, allowing it to ignite th
next charge, thus sustaining the power cycle.
Lead-acid battery cells that are used to ignite a model engine glow plug, due to their two volt output whefreshly charged, usually cause a regular 1.5 volt glow plug to burn out instantaneously, and either a resisto
of the proper value and wattage, or a high-power germanium transistor's base/emitter junction (in a serie
connection with one of the plug's terminals) can reduce the lead-acid cell's voltage to a suitable 1.5 vo
level for engine starting. Technically a glow plug engine is fairly similar to a diesel engine and hot bul
engine in that it uses internal heat to ignite the fuel, but since the ignition timing is not controlled by fue
injection (as in an ordinary diesel engine), or electrically (as in a spark ignition engine), it must be adjuste
by changing fuel/air mixture and plug/coil design (usually through adjusting various inlets and controls o
the engine itself.) A richer mixture will tend to cool the filament and so retard ignition, slowing the engin
This "configuration" can also be adjusted by using varying plug designs for a more exact thermal contro
Of all internal combustion engine types, the glow plug engine resembles most the hot bulb engine, since o
both types the ignition occurs due to a "hot spot" within the engine combustion chamber.
Glow plug engines can be designed for two-cycle operation (ignition every rotation) or four-cycloperation (ignition every two rotations). The two-cycle (or two-stroke) version produces more power, bu
the four-cycle engines have more low-end torque, are less noisy and have a lower-pitched, more realist
sound.
http://en.wikipedia.org/wiki/Nickel-cadmium_batteryhttp://en.wikipedia.org/wiki/Lead-acid_batteryhttp://en.wikipedia.org/wiki/Brushed_DC_electric_motorhttp://en.wikipedia.org/wiki/Resistorhttp://en.wikipedia.org/wiki/Bipolar_junction_transistor#Germanium_transistorshttp://en.wikipedia.org/wiki/Diesel_enginehttp://en.wikipedia.org/wiki/Hot_bulb_enginehttp://en.wikipedia.org/wiki/Hot_bulb_enginehttp://en.wikipedia.org/wiki/Hot_bulb_enginehttp://en.wikipedia.org/wiki/Hot_bulb_enginehttp://en.wikipedia.org/wiki/Hot_bulb_enginehttp://en.wikipedia.org/wiki/Hot_bulb_enginehttp://en.wikipedia.org/wiki/Diesel_enginehttp://en.wikipedia.org/wiki/Bipolar_junction_transistor#Germanium_transistorshttp://en.wikipedia.org/wiki/Resistorhttp://en.wikipedia.org/wiki/Brushed_DC_electric_motorhttp://en.wikipedia.org/wiki/Lead-acid_batteryhttp://en.wikipedia.org/wiki/Nickel-cadmium_battery7/31/2019 prjt nikhil
18/47
18
3.4 PROPELLER:
A propeller is a type offan which transmits power by converting rotational motion into thrust. A pressur
difference is produced between the forward and rear surfaces of the airfoil-shaped blade, and air or water
accelerated behind the blade. Propeller dynamics can be modeled by both Bernoulli's principle and Newton's thir
law. Aircraft propellers convert rotary motion from piston engines or turboprops to provide propulsive force. The
may be fixed or variable pitch. Early aircraft propellers were carved by hand from solid or laminated wood wit
later propellers being constructed from metal. The most modern propeller designs use high-technology composi
materials.
There are actually two types of Propeller. They are:
(1)Pusher Type Propeller(2)Tractor Type Propeller
3.4.1 PULLER TYPE PROPELLER:
UAV NAVS has a 12x6 composite puller type propeller. Puller configuration has the engine mounte
forward of the propeller - which faces in a rearwards direction - giving an appearance that the aircraft is "pushed
through the air. Sometimes the propeller is situated at the rear of the fuselage - more often at the rear of a nacelle
rotating between tail booms. Wing mounted pusher propellers are typically situated behind the trailing edge of thwing. This means that the airframe has a stress applied to it in compression from the rear rather than in tensio
from the front.
http://en.wikipedia.org/wiki/Fan_%28mechanical%29http://en.wikipedia.org/wiki/Rotationalhttp://en.wikipedia.org/wiki/Thrusthttp://en.wikipedia.org/wiki/Airfoilhttp://en.wikipedia.org/wiki/Bernoulli%27s_principlehttp://en.wikipedia.org/wiki/Newton%27s_laws_of_motionhttp://en.wikipedia.org/wiki/Newton%27s_laws_of_motionhttp://en.wikipedia.org/wiki/Reciprocating_enginehttp://en.wikipedia.org/wiki/Turboprophttp://en.wikipedia.org/wiki/Composite_materialhttp://en.wikipedia.org/wiki/Composite_materialhttp://en.wikipedia.org/wiki/Propellerhttp://en.wikipedia.org/wiki/Propellerhttp://en.wikipedia.org/wiki/Composite_materialhttp://en.wikipedia.org/wiki/Composite_materialhttp://en.wikipedia.org/wiki/Turboprophttp://en.wikipedia.org/wiki/Reciprocating_enginehttp://en.wikipedia.org/wiki/Newton%27s_laws_of_motionhttp://en.wikipedia.org/wiki/Newton%27s_laws_of_motionhttp://en.wikipedia.org/wiki/Bernoulli%27s_principlehttp://en.wikipedia.org/wiki/Airfoilhttp://en.wikipedia.org/wiki/Thrusthttp://en.wikipedia.org/wiki/Rotationalhttp://en.wikipedia.org/wiki/Fan_%28mechanical%297/31/2019 prjt nikhil
19/47
19
CHAPTER 4
CONSTRUCTION
The complete fuselage and wing of the UAV NAVS is made up of Balsa Wood.
For the construction purpose we had brought balsa wood from the out source of Banglore.Different grade of balsa
wood has been bought as of 2mm, 4mm, 6mm and 8mm.The overall fuselage length of the UAV NAVS is 120mm
and the wing span is 160mm.The mode of construction of the is same as we see in a plywood. A 4 mm balsa shee
is pasted in between two 2 mm balsa sheet to complete the fuselage structure. The wing is constructed by cutting
the balsa sheet in the shape of the symmetrical aerofoil and combined by joining it in a long balsa rod. The
fuselage and wing is joined with the help of epoxy gum.The fuselage and wing area of the aircraft is coated with
polycote.This will provide a smooth surface which will reduce the drag force formed during flying.
Fig 7 Fuselage Construction
7/31/2019 prjt nikhil
20/47
20
CHAPTER 5
RADIO SYSTEM
5.1 SERVO MOTOR
Fig 8 Servo Motor
A Servo is a small device that has an output shaft. This shaft can be positioned to specific angular
positions by sending the servo a coded signal. As long as the coded signal exists on the input line, the servo will
maintain the angular position of the shaft. As the coded signal changes, the angular position of the shaft changes.
In practice, servos are used in radio controlled airplanes to position control surfaces like the elevators and rudders
They are also used in radio controlled cars, puppets, and of course, robots. Basically it works on a electromagneti
induction. Servomechanism or servo is an automatic device that uses error-sensing negative feedback to correctthe performance of a mechanism. The term correctly applies only to systems where the feedback or error-
correction signals help control mechanical position or other parameters. For example, an automotive power
window control is not a servomechanism, as there is no automatic feedback that controls position the operator
does this by observation. By contrast the car's cruise control uses closed loop feedback, which classifies it as a
servomechanism.
5.2 LIPO BATTERY
Li-poly batteries are also gaining favor in the world of radio-controlled aircraft as well as radio-
controlled cars, where the advantages of both lower weight and greatly increased run times can be sufficient
justification for the price. Some air soft gun owners have switched to LiPo batteries due to the above reasons and
the increased rate of fire they provide. However, lithium polymer-specific chargers are required to avoid fire and
explosion. Explosions can also occur if the battery is short-circuited, as tremendous current passes through the cel
http://en.wikipedia.org/wiki/Radio-controlled_aircrafthttp://en.wikipedia.org/wiki/Radio-controlled_carhttp://en.wikipedia.org/wiki/Radio-controlled_carhttp://en.wikipedia.org/wiki/Airsoft_gunhttp://en.wikipedia.org/wiki/Airsoft_gunhttp://en.wikipedia.org/wiki/Radio-controlled_carhttp://en.wikipedia.org/wiki/Radio-controlled_carhttp://en.wikipedia.org/wiki/Radio-controlled_aircraft7/31/2019 prjt nikhil
21/47
21
in an instant. Radio-control enthusiasts take special precautions to ensure their battery leads are properly
connected and insulated. Furthermore fires can occur if the cell or pack is punctured. Radio-controlled car
batteries are often protected by durable plastic cases to prevent puncture. Specially designed electronic motor
speed controls are used to prevent excessive discharge and subsequent battery damage. This is achieved using a
low voltage cutoff (LVC) setting that is adjusted to maintain cell voltage greater than (typically) 3 V per cell.
5.3 TRANSMITTER & RECIVER
The transmitter that we are using is 9 channels Fly sky 2.4 GHz. It provide three modes of operation such
as glider mode, helicopter mode and aircraft mode. The transmitter is of latest model in which we can program
ourself.
The Fly Sky FS-TH9X is modular system, so specifications may vary depending on the module you select
The transmitter itself is loaded with features, some of which you will usually only find on some high end
transmitters.
Number of Channels: 8ch PPM/9ch PCM Display: 128*64 LCD Support Type: Heli/Acro/Glid User Models: 8 Stick Modes: 4 Encoder Type: PPM/PCM Sub Trim: Yes Simulator Interface: Yes Buzzer: Yes Low Voltage Display: Yes
http://www.helireviews.com/go/turnigy-9x/http://www.helireviews.com/go/turnigy-9x/7/31/2019 prjt nikhil
22/47
22
FIG 9 Transmitter
Fig 10 Reciver
The menus are clearly and easy to navigate using the 12864 pixel LCD display. The only issue I had was that the
+/- buttons are back to front with the positive on the left.
7/31/2019 prjt nikhil
23/47
23
CHAPTER 6
ARDUPILOT BOARD
The ArduPilot Controller board, shown in Figure 6, was used as the main platform for the flight control
system due to the functionality and availability of open-source support. The blogs hosted by Chris Anderson of
DIYDrones provided a means of communication with experienced hobbyists familiar with the components and
troubleshooting procedures.
Figure 11: ArduPilot Controller Board
Based on the Arduino open-source hardware platform, ArduPilot is a full-featured autopilot using infrared
(thermopile) sensors or an Inertial Measurement Unit (IMU) for stabilization and GPS for navigation. The
ArduPilot features include: use for an autonomous vehicle, built-in hardware failsafe that uses a multiplexer chip
and ATTiny processor to toggle control from the RC system to the autopilot, ability to reboot the main processor
in mid-flight, multiple 3D waypoints (limited only by memory), altitude controlled with the elevator and throttle,
6-pin GPS connector for the 4Hz uBlox5 or 1hz EM406 GPS module, six spare analog inputs (with ADC on each
and six spare digital input/outputs for additional sensors.
Furthermore, the board supported the addition of wireless modules for real-time telemetry and was based on a
16MHz Atmega328 processor. The total onboard processing power was approximately 24 MIPS. The 30mm x
47mm board could be powered by either the RC receiver or a separate battery. Four RC-in and out channels
could be processed by the autopilot, in addition to the autopilot on/off channel. The board offered LEDs for powe
failsafe (on/off), status and GPS satellite lock.
Programmability and use required the free Arduino IDE to edit and upload the code to the board. The Arduino
environment simplified the code production, modification, and upload procedures for the ArduPilot. Capable of
running on Windows, Mac OS X, and Linux, the environment was composed in Java and based on Processing,
avr-gcc, and other open source software.
7/31/2019 prjt nikhil
24/47
24
6.1 ARDUPILOT SHIELD V2 KIT WITH AIRSPEED SENSOR
The ArduPilot Shield V2 Kit introduces the capability of monitoring height, speed, and battery level. The
kit in Figure 7 includes: ArduShield Board, Female Pin Headers, Male Pin Headers, Pitot Tube, custom-made
FMA cable, Housing Connector Header, Three-Servo Extension, Bind Plug, Reset button, and extra wire.
Fig 12 Shield kit
With a compact design that matched the ArduPilot board, compatibility issues were reduced and the
following features pertained: on-board differential pressure sensor (MPXV5004DP) for airspeed measurement,
3.3V Voltage Regulator, voltage divider to measure battery level (up to 4 cell LIPOs), dedicated port for infrared
sensors, support for 3Volts GPS including 3v3 TTL conversion, and mirrored status LED's for Power, Status and
GPS Lock. The Bind Plug served as an Auto-Shutdown GPS to eliminate the need to unplug the GPS when
uploading new code or writing to the ArduPilot with the FTDI cable. Figure 8 shows a closer image of the Shield
Board, where the black hub atop the board is the pitot tube connection.
Figure 12: ArduPilot Shield Board
7/31/2019 prjt nikhil
25/47
25
6.2 ARDUPILOT FTDI CABLE
Programming for the I/O controller board was accomplished via the ArduPilot FTDI cable shown in Figur
9. The polarity of the cable is visible through the ArduPilot "BLK" (black) and "GRN" (green) color labels. The
TX/RX signals are 3.3volts, allowing greater flexibility, and the power supply is 5volts through the red wire.
Fig 13 FTDI Cable
6.3 GPS MODULE
Originally, the autopilot system was designed using the 20 Channel EM-406A SiRF III Receiver with
Antenna to provide accurate GPS readings at a rate of four per second, in Figure 10. The unit weighed 16g
including cable, offered extremely high sensitivity of 159dBm and 10m Positional Accuracy (5m with WAAS).
The module required only 1s Hot Start, 38s Warm Start, 42s Cold Start, and 70mA at 4.5-6.5V. This was the
smallest complete module available (30mm x 30mm x 10.5mm), outputting NMEA 0183 and SiRF binary
protocol.
Figure 15: EM-406A Module
7/31/2019 prjt nikhil
26/47
26
However, through excessive testing and troubleshooting, the group concluded that the EM-406A module
lacked reliability and failed to operate under controlled conditions. Therefore, the design was upgraded to utilize
the GS407 U-Blox5 GPS operating at 2Hz, shown below in Figure 11. The module features a u-Blox 5H chipset
with a Sarantel omni-directional Geo-helix S-type active antenna, at a real 2Hz refresh rate that can be used up to
4Hz over fifty channels. The unit supports UBX, NMEA and USB&NMEA with high immunity to RFinterference while offering firmware upgradable capability.
Figure 16: U-Blox5 Module
6.4 GPS ADAPTER AND CABLE
In order to use the U-Blox5 with the ArduPilot Shield board, a uBlox adapter and cable were required.
Figure 12 shows the uBlox GS406/GS407 adapter. The adapter converts to EM406A or easy to use pin headers (-
,+,Tx,RX), and is configurable for servo connectors (-,+,S), thereby easily adaptable to the system overall. The
required power supply for the adapter is 3.3V or 5V-12V. The on-board 3.3V power regulator ensure proper
power supply from the ArduPilot Shield board, with a rechargeable backup battery, a small GPS profile similar to
that of the Shield board. The EM406 Connector makes this unit ArduPilot-Ready with regular pin holes for easy
integration
Figure 17: uBlox Adapter
7/31/2019 prjt nikhil
27/47
27
The EM-406/uBlox Adapter Cable in Figure 13 is a 15cm communication cable that mates with the EM406,
EM401 and uBlox Adapter. The length is ideal for a UAV project where the GPS module may be a distance away
from the controller board. The cable has two 6-pin JST connectors with 1mm pitch and is wired pin 1 to pin 1.
Figure 18: Adapter Cable
6.5 XYZ HORIZON SENSORS
Stabilization was achieved via the AutoPilot XYZ Horizon sensors, which act as both a gyroscope and an
accelerometer, shown in Figure 14. The XY sensors are located on the right, while the left of the image is the Z
component sensor. These thermopile, infrared sensors are less accurate than most commercial UAV autopilot
systems including Inertial Measurement Units (IMUs) or Inertial Navigation Systems (INS); however, the
compatibility issues are simplified. The sensors are used to determine the orientation of the aircraft with respect to
temperature difference analysis of the ground and are compatible with ArduPilot and Range Video OSD. The Op-AMP gain is set to 1000x (1Mohms/1kohms).
Fig 19 XY and Z sensor
7/31/2019 prjt nikhil
28/47
28
6.6 DESIGN PROCESS CONFIGURATION
The controller board was pre-programmed for manual and automatic flight modes through interfacing the
pilot board with the aircrafts servo system. Manual mode allowed for complete user control of the flight, while
automatic allowed the aircraft to fly independent of user control through stabilization and guidance maneuvers.
Fig 20 configuration
Preliminary design of the desired autopilot system, in which two main divisions house several functions:
Flight Control and Flight Plan. The Flight Control division supports the battery monitor, pitot tube, altitude, and
gyros. This component operated based on navigation directions from the Flight Plan division, consisting of the
GPS, digital compass for failsafe, beacon for image recognition, and radar for object detection during flight to
avoid crashing. The data logging function in memory keeps an accurate record of flight path. Error transmissions
and status conditions would be achievable through the hammer board to base station.
7/31/2019 prjt nikhil
29/47
29
Figure 21: Relationship Diagram
7/31/2019 prjt nikhil
30/47
30
CHAPTER 7
PROGRAMMING
7.1 CONFIGURATION PROGRAM OF MICRO CONTROLLER
#define SHIELD_VERSION 1 // Old (red) shield versions is 0, the new (blue) shield
version is 1, -1 = no shield
#define AIRSPEED_SENSOR 0 // (boolean) Do you have an airspeed sensor attached?
1= yes, 0 = no.
#define GPS_PROTOCOL 4 // 0 = NMEA
// 1 = SIRF,
// 2 = uBlox
// 3 = ArduIMU
// 4 = MediaTek,
// 5 = Simulated GPS mode (Debug),
// -1 = no GPS
//Ground Control Station:
#define GCS_PROTOCOL 0 // 0 = Standard ArduPilot
// 1 = special test,
// 2 = Ardupilot Binary(not implemented),
// 3 = Xplane
// -1 = no GCS (no telemtry output)
***************************************/
//Thermopile sensors:#define ENABLE_Z_SENSOR 1 // 0 = no Z sensor, 1 = use Z sensor (no Z requires
field calibration with each flight)
7/31/2019 prjt nikhil
31/47
31
#define XY_SENSOR_LOCATION 0 // XY Thermopiles Sensor placement
// Mounted right side up: 0 = cable in front, 1 = cable
behind
// Mounted upside down: 2 = cable in front, 3 =
cable behind
#define PITCH_TRIM 0 // deg * 100 : allows you to offset bad IR sensor placement
#define ROLL_TRIM 0 // deg * 100 : allows you to offset bad IR sensor
placement
#define AOA 0 // deg * 100 : the angle your plane flies at level - use the
IMU to find this value.
#define ALT_EST_GAIN .01 // the gain of the altitude estimation function, lower
number = slower error correction and smoother output
/***************************************/
//Battery:
#define BATTERY_EVENT 0 // (boolean) 0 = don't read battery, 1 = read battery
voltage (only if you have it wired up!)
#define INPUT_VOLTAGE 5200.0 // (Millivolts) voltage your power regulator is feeding your
ArduPilot to have an accurate pressure and battery level readings. (you need a multimeter to
measure and set this of course)
/***************************************/
// RADIO
#define THROTTLE_PIN 11 // pin 13, or pin 11 only (13 was old default, 11 is a
better choice for most people)
#define THROTTLE_OUT 1 // For debugging - 0 = no throttle, 1 = normal throttle
#define THROTTLE_FAILSAFE 0 // Do you want to react to a throttle failsafe condition?
Default is no 0, Yes is 1
7/31/2019 prjt nikhil
32/47
32
#define THROTTLE_FS_VALUE 975 // (microseconds) What value to trigger failsafe
#define REVERSE_THROTTLE 0 // 0 = Normal mode. 1 = Reverse mode - Try and
reverse throttle direction on your radio first, most ESC use low values for low throttle.
#define FAILSAFE_ACTION 2 // 1 = come home in AUTO, LOITER, 2 = dont
come home
#define AUTO_TRIM 1 // 0 = no, 1 = set the trim of the radio when switching
from Manual
#define SET_RADIO_LIMITS 0 // 0 = no, 1 = set the limits of the Channels with the
radio at launch each time; see manual for more
#define RADIO_TYPE 0 // 0 = sequential PWM pulses, 1 = simultaneous PWM
pulses
#define CH1_MIN 1000 // (Microseconds) Range of Ailerons/ Rudder
#define CH1_MAX 2000 // (Microseconds)
#define CH2_MIN 1000 // (Microseconds) Range of Elevator
#define CH2_MAX 2000 // (Microseconds)
#define CH3_MIN 1000 // (Microseconds) Range of Throttle - Important - please
use debug mode to find your PWM values and set them here.
#define CH3_MAX 2000 // (Microseconds)
#define CH4_MIN 1000 // (Microseconds) Range of Rudder
#define CH4_MAX 2000 // (Microseconds)
#define ADVERSE_ROLL 0.2 // adverse roll correction based on Aileron input
#define CH4_RUDDER 1 // 1 = Use CH4 for rudder, 0 = use CH4 for something
else - like an egg drop.
#define PAYLOAD_CLOSED 45 // -45 to 45 degrees max
#define PAYLOAD_OPEN -45 // -45 to 45 degrees max
/***************************************/
// AIRFRAME SETTINGS
#define MIXING_MODE 0 //Servo mixing mode 0 = Normal, 1 = Elevons (or v tail)
7/31/2019 prjt nikhil
33/47
33
// NOTE - IF USING ELEVONS, 1-2 AND 1-3 SHOULD BE 1
#define REVERSE_ROLL 1 // To reverse roll, PUT -1 to reverse it
#define REVERSE_PITCH 1 // To reverse pitch, PUT -1 to reverse it
#define REVERSE_RUDDER 1 // To reverse rudder for 4 channel control setups
// JUST FOR ELEVONS:
#define REVERSE_ELEVONS 1 // Use 1 for regular, -1 if you need to reverse roll direction
#define REVERSE_CH1_ELEVON -1 // To reverse channel 1 elevon servo, PUT -1 to reverse
it
#define REVERSE_CH2_ELEVON 1 // To reverse channel 2 elevon servo, PUT -1 to reverse
it
/***************************************/
// Airplane speed control
#define AIRSPEED_CRUISE 13 // meters/s : Speed to try and maintain - You must set
this value even without an airspeed sensor!
#define AIRSPEED_RATIO 0.1254 // If your airspeed is under-reporting, increase this value to
something like .2
// NOTE - The range for throttle values is 0 to 125
// NOTE - For proper tuning the THROTTLE_CRUISE value should be the correct value to
produce AIRSPEED_CRUISE in straight and level flight with your airframe
#define THROTTLE_MIN 0 // (0-100 %) Raise it if your plane falls too quickly when
decending.
#define THROTTLE_CRUISE 35 // (0-100 %) Default throttle value - Used for central value.
#define THROTTLE_MAX 60 // (0-100 %) Throttle (lower this if your plane is
overpowered)
// For use in Fly By Wire B mode in meters per second
#define AIRSPEED_FBW_MIN 6 // meters/s : Minimum airspeed for Fly By Wire
7/31/2019 prjt nikhil
34/47
34
mode B, throttle stick at bottom
#define AIRSPEED_FBW_MAX 30 // meters/s : Maximum airspeed for Fly By Wire
mode B, throttle stick at top
/***************************************/
//NAVIGATION: PARAMETERS
//Note: Some Gains are now variables
#define HEAD_MAX 4000 // deg * 100 : The maximum commanded bank angle (left and
right) degrees*100
#define PITCH_MAX 1500 // deg * 100 : The maximum commanded pitch up angle
degrees*100
#define PITCH_MIN -2000 // deg * 100 : The maximum commanded pitch down angle
degrees*100
#define LOITER_RADIUS 40 // meters : radius in meters of a Loiter
/***************************************/
// Auto launch and land
// If you are using ArduIMU the minimum recommended TAKE_OFF_PITCH is 30 degrees
due to linear acceleration effects on the IMU
// If your airframe cannot climb out at 30 degrees do not use this feature if using ArduIMU
#define USE_AUTO_LAUNCH 0 // If set to 1 then in AUTO mode roll will be held to
zero and pitch to TAKE_OFF_PITCH until TAKE_OFF_ALT is reached
#define TAKE_OFF_ALT 75 // meters. Altitude below which take-off controls apply
#define TAKE_OFF_PITCH 15 // degrees : Pitch value to hold during take-off
// This section is for setting up auto landings
// You must have your airframe tuned well and plan your flight carefully to successfully
execute auto landing
7/31/2019 prjt nikhil
35/47
35
#define USE_AUTO_LAND 0 // If set to 1 Last waypoint will be the landing
target. Set altitude to 0 for last WP
#define LAND_PITCH 15 // degrees : Pitch value to hold during landing
#define AIRSPEED_SLOW 5 // meters/s
#define THROTTLE_SLOW 20 // 0-100 : This should be the throttle value that
produces AIRSPEED_SLOW in straight and level flight
#define SLOW_RADIUS 60 // meters : When this becomes the current waypoint we
will decrease airspeed_cruise to AIRSPEED_SLOW. Replace 999 with the beginning of your
landing pattern
#define THROTTLE_CUT_RADIUS 40 // meters : When this becomes the current waypoint we
will cut the throttle; set it so it is well beyond the touchdown zone so that it is not reached, else
you will enter RTL mode or loop waypoint
7/31/2019 prjt nikhil
36/47
36
7.2 CONTROLLING SERVO MOTOR
void demo_servos()
{
delay(30);
set_servo_mux(true);
OCR1A = 1600 * 2;
OCR1B = 1600 * 2;
delay(400);
OCR1A = 1400 * 2;
OCR1B = 1400 * 2;
delay(200);
OCR1A = 1500 * 2;
OCR1B = 1500 * 2;
set_servo_mux(false);
delay(30);
}
void set_servo_mux(boolean mode)
{
while(TCNT1 < 20000){};
if (mode){
//take over the MUX
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);}else{
//release the MUX to allow Manual Control
digitalWrite(4, LOW);
pinMode(4, INPUT);
}
7/31/2019 prjt nikhil
37/47
37
}
// wants +- 45
void set_servos_4()
{
#if GPS_PROTOCOL == 3
if(imu_ok == false && control_mode > MANUAL){ // We have lost
the IMU - Big trouble
servo_out[CH_ROLL] = 0;
servo_out[CH_PITCH] = 0;
servo_out[CH_THROTTLE] = 0;
}
#endif
#if MIXING_MODE == 0
set_ch1_degrees(servo_out[CH_ROLL]); // 45 = right turn (unless reversed)
set_ch2_degrees(servo_out[CH_PITCH]);
#endif
/*Elevon mode*/ //
#if MIXING_MODE == 1
set_ch1_degrees(REVERSE_ELEVONS * (servo_out[CH_PITCH] -
servo_out[CH_ROLL]));
set_ch2_degrees(servo_out[CH_PITCH] + servo_out[CH_ROLL]);
#endif
set_ch4_degrees(servo_out[CH_RUDDER]);
update_throttle();
}
7/31/2019 prjt nikhil
38/47
38
// requires +- 45
void set_ch1_degrees(float deg){
#if MIXING_MODE == 0
radio_out[CH_ROLL] = radio_trim[CH_ROLL] + ((float)REVERSE_ROLL * deg *
11.111f);
#endif
#if MIXING_MODE == 1
radio_out[CH_ROLL] = elevon1_trim + ((float)REVERSE_CH1_ELEVON * deg *
11.111f); //
#endif
radio_out[CH_ROLL] = constrain(radio_out[CH_ROLL],
radio_min[CH_ROLL], radio_max[CH_ROLL]);
radio_out[CH_ROLL] = constrain(radio_out[CH_ROLL], 1000, 2000);
OCR1A = radio_out[CH_ROLL] * 2; //OCR1A is the channel 1 pulse width in half
microseconds
}
void set_ch2_degrees(float deg){
#if MIXING_MODE == 0
radio_out[CH_PITCH] = radio_trim[CH_PITCH] + ((float)REVERSE_PITCH * deg *
11.111f);
#endif
#if MIXING_MODE == 1
radio_out[CH_PITCH] = elevon2_trim + ((float)REVERSE_CH2_ELEVON * deg *
11.111f);
#endif
7/31/2019 prjt nikhil
39/47
39
radio_out[CH_PITCH] = constrain(radio_out[CH_PITCH],
radio_min[CH_PITCH], radio_max[CH_PITCH]);
radio_out[CH_PITCH] = constrain(radio_out[CH_PITCH], 1000, 2000);
OCR1B = radio_out[CH_PITCH] * 2;
}
void set_ch4_degrees(float deg){
//Serial.print("tdeg:");
//Serial.print(deg,DEC);
deg = constrain(deg, -45, 45);
radio_out[CH_RUDDER] = radio_trim[CH_RUDDER] +
((float)REVERSE_RUDDER * deg * 11.111f);
//Serial.print("\tradio_out: ");
//Serial.print(radio_out[CH_RUDDER],DEC);
radio_out[CH_RUDDER] = constrain(radio_out[CH_RUDDER],
radio_min[CH_RUDDER], radio_max[CH_RUDDER]);
//Serial.print("\tradio_out: ");
//Serial.print(radio_out[CH_RUDDER],DEC);
//Serial.print(" : ");
uint16_t timer_out = radio_out[CH_RUDDER] % 512;
timer_ovf_b = radio_out[CH_RUDDER] / 512;
timer_out >>= 1;
if(timer_out != OCR2B)
OCR2B = timer_out;
}
void no_throttle()
7/31/2019 prjt nikhil
40/47
40
{
//OCR2A = ch3_timer_min;
}
// sets the throttle timer value based on throttle percent
// -------------------------------------------------------
void update_throttle()
{
#if THROTTLE_OUT == 1
// convert 0 to 100% into PWM
servo_out[CH_THROTTLE] = constrain(servo_out[CH_THROTTLE], 0,
100);
radio_out[CH_THROTTLE] = (servo_out[CH_THROTTLE] *
(radio_max[CH_THROTTLE] - radio_min[CH_THROTTLE])) / 100;
radio_out[CH_THROTTLE] += radio_min[CH_THROTTLE];
#else
radio_out[CH_THROTTLE] = radio_min[CH_THROTTLE];
#endif
// Jason's fancy 2s hack
uint16_t timer_out = radio_out[CH_THROTTLE] % 512;
timer_ovf_a = radio_out[CH_THROTTLE] / 512;
timer_out >>= 1;
if(OCR2A != timer_out)
OCR2A = timer_out;
}
// Throttle Timer Interrupt
// ------------------------
ISR(TIMER1_CAPT_vect) // Timer/Counter1 Capture Event
7/31/2019 prjt nikhil
41/47
41
{
//This is a timer 1 interrupts, executed every 20us
PORTB |= B00000001; //Putting the pin high!
PORTC |= B00010000; //Putting the pin high!
TCNT2 = 0; //restarting the counter of timer 2
timer_ovf = 0;
}
ISR(TIMER2_OVF_vect)
{
timer_ovf++;
}
ISR(TIMER2_COMPA_vect) // Timer/Counter2 Compare Match A
{
if(timer_ovf == timer_ovf_a){
PORTB &= B11111110; //Putting the pin low
}
}
ISR(TIMER2_COMPB_vect) // Timer/Counter2 Compare Match B Rudder Servo
{
if(timer_ovf == timer_ovf_b){
PORTC &= B11101111; //Putting the pin low!
}
}
void init_PWM()
{
// Servo setup
7/31/2019 prjt nikhil
42/47
42
// -----------
// Timer 1
TCCR1A = ((1
7/31/2019 prjt nikhil
43/47
43
set_ch4_degrees(0);
TIMSK1 |= _BV(ICIE1); // Timer/Counter1, Input Capture Interrupt Enable //PB0 -
output throttle
TIMSK2 = _BV(TOIE1) | _BV(OCIE2A) | _BV(OCIE2B); //
Timer/Counter2 Compare Match A
}
7/31/2019 prjt nikhil
44/47
44
7.3 SENSOR PROGRAMMING
void read_XY_sensors()
{
analog0 = analogRead(0);
analog1 = analogRead(1);
roll_sensor = getRoll() + ROLL_TRIM;
pitch_sensor = getPitch() + PITCH_TRIM;
#if ENABLE_Z_SENSOR == 0
if (analog0 > 511){
ir_max = max((abs(511 - analog0) * IR_MAX_FIX), ir_max);
ir_max = constrain(ir_max, 40, 600);
if(ir_max > ir_max_save){
eeprom_busy_wait();
eeprom_write_word((uint16_t *) EE_IR_MAX,
ir_max); // ir_max
ir_max_save = ir_max;
}
}
#endif
}
void read_z_sensor(void)
{
//Serial.print("ir_max: ");
//Serial.println(ir_max,DEC);
//Checks if the roll is less than 10 degrees to read z sensor
if(abs(roll_sensor)
7/31/2019 prjt nikhil
45/47
45
analog2 = ((float)analogRead(2) * 0.10) + ((float)analog2 * .90);
ir_max = abs(511 - analog2) * IR_MAX_FIX;
ir_max = constrain(ir_max, 40, 600);
}
}
// in M/S * 100
void read_airspeed(void)
{
#if GCS_PROTOCOL != 3
airpressure_raw = ((float)analogRead(AIRSPEED_PIN) * .10) + (airpressure_raw *
.90);
airpressure = (int)airpressure_raw - airpressure_offset;
airpressure = max(airpressure, 0);
airspeed = sqrt((float)airpressure / AIRSPEED_RATIO) * 100;
#endif
airspeed_error = airspeed_cruise - airspeed;
}
void read_battery(void)
{
filter_batt_voltage = ((float)analogRead(BATTERY_PIN) * .05) + (filter_batt_voltage
* .95);
battery_voltage = BATTERY_VOLTAGE(filter_batt_voltage);
if(battery_voltage < INPUT_VOLTAGE)
low_battery_event();
}
7/31/2019 prjt nikhil
46/47
46
// returns the sensor values as degrees of roll
// 0 ----- 511 ---- 1023 IR Sensor
// -90 0 90 degree output * 100
// sensors are limited to +- 60 (6000 when you multply by 100)
long getRoll(void)
{
#if XY_SENSOR_LOCATION ==1
return constrain((x_axis() + y_axis()) / 2, -6000, 6000);
#endif
#if XY_SENSOR_LOCATION ==0
return constrain((-x_axis() - y_axis()) / 2, -6000, 6000);
#endif
#if XY_SENSOR_LOCATION ==3
return constrain((-x_axis() - y_axis()) / 2, -6000, 6000);
#endif
#if XY_SENSOR_LOCATION ==2
return constrain((x_axis() + y_axis()) / 2, -6000, 6000);
#endif
}
long getPitch(void)
{
#if XY_SENSOR_LOCATION ==1
return constrain((-x_axis() + y_axis()) / 2, -6000, 6000);
#endif
#if XY_SENSOR_LOCATION ==0
7/31/2019 prjt nikhil
47/47
return constrain((x_axis() - y_axis()) / 2, -6000, 6000);
#endif
#if XY_SENSOR_LOCATION ==3
return constrain((-x_axis() + y_axis()) / 2, -6000, 6000);
#endif
#if XY_SENSOR_LOCATION ==2
return constrain((x_axis() - y_axis()) / 2, -6000, 6000);
#endif
}
long x_axis(void)// roll
{
return ((analog1 - 511l) * 9000l) / ir_max;
// 611 - 511
// 100 * 9000 / 100 = 90 low = underestimate = 36 looks like 90 = flat plane or
bouncy plane
// 100 * 9000 / 250 = 36 = 36 looks like 36
// 100 * 9000 / 500 = 18 high = over estimate = 36 looks like 18 =
crash plane
}
long y_axis(void)// pitch
{
return ((analog0 - 511l) * 9000l) / ir_max;
}