Browse Source

AP_Baro: work around occasional 0 values from MS5611

this was seen on the PXF board. It isn't yet known why it happens
master
Andrew Tridgell 11 years ago
parent
commit
be02f0c34f
  1. 15
      libraries/AP_Baro/AP_Baro_MS5611.cpp

15
libraries/AP_Baro/AP_Baro_MS5611.cpp

@ -363,7 +363,10 @@ void AP_Baro_MS5611::_update(void) @@ -363,7 +363,10 @@ void AP_Baro_MS5611::_update(void)
_timer = tnow;
if (_state == 0) {
_s_D2 += _serial->read_adc();// On state 0 we read temp
// On state 0 we read temp
uint32_t d2 = _serial->read_adc();
if (d2 != 0) {
_s_D2 += d2;
_d2_count++;
if (_d2_count == 32) {
// we have summed 32 values. This only happens
@ -372,10 +375,15 @@ void AP_Baro_MS5611::_update(void) @@ -372,10 +375,15 @@ void AP_Baro_MS5611::_update(void)
_s_D2 >>= 1;
_d2_count = 16;
}
}
_state++;
_serial->write(CMD_CONVERT_D1_OSR4096); // Command to read pressure
} else {
_s_D1 += _serial->read_adc();
uint32_t d1 = _serial->read_adc();;
if (d1 != 0) {
// occasional zero values have been seen on the PXF
// board. These may be SPI errors, but safest to ignore
_s_D1 += d1;
_d1_count++;
if (_d1_count == 128) {
// we have summed 128 values. This only happens
@ -384,9 +392,10 @@ void AP_Baro_MS5611::_update(void) @@ -384,9 +392,10 @@ void AP_Baro_MS5611::_update(void)
_s_D1 >>= 1;
_d1_count = 64;
}
_state++;
// Now a new reading exists
_updated = true;
}
_state++;
if (_state == 5) {
_serial->write(CMD_CONVERT_D2_OSR4096); // Command to read temperature
_state = 0;

Loading…
Cancel
Save