Use runaway counter trigger

This commit is contained in:
Ben V. Brown
2025-01-11 13:12:02 +11:00
parent 92730d1acb
commit abefe96072
5 changed files with 28 additions and 21 deletions

View File

@@ -22,12 +22,12 @@
#endif #endif
#endif #endif
static TickType_t powerPulseWaitUnit = 25 * TICKS_100MS; // 2.5 s static TickType_t powerPulseWaitUnit = 25 * TICKS_100MS; // 2.5 s
static TickType_t powerPulseDurationUnit = (5 * TICKS_100MS) / 2; // 250 ms static TickType_t powerPulseDurationUnit = (5 * TICKS_100MS) / 2; // 250 ms
TaskHandle_t pidTaskNotification = NULL; TaskHandle_t pidTaskNotification = NULL;
volatile TemperatureType_t currentTempTargetDegC = 0; // Current temperature target in C volatile TemperatureType_t currentTempTargetDegC = 0; // Current temperature target in C
int32_t powerSupplyWattageLimit = 0; int32_t powerSupplyWattageLimit = 0;
bool heaterThermalRunaway = false; uint8_t heaterThermalRunawayCounter = 0;
static int32_t getPIDResultX10Watts(TemperatureType_t set_point, TemperatureType_t current_value); static int32_t getPIDResultX10Watts(TemperatureType_t set_point, TemperatureType_t current_value);
static void detectThermalRunaway(const TemperatureType_t currentTipTempInC, const uint32_t x10WattsOut); static void detectThermalRunaway(const TemperatureType_t currentTipTempInC, const uint32_t x10WattsOut);
@@ -71,7 +71,8 @@ void startPIDTask(void const *argument __unused) {
#endif #endif
#endif #endif
int32_t x10WattsOut = 0; int32_t x10WattsOut = 0;
TickType_t lastThermalRunawayDecay = xTaskGetTickCount();
for (;;) { for (;;) {
x10WattsOut = 0; x10WattsOut = 0;
@@ -105,6 +106,12 @@ void startPIDTask(void const *argument __unused) {
#ifdef DEBUG_UART_OUTPUT #ifdef DEBUG_UART_OUTPUT
log_system_state(x10WattsOut); log_system_state(x10WattsOut);
#endif #endif
if (xTaskGetTickCount() - lastThermalRunawayDecay > TICKS_SECOND) {
lastThermalRunawayDecay = xTaskGetTickCount();
if (heaterThermalRunawayCounter > 0) {
heaterThermalRunawayCounter--;
}
}
} }
} }
@@ -249,8 +256,8 @@ void detectThermalRunaway(const TemperatureType_t currentTipTempInC, const uint3
static bool haveSeenDelta = false; static bool haveSeenDelta = false;
// Check for readings being pegged at the top of the ADC while the heater is off // Check for readings being pegged at the top of the ADC while the heater is off
if (!thisCycleIsHeating && (getTipRawTemp(0) > (ADC_MAX_READING - 8))) { if (!thisCycleIsHeating && (getTipRawTemp(0) > (ADC_MAX_READING - 8)) && heaterThermalRunawayCounter < 255) {
heaterThermalRunaway = true; heaterThermalRunawayCounter++;
} }
if (haveSeenDelta) { if (haveSeenDelta) {
@@ -277,8 +284,8 @@ void detectThermalRunaway(const TemperatureType_t currentTipTempInC, const uint3
TemperatureType_t delta = tipTempMax - tiptempMin; TemperatureType_t delta = tipTempMax - tiptempMin;
haveSeenDelta = true; haveSeenDelta = true;
if (delta < THERMAL_RUNAWAY_TEMP_C) { if (delta < THERMAL_RUNAWAY_TEMP_C && heaterThermalRunawayCounter < 255) {
heaterThermalRunaway = true; heaterThermalRunawayCounter++;
} }
} }
} }
@@ -322,7 +329,7 @@ void setOutputx10WattsViaFilters(int32_t x10WattsOut) {
if (getTipRawTemp(0) > (0x7FFF - 32)) { if (getTipRawTemp(0) > (0x7FFF - 32)) {
x10WattsOut = 0; x10WattsOut = 0;
} }
if (heaterThermalRunaway) { if (heaterThermalRunawayCounter > 8) {
x10WattsOut = 0; x10WattsOut = 0;
} }
#ifdef SLEW_LIMIT #ifdef SLEW_LIMIT

View File

@@ -83,5 +83,5 @@ OperatingMode showWarnings(const ButtonState buttons, guiContext *cxt);
// Common helpers // Common helpers
int8_t getPowerSourceNumber(void); // Returns number ID of power source int8_t getPowerSourceNumber(void); // Returns number ID of power source
extern bool heaterThermalRunaway; extern uint8_t heaterThermalRunawayCounter;
#endif #endif

View File

@@ -161,10 +161,10 @@ OperatingMode gui_solderingMode(const ButtonState buttons, guiContext *cxt) {
return OperatingMode::Sleeping; return OperatingMode::Sleeping;
} }
if (heaterThermalRunaway) { if (heaterThermalRunawayCounter > 8) {
currentTempTargetDegC = 0; // heater control off currentTempTargetDegC = 0; // heater control off
heaterThermalRunaway = false; heaterThermalRunawayCounter = 0;
cxt->transitionMode = TransitionAnimation::Right; cxt->transitionMode = TransitionAnimation::Right;
return OperatingMode::ThermalRunaway; return OperatingMode::ThermalRunaway;
} }
return handleSolderingButtons(buttons, cxt); return handleSolderingButtons(buttons, cxt);

View File

@@ -159,9 +159,9 @@ OperatingMode gui_solderingProfileMode(const ButtonState buttons, guiContext *cx
setBuzzer(false); setBuzzer(false);
return OperatingMode::HomeScreen; return OperatingMode::HomeScreen;
} }
if (heaterThermalRunaway) { if (heaterThermalRunawayCounter > 8) {
currentTempTargetDegC = 0; // heater control off currentTempTargetDegC = 0; // heater control off
heaterThermalRunaway = false; heaterThermalRunawayCounter = 0;
return OperatingMode::ThermalRunaway; return OperatingMode::ThermalRunaway;
} }

View File

@@ -9,7 +9,7 @@
#include "history.hpp" #include "history.hpp"
#include "ui_drawing.hpp" #include "ui_drawing.hpp"
extern bool heaterThermalRunaway; extern uint8_t heaterThermalRunawayCounter;
bool checkExitSoldering(void) { bool checkExitSoldering(void) {
#ifdef POW_DC #ifdef POW_DC