SUKKUR IBA UNIVERSITY
Merit-Quality-Excellence
DEPARTMENT OF ELECTRICAL ENGINEERING
Home Our Journey Components PCB Design CAD Design Coding PID Tuning Project Planning Business-MD Refrences


Introduction to Multiwii code:

Coding is one of the most essential parts of our project. As mentioned before, at first we worked on NodeMCU, but due to lack of a proper code we quit it and moved to Multiwii open source platform.
Multiwii code is, according to our experience, a little more arduous to understand than ESP open source code available on github. When we were working on ESP code, we found that it can not simply be downloaded and installed in any arduino based module, rather it shows a number of errors during compilation. So, first we needed to solve all the conundrums in the code to make it work, and obviously, it is not that easy. It requires a well understanding of code and skills to fix the errors. We tried multiple times to make it work, like we added several libraries, made some changes in code according to our understanding, but nothing worked. Finally we moved toward Multiwii code and found this open source platform remarkably perfect for our project.
When we first downloaded the Multiwii code and tried to compile it in Arduino, it worked well. We then loaded the code successfully to Arduino Nano just by making a few changes in the codes — just uncommented a few lines in the code according to our requirements. This was, probably, a big leap in our project towards success.
Multiwii code contains several files for different functions. We do not need to make any change in other files except ‘config.h’. This is a unique part where we choose quadcopter configuration, types of sensors and also the flight controller we are using_in our case we used ATmega328p microcontroller base flight controller that we have designed. Here is mentioned step by step explanation about ‘config.h’ code:

For Multiwii code Click Here!
For our modified code Click Here!
Step 1:

Choose the right configuration of quadcopter. In our case it is x-configuration, so here we have uncommented #define QUADX. Rest of the code will remain the same.


/************************** The type of multicopter****************************/
//#define GIMBAL
//#define BI
//#define TRI
//#define QUADP
#define QUADX
//#define Y4
//#define Y6
//#define HEX6
//#define HEX6X
//#define HEX6H // New Model
//#define OCTOX8
//#define OCTOFLATP
//#define OCTOFLATX
//#define FLYING_WING
//#define VTAIL4
//#define AIRPLANE
//#define SINGLECOPTER
//#define DUALCOPTER
//#define HELI_120_CCPM
//#define HELI_90_DEG

Step 2:

Next step is to choose the maximum and minimum throttle values. We chose '0' Min throttle because want that quadcopter should not rotate until we arm the transmitter. Also we have selected 2000 max so that we will get full thrust maximum throttle.


/************************** * Min Motor minthrottle****************************/
/* Set the minimum throttle command sent to the ESC (Electronic Speed Controller)This is the minimum value that allow motors to run at a idle speed */

//#define MINTHROTTLE 1300 // for Turnigy Plush ESCs 10A
//#define MINTHROTTLE 1120 // for Super Simple ESCs 10A
//#define MINTHROTTLE 1064 // special ESC (simonk)
//#define MINTHROTTLE 1050 // for brushed ESCs like ladybird
#define MINTHROTTLE 0 // (*) (**)

/************************ * Max Motor maxthrottle *****************************/
/* this is the maximum value for the ESCs at full power, this value can be increased up to 2000 */

#define MAXTHROTTLE 2000

Step 3:

In this part we have to select which circuit board we are using. In our case we have ATmega328p based flight controller, so we chose NANOWII—this board is based on the same microcontroller .


/*************************** Combined IMU Boards ********************************/
//#define FFIMUv1
//#define FFIMUv2
//#define FREEIMUv1
//#define FREEIMUv03
//#define FREEIMUv035
//#define FREEIMUv035_MS <- confirmed by Alex
//#define FREEIMUv035_BMP
//#define FREEIMUv04
//#define FREEIMUv043
#define NANOWII
//#define PIPO
//#define QUADRINO
//#define QUADRINO_ZOOM
//#define QUADRINO_ZOOM_MS
//#define ALLINONE
//#define AEROQUADSHIELDv2
//#define ATAVRSBIN1
//#define SIRIUS
//#define SIRIUSGPS
//#define SIRIUS600
//#define SIRIUS_AIR
//#define SIRIUS_AIR_GPS
//#define SIRIUS_MEGAv5_OSD
//#define MINIWII
//#define MICROWII
//#define CITRUSv2_1
//#define CHERRY6DOFv1_0
//#define DROTEK_10DOF
//#define DROTEK_10DOF_MS
//#define DROTEK_6DOFv2
//#define DROTEK_6DOF_MPU
//#define DROTEK_10DOF_MPU
//#define MONGOOSE1_0
//#define CRIUS_LITE
//#define CRIUS_SE
//#define CRIUS_SE_v2_0
//#define OPENLRSv2MULTI
//#define BOARD_PROTO_1
//#define BOARD_PROTO_2
//#define GY_80
//#define GY_85
//#define GY_86
//#define GY_88
//#define GY_521
//#define INNOVWORKS_10DOF
//#define INNOVWORKS_6DOF
//#define MultiWiiMega
//#define PROTO_DIY
//#define IOI_MINI_MULTIWII
//#define Bobs_6DOF_V1
//#define Bobs_9DOF_V1
//#define Bobs_10DOF_BMP_V1
//#define FLYDUINO_MPU
//#define CRIUS_AIO_PRO
//#define DESQUARED6DOFV2GO
//#define DESQUARED6DOFV4
//#define LADYBIRD
//#define MEGAWAP_V2_STD
//#define MEGAWAP_V2_ADV //#define HK_MultiWii_SE_V2
//#define HK_MultiWii_328P
//#define RCNet_FC
//#define RCNet_FC_GPS
//#define FLYDU_ULTRA
//#define DIYFLYING_MAGE_V1
//#define MultiWii_32U4_SE
//#define MultiWii_32U4_SE_no
//#define Flyduino9DOF
//#define Nano_Plane


Step 4:

Optionally disable stick combinations to arm/disarm the motors. In most cases one of the two options to arm/disarm via TX stick is sufficient, so we choose the first one.


/************************** * ARM/DISARM****************************/
#define ALLOW_ARM_DISARM_VIA_TX_YAW
// #define ALLOW_ARM_DISARM_VIA_TX_ROLL


Step 5:

The following lines apply only for specific receiver with only one PPM sum signal, on digital PIN 2. We need to select the right line depending on the radio brand we are using. As we were using the transmitter and receiver of FLY-SKY, so we chose the sencond option which matches the order of our receiver.


/************************** * PPM Sum Reciver****************************/
//#define SERIAL_SUM_PPM PITCH,YAW,THROTTLE,ROLL,AUX1,AUX2,AUX3,AUX4,8,9,10,11
#define SERIAL_SUM_PPM ROLL,PITCH,THROTTLE,YAW,AUX1,AUX2,AUX3,AUX4,8,9,10,11
//#define SERIAL_SUM_PPM ROLL,PITCH,YAW,THROTTLE,AUX1,AUX2,AUX3,AUX4,8,9,10,11
// #define SERIAL_SUM_PPM PITCH,ROLL,THROTTLE,YAW,AUX1,AUX2,AUX3,AUX4,8,9,10,11


Multiwii Code Explanation:

Here in this video we have explained Multiwii code and described which parts need to be uncommented to run it on any flight controller based on ATmega328P microcontroller controller.







Prev Next