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

SOLVED - Altimeter - Setting altitude programmatically

Messages
1,361
Country
scotland
Hi Folks

Not exactly a gauge question,
neither an FSX one, (all derivatives thereof),
but as you're the variable's subject matter experts......



Question -
I need to programmatically set the altimeter
to the elevation of the current airport.

i.e. Resulting in correct altimeter reading,
as if pilot had set via the Kohlsman/Kollsman's knob.

WRT FSX versions -
What would be the relevant SimVar name(s)
and any appropriate method(s) ?

e.g.
varset('T:FlightInstruments.SimVar, UNITS, MyValue)
or
whatever's appropriate in FSX.



Background -
Working on an MS Flight GenMission,
i.e. Any airport, in any weather conditions.

Altimeter is initiated at 29.92, (or previous settings).

Both of which
result in incorrect altimeter readings
if the user has applied weather-themes.

e.g. Heavy Snow theme
Airport elevation 156ft
HUD displays 1095ft.

Not usually a problem -
Just visually prompt the user to set manually.

Essential in this case -
As currently-available, capacity-capable, aircraft
are restricted to being cockpit-less.

Not a problem on takeoff.
Destination approach likely involves CFIT.



Yes,
I do fully appreciate
IRL if visibility is that bad,
they shouldn't be up there.

However -
Unlike FSX,
Flight's relatively large-scale weather themes,
result in substantially disparate weather at destinations
compared with departure locations.

Resulting in some addictive flying experiences.



Thanks in advance
ATB
Paul
 
Last edited:
I don't know what it would be in C++, but in an XML gauge you would use something like this whenever you wanted to sync the altimeter setting with the ambient pressure:

(A:AMBIENT PRESSURE, mbar) 16 * (>K:KOHLSMAN_SET)

The FS9 SDK says that the K: variable uses millibars * 16 as units, so that's why that's there. I have never used this code, though.
 
Here is some code for a standby altimeter.
The first initialises the altimeter for startup
the rest is the altimeter itself with the kohlsmann knob inupt at the end.
Code:
<!-- Initialise Standby altimeter --> 
   <Element>
      <Select>
         <Value>(L:standby_kohlsman, millibars) 0 == if{ 1013.20 (>L:standby_kohlsman, millibars) }</Value>
      </Select>
   </Element>

   <Element>
      <Select>
         <Value>(L:standby_kohlsman, millibars) (A:SEA LEVEL PRESSURE, millibars) - 29.54545 * (A:PLANE ALTITUDE, feet) + (&gt;L:standby_indicated_altitude, feet)</Value>
      </Select>
   </Element>

Gauge Name="Standby Altimeter" Version="1.0">
   <Image Name="STANDBY_ALTIMETER.bmp" ImageSizes="120,122" Luminous="1"/>
//---------- Flag ----------------
   <Element>
      <Position X="0" Y="0"/>
      <Select>
         <Value>(A:CIRCUIT GENERAL PANEL ON, bool)</Value>
         <Case Value="0">
            <Image Name="STANDBY_ALTIMETER_FLAG.bmp" ImageSizes="120,122" Luminous="1"/>
         </Case>
      </Select>
   </Element>
//---------------------------------------------------
   <Element>
      <Position X="0" Y="0"/>
      <MaskImage Name="STANDBY_ALTIMETER_MASK.bmp" ImageSizes="120,122">
         <Axis X="60" Y="60"/>
      </MaskImage>
      <Image Name="STANDBY_ALTIMETER_1000.bmp" PointsTo="North"  ImageSizes="120,122" Luminous="1">
         <Axis X="60" Y="60"/>
      </Image>
      <Rotate>
         <Value>(L:standby_indicated_altitude, feet) 1000 /</Value>
         <Failures>
            <SYSTEM_PITOT_STATIC Action="Freeze"/>
            <GAUGE_ALTIMETER Action="Freeze"/>
         </Failures>
         <Nonlinearity>
            <Item Value="0" X="0" Y="-30"/>
            <Item Value="50" X="1" Y="30"/>
         </Nonlinearity>
      </Rotate>
   </Element>
//---------------------------------------------------
   <Element>
      <Position X="60" Y="60"/>
      <Image Name="STANDBY_ALTIMETER_ARROW.bmp" PointsTo="North"  ImageSizes="9,60" Luminous="1">
         <Axis X="4" Y="59"/>
      </Image>
      <Rotate>
         <Value>(L:standby_indicated_altitude, feet) 1000 /</Value>
         <Failures>
            <SYSTEM_PITOT_STATIC Action="Freeze"/>
            <GAUGE_ALTIMETER Action="Freeze"/>
         </Failures>
         <Nonlinearity>
            <Item Value="0" X="60" Y="9"/>
            <Item Value="50" X="61" Y="109"/>
         </Nonlinearity>
      </Rotate>
   </Element>
//---------------------------------------------------
   <Element>
      <Position X="0" Y="0"/>
      <MaskImage Name="STANDBY_ALTIMETER_MBS_MASK.bmp" ImageSizes="120,122">
         <Axis X="40" Y="96"/>
      </MaskImage>
      <Image Name="NUMBER_ROLL_5.bmp" ImageSizes="8,119" Luminous="1">
    <Axis X="0" Y="108"/>
      </Image>
      <Shift>
         <Value>(L:standby_kohlsman, millibars) 1000 / flr</Value>
         <Nonlinearity>
            <Item Value="0" X="0" Y="0"/>
        <Item Value="10" X="0" Y="108"/>
         </Nonlinearity>
      </Shift>
   </Element>
   <Element>
      <Position X="0" Y="0"/>
      <MaskImage Name="STANDBY_ALTIMETER_MBS_MASK.bmp" ImageSizes="120,122">
         <Axis X="48" Y="96"/>
      </MaskImage>
      <Image Name="NUMBER_ROLL_5.bmp" ImageSizes="8,119" Luminous="1">
    <Axis X="0" Y="108"/>
      </Image>
      <Shift>
         <Value>(L:standby_kohlsman, millibars) 100 / 10 % flr</Value>
         <Nonlinearity>
            <Item Value="0" X="0" Y="0"/>
        <Item Value="10" X="0" Y="108"/>
         </Nonlinearity>
      </Shift>
   </Element>
   <Element>
      <Position X="0" Y="0"/>
      <MaskImage Name="STANDBY_ALTIMETER_MBS_MASK.bmp" ImageSizes="120,122">
         <Axis X="56" Y="96"/>
      </MaskImage>
      <Image Name="NUMBER_ROLL_5.bmp" ImageSizes="8,119" Luminous="1">
    <Axis X="0" Y="108"/>
      </Image>
      <Shift>
         <Value>(L:standby_kohlsman, millibars) 10 / 10 % flr</Value>
         <Nonlinearity>
            <Item Value="0" X="0" Y="0"/>
        <Item Value="10" X="0" Y="108"/>
         </Nonlinearity>
      </Shift>
   </Element>
   <Element>
      <Position X="0" Y="0"/>
      <MaskImage Name="STANDBY_ALTIMETER_MBS_MASK.bmp" ImageSizes="120,122">
         <Axis X="64" Y="96"/>
      </MaskImage>
      <Image Name="NUMBER_ROLL_5.bmp" ImageSizes="8,119" Luminous="1">
    <Axis X="0" Y="108"/>
      </Image>
      <Shift>
         <Value>(L:standby_kohlsman, millibars) 10 % flr</Value>
         <Nonlinearity>
            <Item Value="0" X="0" Y="0"/>
        <Item Value="10" X="0" Y="108"/>
         </Nonlinearity>
      </Shift>
   </Element>
//---------------------------------------------------
   <Element>
      <Position X="60" Y="60"/>
      <Image Name="NEEDLE_ALT_1.bmp" PointsTo="North" ImageSizes="9,54" Luminous="1">
         <Axis X="4" Y="50"/>
      </Image>
      <Rotate>
         <Value>(L:standby_indicated_altitude, feet)</Value>
         <Failures>
            <SYSTEM_PITOT_STATIC Action="Freeze"/>
            <GAUGE_ALTIMETER Action="Freeze"/>
         </Failures>
         <Nonlinearity>
            <Item Value="0" X="60" Y="9"/>
            <Item Value="500" X="60" Y="109"/>
         </Nonlinearity>
      </Rotate>
   </Element>
   <Element>
      <Position X="60" Y="60"/>
      <Image Name="NEEDLE_ALT_2.bmp" PointsTo="North" ImageSizes="9,54" Luminous="1">
         <Axis X="4" Y="50"/>
      </Image>
      <Rotate>
         <Value>(L:standby_indicated_altitude, feet) 10 /</Value>
         <Failures>
            <SYSTEM_PITOT_STATIC Action="Freeze"/>
            <GAUGE_ALTIMETER Action="Freeze"/>
         </Failures>
         <Nonlinearity>
            <Item Value="0" X="60" Y="9"/>
            <Item Value="500" X="60" Y="109"/>
         </Nonlinearity>
      </Rotate>
   </Element>
//---------------------------------------------------
   <Mouse>     
      <Tooltip>Altimeter %((L:standby_indicated_altitude, feet))%!d! feet  (%((L:standby_kohlsman, millibars))%!1.2f! inHg)</Tooltip>
      <Area Left="0" Right="120" Top="0" Bottom="122">        
         <Area Left="0" Right="60">
            <Cursor Type="DownArrow"/>
            <Click Repeat="Yes">(L:standby_kohlsman, millibars) 0.25 - (&gt;L:standby_kohlsman, millibars)</Click>
         </Area>
         <Area Left="60" Right="120">
            <Cursor Type="UpArrow"/>
            <Click Repeat="Yes">(L:standby_kohlsman, millibars) 0.25 + (&gt;L:standby_kohlsman, millibars)</Click>
         </Area>
      </Area>
   </Mouse>
</Gauge>
 
This initializes the altimeter with a fixed pressure value. I think he was interested in initializing with the current local pressure?
 
This initializes the altimeter with a fixed pressure value. I think he was interested in initializing with the current local pressure?
True, but it also works with weather engine input. So if I start up the sim without weather i.e. Sim default that is always 1013.2Mb. If the weather engine input says otherwise the altimeter instantly goes to the new QNH. So it does both.
 
But your kohlsman variable is only adjusted manually. I assumed he wanted that to be updated automatically and have the altimeter respond to that input, not have the altimeter itself change without changing the kohlsman variable at all.
 
But your kohlsman variable is only adjusted manually. I assumed he wanted that to be updated automatically and have the altimeter respond to that input, not have the altimeter itself change without changing the kohlsman variable at all.
Updating automatically how? You would need to have a way of identifying the QNH of every passing weather station and every transition altitude. Altimeters must respond to changes in the kohlsman value and that as far as I am aware is always adjusted manuelly.
 
Hi Folks

Cheers for info.

To clarify -
Aircraft is on ground, at departure airfield.
i.e. QFE not QNH. EDIT - Ignore this line

Still not found a working solution.

Many thanks
ATB
Paul
 
Last edited:
Set altimeter to current airport altitude or current pressure at airport's altitude? If it's the latter... 'B' is the default key.
 
Your question is rather confusing -
1st you say -
e.g. Heavy Snow theme
Airport elevation 156ft
HUD displays 1095ft
Then you mention -
To clarify -
Aircraft is on ground, at departure airfield.
i.e. QFE not QNH

Which is it?

QNH = airfield elevation above mean sea level when on the airfield
QFE = barometric altimeter setting that causes an altimeter to read zero when at the reference datum of a particular airfield

QNH commands are easy - "B" key - or programmatically, (>K:BAROMETRIC) (XML), BAROMETRIC (Sim Connect?), or KEY_BAROMETRIC (C++) will sync altimeter setting to sea level pressure.
(SDK and used before)
QFE - after testing is nearly the same as Tom's post ( #2 above ) - (A:AMBIENT PRESSURE, mbar) ceil 16 * (>K:KOHLSMAN_SET)
 
Last edited:
Hi Folks

My apologies re: QNH QFE
for my confusing post



As per my original post -

Question -
I need to programmatically set the altimeter
to the elevation of the current airport.

i.e. Resulting in correct altimeter reading,
as if pilot had set via the Kohlsman/Kollsman's knob.

WRT FSX versions -
What would be the relevant SimVar name(s)
and any appropriate method(s) ?

e.g.
varset('T:FlightInstruments.SimVar, UNITS, MyValue)
or
whatever's appropriate in FSX.



FLIGHT does not support
the "B key" methods suggested
FLIGHT has no key-mapping for Altimeter.



In FSX,
are there any non-gauge, non-key,
direct methods to set the altimeter?




Thanks in advance
ATB
Paul
 
We've listed all the ways... how else would you set it? Telekinesis? It's going to either be a key, an event or SimConnect. There is nothing else.
 
Hi Folks

Ed -
If you'd supplied units for Telekinesis,
I was that desperate,
I'd have tried it.;)


Finally got it working.

Turns out MS FLIGHT in this case
uses different variables
for varget() and varset()

Get -
AltimeterPressureSetting

Set -
IncAltimeterPressureSetting
DecAltimeterPressureSetting
SetAltimeterPressureSetting



Set didn't want to play accurately.

So ended up using a loop
to Inc or Dec as required
to match the ARP elevation.


Thanks for your assistance gents,
particularly stonelance, for the var names.


ATB
Paul
 
Back
Top