|
@@ -565,7 +565,14 @@ void manage_heater()
|
565
|
565
|
dTerm_bed= (bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed);
|
566
|
566
|
temp_dState_bed = pid_input;
|
567
|
567
|
|
568
|
|
- pid_output = constrain(pTerm_bed + iTerm_bed - dTerm_bed, 0, MAX_BED_POWER);
|
|
568
|
+ pid_output = pTerm_bed + iTerm_bed - dTerm_bed;
|
|
569
|
+ if (pid_output > MAX_BED_PID) {
|
|
570
|
+ if (pid_error_bed > 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration
|
|
571
|
+ pid_output=PID_MAX;
|
|
572
|
+ } else if (pid_output < 0){
|
|
573
|
+ if (pid_error_bed < 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration
|
|
574
|
+ pid_output=0;
|
|
575
|
+ }
|
569
|
576
|
|
570
|
577
|
#else
|
571
|
578
|
pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);
|