It was a long journey to build a quadcopter from scratch and develop a stable flight algorithm. There are many solutions on the market which will get you a flying quadcopter fairly quickly. To develop such a flight controller was a harder challenge than expected. I made my experiences trying to build a quadcopter myself during the previous year but I did not get it to work. Together with a friend we tackeled the challenge to build a flying quadcopter using the Toradex Colibri T20 module. We dediced to participate at the Toradex Challenge 2014 with our project.

During our work we had to choose different types of sensors and implement every single one of them in the code. There is not much example code available for Colibri Modules online. Additionally we had to figure out what motors, frame and electrical design we were going to use. Many of our sensors and motors went through several iterations to reach our final design. We changed our motor-brand four times until we were happy with the final decision, the Hacker motors. The sensors changed also several times during our project. We started with an I2C Gyro and an USB Accelerometer and then switched to a combined sensor version to reduce weight and gain accuracy. When designing our own PCB this sensor was replaced by an even newer version which included a magnetometer as well. The impact of theses upgrades could be seen well in our hovering tests. The motors were controlled by the Colibri-Module directly in our first design. It took a while to figure out the resolution of the onboard PWM driver was way too low and it had to be replaced it with an external chip. Doing so improved our flight characteristics greatly.

The following spreadsheet shows the amount of time invested in this project during one year.
In the following series I lead you through the cornerstones of this project, beginning with the final hardware setup, the current version of the C++ code and the graphical user interface designed for this project.

Hardware Setup

The frame of the quadcopter is completely made out of carbon and aluminium parts. The main shafts and aluminium brackets are from the Talon V2 frame. The center plates as well as the damping system was designed with NX 9.0. We manufactured those parts with a CNC machine. Videos and details about the general hardware constructions can be found in the previous updates and on our Youtube Channel.

We designed a PCB which houses all our sensors and connects to the Iris Board via headers. It can be mounted directly on top without the need of any wiring. The GPS on is then connected with our PCB directly. The following Sensors are used in our final design:

  • MPU 9250 Sensor: 3x Gyroscope, 3x Accelerometer, 3x Magnetometer, Motion Processor
  • MPL3115A2:Pressure Sensor for altitude measurements
  • PCA9685: I2C to PWM IC needed for the motor controllers
  • ULN2803: LED driver
  • XBee PRO: 1.6km remote connection
  • USB Ambicom: WLAN module
  • U-Blox LEA 6H: GPS module

Software Structure

We’ve implemented all our sensors using classes. The latest version of our source code has over 8000 lines which has all been written by ourselves. Meaning we don't count the code of the included libraries and 3. party code.

Plugging in the battery will power the motors and the Iris Board immediately which in turn provides power to the colibri T20 as well as our sensor board and the GPS and RC receiver. The windows CE7 real time operating system will start booting immediately. After a few seconds it is finished and our control software gets executed.

First all parameters are read from a text file. These are parameters concerning communication, the control algorithm and the hardware setup. Afterwards the motors get initialized and our different threads get started one after another.
Every thread runs a loop at a specific frequency and has its own priority. If all threads were started accordingly the main loop executes. This loop has no other function than keeping the control loop alive. If it gets terminated by the user it can be reactivated. To close the main-loop a specific command has to be sent using our graphical User Interface.

The threads can communicate with each other using the parameter class. This class has several functions inter alia the function to read / write the parameters to a text file or send them to the GUI. At startup of every thread a pointer to this class is provided and therefore allowing full access.

The control thread gets executed every 8 ms and uses the MPU9250 as its interrupt source. The structure is as follows.

  1. Read MPU, barometer and remote control data and convert / filter it
  2. Calculate position, height and stabilization values
  3. Sum up terms to define the motor speeds

Graphical User Interface

The user interface plays a very important role in our project. It is used to plot and save sensor data for later analysis as well as to edit parameters and gives us a status about what the program is currently doing. We can also send commands directly using the implemented console and view the quadcopters status in the 3D real time model. All commands are documented and form the TCL, Tdxcopter Command Language. The most important task is the option to start and stop the control loop as well as the ability to activate different functionalities like GPS position hold or height control.

At first this was unexpected, but the need to constantly debug the system made the TdxCopter GUI a very important part of the project. This led to a significant fraction of the time being devoted to this GUI which now is an invaluable part. Later the GUI will be the program to define way-points and plan the quadcopters behavior.

Source Code

You can download the source code form the GUI and the Quacopter following the link below:


Current Status

The Challenge is completed and we wait for the winners announcement. If you want to dig deeper we've set up this website which contains all our updates concerning the project as well as more pictures and videos: