Browse Source

AP_BattMonitor: Allow generic SMBus batteries to not have cell voltages

master
Michael du Breuil 8 years ago committed by Francisco Ferreira
parent
commit
3dd47bff8b
  1. 7
      libraries/AP_BattMonitor/AP_BattMonitor_SMBus.h
  2. 1
      libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Maxell.cpp
  3. 2
      libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Solo.cpp

7
libraries/AP_BattMonitor/AP_BattMonitor_SMBus.h

@ -23,9 +23,10 @@ public: @@ -23,9 +23,10 @@ public:
// virtual destructor to reduce compiler warnings
virtual ~AP_BattMonitor_SMBus() {}
// all smart batteries provide current and individual cell voltages
bool has_cell_voltages() const override { return _has_cell_voltages; }
// all smart batteries are expected to provide current
bool has_current() const override { return true; }
bool has_cell_voltages() const override { return true; }
protected:
@ -62,6 +63,8 @@ protected: @@ -62,6 +63,8 @@ protected:
int32_t _serial_number = -1; // battery serial number
uint16_t _full_charge_capacity; // full charge capacity, used to stash the value before setting the parameter
bool _has_cell_voltages; // smbus backends flag this as true once they have recieved a valid cell voltage report
};
// include specific implementations

1
libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Maxell.cpp

@ -64,6 +64,7 @@ void AP_BattMonitor_SMBus_Maxell::timer() @@ -64,6 +64,7 @@ void AP_BattMonitor_SMBus_Maxell::timer()
// read cell voltages
for (uint8_t i = 0; i < BATTMONITOR_SMBUS_MAXELL_NUM_CELLS; i++) {
if (read_word(maxell_cell_ids[i], data)) {
_has_cell_voltages = true;
_state.cell_voltages.cells[i] = data;
} else {
_state.cell_voltages.cells[i] = UINT16_MAX;

2
libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Solo.cpp

@ -50,6 +50,8 @@ void AP_BattMonitor_SMBus_Solo::timer() @@ -50,6 +50,8 @@ void AP_BattMonitor_SMBus_Solo::timer()
_state.cell_voltages.cells[i] = cell;
pack_voltage_mv += (float)cell;
}
_has_cell_voltages = true;
// accumulate the pack voltage out of the total of the cells
// because the Solo's I2C bus is so noisy, it's worth not spending the
// time and bus bandwidth to request the pack voltage as a seperate

Loading…
Cancel
Save