Difference between revisions of "S14: Quadcopter"
Proj user12 (talk | contribs) (→Quadcopter Software) |
Proj user12 (talk | contribs) (→Quadcopter Software) |
||
Line 329: | Line 329: | ||
# '''RC Limits''': RC limits are different for arming/disarming and for proper working. We were using the same limits and as a result accidental arm/disarm took place. | # '''RC Limits''': RC limits are different for arming/disarming and for proper working. We were using the same limits and as a result accidental arm/disarm took place. | ||
# '''Gain co-efficients''': Changed from int to float. | # '''Gain co-efficients''': Changed from int to float. | ||
− | # '''Motors jerk effect''': Motors stalled for a fraction of a second and lost control. Initialization angles | + | # '''Motors jerk effect''': Motors stalled for a fraction of a second and lost control. Initialization of angles every iteration in IMU data parsing was commented and the effect vanished. |
# '''PID loop''': Additional changes for P,I and D terms incorporated as per Multiwii 2.1 code. | # '''PID loop''': Additional changes for P,I and D terms incorporated as per Multiwii 2.1 code. | ||
Revision as of 04:30, 20 May 2014
Contents
Grading Criteria
- How well is Software & Hardware Design described?
- How well can this report be used to reproduce this project?
- Code Quality
- Overall Report Quality:
- Software Block Diagrams
- Hardware Block Diagrams
- Schematic Quality
- Quality of technical challenges and solutions adopted.
Quadcopter
Abstract
Applications for smaller Unmanned Aerial Vehicle (UAV) have significantly increased in recent decades. Quadcopter is one of the most successful vertical take-off and landing vehicle with autonomous flight control and stable hovering capabilities. These prominent features have led to a rise in Quadcopter research in universities as well as industries. Quadcopter project engages people from Electrical, Mechanical and Computer science background with knowledge on various concepts like Control systems, Real-Time Embedded Systems, Robotics and Navigation. This web-page provides you detailed information on the mechanics of Quadcopter, Concepts of Flight control along with programming and testing for stable flight.
A Quadcopter (Quad-rotor helicopter) is a multi-rotor aerial vehicle that is lifted and propelled by four rotors. The thrust generated by the propellers lifts the Quadcopter while the flight controller system govern the rotor speed for attitude control. A wireless remote control is used to interact with the flight controller system for changing the flight path. We begin by explain the basics of Quadcopter mechanics, then sections explaining the mechanical design approach, algorithms and parameters used for stable flight control, and lastly the testing and tuning mechanism.
Objective and Scope
Our objective is to assemble the Quadcopter, then design and build a flight controller system that stabilizes the flight and accept commands from a hobbyist remote control during its flight.
The scope of our project can be divided into three parts:
- Design and build interfaces to all the on-board electronic sensor such as IMU, barometer and distance sensors
- Design and build interfaces to telemetry and radio modules to communicate with remote control and the computer
- Process the various sensor inputs and control the brushless motors on board using an electronic speed control system to stabilize the Quadcopter
Team Members & Responsibilities
- Sree Harsha
- PWM Design, Remote Control Input, Quadcopter assembly
- Balaji
- Sensor Data Processing, Quadcopter Assembly
- Divya Kamath
- Flight Controller Design, Code Integration
Introduction
Quadcopter is one of the successful aerial vehicles which support vertical take-off and landing.It has 4 rotors - 2 run clockwise(CW) and 2 counter-clockwise(CCW). This is to cancel out the torque generated by a set of rotors running in any one direction.
There are two types of orientation for a quadcopter : + configuration and X configuration. Our design is an X configuration as it allows unblocked front view for mounting a camera. The quadcopter motion in the 3 axis is known as Pitch, Roll and Yaw.
Pitch is the ascending or descending motion. Roll is tilting towards the left or right. Yaw is rotating left or right.
Quadcopter Modes
Most commercially available quadcopters work in one of two possible modes:
- Aerobatic Mode: This mode allows you to perform spins and flips on the quadcopter. The accelerometer is not necessary in this case.
- Attitute/Stable Mode: This is the preferred mode for beginners and this is the mode our quadcopter will run in. In this mode, data from accelerometer and gyro sensor is combined to calculate the quadcopter angle. Once the remote control stick is moved to non-idle location, the quadcopter angle is changed accordingly and held at the angle. Unlike the aerobatic mode, no spins or flips will be performed.
Arming/Disarming the Quad-copter
We need to take certain safety precautions for every quad-copter. We don't want the quad-copter to accidentally arm while being transported or not in use and similarly we don't want it to disarm when flying. Arming a quad-copter indicates that when throttle is raised, the motors will begin to spin and disarming a quad-copter indicates that motors won't spin.
On most commercially available quad-copters, arming is done with a full-right yaw and no throttle, while disarming is done with a full-left yaw and no throttle. The positions can be swapped as per user preference.
Remote Control Channels
We are currently using a 6 channel remote control to maneuver the quadcopter. The 6 channels are as below:
- Roll/Aileron - Controls the aircraft's right/left movement
- Pitch/Elevation - Moves the copter front/back
- Throttle - Increases the thrust output of the motors. This controls the height at which the Quadcopter should fly.
- Yaw/Rudder - Causes movement about the vertical axis. This changes the direction in which the aircraft is pointing.
- Gear - Not used
- AUX1 - Not used
Schedule
Sl. No | Start Date | End Date | Task | Status | Actual Completion Date |
---|---|---|---|---|---|
1 | 2/28 | 2/28 | Order Components and Make a schedule | Component Ordering Partially Completed (critical components done), Motors pending. (Update 4/14 - All components ordered) | 3/7/2014 |
2 | 3/1 | 3/30 | Components Procurement. | Motors arrived but don't fit into the frame. Got motor mounts from Century Heli shop, drilled holes to fit the motors, backup IMU arrived.(Update 4/14 - All components ordered) | 3/21/2014. |
3 | 2/20 | 3/15 | Establish communication with all sensors and validate data | IMU done. | 3/14/2014 |
4 | 2/28 | 3/5 | Establish communication with radio module of remote control | Coding complete. Testing in progress with Radio remote and receiver.(Update 4/21 - Remote Control Communication Successful | 4/19 |
5 | 2/28 | 3/5 | Speed control of motors | Flashed SimonKK firmware to ESC. One of the ESC went kaput and 2 others have problem running at slower speeds. Tested with another set and motors work fine. Ordered Afro ESC with pre SimonKK firmware flashed. Another frame, radio and few other components ordered as backup. | 3/29/2014 |
6 | 2/28 | 3/25 | Flight Controller Algorithm (PID Controller) | Coding. Playing with the coefficients.
|
4/25 |
7 | 3/15 | 3/30 | Create tasks and integrate complete code | In progress
|
4/23/2014 |
8 | 4/10 | 4/10 | Assemble quadcopter | Complete. Initial flight test with reference flight controller shows jitters with radio PWM input. Magnetometer goes crazy because of motor magnetic field. Control system and sensors will now be placed on an elevated platform. | 3/29/2014 |
9 | 4/10 | 4/18 | Initial testing and tweaks | In progress
Update 4/25 - Initial testing on ground shows that motor speed for corresponding change in sensor and RC is as expected. Next step is to connect to the motors and see how the quad behaves. |
4/25 |
10 | 4/15 | - End | Final Testing | Started 4/25
Update 4/28
Update 5/8
Update 5/9
Update 5/10
- Testing in progress |
Parts List & Cost
Qty | Description | Manufacturer | Part Number | Total Cost |
---|---|---|---|---|
4 | Afro ESC 20Amp Multi-rotor Motor Speed Controller (SimonK Firmware) | Afro ESC | 9192000131-0 | $50.00 |
4 | Turnigy Multistar 4822-690Kv 22Pole Multi-Rotor Outrunner | Turnigy | 9392000004 | $129.80 |
1 | Inertial measurement unit (IMU) MPU-9150 | Sparkfun | SEN-11486 | $40.00 |
1 | SJOne Board | Preet | LPC1758 SJSU CmpE Board | $80.00 |
1 | Turnigy 9X 9Ch Transmitter w/ Module & 8ch Receiver (Mode 2) (v2 Firmware) | Turnigy | TX-9X-M2 | $69.97 |
1 | Turnigy nano-tech 6000mah 4S 25~50C Lipo Pack | Turnigy | N6000.4S.25 | $55.75 |
1 | AQ-600 Carbon Fiber Quadcopter Frame 550mm | HobbyKing | 047000006 | $93.27 |
2 | 10x4.5MR, 10x4.5MRP Propellers, Prop Adapter Ring Set | APC | $26.94 | |
1 | Hobbyking Multi-Rotor Power Distribution Board | HobbyKing | 9171000180 | $2.20 |
Accessories(Wires, bolt+nut, foamboard, prototype board, glue, zip tags, double sided tape, insulation tape) | $50.00 | |||
Total Cost (excluding backup parts, shipping and taxes) | $597.93 |
Backup Parts & cost
Qty | Description | Manufacturer | Part Number | Total Cost |
---|---|---|---|---|
1 | Turnigy 5600mAh 4S 14.8V 60C Hardcase Pack (Removable Leads) | Turnigy | $59.79 | |
1 | Invensence 9150 IMU Breakout board | ebay | $17.00 | |
4 | Electronic Speed Controller (ESC) | Turnigy | Plush 25 | Borrowed |
1 | DX6i 6 Channel 2.4Ghz Tx/Rx Remote Control | Spektrum | DX6i | Borrowed |
1 | Quadcopter frame | HJ MWC | $21.26 | |
1 | Motor mounts | Century Heli | $25.94 | |
1 | Afro ESC 20Amp Multi-rotor Motor Speed Controller (SimonK Firmware) | Afro ESC | 9192000131-0 | $12.49 |
1 | Turnigy Multistar 4822-690Kv 22Pole Multi-Rotor Outrunner | Turnigy | 9392000004 | $32.45 |
Total Cost (excluding shipping and taxes) | $169.11 |
Design & Implementation
The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.
Hardware Design
Discuss your hardware design here. Show detailed schematics, and the interface here.
Pin Connections
Sl. No | Port and Pin Number | Pin Type | Purpose |
---|---|---|---|
1 | P0.0 and P0.1 | UART 3 | IMU Communication (Arduino) |
2 | P2.4, P2.5, P2.6, P2.7, P0.29, P0.30, P0.26, P0.29, P0.30 | GPIO Input | Remote Control Receiver Input |
3 | P2.0, P2.1, P2. 2, P2.3 | PWM | PWM output to motors |
4 | P2.8, P2.9 | UART2 | ZigBee telemetry |
This will be updated in the diagram later. But for now:
- P0.29 - Channel 7 - AUX 1
- P0.30 - Channel 8 - AUX 2
- P0.26 - Channel 5 - Gear
Channel 6 - Not used
Hardware Interface
In this section, you can describe how your hardware communicates, such as which BUSes used. You can discuss your driver implementation here, such that the Software Design section is isolated to talk about high level workings rather than inner working of your project.
Current Design UART for reading sensor data PWM for motor control UART for telemetry
Software Design
MPU-9150
The MPU-9150 consists of a 3-axis accelerometer, 3axis Gyroscope and a 3 axis magnetometer. its a one chip IMU solution with onboard Motion processor for sensor fusion.Though it inherently supports on board Sensor Fusion, the IP is undisclosed. Therefore we used the library for arduino by Pansenti. (https://github.com/Pansenti) The 6 axis sensor fusion (accel+gyro) is done on the MPU and sent to an arduino where the magnetometer data is used for YAW correction. The arduino transmits the orientation data over UART which is recieved by the SJONE for further processing.
For testing, we coded a GUI in python. The code parses the serial data from the arduino and displays the orientation of the IMU in real-time using Vpython.(video and code to be linked).
PID Controller
For our flight controller algorithm, we are using a PID controller. PID (proportional, integral, derivative) controller is a feedback control system which attempts to minimize the error in the output using three constant values: P, I and D i.e. the proportional, integral and derivative values.
Converting Remote Control Data to Motor Speed
The following steps are involved in converting raw RC (remote control) data to motor speed
- Get the RC data. Usually a PWM signal
- Scale up/down this value using a pre-decided curve. (Linear/Exponential)
- Convert this value into angles.
- Apply PID on Roll/Pitch/Yaw RC command (Using the angles calculated by IMU (Inertial Measurement Unit) as the PID input and angles calculated from the previous step as the desired setpoint)
- Use these angles to adjust motor speeds and direction (Add/Subract to Throttle Command)
Implementation
This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.
Mechanical Design
Testing & Technical Challenges
Getting a quadcopter to fly smoothly isn't a smooth process at all. But failures do have teach us a lot. Listed below are some of the issues we faced during the course of this project.
Quadcopter Assembly
- Unexpected Throttle: Throttle seems to shoot to maximum without command. Solution - Order new remote control (:O)
- Bricked ESC: Tried flashing SimonK Firmware into ESC for faster update rate. ESC didnt respond! Solution - Buy a whole new set ESCs (!)
- Propeller Issue: Didnt check propeller specs before ordering. Had to return.
- Specifications were not clear for the products ordered online: Motors were too big for the frame. Different countries follow different metrics. Need to be careful while assembling parts ordered from different websites.
- Magnetic Interference on Compass:Motors create really intense magnetic fields which interferes with the magnetometers magnetic field. As a result magnetometer readings are affected. Magnetometer needs to be kept at an elevation to avoid this.
Quadcopter Software
- UART FIFO: If messages longer than 16 bytes is transmitted over UART, then all characters exceeding 16 bytes are lost. This issue is yet to be resolved. Looking into it.
- (4/23)Resolved this by using Interrupts and queues. The polling method created a time delay causing some data to be lost.
- Rear Right motor was always high and not responding to any input. The issue was that while computing PID we must be measuring the change in value from the center value, but instead we were measuring change from the minimum value.
- Uint to int: A lot of calculation needed the use of integer but we were using unsigned integer types. Hence values were not right.
- Pitch vs motor speed: Change in pitch was causing an opposite change in motor speed. We interchanged the signs for the front and rear motors and resolved this issue.
- IMU Disconnected: Quadcopter goes crazy if the IMU is not connected. Junk values are updated as PID and quadcopter flies away ramming to ceilings! Fixed this terrible bug by introducing a check to see if IMU is connected, if not flight controller loop is not run.
- Motor PWM Percentage: PWM percentage was not calculated based on motor frequency. Fixed this by introducing a formula dependent on motor frequency.
- RC Limits: RC limits are different for arming/disarming and for proper working. We were using the same limits and as a result accidental arm/disarm took place.
- Gain co-efficients: Changed from int to float.
- Motors jerk effect: Motors stalled for a fraction of a second and lost control. Initialization of angles every iteration in IMU data parsing was commented and the effect vanished.
- PID loop: Additional changes for P,I and D terms incorporated as per Multiwii 2.1 code.
Future Enhancement
Future enhancements are to include GPS capabilities and incorporate autonomous take-off and landing capabilities based on GPS co-ordinates between two places.
Conclusion
This project helped us to understand the mechanical, electrical and control system configuration that goes into building and flying a Quadcopter (we now understand the phrase "its not rocket science"!!!!!). We understood the PID control mechanism using which the Quadcopter tries to stabilize itself for a smoother flight. This project helped us to gain a lot of practical knowledge about how a system needs to be planned, designed, integrated and tested. It helped us to realize that backup plan is required no matter how organized and foolproof the original planning is followed. It is very much required to do an initial investigation on the Quadcopter parts as it would save a lot of time, effort and money once started. Every stage impacts the previous stage and future stages. If any of the stages goes kaput, it obliterates all the effort spent and we have to start from the beginning. The assembly and programing is half the effort. An equal effort will need to be spent on tuning the Quadcopter without which all the effort goes into vain in case of crash landing.
Project Video
Upload a video of your project and post the link here.
Project Source Code
Send me your zipped source code and I will upload this to SourceForge and link it for you.
References
Acknowledgement
Any acknowledgement that you may wish to provide can be included here.
References Used
- https://github.com/Pansenti
- https://code.google.com/p/sf9domahrs/
- http://www.rcgroups.com/forums/showthread.php?t=1284741
- http://blog.oscarliang.net/quadcopter-pid-explained-tuning/
- http://aeroquad.com/showthread.php?1167-Stable-Mode-Explained
- http://www.ece.ucdavis.edu/~spencer/195/datasheets/PID-Without-a-PhD.pdf
- http://support.motioneng.com/downloads-notes/tuning/pid_overshoot.htm
- http://www.instructables.com/id/RC-Quadrotor-Helicopter/?ALLSTEPS
- http://www.modelflight.com.au/blog/how-to-fly-remote-control-quadcopter/
- http://www.thorlabs.com/tutorials.cfm?tabID=33653
Appendix
You can list the references you used.