8000 GitHub - PinkFluffyUnic0rn/stm32flight: Flight controller for a small quadcopter
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PinkFluffyUnic0rn/stm32flight

Repository files navigation

STM32 Flight controller

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.
  • telemetry through eLRS.

Devices

  • 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: ESP8266 (ESP-07)
  • Barometer: HP206C

Project structure

  • additional -- the directory containing schematics for the flight controller and BEC:

    • side1.png -- first side of flight controller board that is faced down.
    • side2.png -- second side of flight controller board that is faced up.
    • tps5430.JPG -- DC-DC conveter used to convert battery voltage to 5 volts used by main board's input LDO and FPV camera.
  • 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.
    • bmp280.c and bmp280.h -- driver for a bmp280 barometer (currenty unused).
    • crsf.c and crsf.h -- driver for the CRSF protocol used by a ERLS receiver to interract with the main MCU through UART.
    • esp8266.c and esp8266.h -- driver that process AT command used to interact with an esp8266 (esp-07 board to be precise) throught UART.
    • hmc5883l.c and hmc5883l.h -- driver for an HMC5883L magnetometer (currently unused).
    • hp206c.c -- driver for a HP206C barometer.
    • mpu6500.c and mpu6500.h -- I2C driver for mpu6050 and mpu6500 IMUs (accelerometer + gyroscope).
    • qmc5883l.c and qmc5883l.h -- driver for an QMC5883L magnetometer.
    • icm42688.c and icm42688.h -- driver for an icm42688 IMU (accelerometer + gyroscope).
    • m10.c and m10.h -- driver for a M10 GNSS module.
    • w25.c and w25.h -- driver for a w25q SPI flash.
  • main.c -- all routines related to flight control.

  • dsp.c and dsp.h -- functions for PID control and data filtering like low-pass filtering and complimentary filtering.

  • uartdebug.c and uartdebug.h -- uartprintf function for debugging.

  • all other files are generated by software.

  • rc/rc.c -- configuration tool that works through wi-fi connection created by flight controller.

UAV commands

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.

  • info (mpu | qmc | hp | values | pid) -- mpu6050/qmc5883L/hp206c/control values/PID data
  • r -- turn off motors
  • c [altitude] -- recalibrate
  • calib mag (on|off) -- enter/escape magnetometer calibration mode
  • pid (tilt|stilt|yaw|syaw|throttle/climbrate/altitude) (p|i|d) {val} -- set tilt/tilt speed/yaw/yaw speed/throttle/climb rate/altitude PID P/I/D value.
  • pid (tilt|yaw) (single/double) -- switch to single/double PID loop mode for tilt/yaw
  • compl (attitude/yaw/climbrate/altitude) {val} -- set complimentary filter's time constant for attitude/yaw/climb rate/altitude.
  • lpf (climb|vaccel/altitude) {val} -- set low-pass filter's time constant for climb speed/vertical acceleration/altitude.
  • 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 acceleromter
  • adj gyro (x|y|z) {val} -- set x/y/z offset for gyroscope
  • adj mag (x0|y0|z0|xscale|yscale|zscale|decl) {val} -- set x/y/z offset, x/y/z scale or magnetic declination for magnetometer
  • ctrl (roll|pitch) {val} -- set maximum roll/pitch tilt value 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.
  • flash write -- write settings into MCU's internal flash.

Quadcopter parameters

  • Motors: 1404, 4600 kV
  • Props: 3016
  • Battery: 15.4v (4s), 1100 mAh, 60c
  • Frame: plywood

Quadcopter Weight

  • PCB: ~30g
  • ESCs: ~27g
  • Motors + props: ~53g
  • Battery: 88g
  • BEC: ~5g
  • Antenna: ~10g
  • Frame: ~60g
  • Wires: ~30g
  • Total weight: 303g
0