Skip to content

Commit

Permalink
Revert "Change default state of bms_Status to INACTIVE and only switc…
Browse files Browse the repository at this point in the history
…h to ACTIVE upon reception of SOC from battery."

This reverts commit f6c73e9.
  • Loading branch information
mvgalen committed Jan 14, 2025
1 parent 57fbe69 commit 753b506
Show file tree
Hide file tree
Showing 26 changed files with 2 additions and 63 deletions.
4 changes: 0 additions & 4 deletions Software/src/battery/BMW-I3-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
battery_request_open_contactors_fast = (rx_frame.data.u8[6] & 0x0C) >> 2;
battery_charging_condition_delta = (rx_frame.data.u8[6] & 0xF0) >> 4;
battery_DC_link_voltage = rx_frame.data.u8[7];
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x1FA: //BMS [1000ms] Status Of High-Voltage Battery - 1
battery_status_error_isolation_external_Bordnetz = (rx_frame.data.u8[0] & 0x03);
Expand Down Expand Up @@ -713,8 +711,6 @@ void handle_incoming_can_frame_battery2(CAN_frame rx_frame) {
battery2_request_open_contactors_fast = (rx_frame.data.u8[6] & 0x0C) >> 2;
battery2_charging_condition_delta = (rx_frame.data.u8[6] & 0xF0) >> 4;
battery2_DC_link_voltage = rx_frame.data.u8[7];
if (datalayer.battery2.status.bms_status == INACTIVE)
datalayer.battery2.status.bms_status = ACTIVE;
break;
case 0x1FA: //BMS [1000ms] Status Of High-Voltage Battery - 1
battery2_status_error_isolation_external_Bordnetz = (rx_frame.data.u8[0] & 0x03);
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/BMW-IX-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
min_soc_state = (rx_frame.data.u8[8] << 8 | rx_frame.data.u8[9]);
avg_soc_state = (rx_frame.data.u8[6] << 8 | rx_frame.data.u8[7]);
max_soc_state = (rx_frame.data.u8[10] << 8 | rx_frame.data.u8[11]);
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
}

if (rx_frame.DLC =
Expand Down
4 changes: 0 additions & 4 deletions Software/src/battery/BYD-ATTO-3-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
battery_highprecision_SOC = ((rx_frame.data.u8[5] & 0x0F) << 8) | rx_frame.data.u8[4]; // 03 E0 = 992 = 99.2%
battery_lowest_temperature = (rx_frame.data.u8[1] - 40); //Best guess for now
battery_highest_temperature = (rx_frame.data.u8[3] - 40); //Best guess for now
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x47B: //01,FF,FF,FF,FF,FF,FF,FF - Static, values never changes between logs
break;
Expand Down Expand Up @@ -566,8 +564,6 @@ void handle_incoming_can_frame_battery2(CAN_frame rx_frame) {
battery2_highprecision_SOC = ((rx_frame.data.u8[5] & 0x0F) << 8) | rx_frame.data.u8[4]; // 03 E0 = 992 = 99.2%
battery2_lowest_temperature = (rx_frame.data.u8[1] - 40); //Best guess for now
battery2_highest_temperature = (rx_frame.data.u8[3] - 40); //Best guess for now
if (datalayer.battery2.status.bms_status == INACTIVE)
datalayer.battery2.status.bms_status = ACTIVE;
break;
case 0x47B: //01,FF,FF,FF,FF,FF,FF,FF - Static, values never changes between logs
break;
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/CELLPOWER-BMS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
battery_SOH_percentage = (uint8_t)rx_frame.data.u8[4];
battery_SOC_percentage = (uint8_t)rx_frame.data.u8[5];
battery_remaining_dAh = (uint16_t)((rx_frame.data.u8[7] << 8) | rx_frame.data.u8[6]);
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x3A4: //PDO3_TX - 200ms
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/CHADEMO-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {

datalayer.battery.status.CAN_battery_still_alive =
CAN_STILL_ALIVE; //We are getting CAN messages from the vehicle, inform the watchdog
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;

switch (rx_frame.ID) {
case 0x100:
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/IMIEV-CZERO-ION-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
BMU_Current = ((((((rx_frame.data.u8[2] * 256.0) + rx_frame.data.u8[3])) - 32768)) * 0.01);
BMU_PackVoltage = ((rx_frame.data.u8[4] * 256.0 + rx_frame.data.u8[5]) * 0.1);
BMU_Power = (BMU_Current * BMU_PackVoltage);
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x6e1: //BMU message, 25ms - Battery temperatures and voltages
case 0x6e2:
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/JAGUAR-IPACE-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
HVBatteryContactorStatus = ((rx_frame.data.u8[0] & 0x80) >> 7);
HVBattHVILError = ((rx_frame.data.u8[0] & 0x40) >> 6);
HVILBattIsolationError = ((rx_frame.data.u8[0] & 0x20) >> 5);
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x100:
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/KIA-E-GMP-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
allowedDischargePower = ((rx_frame.data.u8[5] << 8) + rx_frame.data.u8[6]);
SOC_BMS = rx_frame.data.u8[2] * 5; //100% = 200 ( 200 * 5 = 1000 )

if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
} else if (poll_data_pid == 2) {
// set cell voltages data, start bite, data length from start, start cell
set_cell_voltages(rx_frame, 2, 6, 0);
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/KIA-HYUNDAI-64-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
startedUp = true;
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
SOC_Display = rx_frame.data.u8[0] * 5; //100% = 200 ( 200 * 5 = 1000 )
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x594:
startedUp = true;
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/KIA-HYUNDAI-HYBRID-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
available_charge_power = ((rx_frame.data.u8[2] << 8) | rx_frame.data.u8[3]);
available_discharge_power = ((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]);
battery_current_high_byte = rx_frame.data.u8[7];
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
} else if (poll_data_pid == 2) { //21 02
cellvoltages_mv[0] = (rx_frame.data.u8[2] * 20);
cellvoltages_mv[1] = (rx_frame.data.u8[3] * 20);
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/MG-5-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
switch (rx_frame.ID) {
case 0x171: //Following messages were detected on a MG5 battery BMS
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE; // Let system know battery is sending CAN
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x172:
break;
Expand Down
4 changes: 0 additions & 4 deletions Software/src/battery/NISSAN-LEAF-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,6 @@ void handle_incoming_can_frame_battery2(CAN_frame rx_frame) {
if (battery2_TEMP != 0) {
battery2_StateOfHealth = battery2_TEMP; //Collect state of health from battery
}
if (datalayer.battery2.status.bms_status == INACTIVE)
datalayer.battery2.status.bms_status = ACTIVE;
break;
case 0x5C0:
//This temperature only works for 2013-2017 AZE0 LEAF packs, the mux is different on other generations
Expand Down Expand Up @@ -812,8 +810,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
if (battery_TEMP != 0) {
battery_StateOfHealth = (uint8_t)battery_TEMP; //Collect state of health from battery
}
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x5C0:
//This temperature only works for 2013-2017 AZE0 LEAF packs, the mux is different on other generations
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/PYLON-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
current_dA = ((rx_frame.data.u8[3] << 8) | rx_frame.data.u8[2]) - 30000;
SOC = rx_frame.data.u8[6];
SOH = rx_frame.data.u8[7];
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x4220:
case 0x4221:
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/RANGE-ROVER-PHEV-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
WakeUpThermalReq = ((rx_frame.data.u8[6] & 0x08) >> 3);
WakeUpDchReq = ((rx_frame.data.u8[6] & 0x10) >> 4);
StateofHealth = (((rx_frame.data.u8[6] & 0x03) << 8) | rx_frame.data.u8[7]);
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x308: // 190ms
EstimatedLossChg = (((rx_frame.data.u8[0] & 0x03) << 8) | rx_frame.data.u8[1]);
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/RENAULT-KANGOO-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
LB_MaxChargeAllowed_W = (rx_frame.data.u8[0] * 300);
LB_Current = word((rx_frame.data.u8[1] & 0xF), rx_frame.data.u8[2]) * 0.25 - 500; //OK!
LB_SOC = ((rx_frame.data.u8[4] << 8) | (rx_frame.data.u8[5])) * 0.0025; //OK!
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x424: //BMS2
datalayer.battery.status.CAN_battery_still_alive =
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/RENAULT-TWIZY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {

// SOC is encoded as 16 bit integer with SOC% = value / 400
SOC = (((uint16_t)rx_frame.data.u8[4] << 8) | (uint16_t)rx_frame.data.u8[5]) / 4;
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x424:
max_recup_power = rx_frame.data.u8[2] * 500;
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/RENAULT-ZOE-GEN1-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
case 0x654: //SOC
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
LB_SOC = rx_frame.data.u8[3];
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x658: //SOH - NOTE: Not present on 41kWh battery! (Is this message on 21kWh?)
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/RENAULT-ZOE-GEN2-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
switch (reply_poll) {
case POLL_SOC:
battery_soc = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5];
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case POLL_USABLE_SOC:
battery_usable_soc = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5];
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/RJXZS-BMS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
battery_usage_capacity = (rx_frame.data.u8[1] << 8) | rx_frame.data.u8[2];
battery_capacity_percentage = (rx_frame.data.u8[3] << 8) | rx_frame.data.u8[4];
charging_capacity = (rx_frame.data.u8[5] << 8) | rx_frame.data.u8[6];
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
} else if (mux == 0x05) { //Recovery / capacity
charging_recovery_voltage = (rx_frame.data.u8[1] << 8) | rx_frame.data.u8[2];
discharging_recovery_voltage = (rx_frame.data.u8[3] << 8) | rx_frame.data.u8[4];
Expand Down
4 changes: 0 additions & 4 deletions Software/src/battery/SANTA-FE-PHEV-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
case 0x542:
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
SOC_Display = ((rx_frame.data.u8[1] << 8) + rx_frame.data.u8[0]) / 2;
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x588:
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
Expand Down Expand Up @@ -446,8 +444,6 @@ void handle_incoming_can_frame_battery2(CAN_frame rx_frame) {
case 0x542:
datalayer.battery2.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
battery2_SOC_Display = ((rx_frame.data.u8[1] << 8) + rx_frame.data.u8[0]) / 2;
if (datalayer.battery2.status.bms_status == INACTIVE)
datalayer.battery2.status.bms_status = ACTIVE;
break;
case 0x588:
datalayer.battery2.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
Expand Down
3 changes: 0 additions & 3 deletions Software/src/battery/SERIAL-LINK-RECEIVER-FROM-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ void __getData() {
if (_system_bms_status == FAULT) {
batteryFault = true;
set_event(EVENT_SERIAL_TRANSMITTER_FAILURE, 0);
} else {
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
}
}

Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/TESLA-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1558,8 +1558,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
((rx_frame.data.u8[4] << 2) | ((rx_frame.data.u8[3] & 0xC0) >> 6)); //30|10@1+ (0.1,0) [0|102.3] "%"
battery_battTempPct =
(((rx_frame.data.u8[7] & 0x03) << 6) | (rx_frame.data.u8[6] & 0x3F) >> 2); //50|8@1+ (0.4,0) [0|100] "%"
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;
break;
case 0x392: //BMS_packConfig
mux = (rx_frame.data.u8[0] & (0xFF));
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/TEST-FAKE-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ void update_values_battery() { /* This function puts fake values onto the parame

//Fake that we get CAN messages
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;

/*Finally print out values to serial if configured to do so*/
#ifdef DEBUG_LOG
Expand Down
2 changes: 0 additions & 2 deletions Software/src/battery/VOLVO-SPA-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
logging.println("SOC_BMS not valid");
#endif
}
if (datalayer.battery.status.bms_status == INACTIVE)
datalayer.battery.status.bms_status = ACTIVE;

if ((rx_frame.data.u8[0] & 0x04) == 0x04)
CELL_U_MAX = ((rx_frame.data.u8[2] & 0x01) * 256 + rx_frame.data.u8[3]);
Expand Down
2 changes: 1 addition & 1 deletion Software/src/datalayer/datalayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ typedef struct {

/** Other */
/** The current BMS status */
bms_status_enum bms_status = INACTIVE;
bms_status_enum bms_status = ACTIVE;
} DATALAYER_BATTERY_STATUS_TYPE;

typedef struct {
Expand Down
6 changes: 1 addition & 5 deletions Software/src/devboard/utils/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,6 @@ void reset_all_events() {
events.entries[i].MQTTpublished = false; // Not published by default
}
events.level = EVENT_LEVEL_INFO;

datalayer.battery.status.bms_status = INACTIVE;
#ifdef DOUBLE_BATTERY
datalayer.battery2.status.bms_status = INACTIVE;
#endif
update_bms_status();
}

Expand Down Expand Up @@ -502,6 +497,7 @@ static void update_bms_status(void) {
case EVENT_LEVEL_INFO:
case EVENT_LEVEL_WARNING:
case EVENT_LEVEL_DEBUG:
datalayer.battery.status.bms_status = ACTIVE;
break;
case EVENT_LEVEL_UPDATE:
datalayer.battery.status.bms_status = UPDATING;
Expand Down

0 comments on commit 753b506

Please sign in to comment.