Skip to content

Commit

Permalink
Send cellmV when events are raised
Browse files Browse the repository at this point in the history
  • Loading branch information
dalathegreat committed May 12, 2024
1 parent e5c408f commit 59d5653
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
14 changes: 7 additions & 7 deletions Software/src/battery/BMW-I3-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,36 +455,36 @@ void update_values_battery() { //This function maps all the values fetched via

// Start checking safeties. First up, cellvoltages!
if (battery_cell_deviation_mV > MAX_CELL_DEVIATION_MV) {
set_event(EVENT_CELL_DEVIATION_HIGH, 0);
set_event(EVENT_CELL_DEVIATION_HIGH, battery_cell_deviation_mV);
} else {
clear_event(EVENT_CELL_DEVIATION_HIGH);
}
if (detectedBattery == BATTERY_60AH) {
datalayer.battery.info.max_design_voltage_dV = MAX_PACK_VOLTAGE_60AH;
datalayer.battery.info.min_design_voltage_dV = MIN_PACK_VOLTAGE_60AH;
if (datalayer.battery.status.cell_max_voltage_mV >= MAX_CELL_VOLTAGE_60AH) {
set_event(EVENT_CELL_OVER_VOLTAGE, 0);
set_event(EVENT_CELL_OVER_VOLTAGE, (datalayer.battery.status.cell_max_voltage_mV / 20));
}
if (datalayer.battery.status.cell_min_voltage_mV <= MIN_CELL_VOLTAGE_60AH) {
set_event(EVENT_CELL_UNDER_VOLTAGE, 0);
set_event(EVENT_CELL_UNDER_VOLTAGE, (datalayer.battery.status.cell_min_voltage_mV / 20));
}
} else if (detectedBattery == BATTERY_94AH) {
datalayer.battery.info.max_design_voltage_dV = MAX_PACK_VOLTAGE_94AH;
datalayer.battery.info.min_design_voltage_dV = MIN_PACK_VOLTAGE_94AH;
if (datalayer.battery.status.cell_max_voltage_mV >= MAX_CELL_VOLTAGE_94AH) {
set_event(EVENT_CELL_OVER_VOLTAGE, 0);
set_event(EVENT_CELL_OVER_VOLTAGE, (datalayer.battery.status.cell_max_voltage_mV / 20));
}
if (datalayer.battery.status.cell_min_voltage_mV <= MIN_CELL_VOLTAGE_94AH) {
set_event(EVENT_CELL_UNDER_VOLTAGE, 0);
set_event(EVENT_CELL_UNDER_VOLTAGE, (datalayer.battery.status.cell_min_voltage_mV / 20));
}
} else { // BATTERY_120AH
datalayer.battery.info.max_design_voltage_dV = MAX_PACK_VOLTAGE_120AH;
datalayer.battery.info.min_design_voltage_dV = MIN_PACK_VOLTAGE_120AH;
if (datalayer.battery.status.cell_max_voltage_mV >= MAX_CELL_VOLTAGE_120AH) {
set_event(EVENT_CELL_OVER_VOLTAGE, 0);
set_event(EVENT_CELL_OVER_VOLTAGE, (datalayer.battery.status.cell_max_voltage_mV / 20));
}
if (datalayer.battery.status.cell_min_voltage_mV <= MIN_CELL_VOLTAGE_120AH) {
set_event(EVENT_CELL_UNDER_VOLTAGE, 0);
set_event(EVENT_CELL_UNDER_VOLTAGE, (datalayer.battery.status.cell_min_voltage_mV / 20));
}
}

Expand Down
6 changes: 3 additions & 3 deletions Software/src/battery/KIA-E-GMP-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ void update_values_battery() { //This function maps all the values fetched via
cell_deviation_mV = (datalayer.battery.status.cell_max_voltage_mV - datalayer.battery.status.cell_min_voltage_mV);

if (CellVoltMax_mV >= MAX_CELL_VOLTAGE) {
set_event(EVENT_CELL_OVER_VOLTAGE, 0);
set_event(EVENT_CELL_OVER_VOLTAGE, (CellVoltMax_mV / 20));
}
if (CellVoltMin_mV <= MIN_CELL_VOLTAGE) {
set_event(EVENT_CELL_UNDER_VOLTAGE, 0);
set_event(EVENT_CELL_UNDER_VOLTAGE, (CellVoltMin_mV / 20));
}
if (cell_deviation_mV > MAX_CELL_DEVIATION) {
set_event(EVENT_CELL_DEVIATION_HIGH, 0);
set_event(EVENT_CELL_DEVIATION_HIGH, cell_deviation_mV);
} else {
clear_event(EVENT_CELL_DEVIATION_HIGH);
}
Expand Down
6 changes: 3 additions & 3 deletions Software/src/battery/KIA-HYUNDAI-64-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ void update_values_battery() { //This function maps all the values fetched via
cell_deviation_mV = (datalayer.battery.status.cell_max_voltage_mV - datalayer.battery.status.cell_min_voltage_mV);

if (CellVoltMax_mV >= MAX_CELL_VOLTAGE) {
set_event(EVENT_CELL_OVER_VOLTAGE, 0);
set_event(EVENT_CELL_OVER_VOLTAGE, (CellVoltMax_mV / 20));
}
if (CellVoltMin_mV <= MIN_CELL_VOLTAGE) {
set_event(EVENT_CELL_UNDER_VOLTAGE, 0);
set_event(EVENT_CELL_UNDER_VOLTAGE, (CellVoltMin_mV / 20));
}
if (cell_deviation_mV > MAX_CELL_DEVIATION) {
set_event(EVENT_CELL_DEVIATION_HIGH, 0);
set_event(EVENT_CELL_DEVIATION_HIGH, cell_deviation_mV);
} else {
clear_event(EVENT_CELL_DEVIATION_HIGH);
}
Expand Down
6 changes: 3 additions & 3 deletions Software/src/battery/NISSAN-LEAF-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,14 +527,14 @@ void receive_can_battery(CAN_frame_t rx_frame) {
datalayer.battery.status.cell_min_voltage_mV = min_max_voltage[0];

if (cell_deviation_mV > MAX_CELL_DEVIATION) {
set_event(EVENT_CELL_DEVIATION_HIGH, 0);
set_event(EVENT_CELL_DEVIATION_HIGH, (cell_deviation_mV / 20));
}

if (min_max_voltage[1] >= MAX_CELL_VOLTAGE) {
set_event(EVENT_CELL_OVER_VOLTAGE, 0);
set_event(EVENT_CELL_OVER_VOLTAGE, (min_max_voltage[1] / 20));
}
if (min_max_voltage[0] <= MIN_CELL_VOLTAGE) {
set_event(EVENT_CELL_UNDER_VOLTAGE, 0);
set_event(EVENT_CELL_UNDER_VOLTAGE, (min_max_voltage[0] / 20));
}
break;
}
Expand Down
6 changes: 3 additions & 3 deletions Software/src/battery/RENAULT-ZOE-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ void update_values_battery() { //This function maps all the values fetched via
}

if (LB_Cell_Max_Voltage >= ABSOLUTE_CELL_MAX_VOLTAGE) {
set_event(EVENT_CELL_OVER_VOLTAGE, 0);
set_event(EVENT_CELL_OVER_VOLTAGE, (LB_Cell_Max_Voltage / 20));
}
if (LB_Cell_Min_Voltage <= ABSOLUTE_CELL_MIN_VOLTAGE) {
set_event(EVENT_CELL_UNDER_VOLTAGE, 0);
set_event(EVENT_CELL_UNDER_VOLTAGE, (LB_Cell_Min_Voltage / 20));
}
if (cell_deviation_mV > MAX_CELL_DEVIATION_MV) {
set_event(EVENT_CELL_DEVIATION_HIGH, 0);
set_event(EVENT_CELL_DEVIATION_HIGH, (cell_deviation_mV / 20));
} else {
clear_event(EVENT_CELL_DEVIATION_HIGH);
}
Expand Down
6 changes: 3 additions & 3 deletions Software/src/battery/VOLVO-SPA-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,14 @@ void receive_can_battery(CAN_frame_t rx_frame) {
cell_deviation_mV = (min_max_voltage[1] - min_max_voltage[0]);

if (cell_deviation_mV > MAX_CELL_DEVIATION) {
set_event(EVENT_CELL_DEVIATION_HIGH, 0);
set_event(EVENT_CELL_DEVIATION_HIGH, (cell_deviation_mV / 20));
}

if (min_max_voltage[1] >= MAX_CELL_VOLTAGE) {
set_event(EVENT_CELL_OVER_VOLTAGE, 0);
set_event(EVENT_CELL_OVER_VOLTAGE, (min_max_voltage[1] / 20));
}
if (min_max_voltage[0] <= MIN_CELL_VOLTAGE) {
set_event(EVENT_CELL_UNDER_VOLTAGE, 0);
set_event(EVENT_CELL_UNDER_VOLTAGE, (min_max_voltage[0] / 20));
}
ESP32Can.CANWriteFrame(&VOLVO_SOH_Req); //Send SOH read request
}
Expand Down

0 comments on commit 59d5653

Please sign in to comment.