Professional Documents
Culture Documents
ABSTRACT
This project focuses on the design, modeling, implementation and testing of an autonomous unmanned aerial vehicle. 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 flight operation. The autopilot features an advanced, highly autonomous flight control system with an auto-launch and auto landing algorithms.
TABLE OF CONTENT
SL NO.
TITLE
PAGE NO.
ABSTRACT 1. 1.1 1.2 1.3 1.4 2. 2.1 2.2 2.3 2.4 INTRODUCTION Description of UAV Classification of UAV General functions of UAV DESIGN Top View Bottom View Design parameters 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
3
Twin Boom POWERPLANT Key Features Specifications Working Propeller 3.4.1 Pusher Type Propeller
4.
REFERENCE
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 and non 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 surveillance and intelligence gathering UAV.NAVS have a wing span of 1600mm and length of 1200mm.The propeller using is a puller type one. Power-plant is an air-cooled glow engine seated at the rear of the fuselage with a puller propeller. Undercarriage is tricycle type landing gear. Solid spring shock absorbers are employed to reduce the 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 a 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 offers minimum drag and hence good fuel economy. Its light weight makes it portable and can be easily disassembled and reassembled. It can serve both civil and military purposes. It is also of great use in emergency rescue operations and in disaster management.
with a pusher configuration has the engine mounted forward of the propeller - which faces in a rearwards direction - giving an appearance that the aircraft is pushed.
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 deployed 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.2 TRANSPORT:
UAVs can transport goods using various means based on the configuration of the UAV itself. Most payloads are stored in an internal payload bay somewhere in the airframe. With fixed wing UAVs, payloads can also be attached to the airframe, but aerodynamics of the aircraft with the payload must be assessed. For such situations, payloads are often enclosed in aerodynamic pods for transport.
6
CHAPTER 2 DESIGN
UAV NAVS has a blended wing design with a twin boom attached to the rear of the aircraft. The empennage is mounted on the booms. The wings blend smoothly with the fuselage; hence it offers minimum drag and improves fuel efficiency. Twin boom ensures better longitudinal stability and better field of view for camera mounted in front. The airfoil used is Symmetrical airfoil for the main plane and NACA 0012 for the tail unit. The control surfaces include two ailerons on wing, two rudders and a single elevator which performs rolling, yawing and pitching movements respectively. Engine is mounted at the rear of the fuselage with a pusher propeller attached. Undercarriage is tricycle type landing gear. Solid spring shock absorbers are employed to reduce the impact during landing. The design was finalized after a number of iterations.
2.1TOP VIEW
2.4 AEROFOIL :
UAV NAVS uses Symmetrical airfoil for wings and NACA 0012 airfoil for its tail unit. An airfoil is the shape of a wing or blade as seen in cross-section. An airfoil-shaped body moving through a fluid produces a force perpendicular to the motion called lift. Subsonic flight airfoils have a characteristic shape with a rounded leading edge, followed by a sharp trailing edge, often with asymmetric camber. Airfoils design is a major facet of aerodynamics. Various airfoils serve different flight regimes. Asymmetric airfoils can generate lift at zero angle of attack, while asymmetric airfoil may better suit frequent 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 upper surface is shaped so the air rushing over the top speeds up and stretches out. This decreases the air pressure above the wing. The air flowing below the wing moves in a straight line, so its speed and air pressure, the air below the wing pushes upward toward the air above the wing. The wing is in middle, and wing is lifted. The faster an airplane moves, the more lift there is. And when the force of lift is greater than the force of gravity, the airplane is able to fly.
10
2.4.1.3 CHORD:
The chord is the length of the chord line and is the characteristic dimension of airfoil section.
11
Fig 3 Subsonic airfoil Profile geometry 1: Zero lift line; 2: Leading edge; 3: Nose circle; 4: Camber; 5: Maximum thickness; 6: Upper 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 geometry (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 for Aeronautics (NACA). The shape of the NACA airfoils is described using a series of digits following the word "NACA." The parameters in the numerical code can be entered into equations to precisely generate the crosssection of the airfoil and calculate its properties.
12
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 of x (centerline to surface), and t is the maximum thickness as a fraction of the chord (so 100 t gives the last two digits in the NACA 4digit denomination).
The two different types of airfoils used in this model are NACA 0012 and NACA 2408.
13
Leading edge radius: 0.8% Max CL: Max CL angle: Max L/D: Max L/D angle: Max L/D CL: Stall angle: Zero-lift angle: 0.928 12.5 48.121 4.0 0.724 4.5 -2.0
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 a 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, and wear out prematurely due to not receiving enough lubrication. Turning either needle counterclockwise will 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.
15
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
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
16
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, high current capacity rechargeable Nickel Cadmium, Nickel metal hydride or lead-acid battery cell, or a purpose-built "power panel" running on a 12VDC source is applied to the glow plug, initially heating the filament. The name 'glow plug' comes from the fact that the plug's filament glows red hot. The engine is then spun from the outside using a manual crank, built-in rope-based recoil starter, spring-loaded motor or 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 can be removed. Each time combustion keeps the glow plug filament glowing red hot, allowing it to ignite the 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 when freshly charged, usually cause a regular 1.5 volt glow plug to burn out instantaneously, and either a resistor of the proper value and wattage, or a high-power germanium transistor's base/emitter junction (in a series connection with one of the plug's terminals) can reduce the lead-acid cell's voltage to a suitable 1.5 volt level for engine starting. Technically a glow plug engine is fairly similar to a diesel engine and hot bulb engine in that it uses internal heat to ignite the fuel, but since the ignition timing is not controlled by fuel injection (as in an ordinary diesel engine), or electrically (as in a spark ignition engine), it must be adjusted by changing fuel/air mixture and plug/coil design (usually through adjusting various inlets and controls on the engine itself.) A richer mixture will tend to cool the filament and so retard ignition, slowing the engine. This "configuration" can also be adjusted by using varying plug designs for a more exact thermal control. Of all internal combustion engine types, the glow plug engine resembles most the hot bulb engine, since on 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-cycle operation (ignition every two rotations). The two-cycle (or two-stroke) version produces more power, but the four-cycle engines have more low-end torque, are less noisy and have a lower-pitched, more realistic sound.
17
3.4 PROPELLER:
A propeller is a type of fan which transmits power by converting rotational motion into thrust. A pressure difference is produced between the forward and rear surfaces of the airfoil-shaped blade, and air or water is accelerated behind the blade. Propeller dynamics can be modeled by both Bernoulli's principle and Newton's third law. Aircraft propellers convert rotary motion from piston engines or turboprops to provide propulsive force. They may be fixed or variable pitch. Early aircraft propellers were carved by hand from solid or laminated wood with later propellers being constructed from metal. The most modern propeller designs use high-technology composite materials. There are actually two types of Propeller. They are: (1) Pusher Type Propeller (2) Tractor Type Propeller
18
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 sheet 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.
19
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 electromagnetic induction. Servomechanism or servo is an automatic device that uses error-sensing negative feedback to correct the performance of a mechanism. The term correctly applies only to systems where the feedback or errorcorrection 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.
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.
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
21
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.
22
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, a 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 power, 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.
23
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.
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 RF interference while offering firmware upgradable capability.
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.
27
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.
28
29
CHAPTER 7 PROGRAMMING
#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 field calibration with each flight) // 0 = no Z sensor, 1 = use Z sensor (no Z requires
30
#define XY_SENSOR_LOCATION 0
// XY Thermopiles Sensor placement // Mounted right side up: behind // Mounted upside down: 2 = cable in front, 3 = 0 = cable in front, 1 = cable
cable behind #define PITCH_TRIM 0 #define ROLL_TRIM 0 placement #define AOA 0 IMU to find this value. #define ALT_EST_GAIN .01 // the gain of the altitude estimation function, lower // deg * 100 : the angle your plane flies at level - use the // deg * 100 : allows you to offset bad IR sensor placement // deg * 100 : allows you to offset bad IR sensor
/***************************************/ //Battery: #define BATTERY_EVENT 0 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) // (boolean) 0 = don't read battery, 1 = read battery
/***************************************/ // RADIO #define THROTTLE_PIN 11 better choice for most people) #define THROTTLE_OUT 1 #define THROTTLE_FAILSAFE 0 Default is no 0, Yes is 1
31
// For debugging - 0 = no throttle, 1 = normal throttle // Do you want to react to a throttle failsafe condition?
#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 come home #define AUTO_TRIM 1 from Manual #define SET_RADIO_LIMITS 0 // 0 = no, 1 = set the limits of the Channels with the // 0 = no, 1 = set the trim of the radio when switching // 1 = come home in AUTO, LOITER, 2 = dont
radio at launch each time; see manual for more #define RADIO_TYPE 0 pulses #define CH1_MIN 1000 #define CH1_MAX 2000 #define CH2_MIN 1000 #define CH2_MAX 2000 #define CH3_MIN 1000 // (Microseconds) Range of Ailerons/ Rudder // (Microseconds) // (Microseconds) Range of Elevator // (Microseconds) // (Microseconds) Range of Throttle - Important - please // 0 = sequential PWM pulses, 1 = simultaneous PWM
use debug mode to find your PWM values and set them here. #define CH3_MAX 2000 #define CH4_MIN 1000 #define CH4_MAX 2000 #define ADVERSE_ROLL 0.2 #define CH4_RUDDER 1 else - like an egg drop. // (Microseconds) // (Microseconds) Range of Rudder // (Microseconds) // adverse roll correction based on Aileron input // 1 = Use CH4 for rudder, 0 = use CH4 for something
/***************************************/ // AIRFRAME SETTINGS #define MIXING_MODE 0 //Servo mixing mode 0 = Normal, 1 = Elevons (or v tail)
32
// NOTE - IF USING ELEVONS, 1-2 AND 1-3 SHOULD BE 1 #define REVERSE_ROLL 1 #define REVERSE_PITCH 1 #define REVERSE_RUDDER 1 // To reverse roll, PUT -1 to reverse it // To reverse pitch, PUT -1 to reverse it // 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 it // To reverse channel 2 elevon servo, PUT -1 to reverse
/***************************************/ // 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 decending. #define THROTTLE_CRUISE 35 #define THROTTLE_MAX 60 overpowered) // (0-100 %) Default throttle value - Used for central value. // (0-100 %) Throttle (lower this if your plane is // (0-100 %) Raise it if your plane falls too quickly when
// 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
33
mode B, throttle stick at bottom #define AIRSPEED_FBW_MAX 30 mode B, throttle stick at top // meters/s : Maximum airspeed for Fly By Wire
/***************************************/ //NAVIGATION: PARAMETERS //Note: Some Gains are now variables #define HEAD_MAX 4000 right) degrees*100 // deg * 100 : The maximum commanded pitch up angle // deg * 100 : The maximum commanded bank angle (left and
#define PITCH_MAX 1500 degrees*100 #define PITCH_MIN -2000 degrees*100 #define LOITER_RADIUS 40
/***************************************/ // 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 #define TAKE_OFF_PITCH 15 // meters. Altitude below which take-off controls apply // 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
#define USE_AUTO_LAND 0 target. Set altitude to 0 for last WP #define LAND_PITCH 15 #define AIRSPEED_SLOW 5 #define THROTTLE_SLOW 20
// degrees : Pitch value to hold during landing // meters/s // 0-100 : This should be the throttle value that
#define SLOW_RADIUS 60
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
35
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); }
36
} // wants +- 45 void set_servos_4() { #if GPS_PROTOCOL == 3 if(imu_ok == false && control_mode > MANUAL){ the IMU - Big trouble servo_out[CH_ROLL] = 0; servo_out[CH_PITCH] = 0; servo_out[CH_THROTTLE] = 0; } #endif // We have lost
/*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(); }
37
#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]); 1000, 2000); //
radio_out[CH_ROLL] = constrain(radio_out[CH_ROLL],
//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(" : ");
void no_throttle()
39
{ //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 timer_ovf_a timer_out >>= 1; = radio_out[CH_THROTTLE] % 512; = radio_out[CH_THROTTLE] / 512;
{ //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! } }
// -----------
// Timer 1 TCCR1A = ((1<<WGM11) | (1<<COM1B1) | (1<<COM1A1)); //Fast PWM: ICR1=TOP, OCR1x=BOTTOM,TOV1=TOP TCCR1B = (1<<WGM13) | (1<<WGM12) | (1<<CS11); // Clock scaler = 8, 2,000,000 counts per second OCR1A = 3000; 45; 4000 = 2000 = 90 OCR1B = 3000; ICR1 = 40000; // Elevator //50hz freq...Datasheet says (system_freq/prescaler)/target // Rudder - multiply your value * 2; for example 3000 = 1500 =
// Throttle; // Setting up the Timer 2 - 8 bit timer TCCR2A //TCCR2B increment 1 every 4us TCCR2B = _BV(CS21) |_BV(CS20); //prescaler 32, at 16mhz (32/16) = 2, the = 0x0; //Normal Mode = _BV(CS22); //prescaler 64, at 16mhz (64/16) = 4, the counter will
counter will increment 1 every 2us //OCR2A //OCR2B = (CH3_MIN-1000) / 4; = 125; // center the rudder
servo_out[CH_THROTTLE] = 0; update_throttle();
42
set_ch4_degrees(0); TIMSK1 |= _BV(ICIE1); output throttle TIMSK2 = _BV(TOIE1) | _BV(OCIE2A) | _BV(OCIE2B); // // Timer/Counter1, Input Capture Interrupt Enable //PB0 -
43
void read_XY_sensors() { analog0 analog1 roll_sensor pitch_sensor = analogRead(0); = analogRead(1); = getRoll() + ROLL_TRIM; = 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 *) ir_max); // ir_max ir_max_save = ir_max; } } #endif } EE_IR_MAX,
//Checks if the roll is less than 10 degrees to read z sensor if(abs(roll_sensor) <= 1500){
44
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 airpressure airspeed #endif = (int)airpressure_raw - airpressure_offset; = max(airpressure, 0); = sqrt((float)airpressure / AIRSPEED_RATIO) * 100;
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(); }
45
// returns the sensor values as degrees of roll // 0 ----- 511 ---- 1023 // -90 0 90 IR Sensor degree output * 100
long getRoll(void) { #if XY_SENSOR_LOCATION ==1 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
long x_axis(void)// roll { return ((analog1 - 511l) * 9000l) / ir_max; // // bouncy plane // // crash plane } 100 * 9000 / 250 = 36 = 36 looks like 36 611 - 511 100 * 9000 / 100 = 90 low = underestimate = 36 looks like 90 = flat plane or
47