mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 16:55:29 +03:00
Pitot Tube:Rename and Add Macros
This commit is contained in:
parent
b13525dbb3
commit
c02b172b46
5 changed files with 11 additions and 9 deletions
|
@ -68,6 +68,12 @@
|
|||
|
||||
#define C_TO_KELVIN(temp) (temp + 273.15f)
|
||||
|
||||
// Standard Sea Level values
|
||||
// Ref:https://en.wikipedia.org/wiki/Standard_sea_level
|
||||
#define SSL_AIR_DENSITY 1.225f // kg/m^3
|
||||
#define SSL_AIR_PRESSURE 101325.01576f // Pascal
|
||||
#define SSL_AIR_TEMPERATURE 288.15f // K
|
||||
|
||||
// copied from https://code.google.com/p/cxutil/source/browse/include/cxutil/utility.h#70
|
||||
#define _CHOOSE2(binoper, lexpr, lvar, rexpr, rvar) \
|
||||
( __extension__ ({ \
|
||||
|
|
|
@ -59,7 +59,7 @@ static void adcPitotCalculate(pitotDev_t *pitot, float *pressure, float *tempera
|
|||
if (pressure)
|
||||
*pressure = (voltage * PITOT_ADC_VOLTAGE_SCALER - PITOT_ADC_VOLTAGE_ZERO) * PITOT_ADC_VOLTAGE_TO_PRESSURE;
|
||||
if (temperature)
|
||||
*temperature = 288.15f; // Temperature at standard sea level (288.15 K)
|
||||
*temperature = SSL_AIR_TEMPERATURE; // Temperature at standard sea level
|
||||
}
|
||||
|
||||
bool adcPitotDetect(pitotDev_t *pitot)
|
||||
|
|
|
@ -74,10 +74,9 @@ static void virtualPitotCalculate(pitotDev_t *pitot, float *pressure, float *tem
|
|||
}
|
||||
}
|
||||
if (pressure)
|
||||
//*pressure = sq(airSpeed / 100) * AIR_DENSITY_SEA_LEVEL_15C / 2 + P0;
|
||||
*pressure = sq(airSpeed) * AIR_DENSITY_SEA_LEVEL_15C / 20000.0f + P0;
|
||||
*pressure = sq(airSpeed) * SSL_AIR_DENSITY / 20000.0f + SSL_AIR_PRESSURE;
|
||||
if (temperature)
|
||||
*temperature = 288.15f; // Temperature at standard sea level (288.15 K)
|
||||
*temperature = SSL_AIR_TEMPERATURE; // Temperature at standard sea level
|
||||
}
|
||||
|
||||
bool virtualPitotDetect(pitotDev_t *pitot)
|
||||
|
|
|
@ -167,7 +167,7 @@ bool pitotIsCalibrationComplete(void)
|
|||
|
||||
void pitotStartCalibration(void)
|
||||
{
|
||||
zeroCalibrationStartS(&pitot.zeroCalibration, CALIBRATING_PITOT_TIME_MS, P0 * 0.00001f, false);
|
||||
zeroCalibrationStartS(&pitot.zeroCalibration, CALIBRATING_PITOT_TIME_MS, SSL_AIR_PRESSURE * 0.00001f, false);
|
||||
}
|
||||
|
||||
static void performPitotCalibrationCycle(void)
|
||||
|
@ -223,7 +223,7 @@ STATIC_PROTOTHREAD(pitotThread)
|
|||
//
|
||||
// Therefore we shouldn't care about CAS/TAS and only calculate IAS since it's more indicative to the pilot and more useful in calculations
|
||||
// It also allows us to use pitot_scale to calibrate the dynamic pressure sensor scale
|
||||
pitot.airSpeed = pitotmeterConfig()->pitot_scale * fast_fsqrtf(2.0f * fabsf(pitot.pressure - pitot.pressureZero) / AIR_DENSITY_SEA_LEVEL_15C) * 100;
|
||||
pitot.airSpeed = pitotmeterConfig()->pitot_scale * fast_fsqrtf(2.0f * fabsf(pitot.pressure - pitot.pressureZero) / SSL_AIR_DENSITY) * 100;
|
||||
} else {
|
||||
performPitotCalibrationCycle();
|
||||
pitot.airSpeed = 0;
|
||||
|
|
|
@ -59,9 +59,6 @@ typedef struct pito_s {
|
|||
|
||||
#ifdef USE_PITOT
|
||||
|
||||
#define AIR_DENSITY_SEA_LEVEL_15C 1.225f // Air density at sea level and 15 degrees Celsius
|
||||
#define P0 101325.0f // standard pressure [Pa]
|
||||
|
||||
extern pitot_t pitot;
|
||||
|
||||
bool pitotInit(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue