Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

KEY_AP_MAX_BANK_DEC/INC

Featured Replies

  • Commercial Member

In a post a long, long time ago Bill postulated that these events might write to the aircraft.cfg file, but it appears that they don't because however many send_key_events that I trigger, AUTOPILOT_MAX_BANK_ANGLE remains the same. Does anyone know if these events actually work and if so, what do they do?

 

I guess that the alternative is to build a feedback loop against PLANE_BANK_DEGREES but so far I've not been too successful with that! :lol:

 

-Dai

This only works for FSX + and in order to use the Dec/Inc commands for bank a set of bank limits must be set in the aircraft.cfg.

 

Taken from here. Look at the Boeing 737-800 or CRJ example.

 

max_bank The maximum bank angle in degrees that the autopilot will command either left or right.

Airbus A321( max_bank=25.0 )
Boeing 737-800( max_bank=30,25,20,15,10 )
Bombardier CRJ 700( max_bank=30,15 )
Douglas DC-3( max_bank=25.000000 )

 

In our F-111 project we have this in the {Autopilot} section of the aircraft.cfg.

max_bank=60,52,43,34,25 

After that everything works for me although it is XML.

20AUG21_Avsim_Sig.png?dl=1  FS RTWR   SHRS F-111   JoinFS   Little Navmap 
 

 

  • Author
  • Commercial Member

So, looking at the Boeing, the initial max_bank is 10 degrees and sequential KEY_AP_MAX_BANK_INC will give me 15, 20, 25 and 30 degrees in turn?

 

Just to confirm, yes, this is for FSX and Prepar3D. I did design a feedback loop for FS9 using PLANE_BANK_DEGREES which sort-of worked but it randomly overshot the maximum bank angle and just as randomly dropped the nose :(. I made some big holes in the (virtual) ground with that.

 

-Dai

Dai,

 

 Couldn't really tell you because on this side it works. XML wise there are only 2 commands and one "read" variable.

<!-- READ -->
(A:AUTOPILOT MAX BANK, degrees)

<!-- COMMANDS -->
(>K:AP_MAX_BANK_DEC)
(>K:AP_MAX_BANK_INC) 

If you have a registered FSUIPC maybe try monitoring, through the logging facilities,  0x2E04 as a double word and see if your code is actually reaching FS.  Otherwise, all the goodies needed are provided in the B737_800.cab/autopilot.xml and the B737-800 aircraft.cfg .

 

Keep plugging at it, it should work... Unless MS screwed up on the C++ side of it - seriously doubt it as usually the case is backwards dealing with C++ and XML. The C++ stuff works and XML doesn't.   

 

Edit - Just looked at the FSX SDK and -

 

Under "Panel and Gauges SDK / Token Variables" it is listed as -

AUTOPILOT_MAX_BANK  as a Float

 

Under Variables / Simulation Variables it is listed as -

AUTOPILOT MAX BANK  "True if autopilot max bank applied" (??? #####)  as Radians ??? 

 

Both are confirmed the same in the online ESP V1.0 SDK.

 

In the fsx gauges.h the return var is listed as  "AUTOPILOT_MAX_BANK" 

 

I also looked in the FS9 SDk gauges.h and there was nothing listed but if memory serves correctly a function of max bank was used in FS2000 for the Concorde.   Maybe it is still mapped? The way it looks though is that you should be using  AUTOPILOT_MAX_BANK rather than AUTOPILOT_MAX_BANK_ANGLE.. Not a pro at all on the charlie stuff but it seems reasonable. 

20AUG21_Avsim_Sig.png?dl=1  FS RTWR   SHRS F-111   JoinFS   Little Navmap 
 

 

  • Author
  • Commercial Member

Hi Ed

 

That's what I understand too, but the following piece of code simply doesn't work. It's in the PRE_UPDATE section.

aircraft.cfg

[autopilot]
...
max_bank=28,27,26,25,24,23,22,21,20,19,18,17,16
if(getASInd()<200)reqd_max_bank=28;
else if(getASInd()>199 && getASInd()<220)reqd_max_bank=27;
else if(getASInd()>219 && getASInd()<240)reqd_max_bank=26;
else if(getASInd()>239 && getASInd()<260)reqd_max_bank=25;
else if(getASInd()>259 && getASInd()<280)reqd_max_bank=24;
else if(getASInd()>279 && getASInd()<300)reqd_max_bank=23;
else if(getASInd()>299 && getASInd()<320)reqd_max_bank=22;
else if(getASInd()>319 && getASInd()<340)reqd_max_bank=21;
else if(getASInd()>339 && getASInd()<360)reqd_max_bank=20;
else if(getASInd()>359 && getASInd()<380)reqd_max_bank=19;
else if(getASInd()>379 && getASInd()<400)reqd_max_bank=18;
else if(getASInd()>399 && getASInd()<420)reqd_max_bank=17;
else if(getASInd()>419 && getASInd()<440)reqd_max_bank=16;
else if(getASInd()>439)reqd_max_bank=15;

lookup_var(&ap_max_bank);                  // MODULE_VAR ap_max_bank = {AUTOPILOT_MAX_BANK};

current_max_bank=RAD_TO_DEG(ap_max_bank.var_value.n);   // Radians to degrees
current_max_bank=(int)current_max_bank;

if(current_max_bank>reqd_max_bank)
  send_key_event(KEY_AP_MAX_BANK_DEC,0);
else if(current_max_bank<reqd_max_bank)
  send_key_event(KEY_AP_MAX_BANK_INC,0);

What is utterly frustrating is that at some point in the panel load procedure the key_event does trigger under the following circumstances:

 

1. if the loaded flight is in a paused state then both reqd_max_bank and  current_max_bank equal 28, which makes sense. When the flight is released then reqd_max_bank and current_max_bank both switch to the bank angle defined by the initial airspeed.

2. If the loaded flight is NOT in a paused state then reqd_max_bank and current_max_bank both switch to the bank angle defined by the initial airspeed.

 

At all other times the code runs but the key_event is being ignored i.e. reqd_max_bank changes depending on airspeed but current_max_bank remains at the initial value.

  • Author
  • Commercial Member

Okay, got it. The limit of max_bank parameters is nine; any more than that and FS will load the initial one at panel load and then fail afterwards. My guess is someone put a for-loop in the code instead of a do-while (or similar), but it's only a guess.

  • Author
  • Commercial Member

Ed - I'm very sorry to not answer your question, especially after all the help you've given me in the past, but I have to hide behind an NDA. The control surfaces on this aircraft weren't exactly standard and AFAIK, were never attempted again in this fashion.

  • Author
  • Commercial Member

For anyone who's trying to solve the limit-bank-angle-by-speed problem: this works without having to use the FSX bank_angle setup. For me, the nice thing about this procedure is that it quite randomly slightly over-banks and then corrects itself, just as in real life.

// --------------------------------------
// Direction of turn / closing angle
// --------------------------------------
int ap_turn=0;                      // Direction of turn 1=left, 2=right
int ap_delta=0;                     // Closing angle

int getAPDelta(int target)          // target = required heading
{ 
    int delta=0;

    delta=target-(int)getHdgMag();  // PLANE_HEADING_DEGREES_MAGNETIC
    if(delta<-180)delta+=360;
    if(delta>180)delta-=360;
    if(!ap_turn)
    {
        if(delta<0)ap_turn=1;       // Left
        else if(delta>0)ap_turn=2;  // Right
    }
    return abs(delta);              // Closing angle on the new heading
}

// --------------------------------------
// Limit the bank angle depending on airspeed.
// In general, two ticks seem to be enough for the damping timer 
// i.e. the roll section is executed every third cycle
//---------------------------------------
void setBankLimit(int bank_limit,int turn_direction,int damping)
{
    double current_bank=0;
    static double damping_timer=-1;

    current_bank=getBank();                  // PLANE_BANK_DEGREES

    // Make sure the autopilot heading function is disengaged
    send_key_event(KEY_AP_PANEL_HEADING_OFF, 0);
 
   // If we're at the required bank then centre the ailerons. This section executes every cycle
    if((int)current_bank==bank_limit)send_key_event(KEY_AILERON_CENTER,0);
    else
   // If tick 18 is equal to or greater than the damping timer
   // add aileron to accelerate or correct the roll rate
    if(damping_timer==-1 || getTick()>=damping_timer)       // TICK18
    {
        damping_timer=getTick()+damping;        // in ticks
   // Bank left
        if(turn_direction==1)
        {
            if(current_bank<bank_limit)send_key_event(KEY_AILERON_LEFT, 0);
            else if(current_bank>bank_limit)send_key_event(KEY_AILERON_RIGHT, 0);
        }
   // Bank right
        else if(turn_direction==2)
        {
            if(current_bank<bank_limit)send_key_event(KEY_AILERON_RIGHT, 0);
            else if(current_bank>bank_limit)send_key_event(KEY_AILERON_LEFT, 0);
        }
    }
    return;
}

The following is a code snippet from my autopilot to show the usage. As ap_delta and the new heading close to within ten degrees, I hand off back to the FSX autopilot. The transition is seamless.

// Get the closing angle and turn direction
ap_delta=getAPDelta(ins_ap_hdg); // ins_ap_hdg is the required new heading in degrees

//If the closing angle is equal to or less than ten degrees then hand off to the FS autopilot
if(ap_delta<=10)
{
  send_key_event(KEY_HEADING_BUG_SET,ins_ap_hdg);
  send_key_event(KEY_AP_HDG_HOLD_ON,0);
  send_key_event(KEY_AP_WING_LEVELER_OFF,0);
  ap_turn=0;
}
else
// Turn the aircraft onto the new heading
// bank_angle is the bank limit in degrees
// ap_turn is the direction to turn
// damping_rate is in ticks
{
  setBankLimit(bank_angle,ap_turn,damping_rate);
}

  • Commercial Member

Talk about your overkill department, yeesh! I have bank limiting... but not that way and it works in FS9.

 

I can't tell you how it works, NDA (of course). But I can tell you it is 1000% simpler than the approach you took.

Ed Wilson

Mindstar Aviation
My Playland - I69

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.