# Arduino + gyro/accelerometer == flight controller …?

Can I use the combination of an Arduino Mega + MPU-6050 gyro/accelerator module instead of a flight controller? Is there something else needed?

It is said that the gyro/acceleration can be used to maintain the balance of the flying vehicle. How is this achieved?

Is it a must that a gyro/acceleration module is read at a higher rate, almost like continuously?

• This is a really complicated question involving a really complicated answer. The really shorter answer is that you can probably get away with just those, though often a GPS is included. A lot of good information can be found on the AeroQuad forums: aeroquad.com/content.php?s=c8535a515b80184c5bc7505428068e48 – NickHalden Sep 10 '12 at 16:45
• @NickHalden if possible, i honestly prefer that really complicated answer.. – Anubis Sep 10 '12 at 16:51
• @c2h2 true, but for the purpose of interest, Arduino is well suited. It'll be a waste to use a beaglebone for that.. – Anubis Sep 10 '12 at 17:08
• @c2h2 Arduino mega got around 64 I/O's. It's comparable with so called beaglebone.. – David Sep 10 '12 at 17:11
• I do have serious interest in flight controller too. I am actually developing a core board for Ti AM3359 chip (same as beaglebone), featuring the same chip,256ram/2gb flash.. only 5cm*5cm, 160pins, quite suitable for this and only weight 10gram, cost 30usd each... it is being under production already. hopefully it will work well. – c2h2 Sep 10 '12 at 17:13

## 1 Answer

Well,

It sound a little bit limited.

I assume that a flight controller performs dead reckoning by double integrating the measured accelerations. And because this computation is relative and not absolute, errors will sums up and you will have a drift. Thus you have to reduce every sources of errors. One of them is the quantization noise due to the fixed point math. Of course you could use high precision floating point math. But if you think of the amount of required computations and the fact that the ATMega does not have floating point support, it looks difficult. And if you want to add a GPS and implement some Kalman filters for sensor fusion, it will definitely be too demanding for that MCU.

To be more specific:

• To maintain the balance of a flying vehicle you have to determine the relative angles of your vehicle. This cannot be achieved by a simple reading of an accelerometer output because the accelerometer will measure the gravity vector AND the accelerations of your vehicle. In real systems, high precision gyroscopes are used. But it's expensive, bulky and not practical. A cheaper way to do this is to use a rate gyro sensor. It's small, easy to interface and cheap. The output of a rate gyro is a signal which is proportional to the angular speed measured by the chip. If you integrate this signal ( sum ) you have the angular position of the chip. It sounds nice. But the problem is the drift. You have to continuously add measured values. But in real systems measured value is defined by : $$measuredValue = measuredEffects + errors$$ After some times, even if the vehicle is no moving at all, the angles returned by your algorithm will be significantly different from the real position of the vehicle due to the fact that errors sum up too. In order to avoid that, you have to sample your sensor at a high rate, reduce sources of noise (especially in the computation by using high precisions ) and use the fact that your vehicle should be flat most of the time and use that to try to cancel the drifts.

• And yes, you have to continuously read the rate gyro output and sum the read value. But continuous things do not exist in a discrete world... Thus you have to do it at a high rate. I have values such as 100Hz or 1kHz in mind. This has to be checked.

• For the control of the vehicle itself: Once you have a measurement of the attitude, you can apply standard PID control. But it's not easy because axis are not independents...

• Have a look at this PhD thesis report: sky-sailor.ethz.ch/docs/Thesis_Noth_2008.pdf. This guy worked on an autonomous UAV system. Which also includes design of the flight controller. – Blup1980 Sep 21 '12 at 15:55
• A remark to your 3rd point: longitudinal and lateral motion of a traditional aircraft are coupled, but this coupling is (in most cases) negligible. For a quadrocopter or helicopter you are right, though. – PetPaulsen Sep 21 '12 at 16:58