Sign in to follow this  
phjvh

Setting and Activating VS

Recommended Posts

I'm programming a simple, 2-axis autopilot that has only ALT HOLD (capture and hold).It also has a VS function, whereby you can "dial in" the desired VS (plus or minus) and then "activate" it such that the a/c ascends or descends accordingly.What key_event is used to enable the VS HOLD (that works, that is...)This doesn't seem to work: if ( mode == 3 || mode == 5 ) { if ( AUTOPILOT_VERTICAL_HOLDvar.var_value.n == 0) { trigger_key_event(KEY_AP_VS_ON,0); } else { trigger_key_event(KEY_AP_VS_OFF,0); } }neither does KEY_AP_VS_HOLD...

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Bill,Have you tried settingdefault_pitch_mode = 2in the autopilot section of aircraft.cfg?Doug

Share this post


Link to post
Share on other sites

Hi Bill, Doug,As far as I know, the events AP_PANEL_VS_HOLD and AP_VS_HOLD, and related variable AUTOPILOT VERTICAL HOLD are a thing of FS2000 and older, and are not implemented in FS2002/FS2004 anymore.(either deliberately or "bug" :-) )Or have never been implemented att all.Which also explains why they are not described in the panel SDK.Another "proof" of this: the only default aircraft that has a seperate VS Hold button in the AP (the default B747-400), doesn't use it as well: see AutopilotVSSwitch.xml from gauge Boeing747-400.cab.(instead it set/follows the ALtitudeHold).The Assignments menu in FS2004 still has a function "Autopilot vertical speed on/off", but that also does nothing.In other words: the FS2004 AP functions don't have a real V/S Hold function seperately from AltHold, just an AltitudeHold with embedded V/S Hold (when actual Alt deviates too much from set Altitude).The only way to "simulate" a real V/S hold function, is to set an extreme high or low target Altitude, and then activate AltHold (so now the AP maintains the set V/S to reach the new Altitude. I used this "trick" in a FlightLevelChange gauge I created a while ago.The line default_pitch_mode = 2 in the aircraft.cfg has little to do with this. This just means that if you switch on the AP Master, FS automatically switches on AltitudeHold.Also, the decription of default_pitch_mode in the AircraftContainer SDK suggests that the FS2004 AP has a "PitchHold" function (value 1: maintain current pitch). IMO this is not implemented too.If you DO add "default_pitch_mode=1" to the aircraft.cfg file, FS also switches on AltHold when you activate the AP Master. (so there's no difference between value 1 and 2).Of course, I could be wrong. But I think not :-) Cheers, Rob Barendregt

Share this post


Link to post
Share on other sites

Thanks, Doug and Rob, for the replies. I guess I'll have to explore the option of a "rediculously fake altitude change" to implement this feature then... Why can't anything ever be easy? ;)This is the "features list" for this unit:Fits Standard 2.25" Round Insturment Hole Built-in Digital Slaved Directional Gyro Digital Track Selector GPS Nav Mode GPS Steering Altitude Hold Simple Intuitive User Interface All Solid-State Sensors Climb and Descend on Vertical Speed Trim Sensing Pitch Servo that Annunciates for Trim. True Control Wheel Steering* The item in red is the only feature not yet programmed... ;)

Share this post


Link to post
Share on other sites

>> Why can't anything ever be easy? :-)Because us addon designers obviously try to stretch the limit of what is possible in any FS version, or have to live with the limitations of any version.Be glad ..If it would be that easy, anyone could do it ...LOLAnd actually, usually the "trick" is very simple once you know which "trick" to apply. And you do now :-)Cheers, Rob

Share this post


Link to post
Share on other sites

Another way to do this would be to simply override the default AP completely and make a feedback loop on the vertical speed using stabilizer trim as the control variable.Adam

Share this post


Link to post
Share on other sites

Hi Adam,Obviously you are right..But we were talking about easy solutions :-)And I know by experiance that outperforming the standard FS2004 algoritme for ALtHold/ V/S Hold is not an easy thing :-)Cheers, Rob

Share this post


Link to post
Share on other sites

I love this. Most of the time all I have to do is wait and my answers come to me. Why couldn't Linux be this way? (Oh right...egos).Shad

Share this post


Link to post
Share on other sites

>Also, the decription of default_pitch_mode in the>AircraftContainer SDK suggests that the FS2004 AP has a>"PitchHold" function (value 1: maintain current pitch). IMO>this is not implemented too.Oddly enough, while experimenting this afternoon, I did find that at least in C, the AP ATT HOLD does work... ;)if ( mode == 3 || mode == 5 ){ if ( AUTOPILOT_ATTITUDE_HOLDvar.var_value.n == 0) { trigger_key_event(KEY_AP_PITCH_REF_SELECT,0); trigger_key_event(KEY_AP_ATT_HOLD_ON,0) ; } else { trigger_key_event(KEY_AP_PITCH_REF_SELECT,0); trigger_key_event(KEY_AP_ATT_HOLD_OFF,0) ; }}Note however that the key_event AP_PITCH_REF_SELECT must be sent first, followed by the AP_ATT_HOLD_ON command. This will enable the trigger_key_event(KEY_AP_PITCH_REF_INC_UP,0);andtrigger_key_event(KEY_AP_PITCH_REF_INC_DN,0);mouse events to function. Unfortunately, there's no corresponding "display variable" equivalent to V/S... Ah well, I'll keep playing around with it awhile... ;)

Share this post


Link to post
Share on other sites

MS keeps surprising me :-)Since you tested it:1. Does AttitudeHold maintains both pitch AND bank angle ??2. What happens if AttitudeHold is activated and then you activate AltitudeHold ?? Because these two functions obviously conflict.E.g. when the aircraft is climbing on AP with AltHold (and VS Hold) On, and you change the V/S dial, obviously the pitch must change to hold the new VS; which conflicts with AttitudeHold :-)Rob

Share this post


Link to post
Share on other sites

>MS keeps surprising me :-)>>Since you tested it:>>1. Does AttitudeHold maintains both pitch AND bank angle ??ATT_HOLD activates both pitch and bank angle (wing-leveler). So, for my purposes I would simply need to add the command to turn wing leveler back off again... ;)>2. What happens if AttitudeHold is activated and then you>activate AltitudeHold ?? Because these two functions obviously>conflict.Setting any of the several ALT Hold functions will cancel ATT_HOLD immediately. When approaching the desired altitude, simply select KEY_AP_ALT_HOLD (or the XML equivalent) to "capture and hold current altitude."Conversely, if you are already at ALT_HOLD, selecting ATT_HOLD will cancel the ALT_HOLD automatically.>E.g. when the aircraft is climbing on AP with AltHold (and VS>Hold) On, and you change the V/S dial, obviously the pitch>must change to hold the new VS; which conflicts with>AttitudeHold :-)I don't know... I haven't tried that one yet! I'll let you know... :)

Share this post


Link to post
Share on other sites

Hi,A bit off the record, but i use ATT hold also for the autoland function:Until 70 ft radio height APPR HOLD, then between 30 and 70 ft ALT HOLD and THROTTLE CUT.These actions automatically increases pitch and when it reaches + 1 degrees ATT HOLD comes on until the plane touches down.In most weather conditions and plane configurations it gives a smooth landing with a realistic 3-4 degrees pos pitch.When SIM ON GROUND reverse power, speedbrakes, autobrakes etc.I think there are more indications to use ATT HOLD.Still exploring..Jan"Beatus Ille Procul Negotiis"

Share this post


Link to post
Share on other sites

FWIW, this seems to work in the "UP" direction, so I'll simply need to add some additional code to make it do what I want in "either" direction... ;)if (mode == 3 || mode == 5 ){ trigger_key_event(KEY_AP_VS_VAR_SET_ENGLISH, 500); trigger_key_event(KEY_AP_ALT_VAR_SET_ENGLISH, 10000); trigger_key_event(KEY_AP_PANEL_VS_ON, 0); trigger_key_event(KEY_AP_PANEL_ALTITUDE_ON, 0);}else{ trigger_key_event(KEY_AP_PANEL_VS_OFF, 0); trigger_key_event(KEY_AP_PANEL_ALTITUDE_OFF, 0);}By replacing the two passed values to UINT32 variables, I should be able to achieve my goal without too much more bother... :)

Share this post


Link to post
Share on other sites

I've been scratching my head on this problem too for the Aztec panel.The old Piper Altimatic X autopilot has an ALT button but this isn't the normal FS pre-selector for a dialled height. Hit the Alt button and the aircraft will hold current height. I have modelled this in the FS panel without problem.The VS selector on the Altimatic is a rocker switch for UP/DOWN. Press UP and the aircraft will start a climb - further presses increase the rate. The aircraft will happily continue to climb forever (air density permitting) unless you interrupt this by selecting ALT.I tried AP_VS_VAR_INC but this doesn't work as it only pre selects a climb rate - it doesn't engage the climb. Do I have to deviate from the original autopilot and add a VS button as well?

Share this post


Link to post
Share on other sites

Hi,You could try:(L:RATE,number) 50 - 0 max (>L:RATE,number) (L:RATE,number) (>K:AP_VS_VAR_SET_ENGLISH) (L:RATE,number) 50 + 2000 min (>L:RATE,number) (L:RATE,number) (>K:AP_VS_VAR_SET_ENGLISH) or something . Jan"Beatus Ille Procul Negotiis"

Share this post


Link to post
Share on other sites

>>Also, the decription of default_pitch_mode in the>>AircraftContainer SDK suggests that the FS2004 AP has a>>"PitchHold" function (value 1: maintain current pitch). IMO>>this is not implemented too.>>Oddly enough, while experimenting this afternoon, I did find>that at least in C, the AP ATT HOLD does work... ;)> ............. In fact, one can control AC pitch from the KB. I believe the K:Variables are also available. I found I could assign "Synch FD Pitch" to the KB. If the Autopilot is ON, then the FD pitch bar is set to the current AC pitch, and the pitch trim is servoed to hold that pitch. This pitch hold is more stable than the FS 'ALT Hold'. I have also assigned 'Change FD Pitch' to Ctl+ (increase) and Ctl- (decrease). Thus, I can change the AC pitch the autopilot holds from the KB. No doubt, 'FD Pitch' can also be changed in a gauge. Thus, I think 'FD Pitch' would be the K Variable to use to set the Pitch Command. By adjusting FD Pitch from the KB I can set VS near zero once I'm at the desired altitude. AC Alititude is less likely to hunt than if ALT Hold is set. However, one has to adjust FD Pitch regularly to keep altitude from drifting off the desired altitude. To disable the 'Hold FD Pitch' I have to hit Ctl-T. That returns pitch control to the KB trim. I think the FD Pitch is also returned to 0 deg. This also worked in FS2K, but there were no key assignments to increase/decrease FD pitch. I display 'FD pitch' in XML Test gauges so I can see the setting more clearly than on the FD bars. Observations of the FS ALT hold lead me to believe that ALT hold changes 'Hold FD Pitch' to the value that results in the set VS. Once near and at the set Altitude another feedback loop comes in that forces Pitch to the value that maintains VS=0. However, this Integration FB reduces the AC's pitch stability so many AC hunt in altitude. I have little doubt that one could synthesise improved Pitch, VS, and Alt control by simply engauging 'Hold FD Pitch' in a gauge. Then, varying 'FD Pitch' (pitch command) in an appropriate way. If there were a similar way to 'Hold Bank', one could also control Turn Rate and Heading more accurately. Ron

Share this post


Link to post
Share on other sites

> I have also assigned 'Change FD Pitch' to Ctl+ (increase)>and Ctl- (decrease). Thus, I can change the AC pitch the>autopilot holds from the KB. No doubt, 'FD Pitch' can also>be changed in a gauge.>> Thus, I think 'FD Pitch' would be the K Variable to use to>set the Pitch Command.Actually, it can be done Ron, and I posted the C code yesterday that shows how it may be accomplished.Like yourself, I did notice that using the Pitch Hold seemed much more stable and certainly responds much more smoothly than does using VS to control ascending and descending inputs.However, being constrained as I am to implementing the operational features of a specific real world autopilot, that isn't even an option for me to consider (unless cleverly hidden by programming magic)...On this AP, instructing the AP to ascend is as simple as dialing in the desired VS and pressing the selector knob. The a/c will immediately begin an ascent or descent as commanded, at the selected vertical speed, and will continue to do so until told otherwise... ;)

Share this post


Link to post
Share on other sites

>I tried AP_VS_VAR_INC but this doesn't work as it only pre>selects a climb rate - it doesn't engage the climb. Do I have>to deviate from the original autopilot and add a VS button as>well?You should be able to place all the needed code in your mouse event to initiate an ascent or descent using the same series of commands I've listed above (either in C or translated to XML>. Pressing the ALT button again would effectively cancel the VS mode for you, so you needn't worry about that at all.

Share this post


Link to post
Share on other sites

Bill,Did you have a chance to check whether KEY_AP_ATT_HOLD_ON is functional only with AP ON ? Or does it work independently of the master AP switch ?Adam

Share this post


Link to post
Share on other sites

I'm going to look into that method myself, Ron. Currently I emulate pitch hold very effectively by engaging or disengaging WING LEVELER after engaging ATT HOLD. The pitch command I need to emulate does not use VS, so I can get away with it. It simply captures the pitch at the time of engagement and holds it (although it could certainly be more responsive).But using the 'FD Pitch' may be a better option.--Jon

Share this post


Link to post
Share on other sites

>I'm going to look into that method myself, Ron. Currently I>emulate pitch hold very effectively by engaging or disengaging>WING LEVELER after engaging ATT HOLD. The pitch command I need>to emulate does not use VS, so I can get away with it. It>simply captures the pitch at the time of engagement and holds>it (although it could certainly be more responsive).>>But using the 'FD Pitch' may be a better option.>--Jon Since 'FD Pitch' and 'AC Pitch' are A: Variables, one could also create his own 'L:pitch error,number' error and use it to control pitch trim. Which ultimately sets VS and finally Altitude. One could log and plot that L:Pitch Error variable to get a better idea of how the control loop is working. Ron

Share this post


Link to post
Share on other sites

Hi,Is there a Variable to see wether >K:AP_PITCH_REF_INC_DN>K:AP_PITCH_REF_INC_UP and>K:SYNC_FLIGHT_DIRECTOR_PITCH are in use?Btw. works perfect.Alt Hold seems to disable it.Jan"Beatus Ille Procul Negotiis"

Share this post


Link to post
Share on other sites

>Bill,>>Did you have a chance to check whether KEY_AP_ATT_HOLD_ON is>functional only with AP ON ? Or does it work independently of>the master AP switch ?It is only "functional" whenever the AP Master is on.I've posted the "final solution" in a new message ('cause it'd be buried in this thread!) ;)Thanks to everyone for their suggestions!

Share this post


Link to post
Share on other sites

Hi Bill, where is the "final solution"Had a search but no luck.I also suppose things are different in FSX now.cheers,nick

Share this post


Link to post
Share on other sites

>Hi Bill, where is the "final solution">Had a search but no luck.>I also suppose things are different in FSX now.>cheers,>nickOh goodness! I have no idea now, three years later... ;)I would suspect that it's either the same day or within a few days after this last post though...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this