35 #include "physical_constants.h"
37 #define VCC 5.0f //Supply voltage in V
38 #define POWER (2.0f/7.0f)
40 #if defined(PIOS_INCLUDE_MPXV5004)
44 static uint32_t calibrationSum = 0;
45 static int16_t calibrationOffset;
61 uint16_t zeroPoint = (uint16_t)(((
float)calibrationSum) / calibrationCount + 0.5f);
63 calibrationOffset = zeroPoint - (int16_t)(1.0
f/3.3
f*4096.0
f+0.5
f);
73 calibrationOffset = zeroPoint - (int16_t)(1.0
f/3.3
f*4096.0
f+0.5
f);
86 float Qc = 5.0f*(((sensorVal - calibrationOffset)/4096.0
f*3.3
f)/
VCC - 0.2f);
95 float calibratedAirspeed = STANDARD_AIR_MACH_SPEED*sqrtf(5.0f*(powf(Qc/(STANDARD_AIR_SEA_LEVEL_PRESSURE/1000)+1.0f,
POWER)-1.0f));
98 if (calibratedAirspeed > 80) {
99 calibratedAirspeed=80;
103 return calibratedAirspeed;
Main PiOS header to include all the compiled in PiOS options.
float PIOS_MPXV5004_ReadAirspeed(uint8_t airspeedADCPin)
void PIOS_MPXV5004_UpdateCalibration(uint16_t zeroPoint)
ETASV3 Airspeed Sensor Driver.
uint16_t PIOS_MPXV5004_Measure(uint8_t airspeedADCPin)
int32_t PIOS_ADC_GetChannelRaw(uint32_t channel)
uint16_t PIOS_MPXV5004_Calibrate(uint8_t airspeedADCPin, uint16_t calibrationCount)