I've been a long time lurker on this website, checking it almost daily. The last couple of months i was working on my bachelors project which consisted of designing from scratch an autopilot for a RC glider. During that time, this website proved to be invaluable and i would like to share my work hoping that, in return, it could help someone else.
The project was separated in two parts: a semester project which then continued as a bachelors project.
During the semester project, all the hardware was deigned, as well as the low level embedded programming.
During the bachelors project, an initial model of the aircraft was created in Simulink using XFLR5 and AVL.
Then using experimental data logs, I was able to determine simple transfer functions which were used to compute the different PID gains.
In parallel, I programmed a ground control station (Mission Control) which was greatly inspired from happykillmore's GSC (as you can probably notice).
The aircraft i used for the project was the AXN Floater from hobbyking. Here's a picture of the aircraft with the autopilot mounted:
For the final test flight, a small circuit was entered using the mission control application. The aircraft managed to complete two circuits before the battery ran out (it was the 8th test using the same battery). The two plots show the track the aircraft flew, and the pitch and roll closed loop angles:
For more details, you can download both reports here:
http://dl.dropbox.com/u/15692375/AXC-Glider%20Semester.pdf (Semester report)
http://dl.dropbox.com/u/15692375/AXCG%20Bachelor%20Report%20Public.pdf (Bachelor report)
If you guys have any questions / comments, or want more details feel free to ask :).
- Alex
Comments
About the FreeRTOS folder, thank you very much, it will be very usefull for me. I have passed you my mail in a private message. I am using GCC as well, but I will try to port it to G++ as I use Eigen library for my algorithms.
About the climb-rate sensor, we can discuss it further when you are going to implement it, but before derive the signal, you have to amplify it (equivalent to 0 - 300m GROUND altitud static signal) for this you have to use the DAC in your micro to offset the signal into the op amp (from mean sea level to ground altitude), then a low pass filter and then derive it (you will have about +- 5m/s climb rate).
The book focuses entirely on the FreeRTOS API, and is not really focused on the STM32 itself. The FreeRTOS comes with an entire library of different ports (for different MCU and compilers), and the STM32 Cortex M3 is one of them. Implementing into the project is a simple matter of adding the correct files, no extra modifications required. I programmed using Atollic (so GCC compiler), and i wouldn't mind giving you my FreeRTOS folder which already contains the required files for the STM32 Cortex M3 port.
It's true that i hadn't considered the case of auto takeoff and landings, where the airspeed does indeed drop. I'll also consider adding the analog derivation of the static pressure sensor, so thank you for that tip.
Feel free to contact me regarding the STM32 for the firmware :).
@Alex
Thank you very much for your book recommendation, I will check it out. Is it really usefull for ST32 Cortex M3? What I do not want is to spend so much time in low-level issues. I came from an AT91SAM7 (ARM7), and I want to do the transition as transparent and quick as it is possible.
I have been using the MPX5004 for a long time, and I have to say, from my experience, that I spend my flights at cruise speed (not more than 30m/s, and usually 20m/s), and I have to say it is pretty useless for auto take-off and landing (< 3m/s) just employing the full range, keep it in mind xD. You can save an opamp in you schematic (the first buffer from the airspeed) and employ it for derive the static pressure signal with a extra capacitor, so, with just one capacitor you will have an analog climb rate sensor! I have to say it is very usefull for control and keep altitude.
About the AHRS, you can take my M.Sc. Thesis (it is already published in this webpage on 14th July), the computational cost is really low and the performance is really awesome.
Regarding the firmware, can I contact you for specific questions about ST32? I will be worth for me to know first-hand experience from other users.
Cheers
@ Mark, I'm the first to say that the current AHRS is too expensive ;). The VN-100 was used as it provided an easy to use and robust sensor which allowed the project to be completed in the short time frame that was fixed. the next step is indeed to either replace it with a lower cost IMU / AHRS (such as the potential MPU6000) or to design one from scratch.
@ Hector, the final AVL model did indeed have a very low and unrealistic drag coefficient. However, a drag "offset" could be added using real world flight data. Assuming one could fly on a day without any wind, using the GPS data (altitude and ground speed), you could calculate the total mechanical energy (mgh +1/2mv^2) and determine the energy loss which can then easily be translated into a drag coefficient.
As for the 200km/h max speed, the sensor is sensitive enough to measure low "normal" flying speeds (<5-20 m/s) so there's no real reason to increase the gain while sacrificing the full scale. besides, what if you want to use an RC jet that does fly at 150+ km? ;). I already have new sensors in mind that could be used to measure the climb-rate.
I won’t be releasing my source code however (at least not yet), but I am willing to answer any specific questions, etc.
As for using the FreeRTOS, I purchased the e-book "Using the FreeRTOS Real Time Kernel - A Practical Guide - Cortex-M3..." and it taught me all I needed to know on how to use and implement it in my application. My overall implementation is rather basic, with an almost static scheduler as well, with only one small task that is created and deleted according to user input.
@ Ryan, what do you mean by "tried"? if you mean system identification, then i only did it for ailerons->roll angle (so roll rate *1/s). The AVL model (AVL coefficients) has a Cn_da control derivative which means that there is an induced yawing moment due to aileron input, but i did not search for this transfer function. I could however give it a try with my current flight logs and see what i can come up with. however, chances are the effects are rather small and since the AXN floater is a 'twitchy' plane it might be hard to find data curves which show a nice correlation between yaw rate and aileron input.
First of all, nice work Alex.
I sum to Mark Colwell if we can check out your firmware code. I want to introduce the FreeRTOS to my ST32, at the moment my scheduler is static, and it would be nice if I can check it out.
Also I want to know if you have had large differents between your model from AVL and the real flights. I've read that the drag was not so much realistic.
In return I can help you to improve the next iteration of your HW, like improving the air-speed sensor (max 200km/h is useless xD), climb-rate sensor, or even AoA sensor, with not so much effort using the same sensors.
Thanks for sharing
thanks you all for the kind words.
Thanks again to Paul Mather for your gsc, as you can probably tell it helped speed things up quite a bit ;). As for selling the board, there are still small changes I'd like to make and features to add as well as trying to design a lower cost version, but if the interest is there i could always consider it a possibility.
As for the sys ident scripts, there aren't any really. you have to use the ident tool box and manually select the data you want to use etc. it's rather simple once you know how to use the tool box (and if you stick to simple linear SISO systems). if you need a more step by step guide of how to use it let me know.
Fantastic job Alex. I too would like to be keep abreast of your Autonomous Cross Country Glider (AXCG)
project. Pls take care of yourself, and best of luck in your studies. Richard T.