|
@@ -476,6 +476,8 @@ float get_pid_output(int e) {
|
476
|
476
|
#ifdef PIDTEMP
|
477
|
477
|
#ifndef PID_OPENLOOP
|
478
|
478
|
pid_error[e] = target_temperature[e] - current_temperature[e];
|
|
479
|
+ dTerm[e] = K2 * PID_PARAM(Kd,e) * (current_temperature[e] - temp_dState[e]) + K1 * dTerm[e];
|
|
480
|
+ temp_dState[e] = current_temperature[e];
|
479
|
481
|
if (pid_error[e] > PID_FUNCTIONAL_RANGE) {
|
480
|
482
|
pid_output = BANG_MAX;
|
481
|
483
|
pid_reset[e] = true;
|
|
@@ -494,7 +496,6 @@ float get_pid_output(int e) {
|
494
|
496
|
temp_iState[e] = constrain(temp_iState[e], temp_iState_min[e], temp_iState_max[e]);
|
495
|
497
|
iTerm[e] = PID_PARAM(Ki,e) * temp_iState[e];
|
496
|
498
|
|
497
|
|
- dTerm[e] = K2 * PID_PARAM(Kd,e) * (current_temperature[e] - temp_dState[e]) + K1 * dTerm[e];
|
498
|
499
|
pid_output = pTerm[e] + iTerm[e] - dTerm[e];
|
499
|
500
|
if (pid_output > PID_MAX) {
|
500
|
501
|
if (pid_error[e] > 0) temp_iState[e] -= pid_error[e]; // conditional un-integration
|
|
@@ -505,7 +506,6 @@ float get_pid_output(int e) {
|
505
|
506
|
pid_output = 0;
|
506
|
507
|
}
|
507
|
508
|
}
|
508
|
|
- temp_dState[e] = current_temperature[e];
|
509
|
509
|
#else
|
510
|
510
|
pid_output = constrain(target_temperature[e], 0, PID_MAX);
|
511
|
511
|
#endif //PID_OPENLOOP
|