It's not working great, as you will see from the video. I suspect that my pitch and roll measurements aren't as snappy as they used to be, so the controller is always using data that's too old.
so, using the XBee for control comms was a bit problematic, so I splurged on a real RC radio from Hobbyking (the Turnigy 9x). It arrived on Friday, so my weekend was set!
After messing with it and a servo, it was time to connect it to the arduino. My first tests with the "pulseIn" function worked fine as a way to read the PWM signals, but this is not the right way to do it. A more efficient way is to use interrupts. Thanks to the guide at
I got it working with some effort. I stumbled a bit, as it seems that the higher order digital inputs on the mega don't seem to work with pin change inetrrupts, although pulseIn worked. I'll have to look into that. The other thing was a damned compile time error people have been talking about on the arduino.cc site ("collect2.exe. Ld returned 5exit status"). The workaround at forum.arduino.cc/index.php?topic=316146.0 seemed to work.
Some pictures:
Plugged into an Uno.Output showing roll, pitch and throttle outputs from the receiver
I decided to ditch the home brew serial comms over xbee and go with a more professional/hobby radio control system. In the meatime, I wanted to continue to code the control system, so I added a display to give me independence from the arduino serial monitor screen.
Here we see the yaw, pitch and roll numbers from the mpu, zero lag I'm happy to say.
So, i'm using the mpu6050 and the i2cdev libraries, and that all seems to be working out well. Definitely better than me dealing with raw gyro and accelerometer data - that was a nightmare as soon as the props started spinning.
Everything was testing out ok standalone, but then I wanted to switch over to using my xbee modules for comms with my remote controller (a pc with a joystick).
I hate fighting with the things at higher baud rates than 9600, but as soon as I do that (i.e. Use 9600 vsthe mpu6050 example programs use 115200 baud), it throws a wrench into things. I.e. The fifo buffer on the 6050 gets blown, as the program is spending too much time spitting data across a slow connection, I think. In addition to the fifo buffer problem, the yaw pitch roll numbers eventually seem to freeze or go wonky.
So, i tried to set up a timer interrupt (google the "TimerOne" arduino libraries), and just check once a second whether the remote wants the new yaw pitch roll numbers. It's been running like that ok for about half an hour.
In any case, maybe I need an alternative to the xbees (like those nice radio controllers from jhobbyking....)
You can see the mpu6050 on the left (the breakout says "GY-521") and the XBee at the bottom right of the photo.
that's the idea. I made some strides getting it to fly some time ago, but with zero stability. My goal is to have it auto level using a PID loop, but was kind of flommuxed by the vibrations affecting the gyro+accelerometer. I solved that using this mpu6050 modules, and now working on sorting out comms with the xbee. I'll start posting regularly, but progress is slow based on the amount of time putting into it
Always need more UAV projects. Are you writing your own flight controller firmware for the Mega?