From a84bc1bd8dd19d47709614b0c2639958d09fbf7e Mon Sep 17 00:00:00 2001 From: Miguel Benavidez Date: Thu, 4 May 2017 11:29:33 -0700 Subject: [PATCH] altoslib: Fix MS5607 raw data to pressure conversion function MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The MS5607 sensor provides raw 24-bit ADC outputs to the host along with calibration constants necessary to convert those into temperature and pressure values. The datasheet has a flow chart indicating how to perform this computation. There are two parts of the algorithm which adjust the result based on the ambient temperature, temperatures below 20°C get one compensation factor and temperatures below -15°C get an additional factor. The ground station version of this function mistakenly applied the second compensation factor for all temperatures below +15°C. The result was that the pressure computed on the ground when the measured temperature was between -15°C and +15°C was incorrect, resulting in altitudes which were several hundred meters off in some situations. This can be seen when displaying any .eeprom (or .mpd) data files for flights with temperatures in that range. The datafiles themselves are not corrupted, only the display operation. This is not seen for telemetry data, where the pressure and associated altitude is computed in the airframe using the correct algorithm. Thanks much to Miguel and the rest of the Vanguard School TARC team for identifying the problem and providing this fix. Signed-off-by: Keith Packard --- altoslib/AltosMs5607.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index 631bc716..19d2dd6d 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -64,7 +64,7 @@ public class AltosMs5607 { int TEMPM = TEMP - 2000; long OFF2 = ((long) 61 * (long) TEMPM * (long) TEMPM) >> 4; long SENS2 = (long) 2 * (long) TEMPM * (long) TEMPM; - if (TEMP < 1500) { + if (TEMP < -1500) { int TEMPP = TEMP + 1500; long TEMPP2 = (long) TEMPP * (long) TEMPP; OFF2 = OFF2 + 15 * TEMPP2; -- 2.30.2