diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index 1b558389..2b5095ef 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -128,7 +128,7 @@ void Config_PrintSettings(uint8_t level) #endif #ifdef PIDTEMPBED printf_P(PSTR("%SPID heatbed settings:\n%S M304 P%.2f I%.2f D%.2f\n"), - echomagic, echomagic, bedKp, unscalePID_i(bedKi), unscalePID_d(bedKd)); + echomagic, echomagic, cs.bedKp, unscalePID_i(cs.bedKi), unscalePID_d(cs.bedKd)); #endif #ifdef FWRETRACT printf_P(PSTR( diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index cc55f0c4..c53606ce 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6240,18 +6240,18 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) #ifdef PIDTEMPBED case 304: // M304 { - if(code_seen('P')) bedKp = code_value(); - if(code_seen('I')) bedKi = scalePID_i(code_value()); - if(code_seen('D')) bedKd = scalePID_d(code_value()); + if(code_seen('P')) cs.bedKp = code_value(); + if(code_seen('I')) cs.bedKi = scalePID_i(code_value()); + if(code_seen('D')) cs.bedKd = scalePID_d(code_value()); updatePID(); SERIAL_PROTOCOLRPGM(_T(MSG_OK)); SERIAL_PROTOCOL(" p:"); - SERIAL_PROTOCOL(bedKp); + SERIAL_PROTOCOL(cs.bedKp); SERIAL_PROTOCOL(" i:"); - SERIAL_PROTOCOL(unscalePID_i(bedKi)); + SERIAL_PROTOCOL(unscalePID_i(cs.bedKi)); SERIAL_PROTOCOL(" d:"); - SERIAL_PROTOCOL(unscalePID_d(bedKd)); + SERIAL_PROTOCOL(unscalePID_d(cs.bedKd)); SERIAL_PROTOCOLLN(""); } break; diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 7054703b..a630f51b 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -84,12 +84,6 @@ float current_temperature_bed = 0.0; float Kc=DEFAULT_Kc; #endif #endif //PIDTEMP - -#ifdef PIDTEMPBED - float bedKp=DEFAULT_bedKp; - float bedKi=(DEFAULT_bedKi*PID_dT); - float bedKd=(DEFAULT_bedKd/PID_dT); -#endif //PIDTEMPBED #ifdef FAN_SOFT_PWM unsigned char fanSpeedSoftPwm; @@ -424,7 +418,7 @@ void updatePID() } #endif #ifdef PIDTEMPBED - temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; + temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / cs.bedKi; #endif } @@ -751,14 +745,14 @@ void manage_heater() #ifndef PID_OPENLOOP pid_error_bed = target_temperature_bed - pid_input; - pTerm_bed = bedKp * pid_error_bed; + pTerm_bed = cs.bedKp * 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 = cs.bedKi * temp_iState_bed; //K1 defined in Configuration.h in the PID settings #define K2 (1.0-K1) - dTerm_bed= (bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed); + dTerm_bed= (cs.bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed); temp_dState_bed = pid_input; pid_output = pTerm_bed + iTerm_bed - dTerm_bed; @@ -1042,7 +1036,7 @@ void tp_init() #endif //PIDTEMP #ifdef PIDTEMPBED temp_iState_min_bed = 0.0; - temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; + temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / cs.bedKi; #endif //PIDTEMPBED } diff --git a/Firmware/temperature.h b/Firmware/temperature.h index f2929564..9a3cee83 100644 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -81,9 +81,6 @@ extern int current_voltage_raw_bed; float unscalePID_d(float d); #endif -#ifdef PIDTEMPBED - extern float bedKp,bedKi,bedKd; -#endif #ifdef BABYSTEPPING