Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Development of Flight Controller Using Stm

Microcontroller Board
Gokul V, Jayashree T R
Department of Aeronautical Engineering
Rajalakshmi Engineering College
Chennai, India
gokul.v.2018.meav@rajalakshmi.edu.in, jayashree.tr@rajalakshmi.edu.in

Abstract—Nowadays, drones or so-called UAV's are modified according to our needs because they are hardware-
extensively used both in the civil sector and military sector. wise or wholly proprietary. It is necessary to know the
Flight controllers used in UAV’s is the main embedded functioning of the flight controller to modify it. So a flight
hardware electronic component where all the processing take controller is developed by using STM32 microcontroller as a
place. It is considered to be the heart for the drones. There are
base along with various other sensors with the objective to get
several drone flight controller platforms available but they are
either hardware wise or wholly proprietary and doesn't allow high customisation.
for much customisation. For academia it is necessary to know
the functioning of the drone to customise it. So a flight controller
is developed by programming a STM32 (Blue Pill) II. LITERATURE REVIEW
microcontroller to get a high degree of customisation. Sensors
like gyro, barometer, gps, etc., are interfaced with HaiYang Chao, YongCan Cao, YangQuan Chen et al in
microcontroller and the values obtained are manipulated with [1] presented a survey on the autopilot system for small or
control algorithm to achieve the functioning of flight controller micro unmanned aerial vehicles (UAVs). It discusses on
for flying. A telemetry system is also developed to get the useful various commercial, open source and research autopilot
flight information in real time, when the drone is flying for systems. They a re explained on both the hardware and
monitoring purpose. The aim of this project is to create a flight software viewpoints. Several autopilots available in the
controller where the operation of hardware and software are market are compared in terms of sensors and microcontroller
well known in order to get a high customisation where the user
capability. It concludes by stating that design of software is
can modify the code or hardware according to the needs for any
specific purpose.
far more crucial than the hardware for flight controller.

Keywords—uav, flight controller, control algorithm, telemetr y Emad Ebeid, Martin Skriver, Jie Jin et al in [2]
discusses the components of flight controller and the UAV
system. This survey paper also covers both the hardware and
I. INTRODUCTION software of flight controller. It compares the available open
source flight controller platforms depending upon the features
Drones can be broadly classified into two namely fixed - and concludes that on hardware side, pixhawk is best due to
wing and multirotor. In multirotors, quadcopter or quadrotor its flexibility and capabilities. Similarly on software side, it
is a classic arrangement used widely. The quadcopter uses concludes ardupilot is full fledged and comparatively best
four propellers to produce lift and to control the dynamics of software.
drones. Out of four propellers, two rotate clockwise while the
other two rotate counterclockwise. By varying the speed in Sarah Pontes Madruga, Augusto de Holanda B. M.
rotors, the drone is steered and the desired direction is Tavares, Alisson Vasconcelos de Brito, Tiago Pereira
achieved. Nascimento et al in [3] developed a flight controller for
quadcopter based on raspberry pi 3. It explains the
The main components which constitute the quadrotor methodologies and technicalities involved for developing a
are flight controller, airframe, motors propellers, battery, flight controller. It explains on how the motor and other
ESC, transmitter and receiver. A flight controller has sensors sensors communicate with the flight controller through
onboard such as MEMS gyroscope, MEMS barometer, etc., communication protocols. It concludes by saying that
where it gathers data and manipulate it with control methods Implementing on open source hardwares and softwares and
to achieve optimal flying. In response to the input received developing own control algorithms for drones will be a good
from the receiver, the flight controller changes the rpm of the option for better understanding.
motors.
S. Sabikan, S. W. Nawawi et al in [4] proposed an open
The flight controller can be classified into three sections source platform for flight controllers in drones where UAV
namely hardware part, software part and ground control can be used for any outdoor applications. This paper
station. The flight controller hardware consists of experimented autopilot in outdoors and provided results on
microcontroller, sensors and other electronic components. performance, stabilization, interference and vibration. It
The flight controller software a cquires data from sensors and concludes that because of magnetic field interference by
by use of certain control algorithms, it manipulates and motors, battery and ESC’s, the magnetometer may point
operates the drone. The ground control station receives data wrong direction. High vibrations on flight controller may
from the drone when it is on flight and displays the flight data cause accelerometer based altitude and horizontal position
information such as GPS coordinates, battery voltage, speed, estimations to drift far off from the actual values.
etc. There are different flight controller platforms available
for drones, in which we can mainly point out are Pixhawk, Zhaolin Yang, Feng Lin, Ben M. Chen et al in [5]
Naza, Ardupilot Mega, etc. These platforms cannot be analyses various autopilot platforms available and it
introduces various control methodologies to improve the
robustness and performance of the flight controller. It further
emphasises that for long term reliability of flight controller,
Environmental Stress Screening (ESS) needs to be carried
out. i.e., random vibration test and temperature cycling test.

III. COMPONENTS USED


A quadcopter is first designed using a F450 frame along
with four 1000 kV brushless motors, four 30A electronic
speed controllers (ESC’s) and a 2200 mAh LiPo battery of 40
C. We need a quadcopter for testing the flight controller, so
Fig.1. Block diagram of flight controller system
quadcopter is designed and then followed by the flight
controller. The hardware and software part of the flight
controller are discussed below.
E. APC220 Telemetry:
Basically a flight controller is a collection of sensors
The APC220 is a transceiver which provides a solution to
working together to accomplish a desired objective i.e.,
wireless communications. Its operating voltage is around 3.6
flying. The components used for developing this flight
– 5.0 V. It can transmit datas upto a range of about 1000m. B
controller are explained as follows.
default it operates at a baud rate of 9600 bps. It uses
A. STM32 Blue Pill: UART/TTL interface for communicating. Two telemetry
systems will be used, one will be placed in the quadcopter
The STM32F103C8T6 is a high-performance, ARM
while the other is placed in the ground for receiving flight
Cortex-M3 32-bit RISC core operating at a 72 MHz
data from the drone.
frequency. They have high speed memories (Flash memory
64 Kbytes and SRAM up to 20 Kbytes), and a range of F. Arduino UNO
enhanced I/O’s and peripherals connected to two APB buses.
We need another microcontroller for setting up the ground
It has one PWM timer, two I2Cs and SPIs, three USARTs, an
telemetry, so we are using Arduino Uno board. The Arduino
CAN and USB. The operating voltage of this board is 2.0 -
Uno is a microcontroller board based on the ATmega328. It
3.6V.
has 14 digital input/output pins, 6 analog inputs, a 16 MHz
B. MPU6050 Gyroscope Sensor: crystal oscillator, a USB connection, a power jack, an ICSP
header, and a reset button. It is programmed through the
MPU6050 gyroscope sensor consists of three axis
Arduino IDE
accelerometer and three axis gyroscope. It is used for
measuring angular velocity and orientation. The working G. LCD Keypad Shield
principle is based on Coriolis effect. Coriolis effect is a
This lcd keypad shield is developed for arduino
phenomena, i.e., When a body is moving in a specific
compatible boards. It consists of a 1602 white character blue
direction at some velocity, and when angular rate is applied
backlight LCD. It provide a user-friendly interface that allows
to that object, it will produce a perpendicular displacement.
users to go through the menu, make selections etc. In this
In addition to accelerometer and gyroscope, it also consists of
project it is used in the ground telemetry system to display the
temperature sensor integrated to it.
flight datas and go through the menu.
C. MS5611 Barometer Sensor:
The block diagram of the ground telemetry system is
The MS5611 is a high precision air pressure module shown below,
where it finds the altitude based upon the varying air pressure
because the a ir pressure decreases with increasing altitude. It
consists of a micro mechanical sensor chip is furnished with
a pressure membrane. Changes in membrane causes the
membrane to change shape. Then an electrical voltage
proportional to the amount of distortion will be created. By
this change in voltage created we can measure the ambient
pressure.
D. Neo M8N GPS Module:
Neo M8N is a high precision GPS module that includes
an HMC5883L digital compass right into it. This module Fig.2. Block diagram of telemetry system
gives precise position outputs at 10 Hz. In order to locate the
location, atleast 4 satellite signals are needed. This satellite
takes around 10 seconds to locate and acquies upto 6 IV. METHODOLOGY
satellites. It gives an accuracy of around o.9 meters.
The STM32 Blue Pill is programmed through arduino
These sensors are integrated together to form a flight IDE software by selecting the appropriate board, and by
controller. Two telemertry modules is used in this project, the importing STMduino library to the arduino software for
flight controller has one telemetry, which transmits datas compatibility. First, the sensors gyroscope, barometer and
from the sensors like imu, barometer, gps to the ground GPS are individually tested by programming the modules.
telemetry unit. The block diagram of the flight controller There are two types of signals in which the STM board can
sytem is shown below, acquire signals from the receiver. One is by PWM and the
other is PPM. Both work by sending a succession of square
wave pulses from the transmitter to the receiver. The only from the battery is 12.6V. Two resistors are used to convert
difference is PWM uses 6 wires for 6 channels whereas the the max. 12.6 V to 1.1V or below. The diagram of the circuit
PPM uses only one wire for all the 6 channels. Since to reduce is shown below.
the wiring complexity, PPM signals are used for
communication. The gyroscope gives pitch, roll and yaw
values. When the quadcopter is armed, the initial values in the
gyroscope are stored onto the EEPROM memory of the
board. The stored values acts as a base for stabilizing the
drone.
A. PID Controller
The flight controller uses control algorithm to stabilize
the drone when there are sudden disturbances. Without
control algorithm, the drone cannot stabilize itself. So PID
control a lgorithm is used for stabilization. The PID stands for Fig.4. Voltage Divider Circuit
Proportional Integral Derivative algorithm. Term P finds the
difference between the setpoint and the process variable, i.e.,
error and adds a gain such that there will be no error. Term I The Output voltage pin is connected to the analog pin of
uses past error values and integrates it over time to neglect the STM32 board. The output voltage will be in the form of
error. Meanwhile term D estimates the current rate of change analog values ranging from (0 - 4095). This analog value will
and differentiate over time to reduce error. The control be converted to the original voltage by the use of formula.
algorithm takes stored gyro values as a base and tries to Theoretical formula for finding out the output voltage is,
reduce the error. R2
Vout = Vin (1)
R1+R2

The analog value in the STM board will be converted to


original volage by using the below formula in the program.
Analog value
Vin = (2)
112.81

Further the barometer, GPS and telemetry sensors are


interfaced to get the altitude and position coordinates. The
datas acquired during flight are sent to the ground telemetry
for monitoring. The ground telemetry system is powered by
Arduino UNO. LCD display is interfaced with UNO for
visual monitoring of the flight.
Fig.3. Block diagram of control strategy

V. ANALYSIS
The initial imu values (roll, pitch, yaw) is fed into the
controller as an input and depending upon the current state Although the control algorithm is used, the test flight
and the command given, it calculates the error rate and was not stable leading to many drifts. The problem was due
reduces the error by controlling the motors by giving ppm to the gain values. After little tuning, the drone slowly got
pulses to the esc’s which in turn controls the motors and stabilized. The gain values are fine tuned till the drone is
corrects the imu angles of the quadcopter. By this way it completely stabilized. The final gain values after tuning are
stabilizes the drone and neglects the wobbling issues. mentioned below.
In the main program loop an interrupt will be acting, i.e., P Gain = 1.0
always the drone tries to stabilize by processing the PID
I Gain = 0.02
calculations, but when the transmitter sends signals to the
receiver an interrupt will start acting pausing the PID D Gain = 10.0
calculations. When the receiver signals are sensed, interrupt
The readings of the battery voltage was little error
starts acting by measuring the rising edge pulse, then PID
prone due to the interferences of the electronic speed
continues to resume. Immediately when falling edge pulse is
controllers. In order to compensate the error a filter is used.
detected interrupt start acting measure by the falling time and
The formula for the filter is shown below.
again the main program loop will be resumed.
Battery Voltage = (Previous loop voltage * 0.92) + (analog
B. Voltage Divider
value / 1410.1) (3)
In quadcopter it is very much important to know the
The MS5611 barometer is very sensitive to light. When it
battery voltage because when the battery drains during flight,
is exposed to light it gives an error rate of around 5%. In order
drone may crash leading to components malfunction. So it is
to neglect this, the barometer sensor is enclosed inside the
necessary to know the battery voltage. In order to find the
casing with holes drilled on the sides for the air to pass by.
battery voltage, a voltage divider circuit is used in the flight
The comparison at normal condition and light exposure
controller. The voltage divider converts the high voltage
condition is shown in the graph below. (For reference) The
number to smaller one. We need to convert high voltage to
test was done at an height of 20m.
smaller voltage because STM32 is 3.3V tolerant, any voltage
above 3.3V connected to STM32 will damage the board. So
a voltage divider circuit is used. The maximum output voltage
Fig.7. Flight Controller

Fig.5. Barometer Readings

The gyroscope readings from the flight controller are


gathered and tested to check the correctiveness. The
gyroscope gives pitch, roll and yaw values. The datas were
gathered by tilting the quadcopter in various degrees and
directions. The acquired datas a re then visualized and
represented in the graph as shown below.

Fig.8. Flight controller with quadcopter

REFERENCES
[1] HaiYang Chao, YongCan Cao, and YangQuan Chen, “Autopilots
for Small Unmanned Aerial Vehicles: A Survey,” International
Journal of Control, Automation, and Systems, Vol. 8, No.1,
pp.36-44, 2010.
[2] Emad Ebeid, Martin Skriver, Jie Jin, “A Survey on Open-Source
Flight Control Platforms of Unmanned Aerial Vehicle,”
Euromicro Conference on Digital System Design, 2017.
[3] Sarah Pontes Madruga, Augusto de Holanda B. M. Tavares,
Alisson Vasconcelos de Brito, Tiago Pereira Nascimento, “A
Project of an Embedded Control System for Autonomous
Quadrotor UAVs,” Brazilian Symposium on Robotics, 2018.
Fig.6. IMU Data [4] S. Sabikan, S. W. Nawawi, “Open-Source Project (OSPs)
Platform for Outdoor Quadcopter. Journal of Advanced Research
Design,” Vol. 24, No. 1, pp. 13-27, 2016.
[5] Zhaolin Yang, Feng Lin, Ben M. Chen, “Survey of Autopilot for
VI. CONCLUSION: Multi-rotor Unmanned Aerial Vehicles,” IECON 2016 - 42nd
Annual Conference of the IEEE Industrial Electronics Society,
The flight controller is developed by interfacing the pp. 6122-6127, 2016.
sensors and by implementing the PID control algorithm. The [6] H. Lim, J. Park, D. Lee, and H. J. Kim, “Build your own
telemetry system is also developed to monitor the flight datas quadrotor: Open-source projects on unmanned aerial vehicles,”
IEEE Robotics & Automation Magazine, vol. 19, no. 3, pp. 33–
when the drone is flying. The hardware and software 45, 2012.
operations of the flight controller are open and well known [7] Sangook Cho, Sanghyuk Park and Keeyoung Choi, “Autopilot
paving way for high customisation where the user can modify Design for a Target Drone using Rate Gyros and GPS,”
it according to their needs in future to accomplish any International Journal of Aeronautical and Space Science, Vol. 13,
No. 4, pp. 468-473, 2012.
application oriented tasks.
[8] Atheer L. Salihland and M. Moghavvemi, “Flight PID Controller
For future work, we can further use it for any application Design for a UAV Quadrotor,” Scientfic Research and Essays,
Vol. 5, No. 23, pp. 3660 – 3667, 2010.
oriented tasks such as using it for surveillance, agriculture, [9] C. Nam and S. Danielson, “Development of a Small UAV with
weather monitoring, etc. Nowadays usage of drones has been real-time video surveillance,” American Society for Engineering
vast in every industrial sector and finding new ways to Education, 2011.
incorporate for making their task easy. This project can be [10] H. Wu, D. Sun, and Z. Zhou, “Micro air vehicle: Configuration,
analysis, fabrication, and test,” IEEE/ASME Trans. on
very useful in research sectors and other areas to accomplish Mechatronics, vol. 9, no. 1, pp. 108-117, 2004
their needs of application by modifying the flight controller. [11] R. Beard, D. Kingston, M. Quigley, D. Snyder, R. Christiansen,
W. Johnson, T. Mclain, and M. Goodrich, “Autonomous vehicle
technologies for small fixed wing UAVs ,” AIAA J. Aerospace
Computing, Information, and Communication, vol. 2, no. 1, pp.
92-108, 2005.
[12] Rongbing Li, Jianye Liu, Ling Zhang, Yijun Hang,
“LIDAR/MEMS IMU integrated navigation (SLAM) method for
a small UAV in indoor environments,” DGON Inertial Sensors
and Systems (ISS), 2014.
[13] Bolun Zeng ,JIANBO ZHANG ,LANG CHEN ,YAO WANG,
“Self-balancing car based on ARDUINO UNO R3,” IEEE 3rd
Advanced Information Technology, Electronic and Automation
Control Conference (IAEAC), 2018.
[14] LAI Gui-chuan,HUANG Hua-wei, “Design of High Resolution
Pressure and Temperature Measurement System Based on
MS5611-01BA01,” Journal of Sichuan University of Science &
Engineering(Natural Science Edition, 2012.
[15] Aleksandar Rodi´c, Gyula Mester, and Ivan Stojkovi´c,
“Qualitative Evaluation of Flight Controller Performances for
Autonomous Quadrotors,” Intelligent Systems: Models and
Applications, pp. 115-134, 2013.
[16] Lozano, R., Castillo, P., Dzul, A., “ Stabilization of a mini
rotorcraft having four rotors,” IEEE/RSJ International
Conference on Intelligent Robots and Systems, Sendai, Japan,
pp. 2693–2698, 2004.
[17] Turczi, A., “Flight Control System of an Experimental
Unmanned Quad-Rotor Helicopter,”10th International
Symposium of Hungarian Researchers on Computational
Intelligence and Informatics, 2009.

You might also like