diff options
author | Julian Oes <julian@oes.ch> | 2014-08-23 18:03:01 +0200 |
---|---|---|
committer | Julian Oes <julian@oes.ch> | 2014-08-23 18:03:01 +0200 |
commit | 40fe9ab969247315e3065d0423034554cf66b885 (patch) | |
tree | 7a4bed87e47ffa8470b27b65c79998fb50ff5a1c | |
parent | edffb2eede777f3c316bc8a144984d9d12cbd680 (diff) | |
download | px4-firmware-40fe9ab969247315e3065d0423034554cf66b885.tar.gz px4-firmware-40fe9ab969247315e3065d0423034554cf66b885.tar.bz2 px4-firmware-40fe9ab969247315e3065d0423034554cf66b885.zip |
meas_airspeed: don't take the aboslute value
-rw-r--r-- | src/drivers/meas_airspeed/meas_airspeed.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/drivers/meas_airspeed/meas_airspeed.cpp b/src/drivers/meas_airspeed/meas_airspeed.cpp index 159706278..c136c6641 100644 --- a/src/drivers/meas_airspeed/meas_airspeed.cpp +++ b/src/drivers/meas_airspeed/meas_airspeed.cpp @@ -228,8 +228,10 @@ MEASAirspeed::collect() // the raw value still should be compensated for the known offset diff_press_pa_raw -= _diff_pres_offset; - float diff_press_pa = fabsf(diff_press_pa_raw); - + /* don't take the absolute value because the calibration takes this into account and warns the user if the + * tubes are connected backwards */ + float diff_press_pa = diff_press_pa_raw; + /* note that we return both the absolute value with offset applied and a raw value without the offset applied. This @@ -241,14 +243,8 @@ MEASAirspeed::collect() With the above calculation the MS4525 sensor will produce a positive number when the top port is used as a dynamic port and bottom port is used as the static port - - Also note that the _diff_pres_offset is applied before the - fabsf() not afterwards. It needs to be done this way to - prevent a bias at low speeds, but this also means that when - setting a offset you must set it based on the raw value, not - the offset value */ - + struct differential_pressure_s report; /* track maximum differential pressure measured (so we can work out top speed). */ @@ -345,7 +341,7 @@ MEASAirspeed::cycle() /** correct for 5V rail voltage if the system_power ORB topic is available - + See http://uav.tridgell.net/MS4525/MS4525-offset.png for a graph of offset versus voltage for 3 sensors */ @@ -394,7 +390,7 @@ MEASAirspeed::voltage_correction(float &diff_press_pa, float &temperature) if (voltage_diff < -1.0f) { voltage_diff = -1.0f; } - temperature -= voltage_diff * temp_slope; + temperature -= voltage_diff * temp_slope; #endif // CONFIG_ARCH_BOARD_PX4FMU_V2 } |