Red Pitaya Blog

Building an FPGA Flight Controller with Sensor Fusion: A Student's Journey to Auto-Stabilized Drone Flight

Written by Red Pitaya Team | Nov 18, 2025 8:00:00 AM

How a recent University of Kentucky graduate combined his passion for drones and FPGAs to create an autonomous flight stabilization system 

Introduction 

Imagine a drone that can maintain perfectly stable hovering even in windy conditions—correcting its position in real-time without pilot intervention. That's exactly what Matthew Poff set out to create with his FPGA Flight Controller with Sensor Fusion project for the AMD Open Hardware Competition. 

As a recent Computer Engineering graduate from the University of Kentucky, Matthew combined his love of drones with FPGA development to tackle a real-world problem: how to keep drones stable for imaging and flight operations in harsh weather conditions. 

The Challenge: Create a flight controller that gathers gyroscopic data from an inertial measurement unit and generates real-time PWM outputs to motors, automatically correcting the drone's orientation to maintain level flight. 

The Solution: A custom Verilog-based flight controller on the Zybo 7020 FPGA board that processes 9-axis sensor data and calculates corrective motor commands in real-time. 

Project Timeline: 5 months of solo development 

Problem Statement 

Drone pilots and operators face a persistent challenge: maintaining stable hovering positions during imaging operations or flights in rough weather. Wind gusts and turbulence can cause drones to drift or tilt, compromising image quality and flight safety. 

Traditional flight controllers exist, but Matthew wanted to explore FPGA-based solutions for their potential speed advantages and real-time processing capabilities. The goal was to create a system where a sensor could be rotated or positioned anywhere on the gyroscopic Y-axis, causing the motors to automatically adjust their speed to return the drone to straight and level flight. 

Project Development 

System Architecture 

Matthew's flight controller operates through a carefully orchestrated sequence: 

  1. Data Acquisition: An MPU-9250 inertial measurement unit captures 9-axis data (three sensors across three axes: gyroscope, accelerometer, and magnetometer) 
  1. SPI Communication: Sensor data transmits to the FPGA board via SPI protocol 
  1. Dual State Machine Processing:  
  1. Formatting FSM: Processes data for display and sends it via UART to PuTTY for monitoring 
  1. Control FSM: Parses gyroscopic Y-axis data and calculates corrective motor commands 
  1. PWM Generation: Dedicated PWM generation code for left and right motors calculates and updates duty cycles to return the board to level flight 

Hardware Setup 

  • FPGA Board: Zybo 7020 
  • Sensor: MPU-9250 IMU (9-axis inertial measurement unit) 
  • Motors: Two motors for left and right side control 
  • Development Tool: Xilinx Vivado 
  • Monitoring: Red Pitaya STEMlab 125-14 for lab instrumentation 

Communication Protocols 

Two critical communication channels enable the system: 

  • SPI Protocol: Transmits sensor data from the IMU to the FPGA board 
  • UART Protocol: Sends formatted data to PuTTY for real-time monitoring and debugging 

Challenges and Solutions 

The SPI Communication Hurdle 

"The biggest challenge was definitely trying to set up the SPI communication used between the sensor and the FPGA board and setting up the UART between the board and PuTTY," Matthew explains. 

Getting the communication protocols working required careful attention to timing, data formatting, and establishing proper instantiations between modules. These inter-module connections proved particularly tricky during initial testing phases. 

Hardware Selection Issues 

Another early setback came from component selection. Matthew discovered issues with his initial sensor purchase due to missing critical information in the specifications. This taught him a valuable lesson: "Do some further investigating into all parts before you buy them." 

Results 

Indoor testing demonstrated the system's core functionality: 

  • Baseline State: Both motors maintained a 50% duty cycle when the board was level 
  • Corrective Response: Upon rotating the board 45 degrees, one motor automatically increased its duty cycle from 50% to 56% as part of the correction protocol 
  • Real-time Processing: The system successfully processed sensor data and updated motor commands continuously 

While indoor testing conditions limited the magnitude of results, the proof of concept clearly demonstrated the flight controller's ability to detect orientation changes and generate appropriate corrective responses. 

Technical Implementation 

Matthew implemented the entire system in Verilog, creating a multi-nested code structure that handled: 

  • Real-time sensor data acquisition 
  • Protocol communication management 
  • State machine control logic 
  • PWM signal generation 
  • Continuous duty cycle calculations 

The Red Pitaya STEMlab 125-14 played a crucial supporting role, providing all necessary lab instruments in a compact, network-accessible package that could be monitored from his workstation. 

Lessons Learned 

Looking back on the five-month development process, Matthew identified several key insights: 

What He'd Do Differently: "I would have likely done SystemVerilog instead next time, because it is more sophisticated and would lead to far less redundancies and less timing errors." 

Advice for Other Students: 

  • Research all components thoroughly before purchasing 
  • Pay attention to specification details that might impact implementation 
  • Consider more advanced HDL options like SystemVerilog for complex projects 
  • Plan communication protocol implementation carefully—it's often more challenging than expected 

Future Directions 

This project lays the groundwork for several potential enhancements: 

  • Full outdoor flight testing on an actual drone platform 
  • Integration of additional sensor fusion algorithms using accelerometer and magnetometer data 
  • Expansion to full 3-axis stabilization control 
  • Implementation of more sophisticated PID control algorithms 
  • Transition to SystemVerilog for improved code efficiency 

Conclusion 

Matthew's FPGA Flight Controller demonstrates how FPGA technology can address real-world challenges in drone operations. By combining sensor fusion with real-time FPGA processing, he created a system capable of autonomous flight stabilization—a critical capability for professional drone applications from aerial photography to search and rescue operations. 

The project showcases the practical application of digital design concepts: communication protocols, state machines, PWM generation, and real-time control systems. For students interested in embedded systems, FPGAs, or drone technology, this project offers valuable insights into the challenges and rewards of hardware-software integration. 

Resources 

Project Documentation: