Skip to main content
Version: FILS English

Tricopter Drone

A Real-Time Flight Control System for a Tricopter.

info

Description

A Real-Time Flight Control System written in Rust for a drone of type "Tricopter" build on a STM32U545RE-Q that reads data from multiple sensors such as: BMP280 for athmospheric pressure, CM-20948 as an inertial measurement unit. For communication through Wi-Fi/Bluetooth an ESP32-C3 FH4 super mini will be used. The ESP32 will receive the movement desired for the tricopter and will pass it to the Nucleo. A metal-gear servo is used to control the tilt of the rear motor and stabilize the drone. The frame is custom made from readily available materials.

Motivation

I always liked drones, wanted to build one but the classic quadcopter felt a bit too common. I chose the tricopter because of the way it achieves the yaw control, through a servo, by tilting the rear motor instead of relying on differential thrust as quadcopters do. I also wanted a challenge for the hardware part, building it from scratch.

Architecture

Block Diagram

       [POWER SECTION]                       [CONTROL SECTION]

+-----------------------+ +-----------------------+
| 11.1V LiPo Battery | | HOST PC |
| 2200mAh 30C (3S) | | (Debugging) |
+-----------+-----------+ +-----------+-----------+
| ^
| (Raw Power) [USB]
v |
+-------------------+ v
| Matek Mini PDB | +----------------------------+
| (12V / 5V Regs) | | NUCLEO STM32U545RE-Q |
+---+-------+-------+ +---------->| (Main Microcontroller) |
| | | +---+--------+--------+------+
| | [5V REG] | | | |
| +-----------+ | [I2C] [SPI]
| | | |
| [12V] | v v
| | +-------+ +---------+
v | |BMP280 | |ICM-20948|
+--------------+ | +-------+ +---------+
| 3x ESC 30A |<-------- [PWM SIGNALS] ---+
| (w/ BEC) | | +---------------+
+---+---+------+ | | ESP32-C3 FH4 |
| | +<-->| (Wi-Fi/UART) |
| | [3-WIRE PHASE] | +---------------+
| v |
| +--------------+ | +---------------+
| | 3x BRUSHLESS | | | HC-SR04 |
| |1000kV MOTORS | +--- | (Trig/Echo) |
| +--------------+ | +---------------+
| |
| [5V BEC Out] | +---------------+
| (Servo Power) +--- |Buzzer Modules |
v | | (GPIO) |
+--------------+ | +---------------+
| S007 Servo |<-------- [PWM SIGNAL]-----+
+--------------+

Pin Mapping

    +-----------------------+          +----------------------------+
| 11.1V LiPo Battery | VBAT | Matek Mini PDB |
| 2200mAh 30C (3S) +--------->| High Current Input |
+-----------------------+ +----------------------------+

+-----------------------+ +----------------------------+
| Matek Mini PDB | 5V Reg | NUCLEO-U545RE-Q |
| (Power Distribution) +--------->| 5V/GND Pins |
+-----------+-----------+ +----------------------------+
|
| 12V / VBAT Out / GND +----------------------------+
+--------------------->| 3x ESC 30A |
| (Motor Controllers) |
+-------------+--------------+
|
v
3x Brushless Motors

+-----------------------+ +----------------------------+
| 3x ESC 30A | PWM1 <--+ PA1 - Timer PWM Output |
| (Signal Controllers) | PWM2 <--+ PB5 - Timer PWM Output |
| | PWM3 <--+ PA6 - Timer PWM Output |
+-----------------------+ +----------------------------+

+-----------------------+ +----------------------------+
| S007 Servo | PWM <--+ PA0 - Timer PWM Output |
| (Tilt/Yaw) | 5V <--+ ESC 5V BEC (Power) |
+-----------------------+ +----------------------------+

+-----------------------+ +----------------------------+
| ICM-20948 | SCK <--+ pin TBD |
| (9-Axis IMU) | MOSI <--+ pin TBD |
| | MISO -->+ pin TBD |
| | CS <--+ pin TBD |
+-----------------------+ +----------------------------+

+-----------------------+ +----------------------------+
| BMP280 | SCL <---+ pin TBD |
| (Barometer) | SDA <-->+ pin TBD |
+-----------------------+ +----------------------------+

+-----------------------+ +----------------------------+
| ESP32-C3 FH4 | TX -->+ pin TBD |
| (Wi-Fi/BT) | RX <--+ pin TBD |
+-----------------------+ +----------------------------+

+-----------------------+ +----------------------------+
| HC-SR04 | Trig <--+ pin TBD |
| (Ultrasonic) | Echo -->+ pin TBD |
+-----------------------+ +----------------------------+

+-----------------------+ +----------------------------+
| Buzzer Modules | SIG <--+ pin TBD |
| | | |
+-----------------------+ +----------------------------+

Log

Week 4-5

I documented about the hardware and software part of the project, chose the components and ordered them.

Week 6-7

Took measurements of the hardware, builded the frame from scratch and soldered all the wires I needed, the sensors, voltage dividers.

Week 8

Connected the motors, servo, sensors to the STM32 to check they are working as intended.

Hardware

The main component is the Nucleo STM32U545RE-Q board that acts as the flight controller with data based from: BMP280 - measures the air pressure and determines how high is it, CM-20948 9 axis to get the acceleration, gyroscope and compass data, HC-SR04 to measure distance at low altitudes. ESP32-C3 FH4 super mini handles the Wi-Fi and Bluetooth connectivity in order to control the drone remotely. Three 30Amps ESCs to control each 2212 1000kV brushless motor. All of them are powered from a 2200mAh 11.1V 30C battery through a Matek Mini Power Hub and a voltage divider is put at the exit of the power distribution board to measure the voltage that comes out of the battery. Two passive buzzers are used to alert when battery is below a certain limit.

Photos

Hardware image

Schematics

Place your KiCAD or similar schematics here in SVG format.

Bill of Materials

DeviceUsagePrice
STM32U545RE-QThe main microcontroller used106.59 RON
ESP32-C3 FH4 super miniWi-Fi/Bluetooth communication module26.03 RON
BMP280Atmospheric pressure sensing7.54 RON
CM-20948 9 axisInertial measurement unit (IMU)36.72 RON
3 * Brushless motors A2212/13T 1000KVPropulsion motors149.8 RON
Matek Mini Power Hub PDBPower distribution board32.57 RON
DSPOWER S007M Mini ServoTilts rear motor for stabilization/yaw control67.85 RON
3 * 1045 Gemfan Propellers ABSPropellers26.91 RON
2 * XT60 connectorsPower connectors15.74 RON
3 * ESC 30AElectronic speed controllers138.24 RON
LiPo Battery 11.1V - 30C 3S1PPowering the hardware100 RON
HC-SR04 SensorUltrasonic sensor to measure distance6.73 RON
2 * Passive Buzzer ModuleSounds for alerts such as low battery6.44 RON

Software

LibraryDescriptionUsage
icm20948Driver for IMUDecodes raw electrical signals
bmp280-rsBarometer driverConverts raw air pressure readings
pidLoop ControlIt calculates thrust to stabilize the drone
micromathAdvanced math libraryProvides optimized math functions to calculate tilt and orientation
ahrsSensor data fusionCombines Accelerometer, Gyro and Magnetometer data filtering out noise
cortex-mCortex low-level supportLow-level CPU features on the STM32U545RE-Q
cortex-m-rtCortex-M runtimeStartup/interrupt
defmtLogging framworkStructured logging from firmware
defmt-rttRTT logging transportSends defmt logs via RTT
panic-probePanic handlerPrinting panic info
embedded-halHardware abstractionStandard traits used by drivers
embassy-executorAsync task executorRun async tasks
embassy-timeTimers and delaysTimeouts, delays
embassy-syncAsync synchronizationChannels to pass sensor data safely
embassy-stm32STM32 HalHardware control
embassy-embedded-halEmbassy enbedded-hal adaptersLets embedded-hal based drivers work with Embassy objects
  1. Embassy Book
  2. BMP280 Data Sheet
  3. ICM20948 Documentation