Smart ornithopter controller - Page 1
Forum section: electronics / projects

author: DebboR
author_rank: Contributor
timestamp: September 02, 2013, 08:24:43 pm
content: Hello,As a school project, we're working on desinging and building an ornithopter (robot bird). My job is to design a smart controller for the bird that tries to stabilise the flight a little bit (hopefully). The ornithopter will have one main brushless motor (with matching ESC) and has a rotation feedback on one of the gears in the form of a hall-sensor (this signal will be about 100-200Hz max). The tail will be controlled with two RC servos to move it up and down and from left to right.The 'smart' controller will intercept and override the three PWM (servo) signals coming from the main RX as needed to keep a steady flight. It will also have a gyroscope and accelerometer sensor IC (something like the MPU-6050) to have a little feedback about the movements of the bird. I have a few questions:I think the main MCU will be an ATMega2561, as I have several laying around, and it will be clocked at 16MHz (maximum the IC supports). For reading out the PWM signals, what would be the best (and the fastest) way? I think maybe having them hooked up to an interrupt pin which then measures the time between state changes.Would this be sufficient? My main concern about this is using up precious time in the execution of the stabilisation algorithms. I also don't know the frequency of the RX signals (yet), as the RX has yet to be ordered...My other question is, will a 8-bit MCU do the job? I don't expect to use a lot of floating point calculations, as I know this takes longer to process. Maybe I need to look at the 32-bit MCU's of Atmel? Would it make a big difference in the calculation speed?As I'm mainly into programming these days, I think my C skills should be up to the job for this project...Any feedback is greatly appreciated, and I'm going to try to keep this thread updated (and if I don't, feel free to PM me to do so).DebboR

author: Rerouter
author_rank: Super Contributor
timestamp: September 02, 2013, 09:14:49 pm
content: your best bet is to look up quadcopter IMU's inertial measurement units, for me i2C as opposed to analog resulted in the fastest way to get data into the micro (bog standard uno for me) at the moment on a 16Mhz micro its taking about 0.5ms to read per 3 axis sensor,calculating pitch and roll from the accelerometer data is oddly enough quite efficient only needing SQRT and ATAN to be floating, (about 1.5ms for me)you can then throw the accelerometer pitch and roll and the gryos pitch and roll into a complementary filter to better compensate for long term drift,equally though not as important could be yaw from the gyro + heading from a magnetometer if you didnt want the yaw drifting,as for modifying the PWM, how is it currently being generated, you would likely only need to do corrections in the order of 100Hz or possibly less to keep it stable, so it may well be possible to just generate it inside the micro itself,my own code is still in progress so i may share it later, but for the moment i have yet to add the magnetometer heading nor integrate that into the filter,

author: firehopper
author_rank: Frequent Contributor
timestamp: September 02, 2013, 11:32:04 pm
content: www.aeroquad.com< download the flight softwareit has all kinds of functions for doing almost all of that. there might be some info you can use there

author: DebboR
author_rank: Contributor
timestamp: September 03, 2013, 05:56:13 am
content: Thanks for the suggestions. They are indeed very helpful.So can I assume that the ATMega will do the job just fine and that my approach on measuring the duty cycle is sufficient?The aeroquad project will also be helpful I think as they basically also override the signals and use the sensor values. I will definately have a look into that as soon as I get home in the evening.Also, I didnt think of a magnetometer yet. Thanks for the idea!DebboR

author: firehopper
author_rank: Frequent Contributor
timestamp: September 03, 2013, 10:50:20 am
content: I have a aeroquad hexocopter, and it reads the rc signals quite well

author: johnnyfp
author_rank: Frequent Contributor
timestamp: September 03, 2013, 08:08:52 pm
content: ATMega will do just fine. Most of the earlier Quadcopter boards, like the diydrone board and such use atmega's as their main CPU.You might even want to consider putting a few on as they are cheap a dozen. Maybe use one to decode/encode the PWM and the other to do the main processing.If you want to do more complex stuff with optical flow or radar etc then the mega might be a little underpowered. But until you try, you'll never know