Browse Source

Update temperature.cpp

pull/1/head
Rerouter 8 years ago
committed by GitHub
parent
commit
1a2f1d4974
  1. 22
      Marlin/temperature.cpp

22
Marlin/temperature.cpp

@ -136,9 +136,7 @@ volatile bool Temperature::temp_meas_ready = false;
int Temperature::lpq_ptr = 0; int Temperature::lpq_ptr = 0;
#endif #endif
float Temperature::pid_error[HOTENDS], float Temperature::pid_error[HOTENDS];
Temperature::temp_iState_min[HOTENDS],
Temperature::temp_iState_max[HOTENDS];
bool Temperature::pid_reset[HOTENDS]; bool Temperature::pid_reset[HOTENDS];
#endif #endif
@ -148,9 +146,7 @@ volatile bool Temperature::temp_meas_ready = false;
Temperature::pTerm_bed, Temperature::pTerm_bed,
Temperature::iTerm_bed, Temperature::iTerm_bed,
Temperature::dTerm_bed, Temperature::dTerm_bed,
Temperature::pid_error_bed, Temperature::pid_error_bed;
Temperature::temp_iState_min_bed,
Temperature::temp_iState_max_bed;
#else #else
millis_t Temperature::next_bed_check_ms; millis_t Temperature::next_bed_check_ms;
#endif #endif
@ -448,12 +444,6 @@ void Temperature::updatePID() {
#if ENABLED(PID_EXTRUSION_SCALING) #if ENABLED(PID_EXTRUSION_SCALING)
last_e_position = 0; last_e_position = 0;
#endif #endif
HOTEND_LOOP() {
temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki, e);
}
#endif
#if ENABLED(PIDTEMPBED)
temp_iState_max_bed = (PID_BED_INTEGRAL_DRIVE_MAX) / bedKi;
#endif #endif
} }
@ -564,7 +554,6 @@ float Temperature::get_pid_output(int e) {
} }
pTerm[HOTEND_INDEX] = PID_PARAM(Kp, HOTEND_INDEX) * pid_error[HOTEND_INDEX]; pTerm[HOTEND_INDEX] = PID_PARAM(Kp, HOTEND_INDEX) * pid_error[HOTEND_INDEX];
temp_iState[HOTEND_INDEX] += pid_error[HOTEND_INDEX]; temp_iState[HOTEND_INDEX] += pid_error[HOTEND_INDEX];
temp_iState[HOTEND_INDEX] = constrain(temp_iState[HOTEND_INDEX], temp_iState_min[HOTEND_INDEX], temp_iState_max[HOTEND_INDEX]);
iTerm[HOTEND_INDEX] = PID_PARAM(Ki, HOTEND_INDEX) * temp_iState[HOTEND_INDEX]; iTerm[HOTEND_INDEX] = PID_PARAM(Ki, HOTEND_INDEX) * temp_iState[HOTEND_INDEX];
pid_output = pTerm[HOTEND_INDEX] + iTerm[HOTEND_INDEX] - dTerm[HOTEND_INDEX]; pid_output = pTerm[HOTEND_INDEX] + iTerm[HOTEND_INDEX] - dTerm[HOTEND_INDEX];
@ -627,7 +616,6 @@ float Temperature::get_pid_output(int e) {
pid_error_bed = target_temperature_bed - current_temperature_bed; pid_error_bed = target_temperature_bed - current_temperature_bed;
pTerm_bed = bedKp * pid_error_bed; pTerm_bed = bedKp * pid_error_bed;
temp_iState_bed += pid_error_bed; temp_iState_bed += pid_error_bed;
temp_iState_bed = constrain(temp_iState_bed, temp_iState_min_bed, temp_iState_max_bed);
iTerm_bed = bedKi * temp_iState_bed; iTerm_bed = bedKi * temp_iState_bed;
dTerm_bed = K2 * bedKd * (current_temperature_bed - temp_dState_bed) + K1 * dTerm_bed; dTerm_bed = K2 * bedKd * (current_temperature_bed - temp_dState_bed) + K1 * dTerm_bed;
@ -955,16 +943,10 @@ void Temperature::init() {
// populate with the first value // populate with the first value
maxttemp[e] = maxttemp[0]; maxttemp[e] = maxttemp[0];
#if ENABLED(PIDTEMP) #if ENABLED(PIDTEMP)
temp_iState_min[e] = 0.0;
temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki, e);
#if ENABLED(PID_EXTRUSION_SCALING) #if ENABLED(PID_EXTRUSION_SCALING)
last_e_position = 0; last_e_position = 0;
#endif #endif
#endif //PIDTEMP #endif //PIDTEMP
#if ENABLED(PIDTEMPBED)
temp_iState_min_bed = 0.0;
temp_iState_max_bed = (PID_BED_INTEGRAL_DRIVE_MAX) / bedKi;
#endif //PIDTEMPBED
} }
#if ENABLED(PIDTEMP) && ENABLED(PID_EXTRUSION_SCALING) #if ENABLED(PIDTEMP) && ENABLED(PID_EXTRUSION_SCALING)

Loading…
Cancel
Save