Drone firmware: Difference between revisions
Line 21: | Line 21: | ||
==Drone control firmware== | ==Drone control firmware== | ||
The firmware is built on Arduino (Teensyduino) libraries for all low-level handling of interfaces. | |||
===Arduino version === | ===Arduino version === | ||
Line 29: | Line 27: | ||
Arduino version 1.8.13 (specifically the interrupt based ADC library for Teensy) requires at least GCC version 10 to compile. | Arduino version 1.8.13 (specifically the interrupt based ADC library for Teensy) requires at least GCC version 10 to compile. | ||
But changing a few 'constexpr' to 'inline' makes it compile on GCC version 9.3 and work - maybe with a slightly larger code. | But changing a few 'constexpr' to 'inline' in the ADC library makes it compile on GCC version 9.3 and work - maybe with a slightly larger code. | ||
=== Drone control firmware === | === Drone control firmware === | ||
Line 35: | Line 33: | ||
The firmware is in the "drone_ctrl" directory. | The firmware is in the "drone_ctrl" directory. | ||
To compile the source for a Teensy 3.5 or 3.6 the | To compile the source for a Teensy 3.5 or 3.6 the Teensyduino needs to be installed first. | ||
Install | Install Teensyduino, see https://www.pjrc.com/teensy/td_download.html . | ||
Start with installing the most recent supported version of Arduino, then overlay this by installing the Teensiduino. | Start with installing the most recent supported version of Arduino, then overlay this by installing the Teensiduino. | ||
Revision as of 16:32, 4 June 2021
Back to Drone control
Functional overview
Figure. Overall data flow for the drone flight controller. Most blocks also refer to tabs in the GUI (drone_gui).
Figure. The main software functions. Orange blocks are sensor and communication io. Green if the primary measurement and reference (set-point) data (Roll, Pitch, Yaw, Height and possibly lateral velocity. Pink blocks are other software functions. Gray is for configuration and calibration. Yellow blocks are PID control. Diagnosis is mostly battery voltage, but with the capability of measuring temperature and (with internal and external sensor) and current with external sensors.
The pose holds 4 values (roll, pitch, yaw and height). The roll, pitch and yaw position is estimated by the Madgwick filter. The raw gyro values are used as velocity measurement directly and as the D-term by the angle controllers.
Calibration of the gyro and accelerometer is built in. Calibration of the magnetometer is using an external tool (saving the calibration result directly in the onboard flash for the Madgwick filter).
Figure. The PID control blocks all have these functionalities. The yellow circles indicate logging interfaces.
Drone control firmware
The firmware is built on Arduino (Teensyduino) libraries for all low-level handling of interfaces.
Arduino version
Arduino version 1.8.13 (specifically the interrupt based ADC library for Teensy) requires at least GCC version 10 to compile.
But changing a few 'constexpr' to 'inline' in the ADC library makes it compile on GCC version 9.3 and work - maybe with a slightly larger code.
Drone control firmware
The firmware is in the "drone_ctrl" directory.
To compile the source for a Teensy 3.5 or 3.6 the Teensyduino needs to be installed first.
Install Teensyduino, see https://www.pjrc.com/teensy/td_download.html . Start with installing the most recent supported version of Arduino, then overlay this by installing the Teensiduino.
Once installed the directory needs to be prepared for compilation.
Linux
make shortcut links to libraries and compiler. The shourtcut described below assumes you have installed arduino version 1.8.9 (and Teensiduino) in your home directory, change as appropriate:
cd drone_ctrl/motortest ln -s ~/arduino-1.8.9/hardware/teensy/avr/libraries ln -s ~/arduino-1.8.9/hardware/teensy/avr/cores/teensy3 ln -s ~/arduino-1.8.9/hardware/tools/ make make upload
Drone firmware
The drone flight controller firmware is in the "drone_ctrl" directory.
To compile the source for a Teensy 3.5 or 3.6 the Teensiduino needs to be installed first.
Install Teensiduino, see https://www.pjrc.com/teensy/td_download.html . Start with installing the most recent supported version of Arduino, then overlay this by installing the Teensiduino.
Once installed the directory needs to be prepared for compilation.
Linux
make shortcut links to libraries and compiler. The shourtcut described below assumes you have installed arduino version 1.8.9 (and Teensiduino) in your home directory, change as appropriate:
cd drone_ctrl/drone_ctrl ln -s ~/arduino-1.8.9/hardware/teensy/avr/libraries ln -s ~/arduino-1.8.9/hardware/teensy/avr/cores/teensy3 ln -s ~/arduino-1.8.9/hardware/tools/ make make upload