T3

My autopilot

I received request to publish more information about my "custom" autopilot, used for TTT contest, so here it is:My autopilot current version is 4. It all started when I received Welleman pic programmer & experiment board as Christmas present (to be honest, it was selected by myself). My initial interest was to make my sailplane turns more efficient and for that I needed to hold wings always crossed with gravity vector.Initial autopilot (V1) was built around 16f627 pic controler and the only thing it did was to use Parallax dual-axis accelerometer for controlling ailerons; rudder and everything else was under manual control. V2 autopilot used pic16f870 chip and added airspeed measurement (using mpxv5004dp sensor) and attempted to regulate sailplane speed by controlling elevator (it also had MPX4115 sensor for altitude measurement, but it was not used at this stage) . When I upgraded my RC-equipment to 2.4G and receiver inputs started to come in parallel groups, then 8-bit PIC did not manage any more and I upgraded autopilot core to dsPIC30f4013 (autopilot v3), adding also GPS to it. As I struggled to understand, what was actually going on inside autopilot during flights, then I attempted to add SD-card logging into autopilot, but faced memory shortage issues on 30f4013. So I upgraded autopilot core to 30f6012 and current version of autopilot (v4) was born.V4 hardware has 3 revisions, I'm using currently revA, but there is also one board of revB ready and its clear by now that there will also be revC. revA has 10 digital change notification inputs (8 for receiver and 2 for accelerometer, all used), 8 analog inputs (gyros, battery voltage, current sensor, 2 pressure sensors - 6 used currently) and 8 servo outputs(5 used), serial port for GPS/2x16 display and SPI port for SD-card. RevB has 14 digital inputs (change notification or input capture), 8 analog inputs and 8 servo outputs, 2 serial ports (for gps and terminal/radio modem), SPI for SD-card and i2c for (future)electronic compass + 3 led's. RevC will change location of some inputs/outputs. I attached Eagle schematics for revision B board here:apv4.sch.Is my autopilot inspired by UAV devboard - no, its parallel development. However, I would probably use UAV devboard, if it would have more powerful chip, much more inputs/outputs and SD-card on board. I'm also looking forward to implement cosine matrix transform in my software like in Matrixnav (waiting for gyros to arrive at the moment). I sometimes browse through Paparazzi and Matrixnav and other firmwares in order to get ideas and avoid inventing bicycle - however, I find it much easier to understand what others have been doing, if I have been working on topic myself also at least to some extent. So, I will keep inventing my own wheel also.As my goal was never to hold wings level with horizon, then there are no IR sensors, although they can probably be connected to vacant analog port if needed.What I've done with my pilot so far: the progress has been very guick since I got SD-card logging working. Once gyroscopes got involved, then direction control started to work reliably as well. My target was to make my sailplane to hunt for thermals and come home automatically and I succeeded on that: current autopilot can control plane speed, altitude and direction and can bring it home if I order it to. It also detects thermals and circles in them, attempting to shift circling center closer to stronger lift area, while making sure that it does not drift too far from "home". During best flight it used engine only for climbing into altitude and the plane stayed up thermalling for one hour without needing to turn on engine again (then I had to leave and took plane down). Thermalling is problematic in my area due to closure of the airport, so I can not do any altitude records where I usually fly. But, if there is suitable weather during some weekend and no family activities, then I plan to drive to G1 airspace area (this is reserved for sailplane flying) and see, how high it really goes....TTT competition is good stimulus for improving autopilot software and algorithms, I'm looking forward for next round. At the end of it I will probably have wp navigation mode with altitude control done via elevator and speed via motor, also navigation accuracy should be greatly improved. Better control over plane (especially when cosine matrix transform is implemented) will help me to make better thermal turns also, so its all very positive what is going on here.
E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • T3
    I played with airspeed gain, but did not get it right in a way I liked it. I had best results when I adjusted gain (but not controller period) on the fly - when oscillation detection kicked in, then lowered it and when not enough control authority was detected, then increased it.
    CMT is mostly discussed in regards of UAV devboard: http://diydrones.com/page/uav-devboard - there are links to relevant white papers and code on this page .
  • I wonder if combining a PID with airspeed based gain tuning would help, since the pitch response from elevator is a function of airspeed^2. Do you have a link to a CMT for controls explanation?
  • T3
    Hi,

    the code was standard PID controller (controller period was 200ms, as servos could not react with shorter period) with Ziegler–Nichols autotuning. Since I moved to Cosinus Matrix Transform, I do not use it any more.
    It worked just and just OK - if PID was tuned properly, then it worked, but oscillations kept being problems on the edges of airspeed envelope. CMT is much better.


    regards,
    Andrus
  • Can you explain or show the code for your airspeed control via elevator? It is a little inderect, since elevator controls pitch, and then pitch control airspeed, but you seem to have gotten great soaring results! How well did it work for you?
  • T3
    Hi, I'm using brushed motor (Graupner Speed 400+) for testing only, it has integrated ESC and its convenient to test temporary setups with it. No issues with engine-generated electrical noise so far.
  • Very good work!
    It would appear that you’re using the Brushed Motor that came with the frame, but it’s difficult to tell from the photo. If so, what have you incorporated electronically to reduce/eliminate the electrical noise generated by the brushes?
  • T3
    Sorry, no experience with that. You may want to check HCA0811ARG8 or HCA0611ARG8, those have internal ADC and i2c interface (not sure if Ardupilot supports or can be made to support this).
  • thank's very much

    i'll work on that when i'm settled in taiwan .

    just an other question:

    do you know an easy 16bit ADC that i could buy that is easy to interface with a pic or something else??
    i tryed with a max195
    but i have troubles to make it works (for now i hope)

    regards
    jeremy
  • T3
    Hi, 12-bit ADC and mpx4115 will give resolution of about 2 meters (about 6 feet). You will not catch thermals with this, but for altitude hold it should be ok. 16-bit adc will give resolution of about 12cm (5 inch), which should be good for any purpose. Whether you actually get such resolution depends already on how much noise your sensor and ADC have, how stabilized is your voltage, etc, cannot really advise you on this, you got to see yourself.
  • late answer again, sorry!

    thank's for the code!!

    i was planing to use inboard ADC from arduino but i guess if i want a good resolution i should get a 16bit adc??
This reply was deleted.