mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
SITL: SIM_BattMonitor_SMBus add registers to smartbatts
This commit is contained in:
parent
c414a021ae
commit
51eb398277
@ -11,46 +11,67 @@ SITL::SIM_BattMonitor_SMBus::SIM_BattMonitor_SMBus() :
|
||||
add_register("Remaining Capacity", SMBusBattDevReg::REMAINING_CAPACITY, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
add_register("Full Charge Capacity", SMBusBattDevReg::FULL_CHARGE_CAPACITY, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
add_register("Cycle_Count", SMBusBattDevReg::CYCLE_COUNT, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
add_register("Design Charge Capacity", SMBusBattDevReg::DESIGN_CAPACITY, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
add_register("Design Maximum Voltage", SMBusBattDevReg::DESIGN_VOLTAGE, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
add_register("Specification Info", SMBusBattDevReg::SPECIFICATION_INFO, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
add_register("Manufacture Date", SMBusBattDevReg::MANUFACTURE_DATE, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
add_register("Serial", SMBusBattDevReg::SERIAL, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
add_block("Manufacture Name", SMBusBattDevReg::MANUFACTURE_NAME, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
add_block("Device Name", SMBusBattDevReg::DEVICE_NAME, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
add_block("Device Chemistry", SMBusBattDevReg::DEVICE_CHEMISTRY, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
add_register("Manufacture Data", SMBusBattDevReg::MANUFACTURE_DATA, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
|
||||
set_register(SMBusBattDevReg::TEMP, (int16_t)((C_TO_KELVIN(15))*10));
|
||||
// see update for voltage
|
||||
// see update for current
|
||||
// TODO: remaining capacity
|
||||
// TODO: full capacity
|
||||
set_register(SMBusBattDevReg::CYCLE_COUNT, (uint16_t(39U)));
|
||||
// see update for voltage
|
||||
// see update for current
|
||||
|
||||
// Set SPECIFICATION_INFO
|
||||
union {
|
||||
struct {
|
||||
uint8_t revision : 4;
|
||||
uint8_t version: 4;
|
||||
uint8_t vscale: 4;
|
||||
uint8_t ipscale: 4;
|
||||
} fields;
|
||||
uint16_t word;
|
||||
} specinfo;
|
||||
set_register(SMBusBattDevReg::DESIGN_VOLTAGE, (uint16_t(50400U))); // (mV) Design maximum voltage
|
||||
|
||||
specinfo.fields.revision = 0b0001; // version 1
|
||||
// specinfo.fields.version = 0b0011; // 1.1 with PEC; TODO!
|
||||
specinfo.fields.version = 0b0001; // 1.0
|
||||
specinfo.fields.vscale = 0b0000; // unknown...
|
||||
specinfo.fields.ipscale = 0b0000; // unknown...
|
||||
set_register(SMBusBattDevReg::SPECIFICATION_INFO, specinfo.word);
|
||||
// TODO: remaining capacity connect to sim capacity add to update method below?
|
||||
// TODO: Battery mode bit set to mAh vs 10 mWh
|
||||
set_register(SMBusBattDevReg::REMAINING_CAPACITY, (uint16_t(42042U))); // (mAh) Remaining Capacity
|
||||
|
||||
set_register(SMBusBattDevReg::SERIAL, (uint16_t)12345);
|
||||
// TODO: full capacity fill via SIM parameter
|
||||
set_register(SMBusBattDevReg::FULL_CHARGE_CAPACITY, (uint16_t(45000U))); // (mAh) Full charge capacity
|
||||
set_register(SMBusBattDevReg::DESIGN_CAPACITY, (uint16_t(52500U))); // (mAh) Design capacity
|
||||
|
||||
const char *manufacturer_name = "ArduPilot";
|
||||
set_block(SMBusBattDevReg::MANUFACTURE_NAME, manufacturer_name);
|
||||
set_register(SMBusBattDevReg::CYCLE_COUNT, (uint16_t(42U)));
|
||||
|
||||
const char *device_name = "SITLBatMon_V0.99";
|
||||
set_block(SMBusBattDevReg::DEVICE_NAME, device_name);
|
||||
// Set SPECIFICATION_INFO
|
||||
union {
|
||||
struct {
|
||||
uint8_t revision : 4;
|
||||
uint8_t version: 4;
|
||||
uint8_t vscale: 4;
|
||||
uint8_t ipscale: 4;
|
||||
} fields;
|
||||
uint16_t word;
|
||||
} specinfo;
|
||||
|
||||
// TODO: manufacturer data
|
||||
// TODO: compute PEC for relevant monitors
|
||||
specinfo.fields.revision = 0b0001; // version 1
|
||||
// specinfo.fields.version = 0b0011; // 1.1 with PEC; TODO!
|
||||
specinfo.fields.version = 0b0001; // 1.0
|
||||
specinfo.fields.vscale = 0b0000; // unknown...
|
||||
specinfo.fields.ipscale = 0b0000; // unknown...
|
||||
set_register(SMBusBattDevReg::SPECIFICATION_INFO, specinfo.word);
|
||||
|
||||
set_register(SMBusBattDevReg::SERIAL, (uint16_t)12345);
|
||||
|
||||
const char *manufacturer_name = "ArduPilot";
|
||||
set_block(SMBusBattDevReg::MANUFACTURE_NAME, manufacturer_name);
|
||||
|
||||
const char *device_name = "SITLBatMon_V0.99";
|
||||
set_block(SMBusBattDevReg::DEVICE_NAME, device_name);
|
||||
|
||||
const char *device_chemistry = "LION";
|
||||
set_block(SMBusBattDevReg::DEVICE_CHEMISTRY, device_chemistry);
|
||||
|
||||
// Set Manufacture date to 2021 APR 24th
|
||||
const uint16_t manufacturer_date = ((2021 - 1980) << 9) + (04 << 5) + 24;
|
||||
set_register(SMBusBattDevReg::MANUFACTURE_DATE, manufacturer_date);
|
||||
|
||||
// TODO: manufacturer data
|
||||
}
|
||||
|
||||
void SITL::SIM_BattMonitor_SMBus::update(const class Aircraft &aircraft)
|
||||
|
@ -10,12 +10,16 @@ public:
|
||||
static const uint8_t VOLTAGE = 0x09; // Voltage
|
||||
static const uint8_t CURRENT = 0x0A; // Current
|
||||
static const uint8_t REMAINING_CAPACITY = 0x0F; // Remaining Capacity
|
||||
static const uint8_t FULL_CHARGE_CAPACITY = 0x10; // Full Charge Capacity
|
||||
static const uint8_t FULL_CHARGE_CAPACITY = 0x10; // Full Charge Capacity (accounting for battery degradation)
|
||||
static const uint8_t CYCLE_COUNT = 0x17; // Cycle Count
|
||||
static const uint8_t DESIGN_CAPACITY = 0x18; // Design capacity (capacity when newly manufactured)
|
||||
static const uint8_t DESIGN_VOLTAGE = 0x19; // Design voltage
|
||||
static const uint8_t SPECIFICATION_INFO = 0x1A; // Specification Info
|
||||
static const uint8_t MANUFACTURE_DATE = 0x1B; // Manufacture date
|
||||
static const uint8_t SERIAL = 0x1C; // Serial Number
|
||||
static const uint8_t MANUFACTURE_NAME = 0x20; // Manufacture Name
|
||||
static const uint8_t DEVICE_NAME = 0x21; // Device Name
|
||||
static const uint8_t DEVICE_CHEMISTRY = 0x22; // Battery chemistry type
|
||||
static const uint8_t MANUFACTURE_DATA = 0x23; // Manufacture Data
|
||||
};
|
||||
|
||||
|
@ -3,6 +3,10 @@
|
||||
SITL::SIM_BattMonitor_SMBus_Generic::SIM_BattMonitor_SMBus_Generic() :
|
||||
SIM_BattMonitor_SMBus()
|
||||
{
|
||||
|
||||
const char *manufacturer_name = "sitl_smbus_generic";
|
||||
set_block(SMBusBattDevReg::MANUFACTURE_NAME, manufacturer_name);
|
||||
|
||||
}
|
||||
|
||||
void SITL::SIM_BattMonitor_SMBus_Generic::init()
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
void init() override;
|
||||
void update(const class Aircraft &aircraft) override;
|
||||
|
||||
virtual uint8_t cellcount() const = 0;
|
||||
virtual uint8_t cellcount() const { return 12; }
|
||||
|
||||
virtual uint8_t connected_cells() const { return 3; }
|
||||
};
|
||||
|
@ -3,5 +3,15 @@
|
||||
SITL::Maxell::Maxell() :
|
||||
SIM_BattMonitor_SMBus_Generic()
|
||||
{
|
||||
// TO DO set maxell batteries PEC version to V1
|
||||
|
||||
// Note Maxell batteries do not support PEC and ArduPilot checks for this by
|
||||
// checking that the manufacturer name matches "Hitachi maxell"
|
||||
const char *manufacturer_name = "Hitachi maxell";
|
||||
set_block(SMBusBattDevReg::MANUFACTURE_NAME, manufacturer_name);
|
||||
|
||||
const char *device_name = "SITL_maxell";
|
||||
set_block(SMBusBattDevReg::DEVICE_NAME, device_name);
|
||||
|
||||
set_register(SMBusBattGenericDevReg::SERIAL, (uint16_t)37);
|
||||
}
|
||||
|
@ -7,6 +7,14 @@ SITL::Rotoye::Rotoye() :
|
||||
add_register("External Temperature", SMBusBattRotoyeDevReg::TEMP_EXT, SITL::I2CRegisters::RegMode::RDONLY);
|
||||
|
||||
set_register(SMBusBattRotoyeDevReg::SERIAL, (uint16_t)39);
|
||||
|
||||
const char *manufacturer_name = "Rotoye";
|
||||
set_block(SMBusBattDevReg::MANUFACTURE_NAME, manufacturer_name);
|
||||
|
||||
const char *device_name = "SITL_BatMon v4.03";
|
||||
set_block(SMBusBattDevReg::DEVICE_NAME, device_name);
|
||||
|
||||
set_register(SMBusBattGenericDevReg::SERIAL, (uint16_t) 278);
|
||||
}
|
||||
|
||||
void SITL::Rotoye::update(const class Aircraft &aircraft)
|
||||
|
@ -56,6 +56,7 @@ static MaxSonarI2CXL maxsonari2cxl;
|
||||
static MaxSonarI2CXL maxsonari2cxl_2;
|
||||
static Maxell maxell;
|
||||
static Rotoye rotoye;
|
||||
static SIM_BattMonitor_SMBus_Generic smbus_generic;
|
||||
static Airspeed_DLVR airspeed_dlvr;
|
||||
static TSYS01 tsys01;
|
||||
static MCP9600 mcp9600;
|
||||
@ -80,8 +81,9 @@ struct i2c_device_at_address {
|
||||
{ 1, 0x40, ignored }, // KellerLD
|
||||
{ 1, 0x76, ms5525 }, // MS5525: ARSPD_TYPE = 4
|
||||
{ 1, 0x77, tsys01 },
|
||||
{ 1, 0x0B, rotoye }, // Rotoye: BATTx_MONITOR 19
|
||||
{ 2, 0x0B, maxell }, // Maxell: BATTx_MONITOR 16
|
||||
{ 1, 0x0B, rotoye }, // Rotoye: BATTx_MONITOR 19, BATTx_I2C_ADDR 13
|
||||
{ 2, 0x0B, maxell }, // Maxell: BATTx_MONITOR 16, BATTx_I2C_ADDR 13
|
||||
{ 3, 0x0B, smbus_generic}, // BATTx_MONITOR 7, BATTx_I2C_ADDR 13
|
||||
{ 2, 0x28, airspeed_dlvr }, // ARSPD_TYPE = 7 5inch H2O sensor
|
||||
{ 2, 0x77, ms5611 }, // MS5611: BARO_PROBE_EXT = 2
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user