Browse Source

AP_Battery: fixed bug in SUI driver

fixed bug in total voltage
zr-v5.1
Andrew Tridgell 5 years ago
parent
commit
ff112a726b
  1. 5
      libraries/AP_BattMonitor/AP_BattMonitor_SMBus_SUI.cpp

5
libraries/AP_BattMonitor/AP_BattMonitor_SMBus_SUI.cpp

@ -139,10 +139,11 @@ void AP_BattMonitor_SMBus_SUI::read_cell_voltages() @@ -139,10 +139,11 @@ void AP_BattMonitor_SMBus_SUI::read_cell_voltages()
pack_voltage_mv = total_mv;
} else {
// we can't get total pack voltage. Use average of cells we have so far
const uint16_t cell_mv = pack_voltage_mv / SUI_MAX_CELL_READ;
for (uint8_t i = SUI_MAX_CELL_READ; i < cell_count; i++) {
_state.cell_voltages.cells[i] = pack_voltage_mv / SUI_MAX_CELL_READ;
pack_voltage_mv += _state.cell_voltages.cells[i];
_state.cell_voltages.cells[i] = cell_mv;
}
pack_voltage_mv += cell_mv * (cell_count - SUI_MAX_CELL_READ);
}
}

Loading…
Cancel
Save