The flight controller is the nerve center of a drone. Drone flight control systems are many and varied. From GPS enabled autopilot systems flown via two way telemetry links to basic stabilization systems using hobby grade radio control hardware, there is an open source project for you.
Modern drone flight controllers can trace their roots back to R/C helicopters. Historically, R/C planes were controlled directly by the pilot’s radio. Helicopters added a new wrinkle to the mix: tail rotors. Helicopters use their tail (or anti-torque) rotor to counteract the torque of the main rotor attempting to spin the entire helicopter’s body. It all works great when the helicopter is hovering, but what about when the pilot throttles up to fly out? As the pilot throttles up, the torque increases, which causes the entire helicopter to do a pirouette or two, until the torque levels out again. The effect has caused more than one beginner pilot to come nose to nose with their R/C heli.
The solution to this problem was gyroscopes, heavy brass spinning weights that tilted in response to the helicopter’s motion. A hall effect sensor would detect that tilt and command the tail rotor to counteract the helicopter’s rotation. As the years wore on, mechanical gyros were replaced by solid state MEMS gyros. Microcontrollers entered the picture and brought with them advanced processing techniques. Heading hold gyros were then introduced. Whereas older “rate only” gyros would drift, weathervane, and wiggle, heading hold gyros would lock down the helicopter’s nose until the pilot commanded a turn. These single axis flight controllers were quickly adopted by the R/C helicopter community.
Today’s flight control systems have many sensors available to them – GPS, barometric pressure sensors, airspeed sensors, the list goes on. The major contributors to the flight calculations are still the gyros, coupled with accelerometers. As the name implies, accelerometers measure acceleration – be it due to gravity, a high G turn, or stopping force. Accelerometers aren’t enough though – An accelerometer in free fall will measure 0 G’s. Turning forces will confuse a system trying to operate solely on accelerometer data. That’s where gyros come in. Gyros measure rate of rotation about an axis. Just as our helicopter example above covered yaw, gyros can be used to measure pitch and roll of an aircraft. A great comparison of gyros and accelerometers is presented in this video from InvenSense.
Stay with us after the break for a tour of available flight controllers and what each adds to the mix. Inertial Measurement Units (IMU) are devices which read these sensors and execute sensor fusion algorithms to determine current position and attitude. Just about every full scale aircraft produced today has some form of IMU inside it. Even your smartphone can act as an IMU. Give an IMU the ability the control the platform it’s riding on, and you have a flight controller. So how does a flight controller take data from gyros, accelerometers, and other sensors, convert it into a stable flight platform? The answer is in some clever mathematics and software. The core of most flight controllers is a software algorithm called a Proportional Integral Derivative (PID) control loop. PID loops and their tuning is such an important topic that I’m going to dedicate an entire column to it, so if you’re having trouble getting your aircraft stabilized, sit tight, help is on the way! Choosing a flight controller There are a number of popular flight controllers used today. Deciding which one is right for your needs can be a tough choice. We’re covering open source flight controllers here, but I would be lax if I didn’t mention the commercial offerings. The DJI Naza controller is the preeminent commercial control system available. Many professional and hobbyist pilots use this system on a daily basis. Naza gives basic flight control, attitude hold, and return home functionality with a simple interface. Naza isn’t perfect, though. One issue is GPS based flight rejection – DJI autopilot systems will not allow flights over the Forbidden City in China. Undoubtedly this is due to requests by the Chinese government. However, the closed source nature of the system makes one wonder what other “features” might be hiding in the code. The “Big Four” in flight control systems seem to be The KKmulticopter, The Multiwiicopter, The Pixhawk, and the OpenPilot.
The KK board was designed by Rolf R. Bakke, aka KapteinKuk. The most popular form of the KK board seems to be the HobbyKing KK multicopter board, currently at version 2.1.5 if you can find it in stock. The KK2.1 boards are based upon an Atmel ATmega644PA processor and an InvenSense MPU-6050.The 6050 is an interesting chip in that it not only includes 3 gyros and 3 accelerometers, but also a microcontroller dedicated to handling the sensor output. This takes some of the load off the Atmel chip. There is still quite a bit of work to be done for an 8 bit micro, and Rolf speeds up the process by writing the entire firmware in assembly code. The double edged sword here is that the assembly code limits the number of developers in the project. The interface side of KK board is simple. A small graphical LCD and 4 buttons allow the user to program parameters. KK’s flight control algorithms only use P and I, there is no D on the KK board. There doesn’t appear to be an official website for the KK board, but information (and the latest source) can be found on the RCgroups megathread. The KK board can be thought of as a bit of a gateway drug. It’s low cost, easy to set up, and it gets the job done. You don’t need a computer to set it up, everything is on the board mounted LCD. The KK board isn’t a standout performer for any of the common drone types, but if you just want to get out there and have a good flight, it’s plenty good.
Next up is the MultiWii. MultiWii’s name comes from its original sensors. The first revision of the MultiWii was designed to use the Nintendo Wii Nunchuck gyros and accelerometers, as they were cheap and easily available worldwide. Things have changed quite a bit since then. The current MultiWii board, MultiWii Pro (MWP) sports a host of sensor upgrades. The MWP board is based upon the Arduino and utilizes an ATmega2560 processor. Software is written in Arduino’s native wiring language, using everyone’s favorite processing based IDE. The board’s current sensor suite is extensive. In addition to the usual gyros and accelerometers, it has a barometer, magnetometer (compass), and an optional GPS. MultiWii also allows for a number of configuration methods. Off board LCD and OLED displays can be connected for field configuration. A full GUI config program is available via the on-board USB port or a Bluetooth daughterboard. MultiWii’s source is hosted on their Google Code page, though there is a Github mirror for you git fans. MultiWii is quite capable of stabilizing an R/C style airplane, helicopter, or multicopter. The board is on the cusp of being a full-fledged autopilot. It’s not as slick as the APM, partly due to the fact that there isn’t a well funded corporate entity driving development in one direction or another. The core developers are active though, which makes this a good board to watch.
Mega 2 (APM2)
The APM is an open source project from 3DRobotics. It began life as the Ardupilot, a fixed wing flight control system based on the Arduino. The project quickly grew to include rovers, helicopters, and multicopters. While the project is still compatible with the Arduino IDE, the dev site gives tutorials for using Visual Studio on Windows, as well as the ‘make’ command in a Linux environment. The current hardware is the APM2.6, which utilizes an ATmega2560 for the main processor. An ATmega32u4 handles USB functionality. The InvenSense MPU-6000 handles gyro and accelerometer duties. The APM2 has an onboard barometric sensor. Interfaces for off-board GPS and magnetometer/compass modules are provided. APM and Pixhawk use similar software builds, so check the Pixhawk below for more information.
APM2 codebase has grown in complexity so much that they’re running out of memory and processing horsepower on their 8 bit ATmega2560. 3DRobotics obviously needed a newer platform with room for further growth. They chose to build upon the hardware platform of the PX4 project. PX4 started in 2009, and current development is based at Swiss Federal Institute of Technology. 3DRobotics ported the APM code to the Px4, and rolled their own version of the hardware called Pixhawk. Pixhawk uses the STM32F427 processor, which is a 32 bit ARM Cortex M4 core with onboard FPU. 3Drobotics also uses a real-time operating system. NuttX is a free open source RTOS. Designed from the ground up as an RTOS, NuttX is much lighter than Linux or other operating systems. It could be compared to VxWorks or other industrial/aerospace RTOS’s. The Pixhawk includes gyros, accelerometers, barometer, GPS, magnetometer/compass, and telemetry. It also has a MicroSD card slot for data logs, which can make things much easier when looking for help online. PixHawk and APM2 both use GUI based Mission software for configuration. They can also operate as full autopilots, with waypoint based missions. On the source side, Pixhawk has a large active developer community behind it. The source is available on the DIYdrones Github. 3DRobotics definitely has a feature advantage here. They have the resources to implement lots of software features, build molded cases, and complete products. Their IRIS drone is possibly the first fully autonomous drone on the commercial market.
OpenPilot is another long time flight controller project. Currently supporting two platforms, the CopterControl 3D (CC3D), and their new flagship board, the Revolution (Revo). The CC3D uses a STM32F103 Arm Cortex M3, and a suite of both gyros and accelerometers. Thanks in part to the current mini FPV craze, the CC3D board is still seeing quite a bit of popularity. This has caused quite a few derivative boards to pop up, such as the Lumenier edition
and the Acro Naze32. These boards seem to be very good in the “turn and burn” flight style of small FPV multicopters. The Openpilot project is moving to their new board, the Revolution. The Revo uses a STM32F405RGT6 32bit ARM Cortex M4 processor. Revo uses the InvenSense MPU6000 accelerometer/ gyro chip, along with a barometric pressure sensor, and magnetometer. Revo also supports telemetry and GPS. Both CC3D and Revo are configured using GUI based Ground control software. Source code is available on the OpenPilot’s git server. OpenPilot has had some team turnover issues, but they’re making great progress now. The Revo includes some advanced features, like an onboard telemetry radio. Coupled with the current codebase’s ability to handle high speed maneuvers on small, agile multicopters, this board has a bright future.
Advice When Choosing a Controller
All these flight controllers are quite capable. Deciding which to use in your drone depends on the flight characteristics, and the style of flying you’re looking for. Being open source projects, there are derivative boards and low-cost clones available for all of them. Beware of the lowest cost clones. Some of them are great, but others are sub-par to say the least. Sometimes saving a few dollars means lower quality components and assembly. Nothing is worse than seeing hundreds of dollars and hours of effort fall out of the sky because of a cracked solder joint or a bad capacitor.
Hackaday Testbed Update
The parts are finally here and the build has begun! If you want to follow my progress on the Hackaday Drone Testbed, a quadcopter which will be used to test some of these flight controllers, head on over to the Hackaday.io project page! That’s about it for this edition. Until next time, keep Droning On! [Title image by Joergens.mi/Wikipedia]