From a62c079b0f39d8f11382b15ef61f2e640188501d Mon Sep 17 00:00:00 2001 From: kbracher Date: Thu, 27 Mar 2025 16:56:54 +0100 Subject: [PATCH] fix: make adbms overtemp threshold configurable --- AMS_Master_Code/Core/Inc/config_ADBMS6830.h | 2 +- .../Core/Lib/ADBMS6830B_Driver/Core/Inc/ADBMS_Driver.h | 2 +- .../Core/Lib/ADBMS6830B_Driver/Core/Src/ADBMS_HighLevel.c | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/AMS_Master_Code/Core/Inc/config_ADBMS6830.h b/AMS_Master_Code/Core/Inc/config_ADBMS6830.h index 4b60e4c..dedb364 100644 --- a/AMS_Master_Code/Core/Inc/config_ADBMS6830.h +++ b/AMS_Master_Code/Core/Inc/config_ADBMS6830.h @@ -4,7 +4,7 @@ #include "main.h" #define N_BMS 1 -#define ADBMS_SPI_TIMEOUT 100 // Timeout in ms +#define ADBMS_MAX_CHIP_TEMP 110 // max temperature of ADBMS6830B (not battery) in C [[maybe_unused]] static inline void mcuAdbmsCSLow() { HAL_GPIO_WritePin(AMS_CS_GPIO_Port, AMS_CS_Pin, GPIO_PIN_RESET); diff --git a/AMS_Master_Code/Core/Lib/ADBMS6830B_Driver/Core/Inc/ADBMS_Driver.h b/AMS_Master_Code/Core/Lib/ADBMS6830B_Driver/Core/Inc/ADBMS_Driver.h index 29f07b0..127878e 100644 --- a/AMS_Master_Code/Core/Lib/ADBMS6830B_Driver/Core/Inc/ADBMS_Driver.h +++ b/AMS_Master_Code/Core/Lib/ADBMS6830B_Driver/Core/Inc/ADBMS_Driver.h @@ -83,7 +83,7 @@ typedef struct { uint32_t bmsID; struct ADBMS6830_Internal_Status status; - uint16_t internalDieTemp; + int16_t internalDieTemp; uint16_t analogSupplyVoltage; uint16_t digitalSupplyVoltage; uint16_t sumOfCellMeasurements; diff --git a/AMS_Master_Code/Core/Lib/ADBMS6830B_Driver/Core/Src/ADBMS_HighLevel.c b/AMS_Master_Code/Core/Lib/ADBMS6830B_Driver/Core/Src/ADBMS_HighLevel.c index e30a1ed..6fb50f7 100644 --- a/AMS_Master_Code/Core/Lib/ADBMS6830B_Driver/Core/Src/ADBMS_HighLevel.c +++ b/AMS_Master_Code/Core/Lib/ADBMS6830B_Driver/Core/Src/ADBMS_HighLevel.c @@ -106,8 +106,7 @@ ADBMS_DetailedStatus AMS_Idle_Loop() { return (ADBMS_DetailedStatus){ADBMS_UNDERVOLT, match - 1}; } - // TODO: replace with the correct threshold for the internal die temperature - if ((match = any(module.internalDieTemp > 28000 || module.status.THSD))) { + if ((match = any(module.internalDieTemp > ADBMS_MAX_CHIP_TEMP || module.status.THSD))) { return (ADBMS_DetailedStatus){ADBMS_INTERNAL_BMS_OVERTEMP, match - 1}; }