Skip to content

Commit c43159c

Browse files
committed
BMS: add bench-mode macro to disable temperature enforcement
FEB_BMS_DISABLE_TEMP_CHECKS (FEB_Const.h, default 0) compiles out all cell-temperature enforcement for bench bring-up of ADBMS modules with unpopulated thermistors: the over/under-temp fault latch in validate_temps(), the charging temp soft-stop/hard-fault block in FEB_CAN_Charging_Status(), and both balance thermal gates (which all-NaN readings would otherwise hold closed). Readings and diagnostics stay visible; suppressed violations still print a one-shot warning. While enabled, boot logs a prominent warning, the console banner flags bench mode, and BMS|config reports the override state. Never enable on a real pack.
1 parent e56c7c7 commit c43159c

7 files changed

Lines changed: 44 additions & 2 deletions

File tree

BMS/Core/User/Inc/FEB_Const.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@
143143
#define FEB_IVT_PACK_VOLTAGE_CHANNEL 2
144144
#endif
145145

146+
// ********************************** Temperature Enforcement Override (BENCH ONLY)
147+
148+
// Set to 1 to disable ALL cell-temperature enforcement: the over/under-temp
149+
// fault latch (validate_temps), the charging temp soft-stop/hard-fault block
150+
// (FEB_CAN_Charging_Status), and the balance thermal gates. For bench bring-up
151+
// of ADBMS modules with unpopulated thermistors: floating inputs can latch
152+
// spurious temp faults, and all-NaN readings block balancing entirely.
153+
// Readings and diagnostics remain visible; only enforcement is suppressed.
154+
// Logs a warning at boot while enabled. NEVER enable with a real pack.
155+
#ifndef FEB_BMS_DISABLE_TEMP_CHECKS
156+
#define FEB_BMS_DISABLE_TEMP_CHECKS 0
157+
#endif
158+
146159
// ********************************** Accumulator Structure **********************
147160

148161
typedef struct

BMS/Core/User/Src/FEB_ADBMS6830B.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,19 @@ static void validate_temps()
478478
FEB_ACC.banks[bank].temp_violations[sensor]++;
479479
if (FEB_ACC.banks[bank].temp_violations[sensor] >= FEB_TEMP_ERROR_THRESH)
480480
{
481+
#if FEB_BMS_DISABLE_TEMP_CHECKS
482+
/* Bench mode: report the violation but do not latch the fault.
483+
* Fires once per sensor thanks to the saturating counter above. */
484+
printf("[ADBMS] WARNING: temp violation IGNORED (FEB_BMS_DISABLE_TEMP_CHECKS) - "
485+
"Bank %d Sensor %d: %.1fC (limits: %.1f-%.1fC)\r\n",
486+
bank, sensor, temp / 10.0f, tMin / 10.0f, tMax / 10.0f);
487+
#else
481488
printf("[ADBMS] FAULT: Cell temperature out of range - Bank %d Sensor %d: %.1fC (limits: %.1f-%.1fC)\r\n",
482489
bank, sensor, temp / 10.0f, tMin / 10.0f, tMax / 10.0f);
483490
FEB_ADBMS_Update_Error_Type(ERROR_TYPE_TEMP_VIOLATION);
484491
/* Latch for the SM task; evaluate_faults() routes per state group. */
485492
adbms_fault_flags |= ADBMS_FAULT_FLAG_TEMP;
493+
#endif
486494
}
487495
}
488496
}
@@ -799,6 +807,7 @@ void FEB_Cell_Balance_Start()
799807
// Caller must hold ADBMSMutexHandle.
800808
void FEB_Cell_Balance_Process()
801809
{
810+
#if !FEB_BMS_DISABLE_TEMP_CHECKS
802811
// Thermal safety gate. NaN fails the comparison → stops balancing when
803812
// telemetry is unavailable. Direct field read; caller already holds the mutex.
804813
const float gate_max_temp_dC = FEB_ACC.pack_max_temp * 10.0f;
@@ -807,6 +816,7 @@ void FEB_Cell_Balance_Process()
807816
LOG_W(TAG_BALANCE, "Temp limit: pack max=%.1fC, skipping balance cycle", gate_max_temp_dC / 10.0f);
808817
return;
809818
}
819+
#endif
810820

811821
determineMinV();
812822

@@ -876,6 +886,7 @@ void FEB_Cell_Balance_Process()
876886

877887
bool FEB_Cell_Balancing_Status(void)
878888
{
889+
#if !FEB_BMS_DISABLE_TEMP_CHECKS
879890
// The per-cell loop used to index temp_sensor_readings by cell index, which
880891
// only covered FEB_NUM_CELLS_PER_BANK (14) of the FEB_NUM_TEMP_SENSORS (42)
881892
// sensors. Use the pack-wide max computed by compute_pack_temp_stats() so
@@ -888,6 +899,7 @@ bool FEB_Cell_Balancing_Status(void)
888899
LOG_W(TAG_BALANCE, "Temp limit: pack max=%.1fC, stopping", max_temp_dC / 10.0f);
889900
return false;
890901
}
902+
#endif
891903

892904
float min_v = FLT_MAX;
893905
float max_v = -FLT_MAX;

BMS/Core/User/Src/FEB_CAN_Charger.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ int8_t FEB_CAN_Charging_Status(void)
137137
return 1;
138138
}
139139

140+
#if !FEB_BMS_DISABLE_TEMP_CHECKS
140141
/* Highest temperature: soft limit -> stop charging, hard limit -> fault.
141142
* NaN (no temp scan yet) fails both comparisons -> treated as OK; cell-data
142143
* presence is already gated by pack_v above and ADBMS staleness is a fault. */
@@ -149,6 +150,7 @@ int8_t FEB_CAN_Charging_Status(void)
149150
}
150151
return 1;
151152
}
153+
#endif
152154

153155
return 0;
154156
}

BMS/Core/User/Src/FEB_Commands.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,11 @@ static void subcmd_config(int argc, char *argv[])
602602
FEB_Console_Printf("Min Cell V: %.3f V\r\n", FEB_CELL_MIN_VOLTAGE_MV / 1000.0f);
603603
FEB_Console_Printf("Max Cell Temp: %.1f C\r\n", FEB_CELL_MAX_TEMP_DC / 10.0f);
604604
FEB_Console_Printf("Min Cell Temp: %.1f C\r\n", FEB_CELL_MIN_TEMP_DC / 10.0f);
605+
#if FEB_BMS_DISABLE_TEMP_CHECKS
606+
FEB_Console_Printf("Temp Checks: DISABLED (BENCH MODE)\r\n");
607+
#else
608+
FEB_Console_Printf("Temp Checks: enabled\r\n");
609+
#endif
605610
}
606611

607612
/* ============================================================================

BMS/Core/User/Src/FEB_Main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "FEB_CAN_PingPong.h"
1818
#include "FEB_CAN_Charger.h"
1919
#include "FEB_SM.h"
20+
#include "FEB_Const.h"
2021
#include "cmsis_os2.h"
2122
#include "FreeRTOS.h"
2223
#include "task.h"
@@ -104,10 +105,19 @@ void FEB_Init(void)
104105
/* Log after all subsystems initialized */
105106
LOG_I(TAG_MAIN, "BMS initialization complete");
106107

108+
#if FEB_BMS_DISABLE_TEMP_CHECKS
109+
LOG_W(TAG_MAIN, "TEMPERATURE ENFORCEMENT DISABLED (FEB_BMS_DISABLE_TEMP_CHECKS=1)");
110+
LOG_W(TAG_MAIN, "Bench mode: temp faults, charging temp limits, and balance");
111+
LOG_W(TAG_MAIN, "thermal gates are BYPASSED. Do NOT run a real pack.");
112+
#endif
113+
107114
/* Startup banner */
108115
FEB_Console_Printf("\r\n");
109116
FEB_Console_Printf("========================================\r\n");
110117
FEB_Console_Printf(" BMS Console Ready\r\n");
118+
#if FEB_BMS_DISABLE_TEMP_CHECKS
119+
FEB_Console_Printf(" !! TEMP CHECKS DISABLED (BENCH) !!\r\n");
120+
#endif
111121
FEB_Console_Printf("========================================\r\n");
112122
FEB_Console_Printf("Use | as delimiter: BMS|status\r\n");
113123
FEB_Console_Printf("Type 'help' for available commands\r\n");

BMS/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.7.8
1+
1.7.9

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.7.23
1+
1.7.24

0 commit comments

Comments
 (0)