Drone control: Difference between revisions

From Rsewiki
 
(23 intermediate revisions by the same user not shown)
Line 7: Line 7:
== Hardware ==
== Hardware ==


== Drone software ==
Build on a hand-wired PCB as a prototype


There are two versions of the drone firmware, one for the motor test (mostly performance of a single motor) without the need of the prop-sheld and a full version to be used on the flying drone.
[[Drone control hardware]]
<!-- [[File:schematic_rev0.png | 150px]] -->


To get the source code - see section "software and files" below.
== Drone software ==
 
=== Motor test firmware ===
 
The motor test firmware is in the "motortest" 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/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 ===
[[Drone firmware]]


The drone flight controller (base) firmware is in the "drone_ctrl" directory.
== Magnetometer calibration ==


To compile the source for a Teensy 3.5 or 3.6 the Teensiduino needs to be installed first.
Calibration is used using a calibration version of firmware and a calibration app from Prop Shield manufacturer.  


Install Teensiduino, see https://www.pjrc.com/teensy/td_download.html .
[[Drone compass calibration]]
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.
== ESC calibration ==


====Linux====
The drone control uses ESC pulse width from 1 to 2 ms, and all ESCs should be calibrated to use this range.


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:
[[ESC calibration]]
 
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


== Propeller - motor performance ==
== Propeller - motor performance ==


Measured with the "motortest" firmware and the python app below.
[[Drone motor performance]]
The used motor is the 3508-700KV Turnigy Multistar 14 Pole Brushless and a 14x5.5 carbon propeller.
[[File:3508-700-14x5.5-11v.png | 150px]]
The ESC is a Hobby-wing x-rotor 40A controller.
 
=== Time responce ===
 
[[File:3508-700-14x5.5-11v.png | 600px]]
[[File:3508-700-14x5.5-15v.png | 600px]]
 
 
With 11 V supply (left) and 15V (right).
From 1.1ms to the ESC (idle) to 1.9ms almost full throttle. The ESC update frequency is 400 Hz.
 
=== Static response 3508-700 ===
 
Transfer measurement with different propellers.
The Hobby Wing controller is calibrated to 1ms=off, 2ms=full power.
 
The propellers
* 8"x 3.8 APC composite propeller
* 9"x 4.5 APC composite propeller
* 13"x 4.5 carbon fiber
* 14"x 5.5 carbon fiber
* 18"x 5.5 carbon fiber Quanum
 
[[File:trust-per-power-3508-700.png | 600px]]
[[File:rpm-per-power-3508-700.png | 600px]]
 
(left) trust delivered for each propeller size as a function of motor input power.
(right) RPM as a function of input power.
 
=== Static gain 3508-700 ===
 
For the same data as above, bot now related to the ESC input pulse width.
The ESC has been calibrated to 1ms is zero power, 2ms is maximum power.
All data has been scaler to 11V, as the curves scale almost 1:1 with the input voltage.
 
[[File:trust-TF-3508-700.png | 600px]]
[[File:transfer_gain_N-per-ms.png | 600px]]
 
(Left) Trust curve as a function of ESC pulse width.
(Right) Static transfer gain as a function of ESC pulse width.
The transfer gain is fairly constant (within a factor 2) in the useful trust area.
 
=== Software and files ===
 
The files for these results is in our subversion repository:
 
Install subversion - https://subversion.apache.org/packages.html - and from a command line
 
svn checkout svn://repos.gbar.dtu.dk/jcan/mobotware/drone_ctrl
cd drone_ctrl/trunk/motortest_gui
ls
  - motortest_gui.py is the application below.
  - plot_rpm_sensor.m is the Matlab script to make the plots above.
  ... other support and data files.
cd drone_ctrl/trunk/doc/Matlab
  - Simulink version of hexacopter drone


== Motor test app ==
== Motor test app ==


A motor test GUI is available (in the motortest_gui directory) - it will talk to the motortest firmware - and there is no need for the prop-shield for this application.
[[Drone motor test app]]
 
[[File:motortest_gui.png | 120px]]
[[File:motortest_gui.png | 600px]]
 
Motor test GUI. There is the possibility to log time performance (in the log tab), to test run an ESC (or up to 6 ESCs) in the data tab.
 
The hardware configuration and pin-out are described in the hardware section above.
 
== MATLAB simulation ==
 
Once the drone hardware (mass, configuration, motor and propeller) is known, then it can be simulated in Matlab simulink.
The script in the doc/matlab directory has scrips for the simulation and estimating a linear transfer function in an operating point and calculate the needed controller parameters (roll, pitch, yaw - velocity and position as well as height control).
 
Further controllers for lateral velocity are added too, but these last controllers are not included in the drone firmware.
 
[[File:drone_ctrl_simulink.png | 800px]]
 
Simulink model of hexacopter.


[[File:drone_ctrl_sim_hex.png | 600px]]
==Matlab simulation==


Sim mechanics simulated hex-drone hoovering.
[[Drone MATLAB simulation]]
[[File:drone_ctrl_sim_hex.png | 120px]]

Latest revision as of 10:49, 21 December 2020

Drone project

This project is intended to be a rather simple core drone stabilizer application based on Teensy and the prop shield.

Intended to be expanded with an outer control loop with a non-realtime sensor, e.g. GNSS, camera or laser scanner.

Hardware

Build on a hand-wired PCB as a prototype

Drone control hardware

Drone software

Drone firmware

Magnetometer calibration

Calibration is used using a calibration version of firmware and a calibration app from Prop Shield manufacturer.

Drone compass calibration

ESC calibration

The drone control uses ESC pulse width from 1 to 2 ms, and all ESCs should be calibrated to use this range.

ESC calibration

Propeller - motor performance

Drone motor performance

Motor test app

Drone motor test app

Matlab simulation

Drone MATLAB simulation