Skip to content

Commit

Permalink
v1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
qqqlab committed Jun 8, 2024
1 parent 2ce6478 commit 5fb710a
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 14 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

***M**anless **A**erial **D**evice*

__*NOTE: madflight v1.1.2 works with Arduino-ESP 2.x.x, use madflight v1.1.3-DEV for Arduino-ESP 3.x.x (download this repository from Github)*__

This is an Arduino library to build ESP32 / ESP32-S3 / RP2040 / STM32 flight controllers. A functional DIY flight controller can be build for under $10 from readily available development boards and sensor breakout boards. Ideal if you want to try out new flight control concepts, without first having to setup a build environment and without having to read through thousands lines of code to find the spot where you want to change something.

`Quadcopter.ino` is a 1000 line demo program for a quadcopter. It has been flight tested on ESP32, ESP32-S3, RP2040, and STM32F405 microcontrollers with the Arduino IDE. The program can be easily adapted to control your plane or VTOL craft. The source code has extensive documentation explaning what the settings and functions do.
Expand Down Expand Up @@ -98,9 +96,9 @@ By default madflight has these safety features enabled:
<a name="ESP32"></a>
## ESP32 / ESP32-S3 Setup and Pinout

madflight works with [Arduino ESP32 v3.x.x](https://github.com/espressif/arduino-esp32)
madflight works with [Arduino-ESP32 v3.x.x](https://github.com/espressif/arduino-esp32)

madflight v1.1.2 and earlier works with Arduino ESP32 v2.x.x
madflight v1.1.2 and earlier works with Arduino-ESP32 v2.x.x

#### Dual Core / FPU / FreeRTOS

Expand All @@ -115,7 +113,8 @@ A workaround is to use #define USE_ESP32_SOFTWIRE which enables software I2C, bu

(!) So, until a better I2C solution is available: use an SPI IMU sensor on ESP32.

NOTE: as of June 2024 this bug is apparently fixed, but not yet tested with madflight.
NOTE: as of June 2024 this bug is apparently fixed, but not yet confirmed with madflight.


## Pinout ESP32

Expand Down Expand Up @@ -267,7 +266,7 @@ This pinout is optimized for the RP2040-Zero (21 pin) board. This pinout is defi
<a name="STM32"></a>
## STM32 Setup and Pinout

madflight works with [Arduino Core for STM32 v2.x.x](https://github.com/stm32duino/Arduino_Core_STM32)
madflight works with [stm32duino Arduino Core for STM32 v2.x.x](https://github.com/stm32duino/Arduino_Core_STM32)

#### Dual Core / FPU / FreeRTOS

Expand Down
4 changes: 2 additions & 2 deletions examples/01.Quadcopter/01.Quadcopter.ino
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fast blinking - something is wrong, connect USB serial for info
#define HW_PIN_SPI2_MOSI -1
#define HW_PIN_SPI2_SCLK -1
#define HW_PIN_BB_CS -1
*/
//*/

//RP2040 specific options
//#define HW_RP2040_SYS_CLK_KHZ 200000 //overclocking
Expand Down Expand Up @@ -250,7 +250,7 @@ void setup() {

//6 second startup delay
for(int i=20;i>0;i--) {
Serial.printf(MADFLIGHT_VERSION " starting %d ...\n",i);
Serial.printf(MADFLIGHT_VERSION " on " HW_ARDUINO_STR " starting %d ...\n",i);
delay(300);
led.toggle();
}
Expand Down
19 changes: 17 additions & 2 deletions extras/TestMadflight/imu/imu.ino
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
//test program for imu.h - used with madflight 1.1.3

#define IMU_USE IMU_USE_I2C_MPU9250
#define IMU_USE IMU_USE_SPI_MPU6500 // IMU_USE_SPI_BMI270, IMU_USE_SPI_MPU9250, IMU_USE_SPI_MPU6500, IMU_USE_SPI_MPU6000, IMU_USE_I2C_MPU9250, IMU_USE_I2C_MPU9150, IMU_USE_I2C_MPU6500, IMU_USE_I2C_MPU6050, IMU_USE_I2C_MPU6000
#define IMU_I2C_ADR 0x68

/* Override default pins
//ESP32 WeMos LOLIN32-Lite
//IMU SPI:
#define HW_PIN_SPI_MISO 25
#define HW_PIN_SPI_MOSI 14
#define HW_PIN_SPI_SCLK 12
#define HW_PIN_IMU_CS 32
#define HW_PIN_IMU_EXTI 33 //external interrupt pin
//I2C for BARO, MAG, BAT sensors and for IMU if not using SPI
#define HW_PIN_I2C_SDA 23
#define HW_PIN_I2C_SCL 19
//*/

#define MF_TEST MF_TEST_IMU
#include <madflight.h>

Expand Down Expand Up @@ -34,7 +49,7 @@ void imu_loop() {
}

void loop() {
Serial.printf("imu_loop_cnt:%d az:%f gz:%f mz:%f\n",imu_loop_cnt, imu.az, imu.gz, imu.mz);
Serial.printf("imu_loop_cnt:%d ax:%.2f ay:%.2f az:%.2f gx:%.2f gy:%.2f gz:%.2f mx:%.2f my:%.2f mz:%.2f\n",imu_loop_cnt, imu.ax, imu.ay, imu.az, imu.gx, imu.gy, imu.gz, imu.mx, imu.my, imu.mz);
delay(1000);
}

45 changes: 45 additions & 0 deletions extras/TestMadflight/rcin/rcin.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//test program for rcin.h - used with madflight 1.1.3

//--- RC RECEIVER
#define RCIN_USE RCIN_USE_CRSF //RCIN_USE_CRSF, RCIN_USE_SBUS, RCIN_USE_DSM, RCIN_USE_PPM, RCIN_USE_PWM
#define RCIN_NUM_CHANNELS 6 //number of receiver channels (minimal 6)

/* Override default pins
//ESP32 WeMos LOLIN32-Lite
//RC Receiver:
#define HW_PIN_RCIN_RX 16
#define HW_PIN_RCIN_TX 4
#define HW_PIN_RCIN_INVERTER -1 //only used for STM32 targets
//*/

#define MF_TEST MF_TEST_RCIN
#include <madflight.h>


void setup() {
Serial.begin(115200);
while(!Serial);

hw_setup(); //hardware specific setup for spi and Wire (see hw_xxx.h)

rcin.setup(); //Initialize radio communication. Set correct USE_RCIN_xxx user specified defines above. Note: rcin_Setup() function is defined in rcin.h, but normally no changes needed there.

Serial.printf("HW_PIN_RCIN_RX:%d HW_PIN_RCIN_TX:%d\n", (int)HW_PIN_RCIN_RX, (int)HW_PIN_RCIN_TX );
}

void loop() {
static uint32_t ts_last = 0;
bool got_new_data = rcin.update();

if(got_new_data) {
uint32_t ts = micros();
Serial.printf("dt:%d ", (int)(ts-ts_last));
for(int i=0;i<RCIN_NUM_CHANNELS;i++) Serial.printf("pwm%d:%d ", i, rcin.pwm[i]);
Serial.println();
ts_last = ts;
}

delay(1);
}

2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=madflight
version=1.1.2
version=1.1.3
author=qqqlab
maintainer=qqqlab <[email protected]>
license=GNU
Expand Down
2 changes: 1 addition & 1 deletion src/madflight.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define MADFLIGHT_VERSION "madflight v1.1.3-DEV"
#define MADFLIGHT_VERSION "madflight v1.1.3"

/*==========================================================================================
madflight - Flight Controller for ESP32 / RP2040 / STM32
Expand Down
4 changes: 3 additions & 1 deletion src/madflight/hw_ESP32/hw_ESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ This file defines:
HW_xxx and hw_xxx -> all other hardware platform specific stuff
########################################################################################################################*/

#define HW_ARDUINO_STR "Arduino-ESP32 v" ESP_ARDUINO_VERSION_STR

//======================================================================================================================//
// DEFAULT BOARD
//======================================================================================================================//
Expand Down Expand Up @@ -116,4 +118,4 @@ void hw_reboot() {

uint32_t hw_get_core_num() {
return xPortGetCoreID();
}
}
2 changes: 2 additions & 0 deletions src/madflight/hw_RP2040/hw_RP2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ This file defines:
HW_xxx and hw_xxx -> all other hardware platform specific stuff
########################################################################################################################*/

#define HW_ARDUINO_STR "Arduino-Pico v" ARDUINO_PICO_VERSION_STR

//======================================================================================================================//
// DEFAULT BOARD
//======================================================================================================================//
Expand Down
4 changes: 4 additions & 0 deletions src/madflight/hw_STM32/hw_STM32.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ This file defines:
HW_xxx and hw_xxx -> all other hardware platform specific stuff
########################################################################################################################*/

#define df2xstr(s) #s
#define df2str(s) df2xstr(s)
#define HW_ARDUINO_STR "Arduino_Core_STM32 v" df2str(STM32_CORE_VERSION_MAJOR) "." df2str(STM32_CORE_VERSION_MINOR) "." df2str(STM32_CORE_VERSION_PATCH)

//Arduino IDE settings:
//Board: Generic STM32xxx
//Board part number: select according your board
Expand Down
2 changes: 1 addition & 1 deletion src/madflight_board_default_ESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

//RC Receiver:
#ifndef HW_PIN_RCIN_RX
#define HW_PIN_RCIN_RX 5 //also used as PPM input
#define HW_PIN_RCIN_RX 35 //also used as PPM input
#endif
#ifndef HW_PIN_RCIN_TX
#define HW_PIN_RCIN_TX 32
Expand Down

0 comments on commit 5fb710a

Please sign in to comment.