• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FS2004 Autopilot PID Variable Calculation

Alright, after much time I am finally coming back to this. I have successfully written a Heading Hold PID loop that works very well at capturing any heading I set on the autopilot. My gain values are exact matches to what NASA lists on their Boeing 747 simulation document.

The only thing missing is how to control the aileron deflection as a function of the commanded roll rate. If anyone could point me in the right direction with that, I would be grateful!

XML:
    <!-- Gain Adjustments and Tuning Numbers -->
    <Element>  
        <Select>
            <Value>
            0.0016175 (A:AIRSPEED TRUE, knots) * 0.110375 + 0.353 max 1.0 min (>L:Roll Mode TAS Gain, number)
            </Value>
        </Select>
    </Element>
    <!-- HDG Select Mode -->
    <Element>  
        <Select>
            <Value>
            <!--Heading Select Mode, 1.25-->
            (A:PLANE HEADING DEGREES MAGNETIC, degrees) (A:AUTOPILOT HEADING LOCK DIR, degrees) - (>L:AP Heading Error 1, number)
           
            (L:AP Heading Error 1, number) -180 &lt;
            if{ (L:AP Heading Error 1, number) 360 + (>L:AP Heading Error, number) }
            (L:AP Heading Error 1, number) 180 &gt;
            if{ (L:AP Heading Error 1, number) 360 - (>L:AP Heading Error, number) }
            (L:AP Heading Error 1, number) abs 180 &lt;
            if{ (L:AP Heading Error 1, number) (>L:AP Heading Error, number) }
           
            <!-- Positive Bank Error = Left Turn, Negative = Right Turn -->
            <!-- Heading Select Kp = 2.83 -->
            (L:Roll Mode TAS Gain, number) 2.83 * (>L:Kp HDG Select, number)
            (L:Kp HDG Select, number) (L:AP Heading Error, number) * 30 min -30 max (>L:AP Target Bank, number)
           
            (L:AP Target Bank, number) (A:ATTITUDE INDICATOR BANK DEGREES, degrees) - (>L:AP Bank Error, number)
           
            <!--Kp Bank Roll Rate, 1.25-->
            (L:AP Heading Error, number) 0.1 * -3 max 3 min (>L:AP Target Roll Rate, number)
           
            (L:AP Target Bank, number) (A:ATTITUDE INDICATOR BANK DEGREES, degrees) - (L:AP Target Roll Rate, number) * (L:Roll Rate, number) - (>L:Aileron Deflection, degrees)
            (L:Aileron Deflection, degrees) 16383 * (>K:AILERON_SET)
            </Value>
        </Select>
    </Element>
 
Here is how I adjust the ailerons when coding a manual turn knob and to simulate the FS Heading Hold in my propliner AP, if this helps. PP/APP has to do with a Polar Path Compass, and GCA/AILA has to do with an addon Ground Controlled Approach system, so those can be ignored:

XML:
//-------- MANUAL TURN, KNOB != 0 - ADJUST TURN RIGHT IF BANK IS GREATER THAN SET VALUE -----------
   <Element>
    <Select>
      <Value> (L:PPStarted1, enum) 1 != (L:APP_init, bool) ! &amp;&amp; (L:GCA_init, bool) ! &amp;&amp; (L:AILA,bool) ! &amp;&amp; (A:Sim on Ground, bool) ! &amp;&amp; (A:Autopilot master,bool) &amp;&amp; (L:AP_SW, enum) 0 == &amp;&amp; (A:Attitude indicator bank degrees,degrees) (L:Bank Knob2,number) &gt; &amp;&amp; (L:Bank Knob2,number) abs 0 &gt; &amp;&amp; (L:Heading Off, bool) ! &amp;&amp; 
if{ (A:Attitude indicator bank degrees,degrees) (L:Bank Knob2,number) - abs 6 min -500 * d 400 (A:AIRSPEED INDICATED,knots) / * (&gt;K:AXIS_AILERONS_SET) 0 (&gt;L:Sim_Head_Hold, bool) 0 (&gt;L:Head_Bug_Set, bool) } </Value>
    </Select>
   </Element>
//-------- MANUAL TURN, KNOB != 0 - ADJUST TURN LEFT IF BANK IS LESS THAN SET VALUE -----------
   <Element>
    <Select>
      <Value> (L:PPStarted1, enum) 1 != (L:APP_init, bool) ! &amp;&amp; (L:GCA_init, bool) ! &amp;&amp; (L:AILA,bool) ! &amp;&amp; (A:Sim on Ground, bool) ! &amp;&amp; (A:Autopilot master,bool) &amp;&amp; (L:AP_SW, enum) 0 == &amp;&amp; (A:Attitude indicator bank degrees,degrees) (L:Bank Knob2,number) &lt; &amp;&amp; (L:Bank Knob2,number) abs 0 &gt; &amp;&amp; (L:Heading Off, bool) ! &amp;&amp; if{ (A:Attitude indicator bank degrees,degrees) (L:Bank Knob2,number) - abs 6 min 500 * d 400 (A:AIRSPEED INDICATED,knots) / * (&gt;K:AXIS_AILERONS_SET) 0 (&gt;L:Sim_Head_Hold, bool) 0 (&gt;L:Head_Bug_Set, bool) } </Value>
    </Select>
   </Element>

//-------- MANUAL TURN, KNOB = 0 - TURN ON SIMULATED HEADING HOLD -----------
   <Element>
    <Select>
      <Value> (L:PPStarted1, enum) 1 != (L:APP_init, bool) ! &amp;&amp; (L:GCA_init, bool) ! &amp;&amp; (L:AILA,bool) ! &amp;&amp; (A:Sim on Ground, bool) ! &amp;&amp; (A:Autopilot master,bool) &amp;&amp; (L:AP_SW, enum) 0 == &amp;&amp; (L:Bank Knob2,number) 0 == &amp;&amp; (L:Sim_Head_Hold, bool) ! &amp;&amp; (L:Heading Off, bool) ! &amp;&amp; if{ 1 (&gt;L:Sim_Head_Hold, bool) (L:Head_Bug_Set, bool) ! if{ (A:Plane Heading Degrees Magnetic, degrees) (&gt;K:HEADING_BUG_SET) 1 (&gt;L:Head_Bug_Set, bool) } (A:autopilot altitude lock,bool) if{ (&gt;K:AP_ATT_HOLD_ON) (&gt;K:AP_WING_LEVELER_OFF) (&gt;K:AP_ALT_HOLD_ON) } els{ (&gt;K:AP_ATT_HOLD_ON) (&gt;K:AP_WING_LEVELER_OFF) } } </Value>
    </Select>
   </Element>

//-------- SIMULATED HEADING HOLD - ADJUST TURN RIGHT IF BANK IS LESS THAN DESIRED VALUE -----------
   <Element>
    <Select>
      <Value> (L:PPStarted1, enum) 1 != (L:APP_init, bool) ! &amp;&amp; (L:GCA_init, bool) ! &amp;&amp; (L:AILA,bool) ! &amp;&amp; (A:Sim on Ground, bool) ! &amp;&amp; (A:Autopilot master,bool) &amp;&amp; (L:AP_SW, enum) 0 == (L:AP_SW, enum) 1 == (L:Confusion Zone, bool) &amp;&amp; || &amp;&amp; (A:Attitude indicator bank degrees,degrees) /-/ (A:AUTOPILOT HEADING LOCK DIR,degrees) (A:PLANE HEADING DEGREES GYRO,degrees) - 0.1* &lt; &amp;&amp; (L:Heading Off, bool) ! &amp;&amp; (L:Sim_Head_Hold, bool) &amp;&amp; if{ (A:Attitude indicator bank degrees,degrees) /-/ (A:AUTOPILOT HEADING LOCK DIR,degrees) (A:PLANE HEADING DEGREES GYRO,degrees) - 0.2 * - abs 6 min -500 * d 400 (A:AIRSPEED INDICATED,knots) / * (&gt;K:AXIS_AILERONS_SET) } </Value>
    </Select>
   </Element>
//-------- SIMULATED HEADING HOLD - ADJUST TURN LEFT IF BANK IS GREATER THAN DESIRED VALUE -----------
   <Element>
    <Select>
      <Value> (L:PPStarted1, enum) 1 != (L:APP_init, bool) ! &amp;&amp; (L:GCA_init, bool) ! &amp;&amp; (L:AILA,bool) ! &amp;&amp; (A:Sim on Ground, bool) ! &amp;&amp; (A:Autopilot master,bool) &amp;&amp; (L:AP_SW, enum) 0 == (L:AP_SW, enum) 1 == (L:Confusion Zone, bool) &amp;&amp; || &amp;&amp; (A:Attitude indicator bank degrees,degrees) /-/ (A:AUTOPILOT HEADING LOCK DIR,degrees) (A:PLANE HEADING DEGREES GYRO,degrees) - 0.1* &gt; &amp;&amp; (L:Heading Off, bool) ! &amp;&amp; (L:Sim_Head_Hold, bool) &amp;&amp; if{ (A:Attitude indicator bank degrees,degrees) /-/ (A:AUTOPILOT HEADING LOCK DIR,degrees) (A:PLANE HEADING DEGREES GYRO,degrees) - 0.2 * - abs 6 min 500 * d 400 (A:AIRSPEED INDICATED,knots) / * (&gt;K:AXIS_AILERONS_SET) } </Value>
    </Select>
   </Element>

//-------- IF SIMULATED HEADING HOLD IS OFF, ADJUST HEADING BUG TO CURRENT HEADING -----------
   <Element>
    <Select>
      <Value> (L:PPStarted1, enum) 1 != (L:APP_init, bool) ! &amp;&amp; (L:GCA_init, bool) ! &amp;&amp; (L:AILA,bool) ! &amp;&amp; (L:AP_SW, enum) 0 == &amp;&amp; (L:Sim_Head_Hold, bool) ! &amp;&amp; (A:Autopilot master,bool) &amp;&amp; if{ (A:Plane Heading Degrees Magnetic, degrees) (&gt;K:HEADING_BUG_SET) } </Value>
    </Select>
   </Element>
 
I am now completely stumped.

I have the following PID for a heading hold mode:

XML:
    <!-- Gain Adjustments and Tuning Numbers -->
    <Element>   
        <Select>
            <Value>
            0.2 (L:Roll Rate, number) * 1 0.2 - (L:Roll Rate Filter, number) * + (>L:Roll Rate Filter, number)
            
            0.0016175 (A:AIRSPEED TRUE, knots) * 0.110375 + 0.353 max 1.0 min (>L:Roll Mode TAS Gain, number)
            </Value>
        </Select>
    </Element>
    <!-- HDG Select Mode -->
    <Element>   
        <Select>
            <Value>
            <!--Heading Select Mode, 1.25-->
            (A:PLANE HEADING DEGREES MAGNETIC, degrees) (A:AUTOPILOT HEADING LOCK DIR, degrees) - (>L:AP Heading Error 1, number)
            
            (L:AP Heading Error 1, number) -180 &lt;
            if{ (L:AP Heading Error 1, number) 360 + (>L:AP Heading Error, number) }
            (L:AP Heading Error 1, number) 180 &gt;
            if{ (L:AP Heading Error 1, number) 360 - (>L:AP Heading Error, number) }
            (L:AP Heading Error 1, number) abs 180 &lt;
            if{ (L:AP Heading Error 1, number) (>L:AP Heading Error, number) }
            
            <!-- Positive Bank Error = Left Turn, Negative = Right Turn -->
            <!-- Heading Select Kp = 2.83 -->
            (L:Roll Mode TAS Gain, number) 2.83 * (>L:Kp HDG Select, number)
            (L:Kp HDG Select, number) (L:AP Heading Error, number) * 30 min -30 max (>L:AP Target Bank, number)
            
            (L:AP Target Bank, number) (A:ATTITUDE INDICATOR BANK DEGREES, degrees) - (>L:AP Bank Error, number)
                
            (L:AP Heading Error, number) 0.1 * -3 max 3 min (>L:AP Target Roll Rate, number)
            
            (L:AP Target Bank, number) (A:ATTITUDE INDICATOR BANK DEGREES, degrees) - 3.2 * (L:Roll Rate Filter, number) 3.6 * - -12 max 12 min (>L:Aileron Deflection, degrees)
            (L:Aileron Deflection, degrees) 16383 * (>K:AILERON_SET)
            </Value>
        </Select>
    </Element>

The code follows, turns to, and maintains headings very well, but I cannot figure out how to damp out aileron motion. The ailerons are in constant oscillation when banking, or in level flight.
The last lines of the code there is what I would think to do that. That line basically reads:

(Target Bank - Current Bank) * 3.2 - (Roll Rate) * 3.6

This equation is based on the follow information from David Allerton's book. The line...

da = (RollC - Model_Roll) * Bank_K1 - Model_P * Bank_K2

... is mentioned as the calculation of required aileron displacement. He uses values of 3.0 for both. I used 3.2 and 3.6, respectively, because in my NASA 747 papers the following line is mentioned:

1599665291872.png


Where am I going wrong?
 

Attachments

  • 1599665196814.png
    1599665196814.png
    32.8 KB · Views: 198
As this has sprung up in my notifications, I thought I'd take a quick look at my own implementation to see the behaviour. One thing I did for my roll hold setup was to use aileron trim, tuned to replicate aileron movement, than direct aileron commands, which means you don't see the aileron animation (so, no visible oscillation - but, of course, a disadvantage if you want to see it, and can't create a separate animation).

In another system I developed, which uses ailerons directly, I implemented a value threshold around the target bank attitude. Carefully tuned, it meant the system would enter into the threshold region, but would not 'oscillate' within it, so long as the overall bank angle remained within said region. This stops the system trying to 'chase' an absolutely exacting target angle of so many .00 degrees (which its own 'input' oscillations would render unreachable, anyway). Perhaps even just a FLR operation on your target bank vs. error differential may achieve a similar effect? A possible solution? I don't think your algorithm is wrong, and it's worth acknowledging we're dealing with a dynamic system, so thresholds of stability are generally being sought: running on numbered rails rarely truly happens, despite the tireless efforts of engineers!
 
Last edited:
As this has sprung up in my notifications, I thought I'd take a quick look at my own implementation to see the behaviour. One thing I did for my roll hold setup was to use aileron trim, tuned to replicate aileron movement, than direct aileron commands, which means you don't see the aileron animation (so, no visible oscillation - but, of course, a disadvantage if you want to see it, and can't create a separate animation).

In another system I developed, which uses ailerons directly, I implemented a value threshold around the target bank attitude. Carefully tuned, it meant the system would enter into the threshold region, but would not 'oscillate' within it, so long as the overall bank angle remained within said region. This stops the system trying to 'chase' an absolutely exacting target angle of so many .00 degrees (which its own 'input' oscillations would render unreachable, anyway). Perhaps even just a FLR operation on your target bank vs. error differential may achieve a similar effect? A possible solution? I don't think your algorithm is wrong, and it's worth acknowledging we're dealing with a dynamic system, so thresholds of stability are generally being sought: running on numbered rails rarely truly happens, despite the tireless efforts of engineers!

I don't think your first idea would work very well with how limited the aileron trim on a 747 is. Further, its not just that I can see the ailerons oscillating... the period of the oscillation is about 2 seconds from extreme to extreme, and the ailerons are going to full deflection left and right during the oscillation. The airplane is rolling about 2 degrees left and right with each oscillation. Very significant, but actually much more well damped than the default autopilot, if you can believe it.

I also attempted to flr my target bank, but it did nothing to stop the oscillating.

My roll damping, aileron control, etc. values in my flight dynamics are exactly accurate and I am confident in my algorithm as well, I think it is just missing something.
 
Admittedly, with the 'trim' idea, you'd have to depart from absolute 'reality' (as much as it can be, in a sim) and boost their range / effectiveness - but, I'd imagine this is distinctly not what you're after.

Only suggestion I have, is to actually "see" what the ailerons are doing - to construct a data readout for each value (including post gain multipliers) and observe their interactions. I've done this a few times when diagnosing issues. Perhaps you'd need more than just FLR, but a more substantive threshold (which is what I did) , or perhaps this isn't even what is at play here.
 
Using Doug Dawson's L Var debugger, I have already done just that.

In this example, my airplane is attempting to maintain heading 340 at FL130 and 200 kts@ Flaps 10, gear down. The screenshot below was taken when the bank angle was near its extreme, with the airplane banked left wing down ~13 degrees. The heading at this second is 338.7, as can be seen by the heading error value. The ailerons at this second are commanded full right wing down, attempting to correct this roll.

1599693269339.png


The only thing I can see going wrong is that the ailerons are being deflected way beyond limits (for reference, the actual deflection limit is 25 up and 20 down on the 747).
This of course leads me to believe that my aileron deflection formula is to blame, as it does not even nearly command the correct amount of aileron to achieve the desired roll rate.

I think what I am missing the Derivative portion of the controller, linking to target roll rate. But I can't find documentation on how that is implemented.
 
This is an interesting one. Without going back through Allerton's description, I recall that his roll controller was purely proportional - although I did test fly with an integral element in roll with my own implementation, there was no advantage for me. If you've implemented an integral, my instinct would be that this is over-accumulating and over-driving the ailerons (but I assume you've ruled this one out?)

Looking back at Allerton, his basic description of the PID formula is as follows:
Code:
s = s + e
m = Kp * e + Ki * s + Kd * (e – eold)
eold = e

Here, derivative is treated as difference between current and prev errors at timestep * gain. There are other roll control derivatives, based on roll rate etc. Perhaps target roll rate could be removed from the code in favour of proportional tuning so that the roll rate is achieved inherently when correcting? (I know this takes it away from the system as spec'cd, but this might be a useful initial step to eliminate problem code, before reintroducing).
 
Last edited:
This is an interesting one. Without going back through Allerton's description, I recall that his roll controller was purely proportional, which I'd imagine it should be - although I did test fly with an integral element in roll with my own, there was no advantage to be had, as far as I could see. If you've implemented an integral, my instinct would be that this is over-accumulating and over-driving the ailerons (but I assume you've ruled this one out?)

Looking back at Allerton, his basic description of the PID formula is as follows:
Code:
s = s + e
m = Kp * e + Ki * s + Kd * (e – eold)
eold = e

Here, derivative is treated as difference between current and prev errors at timestep * gain. There are other roll control derivatives, based on roll rate etc., but perhaps a timestep approach might help.

Hm, I am not familiar with timestep approach... Care to elaborate further?

I am not very familiar with PID theory, but from what I understand I have not implemented an integrator.

Reading through the book again, he describes the roll controller as a PD bank angle hold mode, with the bank angle required being calculated by the heading hold mode as a function of the heading error (exactly as I have done).

I cannot see where in his example the Derivative function comes in.

1599695168754.png
 
Alright, I think I figured it out....

Turns out it was indeed the final part of the equation causing the problem.
I was multiplying the direct amount of deflection, in degrees, by the axis multiplier (16383) without determining how much of the total deflection is required.

The last line now reads as follows:
Code:
(L:Aileron Deflection, degrees) 25 / 16383 * (>K:AXIS_AILERONS_SET)

And the heading changes are way smoother now. No more aileron flickering. More testing is required but this certainly felt like a "Doh!" moment for me. :)
I also changed this line from using roll rate to using the autopilot target roll rate:
Code:
(L:AP Target Bank, number) (A:ATTITUDE INDICATOR BANK DEGREES, degrees) - 3.2 * (L:AP Target Roll Rate, number) 3.6 * - 12 min -12 max (>L:Aileron Deflection, degrees)
 
Last edited:
Ahah! I admit I was focusing on the top lines of your code, and had just assumed you'd squared away the bottom. Looking now, that easily explains the behaviour indeed - max deflection at all times. Hence why tracing the outputs at every stage can be so valuable.

Happy testing! :)
 
I am still struggling to get proper roll rate implemented...

The autopilot in its current state does not seem to use the target roll rate commands anywhere. It will always deflect immediately to the maximum aileron available to achieve the desired bank, rather than gradually applying aileron to achieve the target roll rate. It is especially bad at high altitude and high airspeed where damping is low and control authority high. I think I need another P or maybe PD controller to achieve this but I cannot find any direct information anywhere.

The only information that seems related is this

1599836344601.png


But I cannot figure out how to implement this information properly.

Any ideas?
 
Last edited:
If you look at my code the deflection used is reduced by the airspeed, so you do not have these problems at high speed.
 
After some more careful reading the best I can understand is that the equations posted in the last image above are definitely meant to control the amount of aileron deflection and the rate of aileron deflection...

This is (to my knowledge) confirmed by this information on a later page:

1599961248982.png


The remarks section at the right is what clues me in to believing this is used for all modes. The result is this if I have it right:

XML:
(L:AP Bank Error, number) 3.2 * 12 min -12 max (>L:Aileron Deflection, number)
(L:AP Roll Rate Error, number) 3.6 * -26 max 26 min (>L:Aileron Deflection Rate, number)

I think implementing the rate of aileron change may be the thing I need but I am not sure. How can I implement this into the (>K:AILERON_SET) command?

EDIT: I am really not sure about this one still. I think I really need to get some kind of aileron control proportional to autopilot target roll rate, and Tom, I appreciate the code example, I think it would work well, but it won't be linked to a realistic roll rate being derived by the autopilot so I am eventually going to try to change it (basically, delaying the inevitable :D )
 
Last edited:
Still trying to figure out the basic values given to me by NASA...

I am about 70% confident that I have this almost figured out. What I have now is this:

XML:
<Element>   
        <Select>
            <Value>
            <!-- Roll Mode TAS Adjustment -->
            0.0016175 (A:AIRSPEED TRUE, knots) * 0.110375 + 0.353 max 1.0 min (>L:Roll Mode TAS Gain, number)
            
            
            
            <!-- Heading Select Mode, Kp = 2.83 * TAS adjustment -->
            (L:AP Heading Mode Knob, number) 1 ==
            if{
            -0.00307692 (A:AIRSPEED INDICATED, knots) * 1.47692 + (>L:Kp Aileron, number)
            
            <!--
            Determine Heading Error
            Positive = Left Turn
            Negative = Right Turn
            -->
            (A:PLANE HEADING DEGREES MAGNETIC, degrees) (A:AUTOPILOT HEADING LOCK DIR, degrees) - (>L:AP Heading Error 1, number)
            <!--Correct For 180 Left or Right-->
            (L:AP Heading Error 1, number) -180 &lt;
            if{ (L:AP Heading Error 1, number) 360 + (>L:AP Heading Error, number) }
            (L:AP Heading Error 1, number) 180 &gt;
            if{ (L:AP Heading Error 1, number) 360 - (>L:AP Heading Error, number) }
            (L:AP Heading Error 1, number) abs 180 &lt;
            if{ (L:AP Heading Error 1, number) (>L:AP Heading Error, number) }
            
            <!--
            Determine Bank Error
            Positive = Left Turn
            Negative = Right Turn
            -->
            <!-- Heading Select Kp = 2.83 -->
            (L:Roll Mode TAS Gain, number) 2.83 * (>L:Kp HDG Select, number)
            (L:Kp HDG Select, number) (L:AP Heading Error, number) * 30 min -30 max (>L:AP Target Bank, number)
            (L:AP Target Bank, number) (A:ATTITUDE INDICATOR BANK DEGREES, degrees) - (>L:AP Bank Error, number)
            
            <!--Kp Bank Roll Rate, 0.1 (3 deg per sec/30 deg max)-->
            (L:AP Bank Error, number) 0.1 * -3 max 3 min (>L:AP Target Roll Rate, number)
            (L:Roll Rate Filtered, number) (L:AP Target Roll Rate, number) - (>L:AP Roll Rate Error, number)
        
            (L:AP Bank Error, number) 3.2 * (>L:Aileron Deflection P, number)
            (L:Roll Rate Filtered, number) -3.6 * (>L:Aileron Deflection D, number)
            
            (L:Aileron Deflection P, number) (L:Aileron Deflection D, number) + 21.26 / 12 min -12 max (>L:Aileron Deflection, number)
            
            (L:Aileron Deflection, number) 16383 * (>K:AXIS_AILERONS_SET)
            }
            els{ 0 }
            </Value>
        </Select>
    </Element>

The only problem is that I *still* have not figured out how to get the autopilot to smoothly apply the aileron at an acceptable rate. It just snaps directly to the commanded setting.

Further, I still cannot seem to understand how to make the autopilot bank the aircraft at a commanded rate of bank per second. The NASA documents give specific bank per second limits for the different modes but I cannot wrap my head around how to make that work.
 
Hi,

To get the ailerons not to "snap" you would probably need to create code that adds a certain value to the current deflection during each sim gauge cycle. This will result in a slower movement of the aileron. Then do a test for when the amount of deflection is correct and stop the code from adding/subtracting.

In words:

"If the required deflection is greater than the current deflection, add a tiny amount to the deflection value"
i.e. if L:Aileron Deflection is greater than the current deflection ((A:AILERON POSITION, number) or (A:AILERON AVERAGE DEFLECTION, degrees) or whatever), then L:Aileron Deflection 1 + 16383 * (>K:AXIS_AILERONS_SET)

The 1 + could be edited to provide the desired aileron rotation speed.
 
Back
Top