mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Merge branch 'dev' into dev
This commit is contained in:
@@ -30,7 +30,7 @@ int32_t powerSupplyWattageLimit = 0;
|
||||
bool heaterThermalRunaway = false;
|
||||
|
||||
static int32_t getPIDResultX10Watts(TemperatureType_t set_point, TemperatureType_t current_value);
|
||||
static void detectThermalRunaway(const TemperatureType_t currentTipTempInC, const TemperatureType_t tError);
|
||||
static void detectThermalRunaway(const TemperatureType_t currentTipTempInC, const uint32_t x10WattsOut);
|
||||
static void setOutputx10WattsViaFilters(int32_t x10Watts);
|
||||
static int32_t getX10WattageLimits();
|
||||
|
||||
@@ -92,8 +92,8 @@ void startPIDTask(void const *argument __unused) {
|
||||
PIDTempTarget = TipThermoModel::getTipMaxInC();
|
||||
}
|
||||
|
||||
detectThermalRunaway(currentTipTempInC, PIDTempTarget - currentTipTempInC);
|
||||
x10WattsOut = getPIDResultX10Watts(PIDTempTarget, currentTipTempInC);
|
||||
detectThermalRunaway(currentTipTempInC, x10WattsOut);
|
||||
} else {
|
||||
detectThermalRunaway(currentTipTempInC, 0);
|
||||
}
|
||||
@@ -228,31 +228,59 @@ int32_t getPIDResultX10Watts(TemperatureType_t set_point, TemperatureType_t curr
|
||||
#endif
|
||||
}
|
||||
|
||||
void detectThermalRunaway(const TemperatureType_t currentTipTempInC, const TemperatureType_t tError) {
|
||||
static TemperatureType_t tipTempCRunawayTemp = 0;
|
||||
static TickType_t runawaylastChangeTime = 0;
|
||||
/*
|
||||
* Detection of thermal runaway
|
||||
* The goal of this is to handle cases where something has gone wrong
|
||||
* 1. The tip MOSFET is broken, so power is being constantly applied to the tip
|
||||
* a. This can show as temp being stuck at max
|
||||
* b. Or temp rising when the heater is off
|
||||
* 2. Broken temperature sense
|
||||
* a. Temp is stuck at a value
|
||||
* These boil down to either a constantly rising temperature or a temperature that is stuck at a value
|
||||
* These are both covered; but looking at the eye/delta between min and max temp seen
|
||||
*/
|
||||
void detectThermalRunaway(const TemperatureType_t currentTipTempInC, const uint32_t x10WattsOut) {
|
||||
|
||||
// Check for thermal runaway, where it has been x seconds with negligible (y) temp rise
|
||||
// While trying to actively heat
|
||||
static TemperatureType_t tiptempMin = 0xFFFF; // Min tip temp seen
|
||||
static TemperatureType_t tipTempMax = 0; // Max tip temp seen while heater is on
|
||||
bool thisCycleIsHeating = x10WattsOut > 0;
|
||||
static TickType_t heatCycleStart = 0;
|
||||
|
||||
// If we are more than 20C below the setpoint
|
||||
if ((tError > THERMAL_RUNAWAY_TEMP_C)) {
|
||||
static bool haveSeenDelta = false;
|
||||
|
||||
// If we have heated up by more than 20C since last sample point, snapshot time and tip temp
|
||||
TemperatureType_t delta = currentTipTempInC - tipTempCRunawayTemp;
|
||||
if (delta > THERMAL_RUNAWAY_TEMP_C) {
|
||||
// We have heated up more than the threshold, reset the timer
|
||||
tipTempCRunawayTemp = currentTipTempInC;
|
||||
runawaylastChangeTime = xTaskGetTickCount();
|
||||
} else {
|
||||
if ((xTaskGetTickCount() - runawaylastChangeTime) > (THERMAL_RUNAWAY_TIME_SEC * TICKS_SECOND)) {
|
||||
// It has taken too long to rise
|
||||
// Check for readings being pegged at the top of the ADC while the heater is off
|
||||
if (!thisCycleIsHeating && (getTipRawTemp(0) > (0x7FFF - 16))) {
|
||||
heaterThermalRunaway = true;
|
||||
}
|
||||
|
||||
if (haveSeenDelta) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentTipTempInC < tiptempMin) {
|
||||
tiptempMin = currentTipTempInC;
|
||||
}
|
||||
if (thisCycleIsHeating && currentTipTempInC > tipTempMax) {
|
||||
tipTempMax = currentTipTempInC;
|
||||
}
|
||||
if (thisCycleIsHeating) {
|
||||
if (heatCycleStart == 0) {
|
||||
heatCycleStart = xTaskGetTickCount();
|
||||
}
|
||||
} else {
|
||||
heatCycleStart = 0;
|
||||
}
|
||||
|
||||
if ((xTaskGetTickCount() - heatCycleStart) > (THERMAL_RUNAWAY_TIME_SEC * TICKS_SECOND)) {
|
||||
if (tipTempMax > tiptempMin) {
|
||||
// Have been heating for min seconds, check if the delta is large enough
|
||||
TemperatureType_t delta = tipTempMax - tiptempMin;
|
||||
haveSeenDelta = true;
|
||||
|
||||
if (delta < THERMAL_RUNAWAY_TEMP_C) {
|
||||
heaterThermalRunaway = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tipTempCRunawayTemp = currentTipTempInC;
|
||||
runawaylastChangeTime = xTaskGetTickCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,4 +336,4 @@ void setOutputx10WattsViaFilters(int32_t x10WattsOut) {
|
||||
#endif
|
||||
setTipX10Watts(x10WattsOut);
|
||||
resetWatchdog();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,20 +29,20 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
enum class OperatingMode {
|
||||
StartupLogo = 0, // Showing the startup logo
|
||||
CJCCalibration, // Cold Junction Calibration
|
||||
StartupWarnings, // Startup checks and warnings
|
||||
InitialisationDone, // Special state we use just before we to home screen at first startup. Allows jumping to extra startup states
|
||||
HomeScreen, // Home/Idle screen that is the main launchpad to other modes
|
||||
Soldering, // Main soldering operating mode
|
||||
SolderingProfile, // Soldering by following a profile, used for reflow for example
|
||||
Sleeping, // Sleep state holds iron at lower sleep temp
|
||||
Hibernating, // Like sleeping but keeps heater fully off until woken
|
||||
SettingsMenu, // Settings Menu
|
||||
DebugMenuReadout, // Debug metrics
|
||||
TemperatureAdjust, // Set point temperature adjustment
|
||||
UsbPDDebug, // USB PD debugging information
|
||||
ThermalRunaway, // Thermal Runaway warning state.
|
||||
StartupLogo=10, // Showing the startup logo
|
||||
CJCCalibration=11, // Cold Junction Calibration
|
||||
StartupWarnings=12, // Startup checks and warnings
|
||||
InitialisationDone=13, // Special state we use just before we to home screen at first startup. Allows jumping to extra startup states
|
||||
HomeScreen=0, // Home/Idle screen that is the main launchpad to other modes
|
||||
Soldering=1, // Main soldering operating mode
|
||||
SolderingProfile=6, // Soldering by following a profile, used for reflow for example
|
||||
Sleeping=3, // Sleep state holds iron at lower sleep temp
|
||||
Hibernating=14, // Like sleeping but keeps heater fully off until woken
|
||||
SettingsMenu=4, // Settings Menu
|
||||
DebugMenuReadout=5, // Debug metrics
|
||||
TemperatureAdjust=7, // Set point temperature adjustment
|
||||
UsbPDDebug=8, // USB PD debugging information
|
||||
ThermalRunaway=9, // Thermal Runaway warning state.
|
||||
};
|
||||
|
||||
enum class TransitionAnimation {
|
||||
|
||||
@@ -138,9 +138,7 @@ OperatingMode gui_solderingMode(const ButtonState buttons, guiContext *cxt) {
|
||||
|
||||
// Draw in the screen details
|
||||
if (getSettingValue(SettingsOptions::DetailedSoldering)) {
|
||||
|
||||
ui_draw_soldering_power_status(cxt->scratch_state.state2);
|
||||
|
||||
} else {
|
||||
ui_draw_soldering_basic_status(cxt->scratch_state.state2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user