diff options
author | Ben V. Brown <[email protected]> | 2020-01-18 13:01:51 +1100 |
---|---|---|
committer | Ben V. Brown <[email protected]> | 2020-01-18 13:01:51 +1100 |
commit | 0a671a97ba20fc4ff9df55753a4cc6f616117d37 (patch) | |
tree | 35b96fb16673716aaaf720c2046e4d6158290a7f | |
parent | 03d3a20f9d868e4e1aa9c71e9c6fa7903a4a9ca4 (diff) | |
download | IronOS-0a671a97ba20fc4ff9df55753a4cc6f616117d37.tar.gz IronOS-0a671a97ba20fc4ff9df55753a4cc6f616117d37.zip |
Add limiter for setpoint > ADC range
-rw-r--r-- | workspace/TS100/Core/Src/TipThermoModel.cpp | 7 | ||||
-rw-r--r-- | workspace/TS100/Core/Src/TipThermoModel.h | 6 | ||||
-rw-r--r-- | workspace/TS100/Core/Src/main.cpp | 20 |
3 files changed, 23 insertions, 10 deletions
diff --git a/workspace/TS100/Core/Src/TipThermoModel.cpp b/workspace/TS100/Core/Src/TipThermoModel.cpp index 3c6b0d64..b3948ad5 100644 --- a/workspace/TS100/Core/Src/TipThermoModel.cpp +++ b/workspace/TS100/Core/Src/TipThermoModel.cpp @@ -119,3 +119,10 @@ uint32_t TipThermoModel::getTipInF(bool sampleNow) { currentTipTempInF += convertCtoF(getHandleTemperature() / 10); //Add handle offset return currentTipTempInF; } + +uint32_t TipThermoModel::getTipMaxInC() { + uint32_t maximumTipTemp = TipThermoModel::convertTipRawADCToDegC( + 0x7FFF - 10); + maximumTipTemp += getHandleTemperature() / 10; //Add handle offset + return maximumTipTemp; +} diff --git a/workspace/TS100/Core/Src/TipThermoModel.h b/workspace/TS100/Core/Src/TipThermoModel.h index 88b0782d..50675796 100644 --- a/workspace/TS100/Core/Src/TipThermoModel.h +++ b/workspace/TS100/Core/Src/TipThermoModel.h @@ -12,9 +12,11 @@ class TipThermoModel { public: //These are the main two functions - static uint32_t getTipInC(bool sampleNow=false); - static uint32_t getTipInF(bool sampleNow=false); + static uint32_t getTipInC(bool sampleNow = false); + static uint32_t getTipInF(bool sampleNow = false); + //Calculates the maximum temperature can can be read by the ADC range + static uint32_t getTipMaxInC(); static uint32_t convertTipRawADCToDegC(uint16_t rawADC); static uint32_t convertTipRawADCToDegF(uint16_t rawADC); diff --git a/workspace/TS100/Core/Src/main.cpp b/workspace/TS100/Core/Src/main.cpp index 5730dd71..7950730b 100644 --- a/workspace/TS100/Core/Src/main.cpp +++ b/workspace/TS100/Core/Src/main.cpp @@ -138,6 +138,9 @@ void startPIDTask(void const *argument __unused) { //Maximum allowed output currentTempTargetDegC = (450); } + if (currentTempTargetDegC > TipThermoModel::getTipMaxInC()) { + currentTempTargetDegC = TipThermoModel::getTipMaxInC(); + } // Convert the current tip to degree's C // As we get close to our target, temp noise causes the system @@ -190,7 +193,8 @@ void startPIDTask(void const *argument __unused) { } #endif - if (systemSettings.powerLimitEnable && x10WattsOut > (systemSettings.powerLimit * 10)) + if (systemSettings.powerLimitEnable + && x10WattsOut > (systemSettings.powerLimit * 10)) setTipX10Watts(systemSettings.powerLimit * 10); else setTipX10Watts(x10WattsOut); @@ -289,17 +293,17 @@ void startMOVTask(void const *argument __unused) { /* The header value is (0xAA,0x55,0xF0,0x0D) but is stored in little endian 16 * bits words on the flash */ -const uint8_t LOGO_HEADER_VALUE[] = {0x55, 0xAA, 0x0D, 0xF0}; +const uint8_t LOGO_HEADER_VALUE[] = { 0x55, 0xAA, 0x0D, 0xF0 }; bool showBootLogoIfavailable() { - uint8_t *header = (uint8_t*) (FLASH_LOGOADDR); + uint8_t *header = (uint8_t*) (FLASH_LOGOADDR); // check if the header is correct. - for(int i = 0; i < 4; i++) { - if(header[i] != LOGO_HEADER_VALUE[i]) { - return false; - } - } + for (int i = 0; i < 4; i++) { + if (header[i] != LOGO_HEADER_VALUE[i]) { + return false; + } + } OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t*) (FLASH_LOGOADDR + 4)); OLED::refresh(); |