This note is from my B.S. thesis in the School of Mechanical and Aerospace Engineering at Seoul National University, Design of Quadrotor UAV Flight Control Computer and Control System (December 2014, advisor: Youdan Kim, Flight Dynamics and Control Lab). Yongjun Seo, then a graduate student in the lab, mentored the project. This part covers the background of the project and the flight control computer (FCC) hardware.

Abstract

The most important part of designing an unmanned aerial vehicle (UAV) is the flight control computer and the control system that keep its attitude stable. In this study, I designed a flight control computer and a controller for a UAV and loaded an attitude control algorithm onto it.

The flight control computer was designed to control a quadrotor. Many previous studies have reported dynamic models of the quadrotor and controllers that stabilize its attitude. Based on them, I designed my own flight control computer. Using Arduino Due hardware and MATLAB Simulink, the flight control computer allows a more intuitive controller design. A PID controller block was loaded onto the flight control computer. When the flight control computer was mounted on a quadrotor, the controller showed satisfactory performance.

Keywords: quadrotor, flight control computer, Simulink, Arduino

Introduction

Background

Thanks to recent advances in motors, batteries, and sensors, small UAVs are drawing attention in many fields. Applications are being studied in the military, agriculture, and service industries, and multi-rotor vehicles, which need no runway for takeoff and landing and are highly maneuverable, are spreading quickly. A multi-rotor is a vehicle that has propellers producing thrust at several locations and moves by changing them.

The most important part of building a UAV is the design of the flight control computer. Designing a flight control computer myself and applying the control theory I learned in my undergraduate courses is a good way to put that theory and knowledge to use. In this study, I designed a flight control computer and a controller for a quadrotor.

Purpose and scope

A quadrotor is naturally unstable, so its attitude must be stabilized by a controller. Many studies have reported dynamic models of the quadrotor and controllers that stabilize its attitude. Most of them, however, programmed the controller on the flight control computer in C. This approach makes it easy to control the hardware directly at a low level, but the code is hard to modify, and extending a function often means writing new code. Above all, the written code does not match the block diagram drawn while designing the controller.

In this study, I wrote the controller code in MATLAB Simulink and applied it directly to the flight control computer. The controller on the flight control computer is then shown clearly as a block diagram, and other controllers can be applied easily later. It also narrows the gap between control theory and program structure, so that a control engineer can do model-based design from theory and dynamic modeling.

What I did

First, I selected hardware suitable for a quadrotor flight control computer and set up the development environment. Next, I modeled the dynamics of the quadrotor and designed a basic controller for it. Then I loaded the controller software onto the selected hardware, tuned the controller, and checked its performance.

Selecting and building the flight control computer hardware

Red ATmega128 microcontroller module board with pin headers
Figure 1. The selected microcontroller module (ATmega128).

Before buying the selected microcontroller and building the FCC hardware, designing and simulating the FCC hardware in a virtual environment saves cost and time. I simulated the microcontroller in Proteus Professional V8.0, a microcontroller simulation program. In Proteus, an FCC circuit can be built from the microcontroller and other electronic components, and when the program file for the real microcontroller is loaded, the microcontroller runs in the virtual environment exactly as it would in reality. So the code compiled for the microcontroller (the .hex file) can be loaded virtually to test every function of the microcontroller.

Proteus Professional 8 window with a microcontroller circuit on the schematic canvas
Figure 2. Layout of Proteus Professional 8.

I wrote the microcontroller code in Atmel Studio 6.2, the integrated development environment from the microcontroller manufacturer. Below is an example I ran to check that code built in Atmel Studio 6.2 works after loading it into Proteus. In this example, the microcontroller is programmed to read four PWM signals, calculate their duty ratios, and send them to a virtual serial port, and the pulses and the microcontroller circuit it needs were built in Proteus.

The four PWM signals were generated to match the specification of the transmitter signals that go into the real microcontroller. This is a function the FCC must have to receive and process the user’s input from the receiver. The microcontroller then processes them and generates the PWM signals that drive the motors, and it sends the motor signals to a virtual serial port for the quadrotor dynamics simulation in the next step.

Proteus schematic of the ATmega128 with four PWM inputs and a virtual serial port
Figure 3. Schematic capture of the example circuit.

With the ATmega128, the PWM signals from the transmitter and the signals from the sensors can be collected easily at a low level. However, previous studies that used only the ATmega128 reported that its limited computing power makes advanced control theory hard to apply. Controllers implemented on the ATmega128 are also text-based, which often makes them hard to analyze and modify. I therefore decided to add a second microcontroller for the control calculations, in addition to the ATmega128 for sensor data collection at the low level.

With MathWorks’ Arduino Support from Simulink, the Simulink blocks written during quadrotor dynamics modeling and controller design can be applied directly to the flight control computer hardware. This brings the strengths of Simulink straight into building the flight control computer. Designing the controller with graphical blocks should make the design more intuitive and shorten development time. Among the Arduino boards supported by Arduino Support from Simulink, I selected the Arduino Due, an open-source board from Arduino.

Prototype flight control computer: an ATmega128 board for data acquisition, an Arduino Due for calculation and control, an AHRS, and a servo for testing
Figure 4. FCC hardware (prototype): ATmega128 for data acquisition, Arduino Due for calculation and control, the AHRS, and a servo for testing.

The ATmega128 code was the same code written during the microcontroller simulation in Proteus. When adding the Arduino Due to the FCC, I focused on building an environment where Simulink blocks can be used.

The Arduino Due receives the serial data from the AHRS (Attitude and Heading Reference System), converts it to Euler angles, and uses them in the control calculations. To confirm that this works, I attached a servo motor and made it output the measured angle directly. The Simulink model written for this is converted automatically into code for the Arduino Due.

Simulink model that reads AHRS serial data and drives a servo on the Arduino Due
Figure 5. Simulink block deployed in the Arduino Due.

After programming, the servo motor moved by the same angle as the tilt of the FCC. This shows that the Simulink models I had been using could be used on the hardware in the same way.

Two photos of the FCC tilted to different roll angles with the servo arm following
Figure 6. Change of the servo motor angle with respect to the roll angle.

In the next step, I planned to deploy the controller built in the quadrotor dynamics simulation to the Arduino Due as is, and build the controller using the data from the ATmega128. That is covered in Part 2.

References

  • 1. Lee, I. (2010). AVR ATmega128 Microcontroller: From Basics to Device Control (with the WinAVR compiler). Seoul: Hongneung Science. (in Korean)