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.

C gauge Autopilot BANK SLEW question

Featured Replies

Hi everybody,How do I control autopilot slew bank?Code below doesn't work, AP is enabled. What is my mistake ?

if( HDG == 0){ // HDG holding enable	if(PLANE_BANK_DEGREES_var.var_value.n > HDG_SLEW){ // HDG_SLEW is required BANK value in degrees		trigger_key_event (KEY_SLEW_BANK_MINUS, 0);	}	if(PLANE_BANK_DEGREES_var.var_value.n < HDG_SLEW){				trigger_key_event (KEY_SLEW_BANK_PLUS, 0);	}}

Still hope to get answer...

  • Moderator

It would really help if you were to explain just what it is you want to achive...The key_event "KEY_SLEW_BANK_MINUS" only works while the sim itself is in "Slew Mode," so for normal operations it is non-functional and quite meaningless...If you are wanting to control the BANK ANGLE, then you would probably want to use:KEY_AP_MAX_BANK_DECKEY_AP_MAX_BANK_INC

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Yes , I want to control BANK ANGLE. Like it can be done in B737.The events you suggest I see in header files that Dai(dragonflight) add as include files to his C-Gauges Create document.But if I understand they are for FSX and those events are absent in FS9 Gauge.h fileI copied lines of events definition to Gauge.h but it still doesn't help

	if(PLANE_BANK_DEGREES_var.var_value.n > HDG_SLEW){				trigger_key_event (KEY_AP_MAX_BANK_DEC, 0);	}	if(PLANE_BANK_DEGREES_var.var_value.n < HDG_SLEW){				trigger_key_event (KEY_AP_MAX_BANK_INC , 0);					}

  • Moderator

Oh boy. No, unfortunately sim1.dll doesn't support those new FSX key_events in FS9. :( The only way to limit your bank angle in FS9 is via the aircraft.cfg file entries:max_bank=25.0 // The maximum angular bank acceleration, in degrees per second squared, that the autopilot will command left or right. max_bank_acceleration=1.8 // The maximum angular bank acceleration, in degrees per second squared, that the autopilot will command left or right. max_bank_velocity=3.0 // The maximum angular bank velocity, in degrees per second, which the autopilot will command left or right.

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

I found solution that work good enough, many thanks to dragondesign Gauge manual.Problem that I still have: ATTITUDE_HOLD doesn't work, it always bring craft to horizontal position,so I decided to exclude it from code.

	   ///////////////////////////////////		//---- HDG		//////////////////////////////////				trigger_key_event (KEY_HEADING_BUG_SET, HDG_Ind);				//---------------------HDG OFF----------------------------------		if ( HDG == -1){			if( AUTOPILOT_HEADING_LOCK_var.var_value.n ==  1) trigger_key_event (KEY_AP_PANEL_HEADING_OFF, 0);		}		//---------------------HDG ON-----------------------------------		if( HDG == 0){			Target_Bank = HDG_SLEW * turn_dir(HDG_Ind, PLANE_HEADING_DEGREES_MAGNETIC_var.var_value.n); // HDG_SLEW get values 30 25 20 15 10			Cur_Bank = cur_bank_convert(PLANE_BANK_DEGREES_var.var_value.n);			//------------------------HEADING-------------------------------			if (turn_dir(HDG_Ind, PLANE_HEADING_DEGREES_MAGNETIC_var.var_value.n) == 0){							if( AUTOPILOT_HEADING_LOCK_var.var_value.n ==  0){				trigger_key_event (KEY_AP_PANEL_HEADING_ON, 0); // hold heading				}				Cur_Bank = 0;				Target_Bank = 0;				Aileron_right = FALSE;				Aileron_left = FALSE;			}			//----------------------HOLD BANK-------------------------------			else{				if( Target_Bank == cur_bank_convert(PLANE_BANK_DEGREES_var.var_value.n)){					if(Aileron_right == TRUE){						for (i=0; i < ailimit; i++){														trigger_key_event (KEY_AILERON_LEFT, 0);							}					}					if(Aileron_left == TRUE){						for (i=0; i < ailimit; i++){														trigger_key_event (KEY_AILERON_RIGHT, 0);							}					}					Aileron_right = FALSE;					Aileron_left = FALSE;					Cur_Bank = Target_Bank;				}				//-----------------------BANK RIGHT-----------------------------				if (Cur_Bank < Target_Bank){//-30 -25 -20 -15 -10 0 10 15 20 25 30					if( AUTOPILOT_HEADING_LOCK_var.var_value.n ==  1)						trigger_key_event (KEY_AP_PANEL_HEADING_OFF, 0);													if( AUTOPILOT_ATTITUDE_HOLD_var.var_value.n == 1)						trigger_key_event(KEY_AP_ATT_HOLD_OFF,0);					if(Aileron_right == FALSE){						if(abs(Target_Bank - Cur_Bank) > 2 )ailimit = 7;						else ailimit = 2;						for (i=0; i < ailimit; i++){														trigger_key_event (KEY_AILERON_RIGHT, 0);							}						Aileron_right = TRUE;						Aileron_left = FALSE;					}				}				//-----------------------BANK LEFT------------------------------				else if (Cur_Bank > Target_Bank){//-30 -25 -20 -15 -10 0 10 15 20 25 30					if( AUTOPILOT_HEADING_LOCK_var.var_value.n ==  1)						trigger_key_event (KEY_AP_PANEL_HEADING_OFF, 0);													if( AUTOPILOT_ATTITUDE_HOLD_var.var_value.n == 1)						trigger_key_event(KEY_AP_ATT_HOLD_OFF,0);					if(Aileron_left == FALSE){						if(abs(Target_Bank - Cur_Bank) > 2 )ailimit = 7;						else ailimit = 2;						for (i=0; i < ailimit; i++){														trigger_key_event (KEY_AILERON_LEFT, 0);							}						Aileron_left = TRUE;						Aileron_right = FALSE;					}				}			}// end of else turn_dir()		}signed int turn_dir(int Target_HDG, double Cur_HDG){	//double offset = 360 - Cur_HDG;	Target_HDG = Target_HDG + 360 - Cur_HDG;	if ( Target_HDG > 360 ) Target_HDG = Target_HDG - 360;		if ( Target_HDG < 10 || Target_HDG > 350) return 0; // don't change bank angle enable HDG_Hold event	else if (Target_HDG < 180) return 1; // turn right	else if (Target_HDG >= 180) return -1; // turn left	 }signed int cur_bank_convert(double Cur_Bank){	if(Cur_Bank > 300 ) Cur_Bank = 360 - Cur_Bank;//right bank 	else Cur_Bank = -Cur_Bank;	return Cur_Bank;}

  • Moderator

Nicely done!If I might make a suggestion though, change every instance of "trigger_key_event" to "send_key_event"......otherwise, the continuous "trigger"ing will interfere with other operations, such as selecting a new altitude, etc.Constantly sending a "trigger..." is a very bad idea. :(

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Only one correction...Adding: trigger_key_event(KEY_AILERON_CENTER,0);

//-----------------------BANK RIGHT-----------------------------				if (Cur_Bank < Target_Bank){//-30 -25 -20 -15 -10 0 10 15 20 25 30					if( AUTOPILOT_HEADING_LOCK_var.var_value.n ==  1)						trigger_key_event (KEY_AP_PANEL_HEADING_OFF, 0);													if( AUTOPILOT_ATTITUDE_HOLD_var.var_value.n == 1)						trigger_key_event(KEY_AP_ATT_HOLD_OFF,0);					if(Aileron_right == FALSE){						trigger_key_event(KEY_AILERON_CENTER,0);						if(abs(Target_Bank - Cur_Bank) > 2 )ailimit = 7;						else ailimit = 2;						for (i=0; i < ailimit; i++){														trigger_key_event (KEY_AILERON_RIGHT, 0);							}						Aileron_right = TRUE;						Aileron_left = FALSE;					}				}				//-----------------------BANK LEFT------------------------------				else if (Cur_Bank > Target_Bank){//-30 -25 -20 -15 -10 0 10 15 20 25 30					if( AUTOPILOT_HEADING_LOCK_var.var_value.n ==  1)						trigger_key_event (KEY_AP_PANEL_HEADING_OFF, 0);													if( AUTOPILOT_ATTITUDE_HOLD_var.var_value.n == 1)						trigger_key_event(KEY_AP_ATT_HOLD_OFF,0);					if(Aileron_left == FALSE){						trigger_key_event(KEY_AILERON_CENTER,0);						if(abs(Target_Bank - Cur_Bank) > 2 )ailimit = 7;						else ailimit = 2;						for (i=0; i < ailimit; i++){														trigger_key_event (KEY_AILERON_LEFT, 0);							}						Aileron_left = TRUE;						Aileron_right = FALSE;					}				}

Nicely done!If I might make a suggestion though, change every instance of "trigger_key_event" to "send_key_event"......otherwise, the continuous "trigger"ing will interfere with other operations, such as selecting a new altitude, etc.Constantly sending a "trigger..." is a very bad idea. :(
Thank you for suggestion , sorry for late reaction but previous message i sent in rush. What is a different between send_event and trigger_event
  • Moderator
What is a different between send_event and trigger_event
Without getting too technical:trigger_key_event is sent in a machine gun like stream... which can effectively block other events from being received... known as a "race condition." The effects for the user being things like the heading bug only inc/dec in 10 degree "jumps," or the altitude preselector inc/dec in 1000' "jumps..."send_key_event is sent once only directly to the Windows Message Pump...Technical explanation*:send_key_event transmits a WM_COMMAND application event (bypasses the keyboard).trigger_key_event initiates the action of a key event.* Note: http://msdn.microsoft.com/en-us/library/cc526958.aspx

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Commercial Member
I found solution that work good enough, many thanks to dragondesign Gauge manual.Problem that I still have: ATTITUDE_HOLD doesn't work, it always bring craft to horizontal position,so I decided to exclude it from code.
That's a known irritation. Whenever you turn ATTITUDE_HOLD on, add this as the following line:-
send_key_event(KEY_AP_WING_LEVELER_OFF,0);

-Dai

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.