Giter VIP home page Giter VIP logo

aio-quadcopter-flight-controller's Introduction

AIO Quadcopter Flight Controller

Read about this project on my website: https://delaney.nyc/projects/

Follow the full project development on the GitHub project page: https://github.com/users/MichaelD33/projects/1

Disclaimer: This is a functional yet unfinished project. The information in this repository is provided without warranty or guaranteed funtionality. If you attempt to replicate this project, I am not responsible for any damages or failures associated with your work.


Basic Overview

This repository contains the flight controller firmware for my custom designed micro quadcopter. This quadcopter design is based on the atmega32u4 chipset. Find the flight controller design files, here: https://github.com/MichaelD33/AIO-Quadcopter-Design

This program takes orientation data from an inertial measurement unit and input from an external remote in order to fly by adjusting the speed of its motors according to calculations made by the control loop.


Setup and Operation

Configuration and setup is relatively straight forward. In this early stage of development, the program only supports sBus type receivers and the MPU6050 combined accelerometer and gyroscope. This flight controller could be easily modified to support other RX types by replacing the SBUS.cpp and SBUS.h files with the appropriate library for reading RX data from your receiver. Output this data to the RX.cpp and RX.h files for processing the individual channels (or output to the main program directly from your RX library and remove the built-in RX files)

Device MCU Pin Input
Frsky XM RX1
MPU6050 SDA, SCL

PWM Motor Outputs: The motor output pins are entirely configurable from within the IDE. Since this flight controller is designed to support brushed motors, the output pins must be PWM capable.

Determining the correct order of the motor outputs can be quite frustrating and may cause the drone to attempt to move in the wrong direction or pitch when intending to roll... When configured correctly, the bottom left motor should correspond with the first field of the pinout array, bottom left with the second, top left with the third, and top right for the fourth (orientation determined according to the direction of the IMU).

For the AIO quadcopter PCB the motor output pins vary for each design, but the proper config is listed in the program main file.

Processor note: this device requires a serial port for the RC input. The receiver is setup under Serial1 for my atmega32u4. This will not work with an atmega328.

Motor Output Diagram:

IMU Offsets: It is important to calibrate the IMU offsets during the initial setup of the quadcopter. This will help compensate for errors in the MPU6050 measurements. These offsets are different for every IMU, so you will need to do this for every individual quadcopter. In the future, I hope to integrate the IMU offset calibration directly into the program; however, for the time being, this is not the case. I recommend this program for obtaining your individual offsets: https://www.i2cdevlib.com/forums/topic/96-arduino-sketch-to-automatically-calculate-mpu6050-offsets/

Add these offsets to the config.h file under the "INERTIAL MEASURMENT UNIT CONFIGURATION" section.

Note: This offset detection program requires the i2cdev library to function. This library is already included with this flight controller repository; however, until the offset feature is implemented directly into the flight controller code, it is necessay to install the library again (directly into your arduino libraries folder), or adjust the IMU.cpp "#include" references to utilize the same library for both the flight controller and the offset detection sketch.

Remote Configuration: The remote configuration is fairly straight-forward if you will be using an s.Bus receiver. Pair the receiver to your remote control and connect it to the Serial1 input on the atmega32u4. Determine the channel endpoints for your remote— technically, these should be 0 —> 2000, but in my case it was 172 -> 1811. You may set this value in the config.h file under the "MINTHROTTLE" and "MAXTHROTTLE" definitions.

(If these parameters are not configured the quadcopter may start the motors even while the throttle is at 0)


Dependancies:

The flight control software is built upon the following resources:


Difficulties

This project originally began as a personal challenge in order to improve my embedded programming skills. While I acknowledged the difficulty of programming a device like this, I also was extremely motivated to learn about the ongoing computational processes that take place in an aerial vehicle like a quadcopter. Throughout the process of designing the hardware and writing the code for the flight controller I continually encountered issues with both the physical electronics and my programming. I am still attempting to fix a number of these issues, many of which emerge from flaws in the device's design; however, I have been working on improvements which will hopefully help to mitigate the issues I am currently facing.

The micro scale design of the all-in-one(AIO) frame leads to stability issues because of increased sensitivity to:

  • Wind, vibrations, PID tuning, changes in CG, changes in mass, etc.

aio-quadcopter-flight-controller's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aio-quadcopter-flight-controller's Issues

Port the relevant changes from the SingleAxisController repository

Most of the recent development on this project has been occurring on a separate repository— see: SingleAxisController repository.

The single-axis controller repository was developed in order to perform testing and data collection in a simplified manner.

The dependencies for this library include:

In theory, the single-axis controller program should be (functionally) the same as the main AIO program, the only difference being the changes that are necessary for testing in this jig. These changes include disabling the unused motors and manipulating the IMU output to provide data which is more convenient for the testing purposes. Nevertheless, I have made a number of changes to the program that have not (yet) been ported to the main controller program. Hence, I will be creating a new branch of the AIOFC repository dedicated to making these adjustments.

These changes include:

  • i2cdev library — quaternion measurement, DMP usage, filtration, etc.
  • Adjust loop sample timing (see SAC issue #5)
  • Update the config.h parameters
  • On the fly PID tuning capability

Further changes and adjustments will be added as noticed.

Convert orientation from QuadX to Quad+ layout

The SAC is designed to test PID parameters for single-motor based control. Currently, the main AIO program utilizes two motors for the roll and pitch axes (this is a QuadX layout). This is an acceptable method; however, given that all my tests are based around a single motor implementation, I believe it may be better to utilize the Quad+ layout on the final device.

external-content duckduckgo-4

  • Apply virtual rotation to IMU output (see SAC issue 3)
  • Convert PID controller motor output to Quad+ configuration

PID Rate Controller Implementation

The PID tuning process has proven much more challenging than initially expected. The device is properly responding to the remote input and external disturbances, but the behavior is either too sluggish or too intense for proper stabilization. Initial testing using the SAC was acceptable, but after porting the appropriate change to this flight controller (#1) I observed that the device was not behaving as expected and that the initial testing using the SAC was not an ideal analog for the quadcopter.

This video may provide deeper insight into the performance of the device: Link.

The solution, here, is to use a separate PID loop, 2 for controlling the rotational rate and stabilization. Given that the motor speed is directly related to the angular velocity of the quadcopter, there is a proportional relationship between the pilot input (as a rotational rate) and the angular velocity of the quadcopter.

There are a few changes which need to be implemented in order to do this:

  • The IMU must output rotational rate data to the MCU
  • A rate controller needs to be implemented for both the pitch and roll axes
  • The IMU output data must be manipulated to output deg/s
  • The rate controller needs to be tuned
  • The stabilization controller needs to be connected to the rate controller (if stabilization is desired)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.