Servers by jDrones

How Autotune PID are calculated?

(Tony) #1

Hello everyone,
I was analyzing the pid on a mission planner after the autotune.
What I was wondering is where the parameters came from.
Is it possible, using the autotune log, to understand how these parameters were calculated?
example know why P goes from 4.5 to example 15.

I wanted to know in particular what practical technique are used to calculate them.
Thanks,
regards.

(rmackay9) #2

Hi Tony,

@Leonardthall is the real expert on autotune so he might be able to help.

(Rick) #3

Autotune finds PIDs experimentally by commanding maneuvers and changing the PIDs until the response meets certain criteria.

The process and criteria are pretty well described by Leonard’s comments in the code. From mode_autotune.cpp:

 * What it's doing during each "twitch":
 *      a) invokes 90 deg/sec rate request
 *      b) records maximum "forward" roll rate and bounce back rate
 *      c) when copter reaches 20 degrees or 1 second has passed, it commands level
 *      d) tries to keep max rotation rate between 80% ~ 100% of requested rate (90deg/sec) by adjusting rate P
 *      e) increases rate D until the bounce back becomes greater than 10% of requested rate (90deg/sec)
 *      f) decreases rate D until the bounce back becomes less than 10% of requested rate (90deg/sec)
 *      g) increases rate P until the max rotate rate becomes greater than the request rate (90deg/sec)
 *      h) invokes a 20deg angle request on roll or pitch
 *      i) increases stab P until the maximum angle becomes greater than 110% of the requested angle (20deg)
 *      j) decreases stab P by 25%

You can look at the rest of the comments in the code if you want a deeper understanding. Some of the #defines describe how the final PID values are generated.

3 Likes
(Leonard Hall) #4

Thanks Anubis!! That pretty much sums it up!

1 Like
(Tony) #5

Thank you very much, you have been very helpful!
that you know, this technique has a particular name?
or if it is possible to derive a mathematical formula or something similar?
Thanks again.

(Sergey) #6

As per comment from source sode, Autotune first tunes rate P, then stab P. So the question is - does an initial stab P affects somehow on the autotune result or not? I.e. will my autotuned PIDs be different starting autotune process with StabP=4.5 and starting with StabP=15?

And as @prova123 noticed autotune increases StabP from default 4.5 to ~15 for me too on 450mm frame. Autotuned PIDs are +/- 30% of the default values. Does this mean something? Default StabP is too low? Owerpowered/underpowered setup?

(Leonard Hall) #7

Hi Tony,

No this approach does not have a name and I have not taken the time to publish it in any control journals. This is an approach I came up based on pretty basic control principles of what is a reasonably simple control problem.

(Leonard Hall) #8

Hi sergbokh,

It actually first tunes rate D then rate P and finally Stab P. Stab P is not used during the tests for rate D or P so it can not have any impact on the final tune.

The stab P can be increased only when there is a good rate tune. Using manual tuning we found numbers o 4.5 to 6 on stab P before you would start to see oscillation or poor performance. With AutoTune we found we could go much higher because the rate D and P were set much better. So the defaults are low because they are chosen to be a safe start for people during their first flight.

2 Likes
(Hari .P) #9

Tuning a 420 mm quad, got STAB P =18.
Is it OK to keep it, or should I lower it ?

(Leonard Hall) #10

I generally find that 18 is a little sharp and the aircraft feels a bit better at 10. Try both and see what you think.

(Hari .P) #11

Thank you sir, i will reduce it and test

(Filippo Franchini) #12

Dear @Leonardthall

I tried to the autotune on my quadcopter (750 mm diagonal) and I got the values in the screenshot attached.

18

In the full parameter list max values accepted for Stabilize roll and pitch P values are 12.000. The copter flies smoothly, should I worry about those high values >13? Should I set those two values to 12.000?

Thank you very much in advance!

Cheers
Filippo

(Leonard Hall) #13

That looks like a good tune. As long as it has no bad habits when in flight you are good!

(Filippo Franchini) #14

Dear @Leonardthall thank you very much for your quick reply. I will look for bad habits and in case I will decrease the high P’s!
Cheers
Filippo