qqqlab / madflight

Flight Controller for Arduino ESP32 / RP2350 / RP2040 / STM32
https://madflight.com
MIT License
114 stars 22 forks source link
betaflight drone esp32 flight-controller madflight quadcopter rp2040 stm32

madflight is a toolbox to build high performance flight controllers with Aduino IDE or PlatformIO for ESP32-S3 / ESP32 / RP2350 / RP2040 / STM32. A functional DIY flight controller can be build for under $10 from readily available development boards and sensor breakout boards.

Flight tested example programs for quadcopter and airplane are included. The example programs are only a couple hundred lines long, but contain the full flight controller logic. The nitty-gritty low-level sensor and input/output management is done by the madflight library.

The source code and website have extensive documentation explaning what the settings and functions do.


If you like madflight, give it a ☆ star, or fork it and contribute!


Required Hardware

Optional Hardware

Getting Started

  1. Connect the required hardware to your controller board:
  2. Install the madflight library in Arduino IDE. (Menu Tools->Manage Libraries, then search for madflight)
  3. Open Examples for custom libraries->madflight->Quadcopter.ino in the Arduino IDE.
  4. Edit the HARDWARE section in madflight_config.h to enable the connected peripherals.
  5. If you're not using the default pinout then setup your board pinout in the CUSTOM PINS section.
  6. Compile Quadcopter.ino and upload it to your board. Connect the Serial Monitor at 115200 baud and check the messages. Type help to see the available CLI commands.
  7. Type calradio and follow the prompts to setup your RC radio receiver.
  8. IMPORTANT: Use CLI calimu and calmag to calibate the sensors.
  9. Use CLI commands pimu, pahrs, pradio, pmot, etc. and check that IMU sensor, AHRS and RC Receiver are working correctly.
  10. Connect motors (no props) and battery and check that motors are spinning correctly.
  11. Mount props, go to an wide open space, and FLY!

Safety First!!!

By default madflight has these safety features enabled:

Software Design

Disclaimer

This code is a shared, open source flight controller for small micro aerial vehicles and is intended to be modified to suit your needs. It is NOT intended to be used on manned vehicles. I do not claim any responsibility for any damage or injury that may be inflicted as a result of the use of this code. Use and modify at your own risk. More specifically put:

THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Logo image copyright (c) 1975 Deutsches MAD Magazine. This project is not associated with MAD Magazine.