aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBen V. Brown <[email protected]>2018-10-30 16:49:30 +1100
committerGitHub <[email protected]>2018-10-30 16:49:30 +1100
commitab6dc6c1524036657818d1028d2a12682fd08583 (patch)
tree7d60e1998d519dcc2e0f24d10d8b70cb9d1cd1f8
parentaa51dc4dbe8612de1d8f40c46682418c8df4ab14 (diff)
parentf081f766cb0043b8882d5c908f1c659f319c2ce7 (diff)
downloadIronOS-ab6dc6c1524036657818d1028d2a12682fd08583.tar.gz
IronOS-ab6dc6c1524036657818d1028d2a12682fd08583.zip
Merge pull request #396 from dhiltonp/watts
PID in watts fixes
-rw-r--r--workspace/TS100/src/main.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/workspace/TS100/src/main.cpp b/workspace/TS100/src/main.cpp
index 6ddb7363..b587dd4e 100644
--- a/workspace/TS100/src/main.cpp
+++ b/workspace/TS100/src/main.cpp
@@ -926,7 +926,7 @@ void startPIDTask(void const *argument __unused) {
#ifdef MODEL_TS80
idealQCVoltage = calculateMaxVoltage(systemSettings.cutoutSetting);
#endif
- int32_t rawC = ctoTipMeasurement(100) - ctoTipMeasurement(101); // 1*C change in raw.
+ uint8_t rawC = ctoTipMeasurement(101) - ctoTipMeasurement(100); // 1*C change in raw.
currentlyActiveTemperatureTarget = 0; // Force start with no output (off). If in sleep / soldering this will
// be over-ridden rapidly
@@ -948,7 +948,10 @@ void startPIDTask(void const *argument __unused) {
// to be unstable. Use a rolling average to dampen it.
// We overshoot by roughly 1/2 of 1 degree Fahrenheit.
// This helps stabilize the display.
- tempError.update(currentlyActiveTemperatureTarget - rawTemp + rawC/4);
+ int32_t tError = currentlyActiveTemperatureTarget - rawTemp + rawC/4;
+ tError = tError > INT16_MAX ? INT16_MAX : tError;
+ tError = tError < INT16_MIN ? INT16_MIN : tError;
+ tempError.update(tError);
// Now for the PID!
int32_t milliWattsOut = 0;
@@ -956,8 +959,10 @@ void startPIDTask(void const *argument __unused) {
// P term - total power needed to hit target temp next cycle.
// thermal mass = 1690 milliJ/*C for my tip.
// = Watts*Seconds to raise Temp from room temp to +100*C, divided by 100*C.
- // divided by 8 to let I term dominate near set point.
- const uint16_t mass = 1690 / 8;
+ // divided by 20 to let I term dominate near set point.
+ // I should retune this, but don't want to do it until
+ // the feed-forward temp adjustment is in place.
+ const uint16_t mass = 1690 / 20;
int32_t milliWattsNeeded = tempToMilliWatts(tempError.average(), mass, rawC);
milliWattsOut += milliWattsNeeded;