Prevented an analog airspeed corner case from happening

This commit is contained in:
Lorenz Meier 2013-08-28 14:34:49 +02:00
parent b7875f4d0f
commit b7ee1d3429
2 changed files with 9 additions and 3 deletions

View File

@ -68,7 +68,8 @@ PARAM_DEFINE_FLOAT(SENS_ACC_XSCALE, 1.0f);
PARAM_DEFINE_FLOAT(SENS_ACC_YSCALE, 1.0f); PARAM_DEFINE_FLOAT(SENS_ACC_YSCALE, 1.0f);
PARAM_DEFINE_FLOAT(SENS_ACC_ZSCALE, 1.0f); PARAM_DEFINE_FLOAT(SENS_ACC_ZSCALE, 1.0f);
PARAM_DEFINE_FLOAT(SENS_DPRES_OFF, 0); PARAM_DEFINE_FLOAT(SENS_DPRES_OFF, 0.0f);
PARAM_DEFINE_INT32(SENS_DPRES_ANA, 0);
PARAM_DEFINE_INT32(SENS_BOARD_ROT, 0); PARAM_DEFINE_INT32(SENS_BOARD_ROT, 0);
PARAM_DEFINE_INT32(SENS_EXT_MAG_ROT, 0); PARAM_DEFINE_INT32(SENS_EXT_MAG_ROT, 0);

View File

@ -301,6 +301,7 @@ private:
float accel_offset[3]; float accel_offset[3];
float accel_scale[3]; float accel_scale[3];
float diff_pres_offset_pa; float diff_pres_offset_pa;
float diff_pres_analog_enabled;
int board_rotation; int board_rotation;
int external_mag_rotation; int external_mag_rotation;
@ -348,6 +349,7 @@ private:
param_t mag_offset[3]; param_t mag_offset[3];
param_t mag_scale[3]; param_t mag_scale[3];
param_t diff_pres_offset_pa; param_t diff_pres_offset_pa;
param_t diff_pres_analog_enabled;
param_t rc_map_roll; param_t rc_map_roll;
param_t rc_map_pitch; param_t rc_map_pitch;
@ -617,6 +619,7 @@ Sensors::Sensors() :
/* Differential pressure offset */ /* Differential pressure offset */
_parameter_handles.diff_pres_offset_pa = param_find("SENS_DPRES_OFF"); _parameter_handles.diff_pres_offset_pa = param_find("SENS_DPRES_OFF");
_parameter_handles.diff_pres_analog_enabled = param_find("SENS_DPRES_ANA");
_parameter_handles.battery_voltage_scaling = param_find("BAT_V_SCALING"); _parameter_handles.battery_voltage_scaling = param_find("BAT_V_SCALING");
@ -784,6 +787,7 @@ Sensors::parameters_update()
/* Airspeed offset */ /* Airspeed offset */
param_get(_parameter_handles.diff_pres_offset_pa, &(_parameters.diff_pres_offset_pa)); param_get(_parameter_handles.diff_pres_offset_pa, &(_parameters.diff_pres_offset_pa));
param_get(_parameter_handles.diff_pres_analog_enabled, &(_parameters.diff_pres_analog_enabled));
/* scaling of ADC ticks to battery voltage */ /* scaling of ADC ticks to battery voltage */
if (param_get(_parameter_handles.battery_voltage_scaling, &(_parameters.battery_voltage_scaling)) != OK) { if (param_get(_parameter_handles.battery_voltage_scaling, &(_parameters.battery_voltage_scaling)) != OK) {
@ -1266,9 +1270,10 @@ Sensors::adc_poll(struct sensor_combined_s &raw)
/** /**
* The voltage divider pulls the signal down, only act on * The voltage divider pulls the signal down, only act on
* a valid voltage from a connected sensor * a valid voltage from a connected sensor. Also assume a non-
* zero offset from the sensor if its connected.
*/ */
if (voltage > 0.4f) { if (voltage > 0.4f && _parameters.diff_pres_analog_enabled) {
float diff_pres_pa = voltage * 1000.0f - _parameters.diff_pres_offset_pa; //for MPXV7002DP sensor float diff_pres_pa = voltage * 1000.0f - _parameters.diff_pres_offset_pa; //for MPXV7002DP sensor