Microchip® Advanced Software Framework

press_altitude.cpp File Reference

Utilities that convert pressure to altitude.

This is a collection of high-level utility functions that will convert a given pressure to an altitude within the Earth's atmosphere using the International Standard Atmosphere (ISA) model. The ISA is an ideal model of how pressure, temperature, density, and viscosity of the atmosphere change with altitude. The basic pressure_altitude_xxx() routines implement ISA equations in a fairly straightforward fashion without additional constraints. For example, the temperature decrease with altitude (lapse rate) is approximately -6.5 degrees Celsius per 1000 meters for standard atmosphere, but the actual rate varies from day to day and throughout the day.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include "press_altitude.h"

Macros

Layer table access convenience macros
#define Pb   (layer_table [(layer)].static_press)
 
#define Tb   (layer_table [(layer)].standard_temp)
 
#define Lb   (layer_table [(layer)].lapse_rate)
 
#define Hb   (layer_table [(layer)].height_bottom)
 
ISA pressure altitude precalculated constants
#define R_g0   (-1 * CONST_REAL_GAS / CONST_STANDARD_GRAVITY)
 

Functions

scalar pressure_altitude (scalar P)
 Get an ISA pressure altitude. More...
 
bool pressure_isa_layer (int index)
 Specify a pressure-altitude layer. More...
 
void pressure_sea_level (scalar P)
 Specify the (corrected) pressure-altitude sea level pressure. More...
 

#define Hb   (layer_table [(layer)].height_bottom)

Referenced by pressure_altitude().

#define Lb   (layer_table [(layer)].lapse_rate)
#define Pb   (layer_table [(layer)].static_press)
#define R_g0   (-1 * CONST_REAL_GAS / CONST_STANDARD_GRAVITY)

Referenced by pressure_isa_layer().

#define Tb   (layer_table [(layer)].standard_temp)

scalar pressure_altitude ( scalar  P)

Get an ISA pressure altitude.

Given atmospheric pressure "P" in pascals, this routine returns the associated barometric altitude ("pressure altitude") using International Standard Atmosphere (ISA) pressure model coefficients and equations.

Parameters
PThe current atmospheric pressure in pascals.
Returns
scalar The altitude in meters.

References Hb, Lb, Pb, and Tb.

bool pressure_isa_layer ( int  index)

Specify a pressure-altitude layer.

The routine sets the pressure_altitude() function to use a specified "layer" in domain [0, 6]. By default layer 0 is assumed. Calling this routine without arguments will set the pressure_altitude() to calculate barometric altitude assuming a pressure domain within ISA layer zero (P < 22 632 pascals).

Parameters
indexThe atmospheric layer index, zero by default.
Returns
bool True if a valid layer index is specified.

References Lb, R_g0, and Tb.

void pressure_sea_level ( scalar  P)

Specify the (corrected) pressure-altitude sea level pressure.

This routine will calculate a bias to correct the ISA standard pressure at sea level (1 atm. = 101 325 Pa) for local variations in barometric pressure at mean sea level (MSL).

Parameters
PThe current local pressure (pascals) at sea level.
Returns
Nothing.

References Pb.