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

Join diydrones

Comments

  • http://playground.arduino.cc/Code/PIDLibrary

    There is PID and Auto tune PID library in Arduino! Anyone tried it before?

  • Has anyone given anymore thought to the adaptive control or an "autotune" PID algorithm? I’m intrigued with the idea of having an automatic setup mode on the APM.

  • I have not looked at the matlab generated c code too closely. It may be possible to make matlab sub functions that match functions that gcc understands and optimises.

    One optimisation that will make all others insignificant is to reduce the data size. I am now using doubles to be on the safe side. If the doubles can be reduced to a 16bit manitissa + exponent, the algorithm would fit many more processors. Reducing data size will cause stability problems so I am avoiding this for now.

    As an example of an algorithm, maybe you are thinking of something like a matrix inversion. I dont know if there is much control over how this level of algorithm is solved. I dont know what the optimisation choices are.

    I am stuck with MS VC++ because that is what my simulation plugin is written in. Having just proven that the filter loading is not significant, I will not put more effort into optimisation for this plugin.

    One aim is to make a library that is as easy to use and understand as possible. Maybe I ought to start an open source project somewhere??
  • Ah oki, now I understand what are you saying.

    One question, can you select what algorithms (for numeric calculations) to employ in C from Matlab?

    Going back to the compiler, GCC 4.5.0 now optimizes at compiling stage all your math code, I strongly recommend you to use it. I've noted a significant performance against other version of GCC and other compilers.
  • Hector,
    The tricks are not optimisations at code level, they are at maths level. Again, I agree a good maths library would beat the Matlab code implementation. I am just not ready for that challenge yet. For example:

    Cholesky factorisation and back substitution: Makes the matrix inversions more stable and quicker.

    Jaccobian matrix through complex differentiation: Necessary for my evolving state models. My models also seem to defy my weak calculus abilities.

    Matt
  • Matthew,

    don't care so much about the "Matlab math tricks". If you are using GCC 4.5.0+ , the compiler will do this job for you. I spent so much time in the past thinking how to optimize my code when I realized the compiler does it better than me :P.
  • Developer
    Super News. Congratulations.
  • Pete, I also have an OpenLog but I have not wired it up yet. LImiting to 5 chars per value plus delimiter gets us to around 9K8baud. It is possible.

    Great progress today. I now have a filter working real time in the simulator. The inputs and outputs are not right but it does show that it is possible to run it. The frame rate is not noticeably lower, getting 40-50Hz depending on scenery.

    The c code was generated from Matlab and manipulated into the flight sim plugin. The matlab code does too many nice maths tricks to cope re-writing from scratch.

    Time to go out into the real world and enjoy some sun. Maybe even fly something..

    Matt
  • Developer
    Matt, I'm happy to provide you with some help any telemetry issues associated with UAV DevBoard as I've been working with that for some months. Our current maximum rate of delivering data is 19.2K Baud (bits) and that is best done to the OpenLog device that some of us are using . The Xbees seem to not run as fast or as well as the OpenLog.
  • Héctor,

    I agree. The target processor has an excellent optimised matrix math library which I wish to make good use of. The matlab code will make a great pseudocode base. It looks like we might have problems with telemetry logs from any of the standard code the autopilots are running.

    I still need to take the smaller step to the simulation plugin using matlab. My desktop PC and MS VC++ compiler should make short work of it.

    I am now translating the algorithm from the last library into the new one. It hurts...

    Matt
This reply was deleted.