Building A Quadcopter! – Part 1

Posted: May 4, 2013 in Hard Projects, Informative Information, Programming, Projects, Quadcopter
Tags: , , , , , , ,

Why hello there!

So for this summer, one of the projects I’m working on is building a quadcopter (or quadrocopter, I prefer this, but both can be used). With exams at school almost over, I have ordered the parts necessary for the project. Unfortunately to keep costs down, I ordered some parts from China, and am still waiting for the parts to come in the mail. While waiting for the parts to come in, I did get some of the US ordered parts in, mainly from SparkFun. While I did get some parts for another project after this one, The one main part I got was the accelerometer/gyrometer (Part: MPU-6050) for the quadcopter, as shown below:

Introducting! The MPU-6050!

Wonderful looking small circuit board, but has proven to be difficult to find code for using the device. I ended up using my Arduino due to the difficulty (and due to the fact that I’m not very good with I2C yet).

Arduino Connected to MPU-6050

After having much trouble with connections, I was finally able to get some communications going between the MPU-6050 and Arduino. Once I got that, through some more hours of research, I figured out the output (x = -14762 y = -278 z = 15000) was basically useless in its current state. After much more research, I couldn’t quite get the concept behind getting a degrees value for the roll, pitch, and yaw. Why do you need the roll, pitch, and yaw? These are directions that a flying machine goes by for navigation and stabilization. After some more work, I was finally able to get a crude output of degrees. It is slightly noisy, but at this point, it looks stable enough for the quadrocopter build. Here’s a video preview of this part in action:

After the accelerometer/gyro part, I moved onto driving the motors. I picked brushless DC motors, due to their superior reliability and power to regular DC motors. Brushless DC motors are a lot more complicated that regular motors, which is a topic for another time. Basically, these motors I’ve purchased use a voltage and current greater than what the little processor that I’m using for the ‘brains’ of the copter, can handle. To resolve this problem, we use a ESC (Electronic Speed Controller). I could have built one with the project, but to save time in construction (I want to get this thing in the air asap!), I opted out for a commercial product instead. Nevertheless, I will approach this in a future revision of the copter.

To control an ESC, we use a 1-2 ms pulse to control it. We can vary this pulse to control the speed of the motor. Easily enough, this is the exact same communications with a servo also. Since I accidentally fried my ESC on my RC car, I can’t do finalized tests until the other parts come in the mail. But like I mentioned, it’s exactly the same as a servo, so I went and grabbed my modified servo (modified for 360 rotation) out of one of my part bins:

Testing the motor code via servo...

After only an hour I had something working. But as soon as I was about to call it quits until the rest of the parts came in the mail, I was like:

“Why not test it in both directions with a pause between each direction?”

Unfortunately, I realized my mistake several hours into research. My ARM M4-Cortex processor has a somewhat weird setup on how to do delays. After working on it more and referencing a old project I’ve done, I was able to get it working:

With the accelerometer/gyro and motor control basically done, I got most of the hard part of the code out of the way. Once I get the rest of the parts in, getting the quadrocopter to fly should be very quick.

Stay tuned!

EDIT:YouTube Videos were reversed.

 – EasternFireTail


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s