• 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.

MSFS Mysterious AUTOPILOT VERTICAL HOLD

Messages
531
Country
france
Hello,

I am working on an autopilot that uses the standard MSFS autopilot. When I engage the ALT mode to reach a given altitude in V/S mode, it works well, the aircraft climbs to the target altitude using the V/S I have set, perfectly. The problem is that during this climb (or descent), I read the AUTOPILOT VERTICAL HOLD SimVar and it is always 0 (false). This Boolean variable is supposed to indicate when the V/S mode is engaged but it remains false, as if the V/S mode was never engaged, while the aircraft correctly climbs/descends to its target altitude.
Isn't it strange?
 
IF MSFS has the same base code as FSX and P3D then no, it is not strange. Vertical Hold has been broken since FS2002 and according to Lockheed-Martin, the bug is buried too deep in the code to fix. They tried. So my guess is that Asobo have implemented an override that looks something like this (at least, this is my implementation of a fix for FSX and P3D):
Code:
//**************************************************************************
// Vertical speed fix
//**************************************************************************
void toggleVerticalSpeed(bool onoff, double rate = 0)
{
    if(onoff == true && rate != 0)
    {
        if (rate > 0)trigger_key_event(KEY_AP_ALT_VAR_SET_ENGLISH, 100000);  // Positive VS = negative pitch demand
        else trigger_key_event(KEY_AP_ALT_VAR_SET_ENGLISH, 0);                       // Negative VS
        trigger_key_event(KEY_AP_VS_VAR_SET_ENGLISH, (UINT32)rate);             // Set required VS
        trigger_key_event(KEY_AP_ALT_HOLD_ON, 0);                                           //Set alt hold on
    }
    else trigger_key_event(KEY_AP_ALT_HOLD_OFF, 0);                                       //Set alt hold off

    return;
}
In this case AUTOPILOT VERTICAL HOLD always shows zero.
 
Thank you for the info, I didn't know this, and I wonder why Asobo kept this in the SDK if it doesn't work, removing it would so much better.
I thank you for sharing the code. In my case, it is not necessary because the target altitude is set before the V/S mode is engaged. My code works fine but the V/S mode flag is wrong, now I know why. I will just create my own boolean variable to replace the SimVar that doesn't work, it shouldn't be too complex.
 
Back
Top