From 3f45e6a5afb3e51f60eae609ca290bde12b69bff Mon Sep 17 00:00:00 2001 From: Thomas Gimpel Date: Sun, 24 Nov 2019 11:50:51 +0100 Subject: [PATCH] generate power pulses also in soldering and sleep mode --- workspace/TS100/Core/Src/main.cpp | 36 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/workspace/TS100/Core/Src/main.cpp b/workspace/TS100/Core/Src/main.cpp index 488f511a..969601d0 100644 --- a/workspace/TS100/Core/Src/main.cpp +++ b/workspace/TS100/Core/Src/main.cpp @@ -40,6 +40,10 @@ void startPIDTask(void const *argument); void startMOVTask(void const *argument); // End FreeRTOS +static const int maxPowerIdleTicks = 1000; +static const int powerPulseTicks = 500; +static const int powerPulseMilliWatts = 5000; + // Main sets up the hardware then hands over to the FreeRTOS kernel int main(void) { /* Reset of all peripherals, Initializes the Flash interface and the Systick. @@ -130,6 +134,7 @@ void startPIDTask(void const *argument __unused) { if (ulTaskNotifyTake(pdTRUE, 2000)) { // This is a call to block this thread until the ADC does its samples uint16_t rawTemp = getTipRawTemp(1); // get instantaneous reading + int32_t milliWattsOut = 0; if (currentlyActiveTemperatureTarget) { // Cap the max set point to 450C if (currentlyActiveTemperatureTarget > ctoTipMeasurement(450)) { @@ -151,7 +156,6 @@ void startPIDTask(void const *argument __unused) { tempError.update(tError); // Now for the PID! - int32_t milliWattsOut = 0; // P term - total power needed to hit target temp next cycle. // thermal mass = 1690 milliJ/*C for my tip. @@ -185,25 +189,19 @@ void startPIDTask(void const *argument __unused) { // basically: temp - lastTemp // Unfortunately, our temp signal is too noisy to really help. - setTipMilliWatts(milliWattsOut); - } else { - -#ifdef MODEL_TS80 - //If its a TS80, we want to have the option of using an occasional pulse to keep the power bank on - // This is purely guesswork :'( as everyone implements stuff differently - if (xTaskGetTickCount() - lastPowerPulse < 10) { - // for the first 100mS turn on for a bit - setTipMilliWatts(5000); // typically its around 5W to hold the current temp, so this wont raise temp much - } else - setTipMilliWatts(0); - //Then wait until the next 0.5 seconds - if (xTaskGetTickCount() - lastPowerPulse > 50) { - lastPowerPulse = xTaskGetTickCount(); - } -#else - setTipMilliWatts(0); -#endif } +#ifdef MODEL_TS80 + //If its a TS80, we want to have the option of using an occasional pulse to keep the power bank on + if (((xTaskGetTickCount() - lastPowerPulse) > maxPowerIdleTicks) && + (milliWattsOut < powerPulseMilliWatts)) { + milliWattsOut = powerPulseMilliWatts; + } + if (((xTaskGetTickCount() - lastPowerPulse) > (maxPowerIdleTicks + powerPulseTicks)) && + (milliWattsOut >= powerPulseMilliWatts)) { + lastPowerPulse = xTaskGetTickCount(); + } +#endif + setTipMilliWatts(milliWattsOut); HAL_IWDG_Refresh(&hiwdg); } else {