Skip to content

Commit

Permalink
Make startup less prone to throw Events
Browse files Browse the repository at this point in the history
  • Loading branch information
dalathegreat committed Dec 15, 2024
1 parent db77fcf commit 0203a85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Software/src/battery/BYD-ATTO-3-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@ void setup_battery(void) { // Performs one time setup at startup
datalayer.battery.info.max_cell_voltage_mV = MAX_CELL_VOLTAGE_MV;
datalayer.battery.info.min_cell_voltage_mV = MIN_CELL_VOLTAGE_MV;
datalayer.battery.info.max_cell_voltage_deviation_mV = MAX_CELL_DEVIATION_MV;
datalayer.battery.status.voltage_dV =
MIN_PACK_VOLTAGE_DV +
1; // Init values in datalayer too low, causes safeties to trigger before values are sampled
#ifdef DOUBLE_BATTERY
datalayer.battery2.info.number_of_cells = 126;
datalayer.battery2.info.chemistry = battery_chemistry_enum::LFP;
Expand Down
3 changes: 2 additions & 1 deletion Software/src/devboard/safety/safety.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ void update_machineryprotection() {
#endif //NISSAN_LEAF_BATTERY

// Check diff between highest and lowest cell
cell_deviation_mV = (datalayer.battery.status.cell_max_voltage_mV - datalayer.battery.status.cell_min_voltage_mV);
cell_deviation_mV =
std::abs(datalayer.battery.status.cell_max_voltage_mV - datalayer.battery.status.cell_min_voltage_mV);
if (cell_deviation_mV > datalayer.battery.info.max_cell_voltage_deviation_mV) {
set_event(EVENT_CELL_DEVIATION_HIGH, (cell_deviation_mV / 20));
} else {
Expand Down

0 comments on commit 0203a85

Please sign in to comment.