Skip to content

STM32F4-based Quadcopter Flight Controller running μC/OS-II RTOS.

Notifications You must be signed in to change notification settings

AoligeiY/Quadcopter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quadcopter Project

Craft

📌 Overview

This project is a Quadcopter firmware based on the STM32F401RET6 microcontroller and the uC/OS-II Real-Time Operating System. Originally developed using Keil MDK, it has been fully ported to the Linux environment and supports building with CMake and the GCC toolchain.

Key features include sensor data acquisition (MPU6050, HMC5883L), attitude estimation (Madgwick/Mahony AHRS), PID attitude control, and ground station communication.

🛠 Hardware Specifications

Component Model/Specs Notes
MCU STM32F401RET6 Cortex-M4F, 84MHz, 512KB Flash, 96KB RAM
IMU (Accel/Gyro) MPU6050 Integrated on GY-86 module
Magnetometer HMC5883L Integrated on GY-86 module
ESC Hobbywing Skywalker 20A
Motor XXD 2212 (1000KV)
Battery Gens Ace Li-Po 3S 2200mAh 30C
Remote Controller Microzone MC6C 2.4G 6-Channel
Receiver Microzone MC6RE-V2 2.4G 6-Channel
Wireless HC-05 Bluetooth Module For debugging and telemetry

📂 Project Structure

The project has been refactored with a clean and logical directory structure:

.
├── Application         # Application Layer
│   ├── Algorithm       # Algorithms (AHRS, PID, Calibration)
│   ├── Sensors         # Sensor Drivers (MPU6050, HMC5883L)
│   ├── Peripheral      # Peripheral Drivers (PWM, IIC, LED, Serial, OLED)
│   ├── Src             # Main Logic (main.c, Tasks)
│   └── Inc             # Common Headers
├── Drivers             # Hardware Abstraction Layer
│   ├── CMSIS           # Cortex-M4 Core Support & Startup Code
│   └── STM32F4xx_StdPeriph_Driver # ST Standard Peripheral Library
├── uCOS-II             # RTOS Kernel
├── CMakeLists.txt      # CMake Configuration
└── arm-none-eabi-gcc.cmake # Toolchain File

🚀 Getting Started

1. Prerequisites

Ensure you have the following tools installed on your Linux system:

  • CMake (>= 3.16)
  • GNU Arm Embedded Toolchain (arm-none-eabi-gcc)
  • Make or Ninja

Ubuntu example:

sudo apt update
sudo apt install cmake gcc-arm-none-eabi build-essential

2. Build

# 1. Create and enter build directory
mkdir build && cd build

# 2. Generate Makefile
cmake ..

# 3. Build (using multi-core)
make -j$(nproc)

Upon successful compilation, the following files will be generated in build/:

  • Quadcopter.elf: ELF file with debug info
  • Quadcopter.hex: Intel HEX firmware
  • Quadcopter.bin: Binary firmware

3. Flash

You can use OpenOCD or STM32CubeProgrammer to flash the firmware.

Using OpenOCD (ST-Link):

openocd -f interface/stlink.cfg -f target/stm32f4x.cfg -c "program build/Quadcopter.elf verify reset exit"

💻 Software Architecture

Key Features

  • RTOS: Ported uC/OS-II with multi-task scheduling (Angle, Motor, Com, LED).
  • Attitude Estimation: Supports Madgwick and Mahony complementary filter algorithms for 9-axis sensor fusion.
  • Control Algorithm: Cascaded PID control algorithm for stable flight.
  • Communication: Supports the ANO (Anonymous) Ground Station protocol for real-time waveform display and PID tuning.

Tasks

  • Task_Startup: System initialization and sensor calibration.
  • Task_Angel: Sensor reading, AHRS calculation, and PID control.
  • Task_Motor: Motor PWM output control.
  • Task_Com: Ground station communication.
  • Task_LED: LED blink.

About

STM32F4-based Quadcopter Flight Controller running μC/OS-II RTOS.

Topics

Resources

Stars

Watchers

Forks

Languages