Friday, 3 February 2017

Procedure to make quadcoper uing ATMEGA 2560


Last week, I decided, I am finally going to build my own RC quadcopter (or quadrocopter, if you prefer). “Why?”, you might ask. Well, basically, it’s video’s like this one, that just make my heart go a little bit faster. So, the goal is to build a quadcopter, that can carry a camera (ideally this one, but…).

Basically, a quadcopter consists of the following parts:

a frame
a flight controller
4 motors
4 ESCs
a battery
an RC receiver
Without thinking too much about it (but having looked at several DIY descriptions, ready-made kits, complete solutions, etc.), I decided to use the information and software from AeroQuad (“The Open Source QuadCopter / Multicopter”) to do it.

"The AeroQuad is an open-source hardware and software project dedicated to the construction of remote controlled four-rotor helicopters, also known as quadcopters or quadrocopters."

The AeroQuad store can provide most -if not all- the necessary parts to build the quadcopter, but of course, it is fun (and probably financially rewarding) to shop around for parts elsewhere. I am not at all sure which parts I will be using for my quadcopter apart from the AeroQuad flight controller. And even though they provide a complete kit, I decided to order the Arduino Mega 2560 somewhere else, because it was cheaper.

So far, I ordered the following materials:

An Arduino Mega 2560 microcontroller (USD 19.00 at BuyInCoins). Ordered June 29, seems to have shipped July 2nd.
AeroQuad v2.1 Shield and other accessories from AeroQuad, for a total of USD 163,55 (+ USD 8,93 shipping). Ordered July 2nd, shipped July 3rd.
That’s basically all I need for the flight controller. I haven’t decided on what kind of motors, ESCs and batteries I will use, and I will have to see if I am going to buy a ready-made frame, or build one myself.


My quadcopter will be an AeroQuad, a design which is based on the Arduino Mega 2560 microcontroller. The board arrived in the mail last Saturday, and since I haven’t owned an Arduino before, everything about it was kind of new to me. So, I did some small experiments.

My laptop runs Debian Wheezy these days, and the Arduino IDE is packaged for that, so installation was as easy as typing:

[code]apt-get install arduino[/code]
The Arduino IDE is a Java application, that has a simple code editor and some built-in tools for compiling your code and uploading it to the Arduino. It comes with some example programs, the simplest of which is called ‘Blink‘ and does little more than make a LED on the board blink on and off.

That worked nicely, and as a first-time Arduino user, it is fun to make the LED blink in a variety of patterns. That grows old quickly though, so on to more challenging tasks.

The next experiment was to download the AeroQuad software and see if I could get that built. It took me a while to figure out where to put the AeroQuad libraries so that the IDE can find them, because the installation instructions described two options, both of which I didn’t like, but in the end, it was obvious.

The default setting in the Arduino IDE for ‘sketchbook location’ (where you keep you Arduino sketches) is $HOME/sketchbook. This means that the AeroQuad libraries need to live in $HOME/sketchbook/libraries, and they will be found.

Something else noteworthy is, that you cannot change the name of the folder containing the AeroQuad software itself. When you unpack the archive, you get a directory named ‘AeroQuad’. I changed it to ‘AeroQuad-3.0.1’, but that doesn’t work. The IDE told me that ‘The file “AeroQuad.ino” needs to be in a sketch folder named “AeroQuad”‘, so I renamed it back.

Now, compiling the code is generally just a matter of clicking a button, but when I tried that with the AeroQuad project, the compiler crashed:

[code]collect2: error: ld terminated with signal 11 [Segmentation fault][/code]
I did try to find out why, but Googling around for a while didn’t give me anything useful, except that the Arduino IDE, when downloaded from the official website, ships with GCC version 4.3.2, while Debian Wheezy is at 4.7.0 at the moment. That’s a rather big difference.

I decided to try the easy way, and just get the official Arduino IDE and install it in /opt/arduino-1.0.1. Clearly a good choice, because compiling the software just worked now. I even uploaded it to the Arduino, but since I don’t have anything to connect to it yet, that was pretty pointless.

The next step will be to assemble the AeroQuad v2.1 Shield, which is a print board that will contain sensors like triple-axis gyroscope, accelerometer, magnetometer and barometric pressure sensor; all the neat stuff that will make the AeroQuad stay up in the air. Today, after being underway for almost three weeks, they arrived at my doorstep. Well, after paying 37 euros for VAT and customs handling costs…

An Arduino Mega 2560
AeroQuad v2.1 Shield and other accessories from AeroQuad
but I left it at that and didn’t actually build anything. I won’t go into the reasons why, I just didn’t.

But! That doesn’t mean that I haven’t been thinking about the project in the mean time. I have been studying the do’s and don’ts of building a quad, reading about motors, ESCs, LiPo batteries, propellors, currents, temperatures, frame characteristics and lots of other complexities. I also tried to get an idea of what flying a quadcopter is all about.

As a matter of fact, I purchased a really small and cheap toy quad from DX a while ago, that has been a lot of fun and it taught me the basics of how to fly a quadcopter. Last weekend, I got to fly a Parrot AR Drone with an onboard camera, and that got me excited enough to reboot the AeroQuad project!

So last night, I sat down to take a last long hard look at all the components I had considered before, and placed a big order with Hobbyking. These are the components I ordered. All prices in US$.

4x Turnigy 2217 16turn 1050kv 23A Outrunner; $16.60 each, makes $66.40
4x TURNIGY Plush 30amp Speed Controller; $12.19 each, makes $48.76
2x ZIPPY Flightmax 4000mAh 3S1P 20C LiPo battery; $19.99 each, makes $39.98
1x Turnigy Talon Quadcopter (V2.0) Carbon Fiber Frame; $66.29
1x Turnigy Accucel-6 50W 6A Balancer/Charger w/ accessories; $22.99
2x 10×4.5 SF Props 2pc Standard Rotation/2 pc RH Rotation (black); $3.14 each, makes $6.28
2x 10X6 Propellers (Standard and Counter Rotating) (6pc); $3.48 each, makes $6.96
So that amounts to a total of US$ 257.66, excluding an outrageous amount of US$ 35.80 for shipping. That brings the total investment so far up to US$ 484,94. Damn, this better become one hell of a flying machine 😉 And I still need to buy a 2.4 GHz transmitter/receiver, too…

I bought two different kinds of props: two sets of 10×4.5 SF props and three sets of 10×6 props. These give different amounts of thrust and flying time, but also a difference in handling and stability of the quad. I’ll have to experiment with those.

One of the high-impact decisions I made, both in terms of cost (probably) and in complexity of the build, is to buy a ready-made frame. I chose Hobbyking’s own Turnigy Talon Quadcopter (V2.0) Carbon Fiber Frame, and it looks like this:

Talon frame

Of course it still going to take some time and effort to get everything mounted on there, but at least I can be sure that the frame is well-balanced and light, yet very strong. The frame only weighs 280 grams, and hopefully this will allow me to keep the total weight of the quad, including motors and battery, around 1 kg. If my (or rather: eCalc’s ;-)) calculations are correct, the quad will be able to carry a payload of at least another 1 kg, which should be plenty for a camera of any sort, and leaves room for more accessories.

Now I’ll have to wait for all the parts to arrive, and then the building can begin. More later!

I rebooted my quadcoper project and ordered a lot of parts from Hobbyking. In the mean time, the parts arrived, and I have been making my first steps in actually building something.

The first thing was assembling the Talon V2.0 carbon fiber frame and mounting the motors. That’s a very easy task, except when trying to fit some props on the motors after mounting them on the frame, I discovered that the Turnigy 2217 motors should be mounted up-side down, so the motor-mounts on the frame had to be flipped. Click the images to enlarge.

 IMG_7907 IMG_7908
The next thing on the list was the power system, meaning everything to connect the motors to the ESCs and the ESCs to the battery. For this, I needed some extra hardware, that I got from different sources:

2 meters of 18AWG silicone wire, to extend the motor-side wires of the ESCs. €2.29 per meter, makes € 4.58.
a power distribution hub, € 4.02.
a 4mm HXT connector, to connect the power distribution to the battery, € 2.50
some heat shrink tube, for protecting soldered connections. 1 meter at € 1.80.
Total expenses for these parts: € 12.90.

First I extended the 3 motor-side wires of every ESC to make them long enough to span the booms of the frame. I just soldered the wires together and covered the joint in shrink tub02e.

 IMG_7910 IMG_7911
Next, I prepared the power distribution hub, by soldering the wires and the HXT connector to it:

 IMG_7914 IMG_7916
To complete the power system, I need 12 connectors to connect the motors to the ESCs. I probably should get some of these 3.5mm “PolyMax” connectors, but I’d rather get them at a local shop and I haven’t been able to find any just yet.

So that’s what has been done so far.

In the mean time, I ordered some more stuff from Hobbyking:

the Turnigy 9X Transmitter & Receiver (Mode 2). Hey, it’s probably a piece of junk, but I have to start somewhere, and this one I can afford right now. Cost: US$ 53.82 and US$ 27.55 for shipping, makes US$ 81.37 in total.
a bunch of EC3 connectors , that I am going to use to connect to ESCs to the power distribution hub. Cost: US$ 6.88 including shipping.
That brings the grand total of all expenses so far at US$ 573.19 + € 12.90.

And there is one more problem to solve. Since the Talon frame is pretty compact, it doesn’t offer enough space for all the components. The top plate will used to house the ESCs, like so:

 IMG_7912
An extra level on top of that is needed to house the Arduino with the AeroQuad shield and the R/C receiver. This level has to be a little bit bigger than the plates of the Talon frame, otherwise there will not be enough room for all the parts.

Fitting an extra level on top of the Talon frame is easy enough. I could use the nylon spacers that came with the frame, or I could easily make some custom spacers using threaded wire. An important question is what material to use: aluminium, wood, plastic? It should be strong, yet light. And affordable. I decided to go with 1.5mm thick epoxy plate. Unfortunately, due to a small error on Conrad’s website, I now have a piece of 0.5mm thick epoxy plate at home, which is too flexible to use. I’ll have to exchange that for the right stuff.

So, the current situation is:

Frame needs an extra level. Correct epoxy plate not yet ordered. Also need a dome or some other protection for the electronics during flight.
Power system: need to buy connectors for motor-to-ESC connections and waiting for EC3 connectors to connect ESCs to power distribution hub. Otherwise finished.
Flight electronics: AeroQuad shield soldering halfway finished. Pictures of that in the next post. Software not yet loaded onto the Arduino, but installed on my computer.

2.4 GHz transmitter/receiver pair is on its way.

I showed the work I had done on the power distribution hub. After I received the EC3 connectors that I ordered, I finished the hub, so now it looks like this. In the second picture, the hub is mounted on the bottom plate of the Talon frame. The only thing missing from this part is the power line for the AeroQuad flight controller. The Arduino will get a direct feed from the battery.

 IMG_7926 IMG_7932
I also equipped all the ESCs with the male end of the EC3 connectors:

 IMG_7922 IMG_7924
Also, in my last post I wrote that I extended the three motor-side wires on each ESC with 18AWG silicone wire. At some point, I decided that 18AWG would be too thin for the motors, and I redid the work with 14AWG wire.

Extra materials bought in this episode:

3m of 14AWG silicone wire, cost: US$ 1,51 /m, total US$ 5.96 incl. shipping
Total expenses so far: US$ 579.15 + € 12.90.

AeroQuad Flight Controller
The second part of this post is about the flight controller. If you go back to my very first post about this project, you can see that the flight controller is made from an Arduino Mega 2560 microcontroller, expanded with a custom-made AeroQuad Shield, that looks like this when it comes in the mail:

AeroQuad shield

After soldering all the pieces together, carefully following the AeroQuad manual, the shield can be mounted on the Arduino. The result looks like this (hopefully I’ll be able to replace the picture with a better one sometime):

 IMG_7933
Today, I hooked it up to my computer, after installing the following software (* unfortunately, the AeroQuad Configurator only runs on Windows and Mac, not Linux, so for someone using Linux for almost everything, that’s a really sad thing):

Arduino 1.0.5 (Windows installer)
AeroQuad Configurator 3.2
AeroQuad flight software 3.2 (from the same page)
The software looks overwhelming at first, but once you click around a little bit, it all seems easy enough. All the necessary steps (uploading software, initializing settings, sensor calibration) are all lined up in easy to find buttons, and so far everything I have tried just worked.

There’s probably a lot to tell about the software, and I have only just made my first steps, but I’ll give you one screenshot. After initializing the software and performing some sensor calibrations, you can select a screen called ‘Sensor data’, that presents a real-time graph of all the sensor output from the AeroQuad shield:

 sensordata
That’s all for now. Next steps:

Connect motors to ESCs
Add Arduino power feed to power distribution hub
Create extra level for mounting the flight controller on the frame

So, the 3 motor-side wires on each ESC were extended using 14AWG silicone wire. Those wires run through the carbon fibre arms of the Talon V2 frame:

 IMG_7937e
The connectors on the motors and on the wires just click together, and they are isolated with shrink wrap. However, this cannot be done at this stage, because the spinning direction of the motors has yet to be determined. The motors are first wired randomly, and later, when a motor turns out to spin in the wrong direction, two of the wires have to be switched. This procedure is part of the calibration, which I am (most conveniently) not going to cover in this post.

For the extra level, I bought some more materials:

Epoxy plate, 1,5mm thick. Cost: € 12.99
Some M3 Nylon Threaded Spacers. Cost: US$ 3.68
Some M3x12mm Nylon Screws. Cost US$ 2.04
M3 Nylon Nuts. Cost: US$ 0.80. Last 3 items added US$ 1.43 for shipping.
I cut a disc out of the epoxy plate, large enough to fit the flight controller, and fitted some nylon spacers on to it. I also added 4 holes for mounting the plate onto the Talon frame. The frame comes with some nylon spacers, meant for mounting a flight controller directly on top of it, and I use those positions for attaching the plate.

 IMG_7940 IMG_7941
It is important to note which is the front side of the quad (see the small pencil-drawn arrow on the mounting plate). The flight controller has to be mounted with one specific side pointing forward. I will be flying in Quad-X mode, meaning that the front of the quad is in the middle between two arms. The mounting holes in the plate are positioned exactly right for this configuration.

Here’s an idea of how it looks when everything is stacked together:

 IMG_7942
Talon V2 frame with power distribution inside
ESCs strapped on the top plate of the frame, with motor-side wires on the inside, and power supply and controller wires on the outside
Epoxy plate mounted on the frame, with leads from the ESCs and the power supply wires for the Arduino coming through the hole in the center of the plate
Arduino mounted on top of the plate
The AeroQuad shield is missing from this picture, as is one other important part: the 2.4 Ghz receiver!

 RX-9X8Cv2
I actually forgot about the receiver when I placed my last order with Hobbyking, and this meant I had no wires to hook the receiver up to the flight controller. Add to your shopping list:

10CM Male to Male Servo Lead (JR) 26AWG (10pcs/set). Cost: US$ 4.51 + US$ 1.43 shipping.
Now, putting it all together is not very difficult anymore. The things I’m going to skip for now are:

Adding a battery. I use a strap to attach it to the bottom plate of the frame.
Wiring the motors and the receiver to the AeroQuad shield
Calibrating the quad and all of the sensors with the AeroQuad Configurator software
Pairing transmitter and receiver and configuring AUX channels on the transmitter
Adding propellors
Fast forward to the (more or less) finished product:

 IMG_7949 IMG_6283
Its maiden flight was on 8 September 2013.

Total expenses: US$ 593.04 + € 25.89, but that excludes some things I forgot to count:

3.5mm polymax connectors
Lots and lots of tie-wraps 🙂











No comments:

Post a Comment