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_MPXV7002)
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)(2.5
f/3.3
f*4096.0
f+0.5
f);
73 calibrationOffset = zeroPoint - (int16_t)(2.5
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.5f);
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 > 59) {
99 calibratedAirspeed=59;
103 return calibratedAirspeed;
Main PiOS header to include all the compiled in PiOS options.
ETASV3 Airspeed Sensor Driver.
float PIOS_MPXV7002_ReadAirspeed(uint8_t airspeedADCPin)
void PIOS_MPXV7002_UpdateCalibration(uint16_t zeroPoint)
uint16_t PIOS_MPXV7002_Calibrate(uint8_t airspeedADCPin, uint16_t calibrationCount)
uint16_t PIOS_MPXV7002_Measure(uint8_t airspeedADCPin)
int32_t PIOS_ADC_GetChannelRaw(uint32_t channel)