To custom code a quadcopter

Hello,

I am making a Quadcopter as my college technical project. I used the body design of HefnyCopter from google code. For The microprocessor part, I'm using a KKmulticopter V5.5 flight controller board which has an ATMEGA168PA processor chip. The atmel chip can be programmed using arduino, so here I am looking for help.

The problem is, Till now I was using the open source codes for the quadcopter. But I feel Its high time, and I would like to code the quadcopter on my own.

I know C/C++ programming, but approaching the problem of flying the quadcopter is become sort of an issue.

If someone could help me get the right approach, I would be really really grateful.
I'm not exactly a noob at coding, so even some tips might help me get a push start. I tried my luck trying to understand the hefnycopter code, but I lost it after a while.

ANY help would be great. Please guide me through this project of mine. :cold_sweat:

Regards

Some help? Pleeease???? :frowning:

Help with what?
How are we supposed to know what it was you lost after a while?

Something is funny here... I have several copters running on the KK board - it is not ATMega. It is ARM. Furthermore, it is so limited on memory that you have to hand-code assembly to fit enough code to run a multi-copter. I think if your goal is to write the code for a multi-copter yourself, then you need to go with another board. I do not think it's possible for a single programmer to complete this project in the time of your college term.

However, the general approach would be to look at existing code to understand what functions you need and how to execute them. It's a lot of math... here is a paper about the math... (You're gonna need your linear algebra for this)

You could start completely from scratch with the information there, and probably create working code just from that, but I don't think you could do it in time. Keep in mind, most of the multi-copter firmware out there has been many years in development. The KK board is unique in that the code is almost all written by Rolf Bakke, and it's hand-coded assembly - but it took him a long time to develop - more than a year.

I'm really sorry but I'm sure the KKmulticopter board as an ATMega168. You can see it here:

http://lab.westernwillow.com/component/kkmulticopter-v55-controller-blackboard

And as far as I know, ATMega can be programmed using arduino.
Regarding the quadcopter physics and dynamics, I have done my homework there. The coding part is where I'm facing issues.

I'm clueless about how to take inputs from the gyros.
Other than that, we are supposed to control the brushless motors using ESCs, which again is something I am not familiar with.

Being a beginner at arduino, I have doubts about a million things. But something like a sample code, If i can get it from a helpful soul, would really help me move a few more steps ahead. (Till I face another impasse and I come back to this forum crying about my issue)

Plus, I'm clueless about how to read a datasheet so I dont know which pin gives what and what do I control using where and stuff like that. (Vague, but I guess I have made my point about being a beginner)

Thanks in advance, If anyone helps me out.

I see what you are talking about now. I thought you meant the original KK board by Rolf Bakke...

Have you taken a look at the Ardupilot code?

Radio Control ESCs for brushless motors are fairly easy to run with Arduino, they just run on the old RC PWM standard (same as servos). Some ESCs designed for multi-copters (such as Afro) will run a faster standard, but they will run the old standard too.

You can find some code for that here...
http://forum.arduino.cc/index.php/topic,20594.0.html

On your issue with reading data sheets... you're gonna have to learn. I've been a programmer for over 25 years, but I messed with hardware very rarely until about 10 years ago - it was a steep learning curve. You just have to attack that with knowledge. You shouldn't really have to read a lot of component documentation for this project though. The Ardupilot does everything you need...

BTW, I recently discovered that Fritzing has the Arduflyer board as a built-in component, so you can use that to get a better idea of the physical layout of stuff. It also probably wouldn't hurt to go ahead and get an Ardupilot board, and build yourself a quad with it and learn how it all works that way, if you have never done that. I can help you with that, I've done it a couple times. The Ardupilot board is really easy to use especially if you have a proven frame design, which it sounds like you've done already?

Abz2604:
I'm clueless
again is something I am not familiar with.

Being a beginner

I'm clueless about how to read a datasheet so I dont know which pin gives what and what do I control using where and stuff like that.

None of the above gives me any confidence that this is a realistic project for you to take on. I don't think you have any concept of the complexity of the problem you are tackling. As a novice you could easily spend literally decades on this without ever achieving controlled flight. Just taking an existing open-source solution targeted at the hardware you are using and tuning that to achieve stable flight would be a considerable achievement. I recommend that you set yourself more realistic goals and try to get an open source controller working. If you manage that and fancy writing your own implementation then you always have that option later. (I suggest you download an open source controller and read through the source and see how much of it you can follow before you tackle that one. I suspect you'll quickly realise it is a waste of several years of your life.)