Drone

Description

The aim of this project is to design and build a quadcopter drone where I would use as few pre-made components as possible. This includes creating the software and circuit board of the flight controller, designing a frame that can be made with no tools and choosing pre-made components (e.g. motors & propellers) which work well together for optimal performance.
I used an iterative approach to the development. This allowed me to test different ideas to gain a greater understanding of how different parameters affected performance in a real world environment. This approach enabled me to be flexible in the design to get the best optimisation possible.

Skills

When I started this project, I knew very little about how drones worked and I enjoyed learning about different components and how they work together.


Design

  • The frame was 3D printed to allow for easy iteration
  • Strength tests were performed to get optimal shape and print settings
  • Flight controller PCB was designed to fit an STM32 in a reasonable footprint
  • Flight controller designed for future use through GPIO and software
  • Flight controller software includes interfacing with sensors and a PID loop
  • Easily configurable through a json file
  • Flight data is logged during flight and can be displayed with grafana
  • Components were tested to find optimal configuration

Build

  • Iterative development allowed for ideas to be validated or discarded quickly
  • Flight controller started off as a basic breadboard, then evolved into a custom PCB
  • The software went through multiple iterations to find what was neede to make the most elegant solution
  • The manufacturing of the frame and assembly was simple due to its design

Deliver

  • Learned how each aspect of the drone works and how they fit together
  • Flight controller software is reliable and can be expanded for use in other projects
  • The controller and radio works consistently
  • The drone's behaviour is predictable which allows for easy troubleshooting and development
  • All the components work together to allow the drone to fly smoothly

Closer Look

The drone flies by spinning four propellers with brushless motors.
Due to the un-aerodynamic shape of quadcopters they are not stable in the air (unlike planes) meaning there needs to be constant adjustments made to the speed of the motors.
The flight controller uses sensors to get the state of the drone (eg rotation) then calculates what speeds the induvidual motors need to spin at, in order to effectively control the drone.
Then the flight controller sends a signal to the electronic speed controllers (ESCs) to set the motor speed.

Diagram showing the main components of the drone and how they are connected:


Different sections of the project are: flight controller, frame, propulsion and main circuit, explained below.

Some pictures of the latest version of the drone:

Drone in flight

An older versions of my drone:

Frame

The frame is the superstructure that all parts of the drone are attached to. It must be rigid and withstand crashing whilst also not being too heavy for the drone.
It is fully 3D printed out of PLA which allows me to not be restricted by size or shape of stock materials and is more consistant than hand tools.

This is the centre of my drone where the four arms, battery holder and electronics are attached to.


I decided to split up the arms from the centre partly due to the maximum size of the printer and it also allows arms to be swapped out if they are damaged or need upgrading.
The arms main function is to hold the motor and propellers, they also have landing legs on the bottom of them.


This is the battery holder which also doubles as a cover for the electronics.
It is placed on top of the drone to help put the centre of mass as close to the propellers as possible which gives them more control so the drone can be more stable.

Flight Controller

The flight controller is the brain of the drone; its main function is to control the state of the drone.
I created the printed circuit board (PCB) and wrote custom software to use the hardware on the PCB and control the devices connected to it.
I designed the board so it can control a large variety of devices therefore I would only need to develop one board for multiple projects. The name of the board is All Purpose Hardware Interface Board (AlPHI B).
It uses an STM32H7 microcontroller because it has a large amount of pins, good processing power and lots of supported software.
The board has multiple sensors: the accelerometer, gyroscope and magnetometer are all used to get the orientation and a barometer for altitude.

Software Loop

The drone knows its state at all times, it knows this by reading the separate sensor values then combining them together to get the state of the drone.
A kalman filter is applied to take out most of the noise from the signal.
It then calculates the difference, or deviation, of where it should be and where it is. It uses deviations to generate corrective commands in order to get the drone to the correct state.
They are generated by using PID control which uses proportional, integral and derivative calculations. Using all three together allows for accurate control.
The user can control where the drone should be by using a controller.
The corrective commands are sent to the speed controller using OneShot125. This is a protocol which sends a pulse between 125 and 250 microseconds long allowing for a maximum rate of 4kHz.
This has a higher refresh rate than normal servo PWM (max 500hz) and is much simpler to implement than digital protocols eg DShot.

Configuration and Logging

The flight controller has an SD card which does two things: log data and load settings. The configuration can be loaded from a json file containing settings for sensors, motors, PID settings and more. This is very useful because the settings are in a clear format and it allows the settings to be changed without having to re-compile and upload any code.
Each loop data is written to a log on an SD card. Info such as time, attitude, PID values and input are logged. This is very useful to figure out what went wrong/underperformed and allows for diagnosing and testing of features.
The values are stored in binary rather than text. This is due to conversion from variables to text takes a lot of time, also it saves space which means longer flights can be logged and writing less data takes less time.
After each flight the data is converted into text and saved to a csv file. This can be imported into Grafana to show graphs like the one below:

Voltage Regulation and Protection

There are two voltage regulators on the board for 5V and 3.3V. These have a large voltage input range (6 - 28V) and high current rating (10A), more than other flight controllers, to allow for most setups to be compatible.
Switching regulators were used because of higher maximum current and higher efficiency throughout the entire input range with the downside of a more complicated PCB design.
I need the large current capacity to drive motors and other devices. This means during the PCB design I had to take into account the trace thickness and via size.
The board has multiple protection features such as reverse polarity protection, fuses (for the whole board and for induvidual components) and diodes to protect from overvoltage from incorrect wiring.

Additional Features

The flight controller includes some extra features and expandability, allowing potential use in other projects.
These features include output such as an RGB LED which shows the status of the drone. There is also a buzzer which can be used to alert people around the device or to help find it.
Up to 13 motors can be attached to the board at one time The high current screw terminals control three channels with up to 2 amps each. For example they could be used for high power LEDs as headlights.
The board has four connectors with a total of 17 GPIO pins. These connectors also have one I2C, one SPI and two UART channels for external devices eg GPS modules.

Printed Circuit Board

Empty PCB of the flight controller:

The front and back of the flight controller:


Schematic:



PCB in KiCad:

Propulsion

The propulsion includes the ESCs, motors and propellers.
The ESC sets the motor speed according to the signal sent from the flight controller.
I chose a 4-in-1 ESC which is able to control all four brushless motors which spin the propellers.

The ESC with all four motors soldered to it:


Mounted motor with propeller attached:

Creating the Project

Each section of the project was developed in parallel so they were improved to both better suit their own function and to help improve other sections.
This means each section has its own version number and may not line up with other versions.

I grouped the flight tests into series, each series having a purpose that it wanted to achieve.

Flight Controller (electronics)

Version 1

Version 2

Version 3

Version 4

Flight Controller (software)

Version 0.1

Version 0.2

Version 0.3

Version 0.4

Version 0.5

Version 0.9

Version 1.0

Frame

Version 0 and Tests

Version 1

Version 2

Version 3

Arm Tests

Version 4

Propulsion and Main Circuit

I used the first set of propulsion to find out how ESC works and to test battery, motor and propeller works as needed.
I wanted to test the thrust of the propellers without having to risk the drone so I devised a thrust stand.

Old Thrust Stand

New Thrust Stand

Choosing New Propulsion

New Thrust Tests

Looking Forward

Files and Links

Source Code (flight controller)
Source Code (radio controller)
Source Code (ESC tester)
Photos, Videos and 3D files