S. Marsanne

Math and Pressure Sensor Conversion Sample Code

Discussion created by S. Marsanne Employee on Dec 18, 2016

Here are some general sample code for handy math, physical unit conversion which was aimed at Pressure Sensors and Altitude. (Converting a pressure into altitude is quick tricky and help understand how planes lands safely.. check out for METAR data to understand more about it)

 

Here are some of the functions in there:

 

conversion module:

void From_Pressure_mb_To_Altitude_US_Std_Atmosphere_1976_ft(double* Pressure_mb, double* Altitude_ft);
void QNH_Set_ISA_Default(void);
void QNH_Altitude(double P);
void From_Tf_n_RH_To_HeatIndex_f(double* Tf, double* RH, double* HeatIndex_f );
void Tc_to_SaturatedVaporPressure(double* Tc, double* PSatV);
void Pmb_n_elevationm_to_Altmb(double* Pmb, double* elevationm, double* Altmb);
u32 RMS_Array_s32_x100(s32* ps32, u8 nb_samples);
void sort_up_pu32( u32 *pu32, u8 size);
void sort_up_pdbl( double *pf, u8 size);
double ComputeBlackMan(u32* pu32, u8 size); // Blackman filter using coefficients

 

Seb_Math module

s32 Interpolate_s32 (s32 x0, s32 x1, s32 y0, s32 y1, s32 x);
float Interpolate_float (float x0, float x1, float y0, float y1, float x);
u8 ValToPercentage(short int x0, short int x1, short int x);
short int PercentageToVal( short int y0, short int y1, u8 x);
void LDIV(u8 bNbofFractionalBits);

// also optionally 64 bit simple arithmetics functions including division
void Mul64 (u32 a, u32 b);
u32 Div64 (u32 Denominator, u32 *Remainder);

Outcomes