Page 1 of 1

Autopilot doesn't care?

Posted: Fri Jan 22, 2016 2:46 pm
by Octal450
Hello all.
Here is the dilemma, this is my first time working with autopilots, so bear with me.

The autopilot for my MD-88 does not turn the yoke enough, therefore it ALWAYS overruns the heading set. Below is the area with the problems. I cannot for the life of me find which value has the problem, and if someone has more knowledge of autopilots, I appreciate.

Code: Select all

<!-- Heading Bug Hold.  2 stage cascade controller. -->

  <!-- Stage #1 sets target roll based on diff between current heading -->
  <!-- and heading bug. -->
  <pid-controller>
    <name>Heading Bug Hold (DG based) Stage 1</name>
    <debug>false</debug>
    <enable>
      <prop>/autopilot/locks/heading</prop>
      <value>dg-heading-hold</value>
    </enable>
    <input>
      <prop>/autopilot/internal/fdm-heading-bug-error-deg</prop>
    </input>
    <reference>
      <value>0.0</value>
    </reference>
    <output>
      <prop>/autopilot/internal/target-roll-deg</prop>
    </output>
    <config>
      <Kp>-1.0</Kp>        <!-- proportional gain -->
      <beta>1.0</beta>     <!-- input value weighing factor -->
      <alpha>0.1</alpha>   <!-- low pass filter weighing factor -->
      <gamma>0.0</gamma>   <!-- input value weighing factor for -->
                           <!-- unfiltered derivative error -->
      <Ti>10.0</Ti>        <!-- 10 integrator time -->
      <Td>0.00001</Td>     <!-- 0.00001 derivator time -->
      <u_min>-20.0</u_min> <!-- minimum output clamp -->
      <u_max>20.0</u_max>  <!-- maximum output clamp -->
    </config>
  </pid-controller>

  <!-- Stage #2 drives the ailerons to achieve the desired roll deg. -->
  <pid-controller>
    <name>Heading Bug Hold (DG based) Stage 2</name>
    <debug>false</debug>
    <enable>
      <prop>/autopilot/locks/heading</prop>
      <value>dg-heading-hold</value>
    </enable>
    <input>
      <prop>/orientation/roll-deg</prop>
    </input>
    <reference>
      <prop>/autopilot/internal/target-roll-deg</prop>
    </reference>
    <output>
      <prop>/controls/flight/aileron</prop>
    </output>
    <config>
      <Kp>0.5</Kp>        <!-- 0.5 proportional gain -->
      <beta>1.0</beta>    <!-- 1.0 input value weighing factor -->
      <alpha>0.1</alpha>  <!-- 0.1 low pass filter weighing factor -->
      <gamma>0.0</gamma>  <!-- 0.0 input value weighing factor for -->
                          <!-- unfiltered derivative error -->
      <Ti>1.0</Ti>       <!-- 10 integrator time -->
      <Td>0.00001</Td>    <!-- 0.00001 derivator time -->
      <u_min>-1</u_min> <!-- -1.0 minimum output clamp -->
      <u_max>1</u_max>  <!-- 1.0 maximum output clamp -->
    </config>
  </pid-controller>


These are the unmodified values. I have tried numbers from other aircraft, but it only seems to affect the initial bank, not the corrective bank to level at the selected heading.

ATC411

Re: Autopilot doesn't care?

Posted: Fri Jan 22, 2016 4:56 pm
by sanhozay
The rule of thumb for getting out of a turn is usually to start rolling level at half the bank angle. In your case, the bank angle is 20 degrees, so you'd start rolling level at 10 degrees from your target heading. With a Kp of -1.0 in your first controller, you are rolling out early (at 20 degrees), which might sound like a good thing to avoid overshoot, but the integrator term (Ki) is quite strong at 10. I suspect the integrator is winding up to a large value between 20 degrees from the target heading and the target heading itself. This then carries you beyond the target.

Try a Kp of -2.0, so the roll out from your maximum bank angle starts later (at 10 degrees from target -- 2.0 * 10 degrees == max bank of 20), and use a larger Ki (which means less integrator). I'd try 40 and see how it goes.

I'd avoid trying to fix this by increasing the max bank angle. That can cause problems with other controllers, e.g. oscillating side to side on a localizer.

Autopilots take a long time to tune. It's important to get the bank angle to aileron as good as you can because other modes, e.g. NAV hold will make use of it.

Re: Autopilot doesn't care?

Posted: Sun Jan 24, 2016 8:24 pm
by Octal450
Sounds good, I will try that and report. Thanks. Could you explain a little bit more what KP KI TI TD Alpha Beta Gamma and those other thing are?

Re: Autopilot doesn't care?

Posted: Mon Jan 25, 2016 9:50 am
by sanhozay
The article in the Flightgear Wiki is a really good tutorial guide:

http://wiki.flightgear.org/index.php?ti ... _autopilot

Most PID controllers in Flightgear only make use of the Kp, Ki, u_min and u_max elements. The others can be removed from the config section so that it uses the default values.

Kp is the proportional gain component of the controller and is the main driver of that autopilot stage. The input is multiplied by this value to get a base value for the output.

Ki is the integral term. This accumulates over time and is used to correct for drift. It should be insignificant when the Kp is doing its work. Note that the Ki part of the controller is disabled when the output of the controller is at its min/max value.

The u_min and u_max values clamp the output within a range.

Re: Autopilot doesn't care?

Posted: Mon Jan 25, 2016 5:37 pm
by Octal450
So the KP changes how much the autopilot outputs the yoke? I will try your suggestion and report. First autopilot I worked on that had this issue!

Re: Autopilot doesn't care?

Posted: Mon Jan 25, 2016 6:17 pm
by sanhozay
It's not quite as simple as that. With a PID controller, Kp, Ki and Td all affect how the output responds to the input and each mode of the autopilot may have multiple filters and controllers chained together.

For the controller you are looking at (heading error -> roll), you probably don't even need a PID controller. A pure gain filter (which is what a PID controller becomes if it only has Kp) will do the calculation. See the wiki article.

Re: Autopilot doesn't care?

Posted: Mon Jan 25, 2016 6:34 pm
by Octal450
That makes sense. I will try to change the numbers and report.

Re: Autopilot doesn't care?

Posted: Tue Jan 26, 2016 1:17 pm
by jwocky
Okay, here is the dirty trick ... you don't use fdm-heading-bug-error-deg but you hang a simple predict on it and use that as reference. The problem is not that the yoke isn't turned fast enough, the problem is, it isn't turned EARLY enough.
Feel free to copy and paste such things from my SYS8 AP in the JPack.

Re: Autopilot doesn't care?

Posted: Tue Jan 26, 2016 3:21 pm
by Octal450
No, it is that is isnt turned enogh in general. 10degrees from the set heading it begins to straighten out. But since the yoke is barely turned, it overruns the heading. Anyways, thanks to sanhozay, I managed to fix this! But thanks anyways!

Re: Autopilot doesn't care?

Posted: Wed Oct 23, 2019 3:30 am
by Octal450
blast from the past reading this.. WOW
now this type of problem for me, is second nature to solve

J