EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: DebboR on September 02, 2013, 08:24:43 pm

Title: Smart ornithopter controller
Post by: DebboR on September 02, 2013, 08:24:43 pm
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
Title: Re: Smart ornithopter controller
Post by: Rerouter on September 02, 2013, 09:14:49 pm
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,
Title: Re: Smart ornithopter controller
Post by: firehopper on September 02, 2013, 11:32:04 pm
www.aeroquad.com (http://www.aeroquad.com) < download the flight software :)
it has all kinds of functions for doing almost all of that. there might be some info you can use there :)
Title: Re: Smart ornithopter controller
Post by: DebboR on September 03, 2013, 05:56:13 am
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
Title: Re: Smart ornithopter controller
Post by: firehopper on September 03, 2013, 10:50:20 am
I have a aeroquad hexocopter, and it reads the rc signals quite well :)
Title: Re: Smart ornithopter controller
Post by: johnnyfp on September 03, 2013, 08:08:52 pm
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 :)