Its not only a Quadcopter ,,,, Its a open source Machine!!!!
Many of you face a problem when it comes to Flight Controller which is the brain of the Multirotor. 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!
Step 1: Flight Controller Designing
Here are the Schematics for the flight controller board. you can make one on your general purpose PCB or can Order a PCB from manufacturer as i did.
- 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
- A4 << SDA
- A5 << SCL
- D8 << Anode Leg of LED
- D2 << Throttle
- D4 << Elerons
- D5 << Ailerons
- D6 << Rudder
- D7 << AUX 1
Step 2: Building a Frame
I bought a DJI 450 frame and attached my motors and everything on it. Yo can see the video on how i did it.
Step 3: Attaching the Flight Controller Onto the Frame
Flight Controller Code
First Download the Multiwii Code from the Below Download Link.
Extract ‘Multiwii_2.4.zip’ that you downloaded and Open it, now open the Multiwii Folder.
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)
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.
Out of those many Tabs search for Config.h and Open it.
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.
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.
Scroll down again till the ‘Buzzer Pin’ setup and uncomment it.
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
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.
Go to Tools>>Board Manager and Select the Arduino that You are Using.In my case, it’s Arduino Nano.
Now go to serial Port and select the COM Port to which your Arduino Nano is connected to.
Upload the code by Clicking on the Arrow Symbol as shown in above Image, and wait for the code to get Uploaded.
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.
After the connecting the flight controller to the Computer, Open the Multiwii 2.4 Folder >> MultiwiiConfig Folder.
Now open the Folder which will be compatible with your Operating system, mine is 64bit Windows so I will open ‘application.windows64’ Folder.
Run the MultiwiiConfig Application
Select the COM port to which your Arduino is connected and then click on Start.
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!!!