Quadcopter with Custom Flight Controller (WIP)

C, MATLAB, Simulink, FreeRTOS

Main project image

Built and programmed a custom quadcopter with a custom flight controller built around an ESP-32.

CAD & Modeling

I am in the process of building and programming a custom quadcopter with a custom flight controller. I began the process by choosing electronic components and creating a basic CAD model of the design. After estimating the weight, moment of inertia, and motor parameters, I created a model of the drone and its sensors using MATLAB and Simulink. This helped me plan the structure of the control system and determine initial tuning parameters. For the first iteration, I used basic filters and Riemann integration for the attitude estimation, and PID for the control.

Image of Simulink model of drone and control system

Custom Flight Control Code

For the flight controller I opted to use an ESP32 devboard, along with an external chip containing a 6 axis IMU and a magnetometer. The flight control code was programmed in C using FreeRTOS based on parameters determined from the Simulink modeling. It has interrupt-driven IMU data reception, and tasks to receive controller input wirelessly, estimate the attitude using an EKF, and generate control inputs for the motors using the PID controllers. The code calibrates the IMU in order to account for drift and uses gravity from the accelerometer as a weak absolute angle measurement. I am currently in the process of finishing the electronics and adding magnetometer readings to the EKF.

The Future

I am still in the progress of developing this, and have not tested it in flight yet. The primary reason for this is that I have not soldered the power electronics yet. After that, I will test in flight, and possibly retune the controller. Other improvements I plan to make in the future: