Cd-5-Doc Quadcopter Batch No 30 PDF
Cd-5-Doc Quadcopter Batch No 30 PDF
Cd-5-Doc Quadcopter Batch No 30 PDF
GOKARAJU RANGARAJU INSTITUTE OF ENGINEERING AND TECHNOLOGY (Affiliated to Jawaharlal Nehru Technological University) HYDERABAD 500 090 2013
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING GOKARAJU RANGARAJU INSTITUTE OF ENGINEERING AND TECHNOLOGY (Affiliated to Jawaharlal Nehru Technological University) HYDERABAD 500 090 2013
Department of Electronics and Communication Engineering Gokaraju Rangaraju Institute of Engineering and Technology (Affiliated to Jawaharlal Nehru Technological University) Hyderabad 500 090
2013
Certificate
This is to certify that this project report entitled radio controlled quad copter by SiddharthSuresh(09241A0436),AnandKarwa(09241A0459),Rakeshmallem(09241A0493) ,Srikanth Bablu(09241A04B2) submitted in partial fulfillment of the requirements for the degree of Bachelor of Technology in Electronics and Communication Engineering of the Jawaharlal Nehru Technological University, Hyderabad, during the academic year 2012-2013, is a bonafide record of work carried out under our guidance and supervision. The results embodied in this report have not been submitted to any other University or Institution for the award of any degree or diploma.
(External Examiner)
Acknowledgements:
It is a pleasure to express thanks to Mrs.Hima Bindu for the encouragement and guidance throughout the course of this project. We would like to express my deep sense of gratitude and admiration to Dr.Ravi Billa, Head Of Electronics & Communication Engineering Department . At the outset we sincerely thank the Management and Faculty of ECE, GRIET, for their kind cooperation in supporting for our project.
SIDDHARTH SURESH ________________________ ANAND KARWA RAKESH MALLEM SRIKANTH BABLU _________________________ _________________________ _________________________
Abstract:
The use of quad copter in the field of armed appliances has grown drastically to operate in dangerous situations where human can be safe at a distance. Our project has verified that it is possible to build a small-scale Quadcopter that could be used for both military and commercial use. Our most significant problems to date have been an ambitious development schedule coupled with very limited funds. These constraints have forced compromise in components selected and methods used for prototype development. Our teams Quadcopter prototype is a very limited version of what could be created in a production facility using more advanced technology. Currently our Quad copter has achieved only tethered flight and it can maintain a stable position when flying. Our next step is to fix the software so that we can achieve controllable undeterred flight. We are also working on integrating our own Graphical User Interface (GUI) which will allow us to have direct control over all systems. Although there are many enhancements that we could do to the design, we have proven that it is possible to produce a small scale UAV that performs functions of interest to the military as well as commercial/industrial applications.
TABLE OF CONTENTS: INTRODUCTION:..................................................................1 PROTOTYPE SPECIFICATIONS:...........................................2 1.CONTROL BOARD..........................................................2 2.ELECTRONIC SPEED CONTROLLER(ESC)..................12 3.BRUSHLESS DC MOTOR..............................................14 4.LI-PO BATTERY............................................................17 5.TRANSMITTER AND RECIEVER..................................18 ASSEMBLY:.......................................................................22 1.THEORY OF QUADCOPTER........................................23 2.DESIGN.........................................................................26 SOFTWARE IMPLEMENTATION:......................................27 CONCLUSION:....................................................................43 SCHEMATIC:......................................................................44 REFERENCE:.......................................................................45
INTRODUCTION:
Quad copter is an aerial vehicle which is operated to fly independently.There are several advantages to quad copters over comparably-scaled helicopters. First, quad rotors do not require mechanical linkages to vary the rotor blade pitch angle as they spin. This simplifies the design and maintenance of the vehicle. Second, the use of four rotors allows each individual rotor to have a smaller diameter than the equivalent helicopter rotor, allowing them to possess less kinetic energy during flight. This reduces the damage caused should the rotors hit anything. For small-scale UAVs, this makes the vehicles safer for close interaction. Some small-scale quad -copters have frames that enclose the rotors, permitting flights through more challenging environments, with lower risk of damaging the vehicle or its surroundings.The prototype has four arms made of light weight fibre frame to which four motors can be assembled. These motors are controlled by means of electronic speed controllers(ESC).These ESCs are connected to the pins of control board. The signal from microcontroller goes to ESCs which in turn control the speed of motor. In this design we are using four brushless motors which is able to make the prototype fly and to change its direction. In this type Invensense gyroscopes are used to attain stability of quad copter. These gyros are used to maintain good stability condition so that it can balance the whole body of it. The power distribution in this system is done by a high capacity Li-Po battery of 11.1V giving adequate power supply.
Designed by the Grand father of the KK revolution, Rolf R Bakke, exclusively for HobbyKing, the KK2.0 is the evolution of the first generation KK flight control boards. The KK2.0 was engineered from the ground up to bring multi-rotor flight to everyone, not just the experts. A host of multi-rotor craft types are pre-installed. Simply select the craft type, check motor layout/propeller direction, calibrate the ESCs and radio and it is ready to go. All of which can be done with the help of the on screen prompts. The original KK gyro system has been updated to an incredibly sensitive dual chip 3 Axis gyro and single chip 3-axis accelerometer system making this the most stable KK board ever and allowing for the addition of an Auto-level function. At the heart of the KK2.0 is an Atmel Mega324PA 8-bit AVR RISC-based microcontroller with 32k of memory. An additional 2 motor output channels have been added to the KK2.0 allowing for a total of 8 motors to be controlled (Octo copter). A handy Piezo buzzer is also included with the board for audio warning when activating and deactivating the board.
2
The pin diagram of the Atmel Mega324PA is shown in the figure below.
The 6 Pin USB asp AVR Programming interface ensures future software updates will be quick and efficient.
Specifications:
Size: 50.5mm x 50.5mm x 12mm Weight: 21 gram (IncPiezo buzzer) IC: Atmega324 PA Gyro: InvenSense Inc. Accelerometer: Anologue Devices Inc. Auto-level: Yes Input Voltage: 4.8-6.0V AVR interface: standard 6 pin. Signal from Receiver: 1520us (5 channels) Signal to ESC: 1520us
The M1 connector must always have a ESC connected, because this ESC will be the only one thatsupplies the FC with 5V power. This ensures stable power to the FC.The M2 to M4's 5V power pin is connected together, and any servos here will be supplied by any ESC's connected here. There is no necessity to cut the 5V (red) lead on any ESC unless it has a SwitchingBEC. With many servos, for example airplane stabilization, there may be need of an extra BEC. Donot use multiple switched BEC's. Set up a new model on your transmitter, Use a normal airplane profile. Turn on the power and press the menu button and enter the "Receiver Test" submenu. Move each channel on your transmitter and check that the displayed direction corresponds withthe stick movements. If they disagree, reverse the channel on your transmitter. Check that the AUX channel show "ON" when the switch on your transmitter is in your preferred onposition. If not, reverse the AUX channel on your transmitter. Use the trims or sub-trims and adjust the channel values shown on the LCD to zero. Enter the "Load Motor Layout" sub-menu and choose the configuration you want. If the configurationyou want is not listed, use the "Mixer Editor" sub-menu to make one. Enter the "Show Motor Layout" sub-menu and confirm the following. Check if the configuration is correct.Check if the motors and servos are connected to the correct output and correct rotation direction.Check if the motorspeeds up when dropping the arm it is mounted on. Enter the "PI Editor " sub-menu and check for correct PI gain values. Use known good values or thedefault ones. Now we can mount the propellers and test it. Arm the device by giving right rudder and zero throttle for a few seconds. It will beep and the LED will turn on. Do not arm it until themulticopteris put on theground. SAFE mode the device after landing by holding the rudder to left at zero throttle and the LED will turnoff. If it shakes and maybe climbs after its airborne, adjust the Roll and Pitch P-gain down.
6
If it easily tips over after its airborne, adjust up. If it drifts away, use the trims to keep the drift down. It will normally drift away with the wind. For excessive trimsetings, check if the arms and motors have the correct angles and that the motors aregoodIncrease the Roll and Pitch I-gain until it flies straight forward without it pitching up or down. Turn on the Self-leveling by holding right aileron while arming or disarming it. Turn it off by holdingleft aileron. Sub-menu descriptions
"PI Editor":
Adjust the PI gain settings here. Use the PREV and NEXT buttons to highlight the parameter that needs to changed, then press the CHANGE button. To adjust both Roll and Pitch at the sametime, see the"Mode Settings "sub-menu.
"Receiver test":
To check output from the receiver.
"Mode Settings":
"Self Level" item: How the self-leveling function will be controlled: "stick": Turn on Self-leveling by holding the aileron to the right when arming or disarming. Turn it ofwith left aileron. "AUX": AUX switch channel controls the self-leveling function. "I part of PI" item: How the heading-hold function will be controlled: "On": Always on. "AUX": AUX switch channel controls the heading-hold function. "Arming" item: How the heading-hold function will be controlled: "Stick": Arm with right rudder at zero throttle. Disarm with left rudder at zero throttle. "On": Always on. Careful with this one. Use it only when the FC does not control any motors, e.g.when using it for airplane stabilization. "Link Roll Pitch" item: 1. "On": Edit the Roll and Pitch gain parameters together. 2. "Off": Edit the Roll and Pitch gain parameters separately. Use it when the multicopter has differentinertial mass on the different axis.
"Stick Scaling"
Here response from the stick can be adjusted to our liking. Higher number gives higher response.This is similar to the endpoint or volume adjustment on the transmitter.The transmitter can also be adjustedby adjusting the stick response and use the stick scaling if even more response is needed.
"Misc. Settings":
"Minimum Throttle" item: Adjust just high enough to keep all the motors running when the throttle isabove zero. "LCD Contrast" item: Adjust the LCD contrast.
"Self-level Settings":
"Self-level Gain" item: The power of the self-leveling. Higher number is stronger. "Self-level Limit" item: Limits the max power of self leveling. Higher number is higher limit.
"Sensor Test":
Displays the output from the sensors. See if all shows "OK". Move the FC around and see that thenumbers change.
"Sensor Calibration":
Follow the instructions on the LCD. The calibration is only necessary to be done once per initial setup.
8. Wait for the idle throttle calibrated signal. 9. Release the buttons.
"Mixer Editor":
This menu lets you adjust where and how much signal the motors gets from the sticks and sensors. This makes us able to make any configuration possible, with up to 8 motors or servos. To change between the output channels 1-8, press CHANGE when the upper right number is highlighted. The value is given by "Throttle" item: Amount of throttle command. Usually 100% if the output channel is connected to a ESC. "Aileron" item: Amount of aileron/roll command. Use positive value for motors on the right side of the roll axis, and negative for the left side of the roll axis. The value is given by the motor's distance from the roll axis.. More is further away. "Elevator" item: Amount of elevator/pitch command. Use positive value for motors on the front side of the pitch axis, and negative he motor's distance from the pitch axis. More is further away. "Rudder" item: Amount of rudder/yaw command. Usually 100%. Use a positive value for a CW spinning propeller, and negative for a CCW spinning propeller. "Offset" Item: Applies a constant offset to the channel. Keep this zero when it is a ESC channel, and around 50% when connected to a servo. Fine tune servo can be positioned by adjusting this value. "Type" Item: Set it to the type (servo or ESC) connected to the channel. 1. For ESC: Output PWM rate is always high. Gives a output zero when disarmed or throttle is at idle. Applies the "Minimum Throttle" item from the "Misc. Settings" sub-menu when armed and throttle is above zero. 2. For Servo: Output PWM rate can be high or low. Outputs the offset value when disarmed or throttleis at idle. "Rate":High rate (400Hz) for ESC or digital servos, or low rate (80Hz) for analog servos.
afterwards.
TUNING GUIDE:
1. Make sure the KK2.0 reads the transmitter stick neutrals. Go to the "Receiver Test" menu and use the trims to get the values to zero. 2. Go to the "PI Editor" menu and set P to 150 and I to zero for both the Roll and Pitch Axis. It is only necessary to edit the roll axis and the pitch axis will be automatically changed to the same values as the roll axis.Leave the P-limit and I-limit alone, it is seldom necessary to change them. 1. Hover the aircraft and compare the response to the multi copter to other quad copters. 2. Adjust according to the response. For newbies who do not knowhow to fly, just leave the I-gain at zero or the default value. Also the Yaw PI-gains can be left at default, but it must be remembered to zero them for the string tuning method.
GYROSCOPE THEROY
A gyroscope is defined as a rigid rotating object, symmetric about one axis. Generations of children, back at least to Greek antiquity, have found fascination in the behavior of tops, to give the gyroscope its common name. A number of eminent physicists have also found the complex behaviour of spinning objects a matter of interest and a fit subject for detailed analysis.
10
More recently, very carefully engineered gyroscopes were used for navigation because the axis of spin points in a nearly fixed direction when external torques are small. This makes the gyroscope a good replacement for a magnetic compass, particularly in regions where magnetic compasses are unreliable. As with any mechanical system, the motion of a gyroscope can be understood completely by a systematic to all the particles of which the rigid body is made. It is much more efficient, however, to exploit the fact that most of the forces act between the particles of the body, and simply have the effect of making it rigid. The overall motion is then described by
with the torque due to external forces Although an apparently simple equation, analysis of the resulting motions can become very complicated. For understanding this concept let us take an simplified example
Our toy is spinning about its axis with an angular speed supported at one end on a frictionless bearing. Choosing the origin at the pivot, gravity will produce a torque about the origin because the centre of mass is not necessarily above the pivot point, but there are no other external forces that can produce a torque because the bearing is assumed frictionless. This implies that both with and must be constant. Further, the total mechanical energy, including gravitational potential, must also be constant. The motion will still be interesting, but these conditions let us understand some qualitative features.
11
First, consider the case where the top is spinning rapidly with its axis more or less horizontal. The external force is vertically downwards, so, the torque is horizontal, perpendicular to the axis of rotation. Since the spin angular momentum to the axis of rotation, direction. is the same length as is parallel
An electronic speed control or ESC is an electronic circuit with the purpose to vary an electric motor's speed, its direction and possibly also to act as a dynamic brake. ESCs are often used on electrically powered radio controlled model , with the variety most often used for brushless motor essentially providing an electronically-generated three phase electric power low voltage source of energy for the motor.
Brushless ESC systems basically drive tri-phase brushless motors by sending sequence of signals for rotation. Brushless motors, otherwise called out runners or in runners, have become very popular with radio controlled airplane hobbyists because of their efficiency, power, longevity and light weight in comparison to traditional brushed motors. However,brushless AC motor controllers are much more complicated than brushed motor controllers. Most modern ESCs incorporate a battery eliminator circuit (or BEC) to regulate voltage for the receiver, removing the need for receiver batteries.
12
14
Brushless motors may be described as stepper motors; however, the term stepper motor tends to be used for motors that are designed specifically to be operated in a mode where they are frequently stopped with the rotor in a defined angular position.
Here we use DC Outrunner . The term outrunner refers to a type of brushless motor primarily used in electrically propelled, radio-controlled model aircraft. This type of motor spins its outer shell around its windings, much like motors found in ordinary CD-ROM computer drives. In fact, CD-ROM motors are frequently rewound into brushless outrunner motors for small park flyer aircraft. Parts to aid in converting CD-ROM motors to aircraft use are commercially available. The stationary (stator) windings of an outrunner motor are excited by conventional DC brushless motor controllers. A direct current (switched on and off at high frequency for voltage modulation) is typically passed through three or more nonadjacent windings together, and the group so energized is alternated electronically based upon rotor position feedback. The number of permanent magnets in the rotor does not match the number of stator poles, however. The difference between the number of magnet poles and the number of stator poles provides an effect that can be understood as similar to planetary gearing. The number of magnet poles divided by 2 gives the ratio of magnetic field rotation speed to motor rotation speed. Consequently the advance of the electromagnetic impulse around the motor axis proceeds much faster than the rotor turns. With more magnet poles the maximum torque is increased, while the speed of rotor advance is decreased in proportion to the ratio of magnet poles to stator poles.In our project we use MYSTERY A2212-15 930KV BRUSHLESS OUTRUNNER MOTOR .
15
- RPM/V: 930 RMP/V - Input Voltage: 7.4~11.1V - No-load Current: 0.4A - Load Current: 12A - Shaft Diameter: 3mm / 0.12in - Cable Length: 60mm / 2.4in - Dimensions: 38 x 30 mm / 1.5 x 1.2in(L x Dia.)
16
BRUSHLESS DC MOTOR
Lithium-Polymer Battery:
Lithium-ion polymer batteries, polymer lithium ion or more commonly Li-Po batteries (abbreviated Li-poly, Li-Pol, LiPo, LIP, PLI or LiP) are rechargeable (secondary cell) batteries. LiPo batteries are usually composed of several identical secondary cells in parallel to increase the discharge current capability, and are often available in series "packs" to increase the total available voltage.Li-poly batteries are also gaining favor in the world of radio-controlled aircraft, radio-controlled cars and large scale model trains, where the advantages of both lower weight and greatly increased run times and power delivery can be sufficient justification for the price. 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. Extremely high performance RC batteries which (appear to) utilize nano wire battery technology were introduced in approximately March 2009, and have since become extremely popular.These new Lithium Polymer (LiPo) batteries boast extremely high charge and discharge rates up to 5~15C charge rates, and 65C continuous dischargerates, with 165C burst discharge. Here we use ZOP POWER 2200MAH LIPO.
17
RECEIVER MODULE
18
Receiver specification :
Channel: 6 Frequency band: 2.4GHz Power resorce: 1.5V*4AAbattery Program type: GFSK Modulation type: FM RF receiver sensitivity: -76db Static current: 85mA Size: 45*23*13.5mm Weight: 12g Colour:gray semi-transparent Antenna length: 26mm
19
Transmitter specification:
Channels: 6 Frequency band: 2.4GHz Simulator port: PS-2 Power resource: 1.5V*8AAbattery Program type:GFSK Modulation type: FM RF power:19db Static current: 250mA Antenna length: 26mm Sub trim: yes Thro cuv: programmable Pith cuv: programmable Support multiple user model Support trim movement Support rudder angle overturned Support rudder angle adjustment Support programmable channel output.
20
Some of the initial steps to start with the transmitter and receiver can be given as
1. Install the battery to 2.4G transmitter and shut it down. 2. Insert the matching lines to the channel bat port of the receiver. 3. Connect the receiver battery to any one of the channel port,on the same time the two LED are flashing and this means the receiver are going to the match status. 4. Press and hold the button on the transmitter,and then switch on the power supply. 5. Observe the LED on the receiver,if found that the LED is not flash anymore and that means successful matched. 6. Release the match button on the transmitter,take out the match line. 7. Install the server and then test. 8. If the tests fail,please repeat the action above.
21
9. If the tests success,then insert the power supply port into BAT,match complete.
Here we use t6configere it is the calibration part of the receiver it calibrates the transmitter for proper flying of the quad copter.
ASSEMBLY OF QUADCOPTER:
QUADCOPTER FRAME:
It is the important part of the quad copter it should be made of fiber or plastic which is of light weight and strong. In our project we use Q450. This Q450 is a well thought out 450mm quad frame built from quality materials. The main frame is glass fiber while the arms are constructed from ultra durable polyamide nylon.
22
THEORY OF QUADCOPTER:
Assembly is a breeze with pre-threaded brass sleeves for all of the frame bolts, so no lock-nuts are required. It utilizes one size of bolt for the entire build, making the hardware very easy to keep in order and only requiring one size of hex wrench to assemble. A great feature of this frame is the large mounting tabs at the front and rear of the main frame bottom plate for mounting cameras or other accessories. This makes for a great way to take aerial video or fly FPV without the need to add any additional mounting brackets. The Q450 also features coloured arms (2 white and 2 red) which are great for orientation. It helps to keep us flying the right direction without the need for different coloured props. It consists of power board which gives ease in wiring in the board.
23
Features:
Built from quality glass fibre and polyamide nylon. Pre-threaded brass sleeves for all of the frame bolts. Coloured arms for orientation to keep you flying in the right direction. Large mounting tabs on main frame bottom plate for easy camera mounting.
PROPELLERS:
It is also main part of the quad copter for flying, there are two types of propellers used in the quad copter they mostly left hand propellers and right hand propellers.
24
Left hand propellers are also called as normal propeller and they are mounted to the motor which is moving in counter clock wise direction. Right hand propellers are also called as pusher propellers and they are mounted to the motor which is moving in the clock wise direction. We are using four propellers controlled by motors and ESCs. Using gyroscopes we can measure the orientation of prototype in X,Y and Z directions. These are used to adjust the RPM of each motor.
25
ORIENTATION OF AXIS
This prototype contains a theory in which two motors rotate in clockwise directions and other two opposite motors rotates in counter clockwise direction as shown in the figure below.
26
Software implementation:
#include <KK2LCD.h> //AIL, THR etc //can also be digital outputs const byte IN1 = 0; //PD3 (PCINT27/TXD1/INT1) not tested, but use Serial1 const byte IN2 = 1; //PD2 (PCINT26/RXD1/INT0) interrupts good for CCPM decoding. const byte IN3 = 2; //PD0 (PCINT24/RXD0/T3) tx0 is on the lcd not sure if using this would conflict with the lcd const byte IN4 = 3; //PB2 (PCINT10/INT2/AIN0) const byte IN5 = 4; //PB0 (PCINT8/XCK0/T0) //timer/counter0 source //motor outputs can also be digital inputs. these also have PCINT16 to 23 Arduino interrupts not tested. const byte OUT1 = 5; //PC6 (TOSC1/PCINT22) //32.768kHz crystal or custom clock source for counter (rpm sensor) const byte OUT2 = 6; //PC4 (TDO/PCINT20) //JTAG
27
const byte OUT3 = 7; //PC2 (TCK/PCINT18) //JTAG const byte OUT4 = 8; //PC3 (TMS/PCINT19) //JTAG const byte OUT5 = 9; //PC1 (SDA/PCINT17) //I2C const byte OUT6 = 10; //PC0 (SCL/PCINT16) //I2C const byte OUT7 = 11; //PC5 (TDI/PCINT21) //JTAG const byte OUT8 = 12; //PC7 (TOSC2/PCINT23) //32.768kHz crystal const byte RED_LED = 13; //PB3 (PCINT11/OC0A/AIN1) //same as arduino! i2c not tested
//important enable the internal pullups when using these as inputs const byte BUT1 = 14; //PB7 (PCINT15/OC3B/SCK) PWM const byte BUT2 = 15; //PB6 (PCINT14/OC3A/MISO) PWM const byte BUT3 = 16; //PB5 (PCINT13/ICP3/MOSI) const byte BUT4 = 17; //PB4 (PCINT12/OC0B/SS) const byte _BUZZER = 18; //PB1 (PCINT9/CLKO/T1) CLOCK output can adjust with system prescaler. (make tones) not tested //uncomment if you want to write your own LCD library /* const byte LCD_CS1 = 19; const byte LCD_RES = 20; const byte LCD_A0 = 21; const byte LCD_SCL = 22; const byte LCD_SI = 23; */ pwm not tested
//analog reads must be done using thier channels, specifying digital pin numbers will not work in this case const byte BATT = 3;
28
const byte GYR_R = 1; const byte GYR_Y = 2; const byte GYR_P = 4; const byte ACC_X = 5; const byte ACC_Y = 6; const byte ACC_Z = 7; //most of the hardware pwm is on the LCD, LED pins so dont bother. There is PWM on the buttons. const int switch_release_debounce_us = 100; //milliseconds const int switch_press_debounce_uS = 500; //microseconds
pinMode(RED_LED, OUTPUT);
pinMode(GYR_R, INPUT); pinMode(GYR_Y, INPUT); pinMode(GYR_P, INPUT); pinMode(ACC_X, INPUT); pinMode(ACC_Y, INPUT); pinMode(ACC_Z, INPUT); pinMode(BUT1,INPUT); digitalWrite(BUT1, HIGH); //enable internal pullup. pinMode(BUT2,INPUT); digitalWrite(BUT2, HIGH);
29
st7565Init( Font5x7 ); st7565SetBrightness(12); st7565DrawString_P( 64, 40, PSTR("Arduino on") ); st7565DrawString_P( 64, 32, PSTR(" the KK2.") ); st7565DrawString_P( 64, 24, PSTR("Test suite") ); st7565DrawString_P( 64, 16, PSTR(" v1.0 ") ); st7565DrawString_P( 64, 8, PSTR( " Marc G") ); st7565DrawString_P( 50, 1, PSTR("Press any key") ); st7565WriteLogo(); //see library to modify delay(1000); while(true) {
if(!digitalRead(BUT1)||!digitalRead(BUT2)||!digitalRead(BUT3)||!digitalRead(BUT4) ){ break; } } }
int ii = 0;
// every time I write debounce code it comes out different. Complicated but I like the feel of it. byte button4Pressed() { if(!digitalRead(BUT4)) { delayMicroseconds(switch_press_debounce_uS); if(!digitalRead(BUT4)) { while(!digitalRead(BUT4)) { st7565SetBrightness(12); st7565ClearBuffer(); st7565SetFont( Font12x16 ); st7565DrawString_P( 42, 26 , PSTR("Next") ); st7565Refresh(); digitalWrite(RED_LED,HIGH); //we could put a beep in here too. } delayMicroseconds(switch_release_debounce_us); digitalWrite(RED_LED,LOW); return 1; } } return 0;
31
void fonts() { //delay(200); // st7565SetBrightness(12); while(true) { st7565ClearBuffer(); st7565SetBrightness(12); st7565SetFont( Font12x16 ); st7565DrawString_P( 0, 0, PSTR("Font12x16") ); st7565SetFont( Font12x24Numbers ); st7565DrawString_P( 0+40, 15+12, PSTR("12") ); st7565DrawString_P( 34+40, 15+12, PSTR("24") ); st7565SetFont( Font12x16 ); st7565DrawChar( 24+40, 20+12, (uint8_t) '.' ); st7565SetFont( Font5x7 ); st7565DrawString_P( 20, 14, PSTR("Font5x7") ); st7565DrawString_P( 102, 54, PSTR("Next") ); st7565Refresh(); if(button4Pressed()) return; } }
/*
32
// needs fixing, causes memory leaks !! void drawCoordinates(int x, int y) { Str = String(x) + "," + String(y); Str.toCharArray(str,6); st7565DrawString( x, y, str); }
void text_position() { delay(200); st7565SetBrightness(12); while(true) { st7565ClearBuffer(); st7565SetBrightness(12); st7565SetFont( Font5x7 ); st7565DrawString_P( 0, 8, PSTR("Co-ords test") ); drawCoordinates(0,0); drawCoordinates(80,0); drawCoordinates(81,8); drawCoordinates(82,16); drawCoordinates(83,24); drawCoordinates(84,32); drawCoordinates(85,40); drawCoordinates(86,48); drawCoordinates(0,20);
33
drawCoordinates(6,28); drawCoordinates(0,56); drawCoordinates(38,56); st7565DrawString_P( 102, 56, PSTR("Next") ); st7565Refresh(); if(button4Pressed()) return; } }*/
void analog() { int aread = 0; // delay(switch_release_debounce); st7565SetBrightness(12); while(true) { st7565ClearBuffer(); st7565SetBrightness(12); st7565SetFont( Font12x16 ); st7565DrawString_P( 0, 0, PSTR("Analog Read") ); st7565SetFont( Font5x7 );
void buttons()
36
{ st7565SetBrightness(12); // delay(switch_release_debounce); while(true) { st7565ClearBuffer(); st7565SetFont( Font12x16 ); st7565DrawString_P( 0, 0, PSTR(" Buttons") ); st7565SetFont( Font12x24Numbers );
st7565Refresh(); if(button4Pressed())
37
return; } }
void leds() { // delay(switch_release_debounce); st7565SetBrightness(12); while(true) { byte offset = 0; for (int i = 0;i<14 ;i++) { st7565ClearBuffer(); st7565SetFont( Font12x16 ); st7565DrawString_P( 0, 0, PSTR("Digital out") );
} }
39
Str = String(i); Str.toCharArray(str,5); st7565SetFont( Font12x24Numbers ); st7565DrawString( 50, 20, str); st7565SetBrightness(i); st7565SetFont( Font5x7 ); st7565DrawString_P( 102, 56, PSTR("Next") ); st7565Refresh();
//gives us a delay of 250ms while still detecting button presses for(int k = 0;k<50;k++) { if(button4Pressed()) return; delay(5); }
40
} } }
void time() { unsigned long time = 0; st7565SetBrightness(12); st7565ClearBuffer(); st7565SetFont( Font12x16 ); st7565DrawString_P( 0, 0, PSTR("Test clock") ); st7565SetFont( Font5x7 ); st7565DrawString_P( 4, 24, PSTR("One flash per second.") ); st7565DrawString_P( 102, 56, PSTR("Next") ); st7565Refresh();
42
Conclusion:
The overall goal of this project was to create a sustainable and flexible platform for an UNMANNED AERIAL VEHICLE (UAV) using a Quadcopter design profile. To this effect, we have completed this requirement and feel the project was a success. The platform which we have created is capable of sustained autonomous flight. While this in essence proves to be short of our ultimate goal, the group is proud to have created a proven and solid platform for later development. Our platform can be outfitted with additional sensors (cameras, IR sensors, wireless technology) to expand the overall usefulness and flexibility the Quadcopter design. The capabilities of this design may prove to be asymptotic in nature, however these may not be realized until proper funding is given and experimental analysis is conducted. Given the stable platform produced by this group, further research and development can and should be done to improve the functionality of our design. This may be done by a later Senior. Design team or by ourselves during our own time and schedule. This project has increased our interests in robotics and autonomous design, knowledge which will serve useful throughout our professional careers. We feel that this form of thinking and engineering will be prevalent in the modern world and beyond as new applications are found which will test the limits of current technologies. The concept and goal of Senior Design growing out of an interest and incorporating the knowledge and skills learned over the undergraduate career, this has been encapsulated in our project. Overall, the group is proud of our accomplishments and has enjoyed working on the fore-front of engineering technology over the extent of our Senior Design coursework.
43
SCHEMATIC GYROSCOPE:
OF
ACCELOROMETER
AND
44
REFERENCE:
1.H. Huang, G. M. Hofmann, S. L. Waslander, and C. J. Tomlin, Aerodynamics and control of autonomous quad rotor helicopters in aggressive manoeuvring, IEEE International Conference on Robotics and Automation, pp. 32773282, May 2009. 2.K. M. Zemalache, L. Beji, and H. Marref, Control of an under-actuated system: Application to a four rotors rotorcraft 3.Gabriel Hoffmann. (2007, January 15) Schematic of reaction torques on each motor of a quadrotor aircraft, due to spinning rotors. 4.K. Munson. (1968). Helicopters and Other Rotorcraft Since 1907
45