Browse Source

Always calculate extruder temperature PID d term (PR#2432)

ayberkozgur 10 years ago
parent
commit
7268d46508
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      Marlin/temperature.cpp

+ 2
- 2
Marlin/temperature.cpp View File

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

Loading…
Cancel
Save