1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-25 17:25:18 +03:00

Pitot Tube:Rename and Add Macros

This commit is contained in:
JuliooCesarMDM 2022-05-07 14:13:43 -03:00
parent b13525dbb3
commit c02b172b46
5 changed files with 11 additions and 9 deletions

View file

@ -68,6 +68,12 @@
#define C_TO_KELVIN(temp) (temp + 273.15f) #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 // copied from https://code.google.com/p/cxutil/source/browse/include/cxutil/utility.h#70
#define _CHOOSE2(binoper, lexpr, lvar, rexpr, rvar) \ #define _CHOOSE2(binoper, lexpr, lvar, rexpr, rvar) \
( __extension__ ({ \ ( __extension__ ({ \

View file

@ -59,7 +59,7 @@ static void adcPitotCalculate(pitotDev_t *pitot, float *pressure, float *tempera
if (pressure) if (pressure)
*pressure = (voltage * PITOT_ADC_VOLTAGE_SCALER - PITOT_ADC_VOLTAGE_ZERO) * PITOT_ADC_VOLTAGE_TO_PRESSURE; *pressure = (voltage * PITOT_ADC_VOLTAGE_SCALER - PITOT_ADC_VOLTAGE_ZERO) * PITOT_ADC_VOLTAGE_TO_PRESSURE;
if (temperature) 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) bool adcPitotDetect(pitotDev_t *pitot)

View file

@ -74,10 +74,9 @@ static void virtualPitotCalculate(pitotDev_t *pitot, float *pressure, float *tem
} }
} }
if (pressure) if (pressure)
//*pressure = sq(airSpeed / 100) * AIR_DENSITY_SEA_LEVEL_15C / 2 + P0; *pressure = sq(airSpeed) * SSL_AIR_DENSITY / 20000.0f + SSL_AIR_PRESSURE;
*pressure = sq(airSpeed) * AIR_DENSITY_SEA_LEVEL_15C / 20000.0f + P0;
if (temperature) 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) bool virtualPitotDetect(pitotDev_t *pitot)

View file

@ -167,7 +167,7 @@ bool pitotIsCalibrationComplete(void)
void pitotStartCalibration(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) 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 // 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 // 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 { } else {
performPitotCalibrationCycle(); performPitotCalibrationCycle();
pitot.airSpeed = 0; pitot.airSpeed = 0;

View file

@ -59,9 +59,6 @@ typedef struct pito_s {
#ifdef USE_PITOT #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; extern pitot_t pitot;
bool pitotInit(void); bool pitotInit(void);