Implementing a flight controller for a small quadcopter. UAV is controlled through ELRS transmitter.
What's done:
- single roll/pitch PID control loop, stabilization using gyroscope (accro mode) readings.
- double roll/pitch PID control loop, stabilization using accelerometer/gyroscope readings.
- yaw stabilization using gyroscope readings.
- yaw stabilization using magnetometer/gyroscope readings.
- acceleration stabilization using accelerometer readings.
- configuration through wi-fi.
- altitude hold.
- dshot-300 ESC control protocol.
- IRC Tramp VTX control.
- telemetry through eLRS.
- terminal configuration tool.
- Qt5 based GUI configuration tool.
- MCU: STM32F405RGT6
- Crystall oscillator: 20 Mhz
- DC-DC converter for control board and camera: TPS5430
- Control board voltage regulator: AMS1117-3.3
- Accelerometer/Gyroscope: ICM-42688-P
- Magnetometer: QMC5883L
- Remote control: ERLS CRSF receiver
- Telemetry/debug/config: ESP8285
- Barometer: DPS368
-
pcb
-- the directory containing schematics for the flight controller and BEC:bottom.png
-- bottom side of flight controller board.top.png
-- top side of flight controller board.ground.png
-- ground layer of flight controller board.power.png
-- power layer of flight controller board.tps5430.JPG
-- DC-DC conveter used to convert battery voltage to 5 volts used by main board's input LDO and FPV camera.conponentvalues.txt
-- values and types for components on schematics.
-
additional
-- additional filesframe.dxf
-- quadcopter frame outline.
-
devices
-- drivers for devices used by the flight controller:device.h
-- main interface for a character device. Used by almost all devices in devices directory.uartconf.c
and `uartconf.h -- driver that receives and sends data through one of UART's used for configuration and debugging.bmp280.c
andbmp280.h
-- driver for a bmp280 barometer (currenty unused).crsf.c
andcrsf.h
-- driver for the CRSF protocol used by a ERLS receiver to interract with the main MCU through UART.esp8266.c
andesp8266.h
-- driver used to exchange data with esp8285 through SPI.hmc5883l.c
andhmc5883l.h
-- driver for an HMC5883L magnetometer (currently unused).hp206c.c
andhp206c.h
-- driver for a HP206C barometer.dps368.c
anddps368.h
-- driver for a DPS368 barometer.mpu6500.c
andmpu6500.h
-- I2C driver for mpu6050 and mpu6500 IMUs (accelerometer + gyroscope).qmc5883l.c
andqmc5883l.h
-- driver for an QMC5883L magnetometer.icm42688.c
andicm42688.h
-- driver for an icm42688 IMU (accelerometer + gyroscope).m10.c
andm10.h
-- driver for a M10 GNSS module.w25.c
andw25.h
-- driver for a w25q SPI flash.irc.c
andirc.h
-- driver for an IRC Tramp controlled VTX device.
-
main.c
-- all routines related to flight control. -
global.h
-- global values used in many places in source code. -
crc.h
-- CRC-8 implementation. -
stm32periph.c
andstm32periph.h
-- stm32 periphery initialization and error handling. -
util.c
andutil.h
-- common utility functions that can be used in more than one source file. -
dsp.c
anddsp.h
-- functions for PID control and data filtering like low-pass filtering and complimentary filtering. -
command.c
andcommand.h
-- configuration and informational commands processing API. -
timev.c
andtimev.h
-- periodic event processing API. -
uavconf/uavconf.c
-- configuration tool that works through wi-fi AP created by flight controller using UDP protocol. -
uavconf_gui
-- gui configuration tool:main.cpp
-- entry point for GUI configuration tool.mainwidget.cpp
-- implementation for Qt5 related functions.mainwidget.h
-- headers for Qt5 related functions.uavconf.c
anduavconf.h
-- API for UDP interaction with UAV.
-
all other
.c
,*.h
and*.s
files are generated by software.
Debug and configuration is performed through AP named copter
created
by this UAV. Listed commands should be sent using UDP/IP to address
192.168.3.1
.
r
-- turn off motorsc [altitude]
-- recalibrate and set altitude reference value.calib mag (on|off)
-- enter/escape magnetometer calibration modeflash (write|read) {N}
-- write/read settings into/from MCU's internal flash slot '{N}'.system esp (flash|run)
-- set onboard wi-fi chip to flash/run mode.info (mpu | qmc | hp | | dev | values | pid | gnss | ctrl | filter)
-- get various values and infomation:mpu
-- ICM-42688-P IMU data.qmc
-- QMC5883L magnetometer data.dev
-- all devices status.values
-- configuration values.pid
-- PID values.gnss
-- M10 GNSS data.ctrl
-- eLRS remote configuration values.filter
-- complimentary and LPF filters configuration values.
log set {l}
-- set log length to{l}
records and if{l}
greater than0
start logging. If{l}
is0
, stop logging.log rget {b} {e}
-- get log records whose number starts from{b}
and end with{e} - 1
.log bget {n1}...{nN}
-- get batch of log records with numbers{n1}...{nN}
.log freq {val}
-- set log frequency.log record size {val}
-- set log record size.log {N} {name}
-- set '{N}'-th log field to value named '{name}'.pid (tilt|yaw) mode (single/double)
-- switch to single/double PID loop mode for tilt/yaw.pid (tilt|stilt|yaw|syaw|throttle/climbrate/altitude) (p|i|d) {val}
-- set PID controller values:tilt
-- tilt PID controler P/I/D value.stilt
-- pitch/roll rotation speed PID controller P/I/D value.yaw
-- yaw PID controller P/I/D value.syaw
-- yaw rotation speed PID controller P/I/D value.throttle
-- acceleration PID controller P/I/D value.climbrate
-- climb speed PID controller P/I/D value.altitude
-- altitude PID controller P/I/D value.
compl (attitude/yaw/climbrate/altitude) {val}
-- set complimentary filters time constants:attitude
-- filter that mixing accelerometer and gyroscope data to get pitch/roll value.yaw
-- filter that mixing gyroscope and magnetometer data to get yaw value.climb rate
-- filter that mixing acceleromter interated data and barometer data to get climb speed value.altitude
-- filter that mixing climb rate value and barometer data to get altitude value.
lpf (gyro/accel/d/climb) {val}
-- set low-pass filter's time constant for gyroscope/accelerometer/d/vertical acceleration.adj (rollthrust/pitchthrust) {val}
-- adjust motors thrust.adj (roll|pitch|yaw) {val}
-- set offset for roll/pitch/yaw (only for dual PID loop mode).adj acc (x|y|z) {val}
-- set x/y/z offset for acceleromteradj gyro (x|y|z) {val}
-- set x/y/z offset for gyroscopeadj mag (x0|y0|z0|xscale|yscale|zscale|decl) {val}
-- set x/y/z offset, x/y/z scale or magnetic declination for magnetometeradj curr (offset|scale) {val}
-- set current meter offset/scale value.adj althold hover {val}
-- set hover throttle.ctrl (roll|pitch) {val}
-- set maximum roll/pitch tilt value in radians.ctrl (sroll|spitch) {val}
-- set roll/pitch rotation speed in for single loop mode in radians.ctrl (syaw|yaw) {val}
-- set yaw rotation speed for single/double loop mode in radians.ctrl accel {val}
-- set maximum acceleration for throttle loop.ctrl climbrate {val}
-- set maximum climb rate in m/s.ctrl altmax {val}
-- set maximum altitude in meters.
Log records got by commands log rget
and log bget
are just lines
with set of space separated numeric strings and have such format:
{CRC} {number} {v0} ... {vN}
, where {CRC}
is CRC-8 sum of record line, {number}
-- record
number and {v0} ... {vN}
-- N record values.
- Motors: 1404, 3800 kV
- Props: 3030
- Battery: 14.8v (4s), 1300 mAh, 120c
- Frame: carbon fiber
- PCB and camera: 20g
- ESC: 30g
- Motors + props: 48g
- Battery: 148g
- BEC: ~6g
- Antenna: 10g
- Frame: ~114g
- Total weight: 376g