This project involved designing and building a real-time flight controller for a fixed-wing aircraft using an STM32L4A6ZG Nucleo board programmed entirely in bare-metal C. The system reads orientation data from an onboard IMU via I2C and applies a custom Kalman filter to estimate pitch, roll, and yaw angles with minimal noise and latency. A full PID control loop then computes actuator commands to stabilize flight, with precise PWM signals generated using TIM5. Live telemetry is streamed over UART, enabling real-time logging and in-flight tuning of PID gains. This project served as a rigorous test of embedded systems design, sensor fusion, and classical control theory, all grounded in low-level microcontroller architecture.
Microcontroller: STM32L4A6ZG Nucleo (bare-metal C)
Sensors: 6-DOF IMU (accelerometer, gyroscope)
Filtering: Custom Kalman filter for pitch/roll/yaw estimation
Control: PID loops for roll, pitch, yaw stabilization
Actuators: PWM output to control ailerons, rudder, and elevator
Telemetry: UART serial link, real-time PID tuning and flight data logging via MATLAB
Power: Li-Po battery, voltage regulators for 3.3V and 5V rails
Size: 324 mm × 96 mm × 50.3 mm
Weight: 1,360.7 g
Battery life: >18 hours
Servos: SG90, 5 V
IMU: MPU6050, 3.3 V, 1 kHz sample rate
Interfaces: UART (115200 baud), I²C (100 kHz), TIM5 (1 MHz)
Top View – full airframe layout with control surfaces
System Schematic
Code Flow Diagram
Results
SteadiFly successfully demonstrated real-time stabilization of pitch, roll, and yaw in a fixed-wing aircraft test rig.
The Kalman filter smoothed noisy accelerometer/gyroscope data, producing stable orientation estimates.
Independent PID controllers for each axis provided consistent corrective actuation through servos.
The UART interface allowed in-flight PID tuning and MATLAB logging, which accelerated testing and parameter optimization.
Lessons Learned
Sensor tuning is iterative: Calibrating gyroscope bias and tuning the Kalman filter required repeated test flights and log analysis.
Low-level I²C configuration (without STM32 HAL) was challenging, but ultimately gave tighter control over timing and reliability.
UART-based PID tuning avoided the need for constant code reflashing, saving hours of debug time.
Servo mapping and scaling were critical — improper ranges caused instability until carefully constrained.
Future improvements would include GPS integration for waypoint navigation, additional redundancy, and expansion toward a full autonomous flight controller.
Full SteadiFly Report
Click Image Above to View Code on GitHub