Merge pull request #1423 from jonny5532/feature/remove-cell-count-from-custom-bms

Remove hardcoded cell counts from custom-BMS batteries
This commit is contained in:
Daniel Öster 2025-08-16 12:23:07 +03:00 committed by GitHub
commit fd0b72af1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 7 additions and 7 deletions

View file

@ -16,6 +16,7 @@ static uint32_t remaining_capacity_mAh = 0;
static uint16_t cellvoltages_mV[48] = {0};
static uint16_t cellvoltage_min_mV = 0;
static uint16_t cellvoltage_max_mV = 0;
static uint16_t cell_count = 0;
static uint16_t SOC = 0;
static bool has_fault = false;
@ -54,6 +55,9 @@ void DalyBms::update_values() {
datalayer.battery.status.cell_min_voltage_mV = cellvoltage_min_mV;
datalayer.battery.status.cell_max_voltage_mV = cellvoltage_max_mV;
// Use the received value from the BMS, to avoid needing to configure it
datalayer.battery.info.number_of_cells = cell_count;
datalayer.battery.status.temperature_min_dC = temperature_min_dC;
datalayer.battery.status.temperature_max_dC = temperature_max_dC;
@ -63,7 +67,6 @@ void DalyBms::update_values() {
void DalyBms::setup(void) { // Performs one time setup at startup
strncpy(datalayer.system.info.battery_protocol, Name, 63);
datalayer.system.info.battery_protocol[63] = '\0';
datalayer.battery.info.number_of_cells = CELL_COUNT;
datalayer.battery.info.max_design_voltage_dV = MAX_PACK_VOLTAGE_DV;
datalayer.battery.info.min_design_voltage_dV = MIN_PACK_VOLTAGE_DV;
datalayer.battery.info.max_cell_voltage_mV = MAX_CELL_VOLTAGE_MV;
@ -138,6 +141,7 @@ void decode_packet(uint8_t command, uint8_t data[8]) {
remaining_capacity_mAh = decode_uint32be(data, 4);
break;
case 0x94:
cell_count = data[0];
break;
case 0x95:
if (data[0] > 0 && data[0] <= 16) {

View file

@ -57,8 +57,8 @@ void OrionBms::update_values() {
datalayer.battery.status.cell_min_voltage_mV = Minimum_Cell_Voltage;
//If user did not configure amount of cells correctly in the header file, update the value
if ((amount_of_detected_cells > NUMBER_OF_CELLS) && (amount_of_detected_cells < MAX_AMOUNT_CELLS)) {
//Use the reported number of cells to avoid needing to configure it
if (amount_of_detected_cells < MAX_AMOUNT_CELLS) {
datalayer.battery.info.number_of_cells = amount_of_detected_cells;
}
}
@ -115,7 +115,6 @@ void OrionBms::transmit_can(unsigned long currentMillis) {
void OrionBms::setup(void) { // Performs one time setup at startup
strncpy(datalayer.system.info.battery_protocol, Name, 63);
datalayer.system.info.battery_protocol[63] = '\0';
datalayer.battery.info.number_of_cells = NUMBER_OF_CELLS;
datalayer.battery.info.max_design_voltage_dV = MAX_PACK_VOLTAGE_DV;
datalayer.battery.info.min_design_voltage_dV = MIN_PACK_VOLTAGE_DV;
datalayer.battery.info.max_cell_voltage_mV = MAX_CELL_VOLTAGE_MV;

View file

@ -18,7 +18,6 @@ class OrionBms : public CanBattery {
private:
/* Change the following to suit your battery */
static const int NUMBER_OF_CELLS = 96;
static const int MAX_PACK_VOLTAGE_DV = 5000; //5000 = 500.0V
static const int MIN_PACK_VOLTAGE_DV = 1500;
static const int MAX_CELL_VOLTAGE_MV = 4250; //Battery is put into emergency stop if one cell goes over this value

View file

@ -93,7 +93,6 @@ void SimpBmsBattery::transmit_can(unsigned long currentMillis) {
void SimpBmsBattery::setup(void) { // Performs one time setup at startup
strncpy(datalayer.system.info.battery_protocol, Name, 63);
datalayer.system.info.battery_protocol[63] = '\0';
datalayer.battery.info.number_of_cells = CELL_COUNT;
datalayer.battery.info.max_design_voltage_dV = MAX_PACK_VOLTAGE_DV;
datalayer.battery.info.min_design_voltage_dV = MIN_PACK_VOLTAGE_DV;
datalayer.battery.info.max_cell_voltage_mV = MAX_CELL_VOLTAGE_MV;

View file

@ -22,7 +22,6 @@ class SimpBmsBattery : public CanBattery {
static const int MAX_CELL_VOLTAGE_MV = 4250; //Battery is put into emergency stop if one cell goes over this value
static const int MIN_CELL_VOLTAGE_MV = 2700; //Battery is put into emergency stop if one cell goes below this value
static const int MAX_CELL_DEVIATION_MV = 500;
static const int CELL_COUNT = 96;
static const int SIMPBMS_MAX_CELLS = 128;