aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBen V. Brown <[email protected]>2021-05-06 21:35:43 +1000
committerBen V. Brown <[email protected]>2021-05-06 21:35:43 +1000
commit293c09cffaf7fb988f6341cc6bb39a37fdd4b32d (patch)
tree955ba09458e3812cb99a63414f99a09e5cece851
parent73f11499b699b00560c1d383341e95bc59028019 (diff)
downloadIronOS-293c09cffaf7fb988f6341cc6bb39a37fdd4b32d.tar.gz
IronOS-293c09cffaf7fb988f6341cc6bb39a37fdd4b32d.zip
Add slew rate to the PID output for MHP
-rw-r--r--source/Core/Inc/configuration.h2
-rw-r--r--source/Core/Threads/PIDThread.cpp22
2 files changed, 18 insertions, 6 deletions
diff --git a/source/Core/Inc/configuration.h b/source/Core/Inc/configuration.h
index f70f83b4..66f3f828 100644
--- a/source/Core/Inc/configuration.h
+++ b/source/Core/Inc/configuration.h
@@ -220,7 +220,7 @@
#define MIN_BOOST_TEMP_C 150 // The min settable temp for boost mode °C
#define MIN_BOOST_TEMP_F 300 // The min settable temp for boost mode °F
#define NO_DISPLAY_ROTATE // Disable OLED rotation by accel
-
+#define SLEW_LIMIT 50 // Limit to 3.0 Watts per 64ms pid loop update rate slew rate
#endif
#ifdef MODEL_TS100
diff --git a/source/Core/Threads/PIDThread.cpp b/source/Core/Threads/PIDThread.cpp
index 278de3a3..e8a69073 100644
--- a/source/Core/Threads/PIDThread.cpp
+++ b/source/Core/Threads/PIDThread.cpp
@@ -34,6 +34,9 @@ void startPIDTask(void const *argument __unused) {
// be over-ridden rapidly
pidTaskNotification = xTaskGetCurrentTaskHandle();
uint32_t PIDTempTarget = 0;
+#ifdef SLEW_LIMIT
+ int32_t x10WattsOutLast = 0;
+#endif
for (;;) {
if (ulTaskNotifyTake(pdTRUE, 2000)) {
@@ -109,12 +112,21 @@ void startPIDTask(void const *argument __unused) {
x10WattsOut = 0;
}
if (systemSettings.powerLimit && x10WattsOut > (systemSettings.powerLimit * 10)) {
- setTipX10Watts(systemSettings.powerLimit * 10);
- } else if (powerSupplyWattageLimit && x10WattsOut > powerSupplyWattageLimit * 10) {
- setTipX10Watts(powerSupplyWattageLimit * 10);
- } else {
- setTipX10Watts(x10WattsOut);
+ x10WattsOut = systemSettings.powerLimit * 10;
+ }
+ if (powerSupplyWattageLimit && x10WattsOut > powerSupplyWattageLimit * 10) {
+ x10WattsOut = powerSupplyWattageLimit * 10;
+ }
+#ifdef SLEW_LIMIT
+ if (x10WattsOut - x10WattsOutLast > SLEW_LIMIT) {
+ x10WattsOut = x10WattsOutLast + SLEW_LIMIT;
}
+ if (x10WattsOut < 0) {
+ x10WattsOut = 0;
+ }
+ x10WattsOutLast = x10WattsOut;
+#endif
+ setTipX10Watts(x10WattsOut);
#ifdef DEBUG_UART_OUTPUT
log_system_state(x10WattsOut);
#endif