Skip to content

Commit 1c83b4d

Browse files
committed
tweak autoTune
1 parent 1626eef commit 1c83b4d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/QuickPID.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,13 @@ byte AutoTunePID::autoTuneLoop() {
296296
if (*_input > _atSetpoint) {
297297
_t0 = micros();
298298
if (_printOrPlotter == 1) Serial.print(F(" t0 →"));
299+
_inputLast = *_input;
299300
_autoTuneStage = T1;
300301
}
301302
return AUTOTUNE;
302303
break;
303304
case T1: // get t1
304-
if (*_input > _atSetpoint + 0.2) {
305+
if ((*_input > _atSetpoint) && (*_input > _inputLast)) {
305306
_t1 = micros();
306307
if (_printOrPlotter == 1) Serial.print(F(" t1 →"));
307308
_autoTuneStage = T2;

src/QuickPID.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class AutoTunePID {
4141
bool _printOrPlotter = false;
4242
uint32_t _tLoop, _tLast, _t0, _t1, _t2, _t3;
4343
float _outputStep, _hysteresis, _atSetpoint, _atOutput;
44-
float _Ku, _Tu, _td, _kp, _ki, _kd, _rdAvg, _peakHigh, _peakLow;
44+
float _Ku, _Tu, _td, _kp, _ki, _kd, _rdAvg, _peakHigh, _peakLow, _inputLast;
4545

4646
const uint16_t RulesContants[10][3] =
4747
{ //ckp, cki, ckd x 1000

0 commit comments

Comments
 (0)