Arduino Flight controller For your Quadcopter

It’s a wish of every engineer to Built their own Multirotor from scratch, Quadcopter to be more specific.It’s not at all a hard thing to build one, But many of them face a problem when it comes to Flight Controller aka the brain of the Multirotor.I know that there are plenty of ready-made pre-flashed Flight controllers in the market for cheap, But have you thought of building your own Flight controller with your Arduino? So this is the right place to understand and build your own Flight controller for your quadcopter or Multirotor with your Arduino.

Now the questions come, Where and how do I get the code for the quadcopter? So the answer is Multiwii.

MultiWii is a Very popular flight controller software for DIY Multi-rotors with a large community. It has Support various Multi-copters with advanced features such as Bluetooth Control by your Smartphone, OLED Display, Barometer, Magnetometer, GPS position hold and return to home, LED strips and many more.

So let’s build our Flight controller using Arduino!

Introduction

In this tutorial, we are going to use an Arduino Nano and Build Flight controller for Quadcopter i.e Multi-rotor with 4 Propellers.You can use any Arduino that is available to you, But I personally prefer the Nano version of Arduino as it has the same Microcontroller as the Arduino UNO, Small in size, Light weight and also features a USB mini type B port.The pin configuration remains same for all Arduino types.

The Multiwii Supports a wide range of Gyroscope and Accelerometer Modules, But in this tutorial, we are going to use GY-521 cheapest available and consist of MPU 6050 i.e a Gyroscope as well as Accelerometer both in a single chip.If you want to have Altitude Control You can use GY-87 which has a barometer in addition.

You can use your traditional Transmitter Receiver for communication i.e to control your Quadcopter

If you want to control your Quadcopter using your smartphone via Bluetooth then you get this Functionality in Multiwii.For that, you will need a Bluetooth Module like JY-MCU, HC-05, HC-06 and much more.Using this Bluetooth functionality you get a range of 20 meters(Depends on module used and smartphone).This feature is completely OPTIONAL

We will use a small 3mm LED for indicator purpose.You can use a Buzzer instead of LED.This Feature is Optional but I recommend this feature.

 

Things You Need:

Arduino Flight Controller Components
Arduino Flight Controller Components
  • Arduino UNO or Nano
  • MPU-6050 Module
  • Prototype Board
  • Male and Female Headers
  • LED and a 330 ohm Resistor
  • Thin Wires
  • HC-05 Bluetooth Module (Optional)

Schematics

Let’s Follow the below schematics and build the controller.

Arduino Flight Controller Schematics
Arduino Flight Controller Schematics

 

ESC Connections

D3 << ESC 1 Signal Pin

D9 << ESC 3 Signal Pin

D10 << ESC 2 Signal Pin

D11 << ESC 4 Signal Pin

Bluetooth Module Connections

TX << RX

RX << TX

MPU-6050 Connections

A4 << SDA

A5 << SCL

LED Indiacator

D8 << Anode Leg of LED

Receiver Connections

D2 << Throttle

D4 << Elerons

D5 << Ailerons

D6 << Rudder

D7 << AUX 1

NOTE:-  Ground all the ESC’s,Bluetooth Module,MPU-6050 and Receiver by connecting GND(Ground) Pins of all Mentioned parts to the GND Pin of Arduino in Your Flight Controller.

Wiring the Circuit

Soldering Female Headers for Arduino Nano
Soldering Female Headers for Arduino Nano

First, we Solder the Female Headers on to the prototype board so as it can accommodate the Arduino Nano in it.Make sure you solder them in the center of the Prototype board so that we can solder the headers for ESC’s, Receiver, Bluetooth Module, MPU and also have some room for other additional features which can be added later on.

Soldering male Headers for ESC's
Soldering male Headers for ESC’s

Now we solder the Male headers for the ESC’s and Receiver on to the right side of the female headers for Arduino.

The Rows of Male headers for your copter ESC’s will depend on the type of multi-rotor your are Building.If you are Building a Quadcopter you are going to have 4 Motors with 4 ESC’s so you will need 4 Rows with 3 male headers in each Row.Out of the 3 Headers in Row, the First header is for Signal Pin, Second for 5v(Some ESC may not have this Pin), and Third for Ground.

Similary in Tricopter you will need 3 Rows, in Hexacopter  6 Rows and so on.

After we finish soldering the ESC’s headers we can now solder the Headers for the Receiver.

Now a Multirotor normally has Four Channels which are Throttle, Pitch, Yaw, and Roll.The fifth channel is Auxillary Channel (Used for changing Flight Modes).

So we need 5 Rows of male Headers out of which one will have 3 headers in a row and others will be having a single header in a Row.

We also need to solder two female headers for the MPU and Bluetooth Module.I soldered the Header for MPU on the Left and For Bluetooth Module on the bottom left.

All Connections Soldered
All Connections Soldered

Now we need to connect all headers to Respective Arduino Pins with wires.I used Breadboard wires for connections as in above Image.

Do the Connections in sequence so that you don’t miss out any connections

I first connected all The Grounds to the Ground of Arduino i.e connected Ground of all ESC’s (The rightmost Headers), Ground of Receiver (The rightmost header of the Throttle signal header, Ground of MPU and Bluetooth Module.

Then I connected the SDA and SCL of MPU to the A4 and A5 of Arduino and the TX and RX of Bluetooth Module to the RX and TX of Arduino.

After that, I connected all Signal pins of ESC1, ESC2, ESC3, ESC4 to D3, D10, D9, D11 and Then the signal pins of Receiver i.e Throttle, Elerons (Pitch), Ailerons (Roll), Rudder (Yaw), Auxillary to D2, D4, D5, D6, D7.

Also, we connect the positive Terminal (Long Lead of the LED to the D8 Pin of Arduino and the negative Terminal (Short Lead) to the Ground of Arduino with a 330-ohm resistor in between the Ground and Negative Terminal.

The only thing we are left with is, Powering the Circuit i.e providing Positive 5V to Arduino, MPU and Bluetooth Module.You will need a small 5v Battery to power all of these by connecting Everyone in Parallel i.e Connecting the Ground(Black wire) of the Battery to the Ground of Arduino and the 5V( Red Wire) to the 5V pin of Arduino, 5V pin of MPU, and the 5V pin of Bluetooth Module.

In my case, I used the 5V from my ESC’s to power On the circuit because they had a BEC (Battery eliminator circuit).Not all ESC’s have this Feature, So you may need to use a battery instead.

 

Soldering Male Headers to MPU-6050
Soldering Male Headers to MPU-6050

Solder male headers to your MPU 6050 or the one you wish to use.

Now Flip the board and connect all components i.e Arduino, MPU, and Bluetooth Module to the Prototype Board on to their respective Headers.

Now Our Flight controller is ready!! It’s time to Program the Arduino with the Multiwii Code for your Multi-rotor.

Complete Build of Arduino Flight Controller
Complete Build of Arduino Flight Controller

 

 

Flight Controller Code

First Download the Multiwii Code from the Below Download Link.

Download

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

Extract ‘Multiwii_2.4.zip’ that you downloaded and Open it, now open the Multiwii Folder.

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

Search for Multiwii File with ‘.ino’ or File type specified as ‘Arduino File’ using Arduino IDE.

(Don’t open any ‘H File’ or ‘CPP File’ those are the support files for our Multiwii Code, Only open Multiwii.ino File)

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

After opening the Muiltiwii.ino file in Arduino IDE you will see many tabs Alarms.cpp, Alarms.h, EEPROM.cpp, EEPROM.h and many more.

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

Out of those many Tabs search for Config.h and Open it.

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

After you open the Config.h Tab Scroll down till you find ‘The type of multicoptor’

Search for the type of Multi-rotor you are Building and Uncomment it.

For example, I’m building Quadcopter with X configuration so I will uncomment QUADX by removing the ‘//’ before ‘#define QUADX’, similarly you can do it with your type of Multirotor.

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

Again scroll down till you find ‘Combined IMU Boards’ and uncomment the type of your Gyro+Acc Board.Mine was GY-521 so I uncommented GY-521.

You can even add more sensors like BMP 180 barometer or SRF-04 Ultrasonic sensor and many more by uncommenting them in this section.

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

Scroll down again till the ‘Buzzer Pin’ setup and uncomment it.

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

Scroll again and Find ‘Buzzer’ and uncomment the first 3 options.this are for Flight indicator Purpose.

Similarly, you can add many features like OLED Display, LCD Display, GPS etc  just by uncommenting them in the config.h.Now the Code has to be flashed to Arduino.

Uploading the code

Programming Arduino with Quadcopter Code
Programming Arduino with Quadcopter Code

Remove the Arduino from the Flight controller Board and connect it to your computer via USB Cable.Don’t connect the Arduino directly while it is on the Flight controler Board, always remove it and then connect.

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

Go to Tools>>Board Manager and Select the Arduino that You are Using.In my case, it’s Arduino Nano.

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

Now go to serial Port and select the COM Port to which your Arduino Nano is connected to.

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

Upload the code by Clicking on the Arrow Symbol as shown in above Image, and wait for the code to get Uploaded.

Connecting Flight Controller to Computer
Connecting Flight Controller to Computer

Once the code is Uploaded Disconnect the Arduino From Computer and place it again on to your Flight Controller.Connect your Receiver to the Respective Headers.connect the 5V Battery to power ON the Flight controller.

I connected all ESC’S to Flight Controller Because I used the ESC’s to provide 5V to all parts of the Flight Controller i.e using the BEC (Battery Eliminator Circuit) of the ESC.So I didn’t use any external 5V Battery.

The Led Indicator Blinks, this indicates that the Flight Controller has Booted.

Now connect the Flight controller to the Computer via USB Cable and let’s see how it is performing.

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

After the connecting the flight controller to the Computer, Open the Multiwii 2.4 Folder >> MultiwiiConfig Folder.

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

Now open the Folder which will be compatible with your Operating system, mine is 64bit Windows so I will open ‘application.windows64’ Folder.

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

Run the MultiwiiConfig Application

Multiwii Quadcopter Configuration
Multiwii Quadcopter Configuration

Select the COM port to which your Arduino is connected and then click on Start.

Multiwii Configurator
Multiwii Configurator

Now You can see the Live Flight controller Data in the MultiwiiConfig.Moving your Flight Controller will reflect the Gyroscope and Accelerometer Data on Screen.You can see the Orientation of your Flight Controller at the Bottom Right.

Here we can Tweak the PID values of the Flight Controller for a Smooth Flight.We assign various Flight Modes to the Auxillary Switch from here.

Moving the Transmitter sticks will show the values of respective Channels.The Respective Motor Speeds are shown on the Right Box.

Just attach your Flight Controller to your Multirotor and it is ready to Fly!!!

Happy Flying!

Arduino Quadcopter
Arduino Quadcopter

Watch My YouTube Video On Arduino Quadcopter Flight Controller 

 

 

 

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons