Merge pull request #1206 from Ralim/ts100-runaway
TS100 warning fix (#1192)
This commit is contained in:
@@ -20,6 +20,7 @@ static const uint8_t tempMeasureTicks = 14;
|
|||||||
uint16_t totalPWM; // htim2.Init.Period, the full PWM cycle
|
uint16_t totalPWM; // htim2.Init.Period, the full PWM cycle
|
||||||
|
|
||||||
static bool fastPWM;
|
static bool fastPWM;
|
||||||
|
static bool infastPWM;
|
||||||
|
|
||||||
void resetWatchdog() { HAL_IWDG_Refresh(&hiwdg); }
|
void resetWatchdog() { HAL_IWDG_Refresh(&hiwdg); }
|
||||||
#ifdef TEMP_NTC
|
#ifdef TEMP_NTC
|
||||||
@@ -135,7 +136,7 @@ uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
|
|||||||
|
|
||||||
static void switchToFastPWM(void) {
|
static void switchToFastPWM(void) {
|
||||||
// 10Hz
|
// 10Hz
|
||||||
fastPWM = true;
|
infastPWM = true;
|
||||||
totalPWM = powerPWM + tempMeasureTicks + holdoffTicks;
|
totalPWM = powerPWM + tempMeasureTicks + holdoffTicks;
|
||||||
htim2.Instance->ARR = totalPWM;
|
htim2.Instance->ARR = totalPWM;
|
||||||
htim2.Instance->CCR1 = powerPWM + holdoffTicks;
|
htim2.Instance->CCR1 = powerPWM + holdoffTicks;
|
||||||
@@ -144,7 +145,7 @@ static void switchToFastPWM(void) {
|
|||||||
|
|
||||||
static void switchToSlowPWM(void) {
|
static void switchToSlowPWM(void) {
|
||||||
// 5Hz
|
// 5Hz
|
||||||
fastPWM = false;
|
infastPWM = false;
|
||||||
totalPWM = powerPWM + tempMeasureTicks / 2 + holdoffTicks / 2;
|
totalPWM = powerPWM + tempMeasureTicks / 2 + holdoffTicks / 2;
|
||||||
htim2.Instance->ARR = totalPWM;
|
htim2.Instance->ARR = totalPWM;
|
||||||
htim2.Instance->CCR1 = powerPWM + holdoffTicks / 2;
|
htim2.Instance->CCR1 = powerPWM + holdoffTicks / 2;
|
||||||
@@ -152,16 +153,10 @@ static void switchToSlowPWM(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setTipPWM(const uint8_t pulse, const bool shouldUseFastModePWM) {
|
void setTipPWM(const uint8_t pulse, const bool shouldUseFastModePWM) {
|
||||||
PWMSafetyTimer = 10; // This is decremented in the handler for PWM so that the tip pwm is
|
PWMSafetyTimer = 20; // This is decremented in the handler for PWM so that the tip pwm is
|
||||||
// disabled if the PID task is not scheduled often enough.
|
// disabled if the PID task is not scheduled often enough.
|
||||||
|
fastPWM = shouldUseFastModePWM;
|
||||||
pendingPWM = pulse;
|
pendingPWM = pulse;
|
||||||
if (fastPWM != shouldUseFastModePWM) {
|
|
||||||
if (shouldUseFastModePWM) {
|
|
||||||
switchToFastPWM();
|
|
||||||
} else {
|
|
||||||
switchToSlowPWM();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// These are called by the HAL after the corresponding events from the system
|
// These are called by the HAL after the corresponding events from the system
|
||||||
// timers.
|
// timers.
|
||||||
@@ -182,6 +177,14 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
|||||||
} else {
|
} else {
|
||||||
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
|
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
|
||||||
}
|
}
|
||||||
|
if (fastPWM != infastPWM) {
|
||||||
|
if (fastPWM) {
|
||||||
|
switchToFastPWM();
|
||||||
|
} else {
|
||||||
|
switchToSlowPWM();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if (htim->Instance == TIM1) {
|
} else if (htim->Instance == TIM1) {
|
||||||
// STM uses this for internal functions as a counter for timeouts
|
// STM uses this for internal functions as a counter for timeouts
|
||||||
HAL_IncTick();
|
HAL_IncTick();
|
||||||
|
|||||||
@@ -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))
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ void startPIDTask(void const *argument __unused) {
|
|||||||
uint32_t PIDTempTarget = 0;
|
uint32_t PIDTempTarget = 0;
|
||||||
// Pre-seed the adc filters
|
// Pre-seed the adc filters
|
||||||
for (int i = 0; i < 128; i++) {
|
for (int i = 0; i < 128; i++) {
|
||||||
vTaskDelay(5);
|
osDelay(5);
|
||||||
TipThermoModel::getTipInC(true);
|
TipThermoModel::getTipInC(true);
|
||||||
getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 1);
|
getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 1);
|
||||||
}
|
}
|
||||||
@@ -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