Dont wrap negative deltas
This commit is contained in:
@@ -95,7 +95,7 @@
|
|||||||
#define DETAILED_IDLE 0 // 0: Disable 1: Enable - Default 0
|
#define DETAILED_IDLE 0 // 0: Disable 1: Enable - Default 0
|
||||||
|
|
||||||
#define THERMAL_RUNAWAY_TIME_SEC 20
|
#define THERMAL_RUNAWAY_TIME_SEC 20
|
||||||
#define THERMAL_RUNAWAY_TEMP_C 20
|
#define THERMAL_RUNAWAY_TEMP_C 10
|
||||||
|
|
||||||
#define CUT_OUT_SETTING 0 // default to no cut-off voltage
|
#define CUT_OUT_SETTING 0 // default to no cut-off voltage
|
||||||
#define RECOM_VOL_CELL 33 // Minimum voltage per cell (Recommended 3.3V (33))
|
#define RECOM_VOL_CELL 33 // Minimum voltage per cell (Recommended 3.3V (33))
|
||||||
|
|||||||
@@ -148,12 +148,12 @@ void detectThermalRunaway(const int16_t currentTipTempInC, const int tError) {
|
|||||||
|
|
||||||
// Check for thermal runaway, where it has been x seconds with negligible (y) temp rise
|
// Check for thermal runaway, where it has been x seconds with negligible (y) temp rise
|
||||||
// While trying to actively heat
|
// While trying to actively heat
|
||||||
|
|
||||||
|
// If we are more than 20C below the setpoint
|
||||||
if ((tError > THERMAL_RUNAWAY_TEMP_C)) {
|
if ((tError > THERMAL_RUNAWAY_TEMP_C)) {
|
||||||
// Temp error is high
|
|
||||||
|
// If we have heated up by more than 20C since last sample point, snapshot time and tip temp
|
||||||
int16_t delta = (int16_t)currentTipTempInC - (int16_t)tipTempCRunawayTemp;
|
int16_t delta = (int16_t)currentTipTempInC - (int16_t)tipTempCRunawayTemp;
|
||||||
if (delta < 0) {
|
|
||||||
delta = -delta;
|
|
||||||
}
|
|
||||||
if (delta > THERMAL_RUNAWAY_TEMP_C) {
|
if (delta > THERMAL_RUNAWAY_TEMP_C) {
|
||||||
// We have heated up more than the threshold, reset the timer
|
// We have heated up more than the threshold, reset the timer
|
||||||
tipTempCRunawayTemp = currentTipTempInC;
|
tipTempCRunawayTemp = currentTipTempInC;
|
||||||
|
|||||||
Reference in New Issue
Block a user