|
|
|
@ -10,12 +10,13 @@ extern const AP_HAL::HAL& hal;
@@ -10,12 +10,13 @@ extern const AP_HAL::HAL& hal;
|
|
|
|
|
#include <AP_HAL/AP_HAL.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define BATTMONITOR_SMBUS_MAXELL_TEMP 0x08 // temperature register
|
|
|
|
|
#define BATTMONITOR_SMBUS_MAXELL_VOLTAGE 0x09 // voltage register
|
|
|
|
|
#define BATTMONITOR_SMBUS_MAXELL_CURRENT 0x0a // current register
|
|
|
|
|
#define BATTMONITOR_SMBUS_MAXELL_SPECIFICATION_INFO 0x1a // specification info
|
|
|
|
|
#define BATTMONITOR_SMBUS_MAXELL_MANUFACTURE_NAME 0x20 // manufacturer name
|
|
|
|
|
|
|
|
|
|
#define BATTMONITOR_SMBUS_MAXELL_CELL_VOLTAGES 6 |
|
|
|
|
#define BATTMONITOR_SMBUS_MAXELL_NUM_CELLS 6 |
|
|
|
|
uint8_t maxell_cell_ids[] = { 0x3f, // cell 1
|
|
|
|
|
0x3e, // cell 2
|
|
|
|
|
0x3d, // cell 3
|
|
|
|
@ -29,7 +30,6 @@ uint8_t maxell_cell_ids[] = { 0x3f, // cell 1
@@ -29,7 +30,6 @@ uint8_t maxell_cell_ids[] = { 0x3f, // cell 1
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Other potentially useful registers, listed here for future use |
|
|
|
|
* #define BATTMONITOR_SMBUS_MAXELL_TEMP 0x08 // temperature register
|
|
|
|
|
* #define BATTMONITOR_SMBUS_MAXELL_CHARGE_STATUS 0x0d // relative state of charge
|
|
|
|
|
* #define BATTMONITOR_SMBUS_MAXELL_BATTERY_STATUS 0x16 // battery status register including alarms
|
|
|
|
|
* #define BATTMONITOR_SMBUS_MAXELL_BATTERY_CYCLE_COUNT 0x17 // cycle count
|
|
|
|
@ -76,7 +76,8 @@ void AP_BattMonitor_SMBus_Maxell::timer()
@@ -76,7 +76,8 @@ void AP_BattMonitor_SMBus_Maxell::timer()
|
|
|
|
|
_state.healthy = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < BATTMONITOR_SMBUS_MAXELL_CELL_VOLTAGES; i++) { |
|
|
|
|
// read cell voltages
|
|
|
|
|
for (uint8_t i = 0; i < BATTMONITOR_SMBUS_MAXELL_NUM_CELLS; i++) { |
|
|
|
|
if (read_word(maxell_cell_ids[i], data)) { |
|
|
|
|
_state.cell_voltages.cells[i] = data; |
|
|
|
|
} else { |
|
|
|
@ -95,6 +96,12 @@ void AP_BattMonitor_SMBus_Maxell::timer()
@@ -95,6 +96,12 @@ void AP_BattMonitor_SMBus_Maxell::timer()
|
|
|
|
|
_state.current_amps = -(float)((int16_t)data) / 1000.0f; |
|
|
|
|
_state.last_time_micros = tnow; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// read temperature
|
|
|
|
|
if (read_word(BATTMONITOR_SMBUS_MAXELL_TEMP, data)) { |
|
|
|
|
_state.temperature_time = AP_HAL::millis(); |
|
|
|
|
_state.temperature = ((float)(data - 2731) * 0.1f); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// read word from register
|
|
|
|
|