Add M304 way and eeprom settings for Water cooling PID

parent 6bdf06a5
......@@ -105,7 +105,7 @@
* M301 - Set PID parameters P I and D
* M302 - Allow cold extrudes
* M303 - PID relay autotune S<temperature> sets the target temperature (default target temperature = 150C). H<hotend> C<cycles>
* M304 - Set bed PID parameters P I and D
* M304 - Set bed PID parameters P I and D or Water Cooling if L parameter
* M350 - Set microstepping mode.
* M351 - Toggle MS1 MS2 pins directly.
* M400 - Finish all moves
......
......@@ -67,4 +67,45 @@
/***********************************************************************
************************ PID Settings - WATER ***************************
***********************************************************************
* *
* PID Tuning Guide here: http://reprap.org/wiki/PID_Tuning *
* Select PID or bang-bang with PIDTEMPWATER. *
* If bang-bang, WATER_LIMIT_SWITCHING will enable hysteresis *
* *
***********************************************************************/
// Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder.
// If your PID_dT is the default, and correct for your hardware/configuration, that means 7.689Hz,
// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating.
// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater.
// If your configuration is significantly different than this and you don't understand the issues involved, you probably
// shouldn't use bed PID until someone else verifies your hardware works.
// If this is enabled, find your own PID constants below.
#define PIDTEMPWATER
//#define WATER_LIMIT_SWITCHING
#define WATER_HYSTERESIS 2 //only disable heating if T<target-WATER_HYSTERESIS and enable heating if T<target+WATER_HYSTERESIS (works only if WATER_LIMIT_SWITCHING is enabled)
#define WATER_CHECK_INTERVAL 5000 //ms between checks in bang-bang control
// This sets the max power delivered to the bed.
// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis)
// setting this to anything other than 255 enables a form of PWM to the bed,
// so you shouldn't use it unless you are OK with PWM on your bed. (see the comment on enabling PIDTEMPWATER)
#define MAX_WATER_POWER 255 // limits duty cycle to bed; 255=full current
#define PID_WATER_INTEGRAL_DRIVE_MAX MAX_WATER_POWER // limit for the integral term
// 120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
// from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
#define DEFAULT_waterKp 10.00
#define DEFAULT_waterKi .023
#define DEFAULT_waterKd 305.4
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
//#define PID_WATER_DEBUG // Sends debug data to the serial port.
/***********************************************************************/
#endif
......@@ -16,7 +16,7 @@
*
*/
#define EEPROM_VERSION "MKV428"
#define EEPROM_VERSION "MKV429"
/**
* MKV428 EEPROM Layout:
......@@ -73,6 +73,7 @@
*
* PIDTEMPBED:
* M304 PID bedKp, bedKi, bedKd
* M304 L PID waterKp, waterKi, waterKd
*
* DOGLCD:
* M250 C lcd_contrast
......@@ -210,6 +211,12 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR(i, bedKd);
#endif
#if ENABLED(PIDTEMPWATER)
EEPROM_WRITE_VAR(i, waterKp);
EEPROM_WRITE_VAR(i, waterKi);
EEPROM_WRITE_VAR(i, waterKd);
#endif
#if HASNT(LCD_CONTRAST)
const int lcd_contrast = 32;
#endif
......@@ -359,6 +366,13 @@ void Config_RetrieveSettings() {
EEPROM_READ_VAR(i, bedKd);
#endif
#if ENABLED(PIDTEMPWATER)
EEPROM_READ_VAR(i, waterKp);
EEPROM_READ_VAR(i, waterKi);
EEPROM_READ_VAR(i, waterKd);
#endif
#if HASNT(LCD_CONTRAST)
int lcd_contrast;
#endif
......@@ -585,6 +599,13 @@ void Config_ResetDefault() {
bedKd = scalePID_d(DEFAULT_bedKd);
#endif
#if ENABLED(PIDTEMPWATER)
waterKp = DEFAULT_waterKp;
waterKi = scalePID_i(DEFAULT_waterKi);
waterKd = scalePID_d(DEFAULT_waterKd);
#endif
#if ENABLED(FWRETRACT)
autoretract_enabled = false;
retract_length = RETRACT_LENGTH;
......@@ -787,7 +808,7 @@ void Config_ResetDefault() {
ECHO_EM(" (Material GUM)");
#endif // ULTIPANEL
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED)
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED) || ENABLED(PIDTEMPWATER)
if (!forReplay) {
ECHO_LM(CFG, "PID settings:");
}
......@@ -811,6 +832,12 @@ void Config_ResetDefault() {
ECHO_MV(" I", unscalePID_i(bedKi));
ECHO_EMV(" D", unscalePID_d(bedKd));
#endif
#if ENABLED(PIDTEMPWATER)
ECHO_SMV(CFG, " M304 L P", waterKp); // for compatibility with hosts, only echos values for E0
ECHO_MV(" I", unscalePID_i(waterKi));
ECHO_EMV(" D", unscalePID_d(waterKd));
#endif
#endif
#if ENABLED(FWRETRACT)
......
......@@ -148,7 +148,7 @@
* M301 - Set PID parameters P I D and C
* M302 - Allow cold extrudes, or set the minimum extrude S<temperature>.
* M303 - PID relay autotune S<temperature> sets the target temperature (default target temperature = 150C). H<hotend> C<cycles>
* M304 - Set bed PID parameters P I and D
* M304 - Set bed PID parameters P I and D or Water cooling if L parameter
* M350 - Set microstepping mode.
* M351 - Toggle MS1 MS2 pins directly.
* M380 - Activate solenoid on active extruder
......
......@@ -6167,19 +6167,38 @@ inline void gcode_M226() {
}
#endif
#if ENABLED(PIDTEMPBED)
#if ENABLED(PIDTEMPBED) || ENABLED(PIDTEMPWATER)
// M304: Set bed PID parameters P I and D
inline void gcode_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 ENABLED(PIDTEMPWATER)
if (code_seen('L')) {
if (code_seen('P')) waterKp = code_value();
if (code_seen('I')) waterKi = scalePID_i(code_value());
if (code_seen('D')) waterKd = scalePID_d(code_value());
updatePID();
ECHO_SMV(OK, " L p:", waterKp);
ECHO_MV(" i:", unscalePID_i(waterKi));
ECHO_EMV(" d:", unscalePID_d(waterKd));
updatePID();
ECHO_SMV(OK, "p:", bedKp);
ECHO_MV(" i:", unscalePID_i(bedKi));
ECHO_EMV(" d:", unscalePID_d(bedKd));
}
#endif
#if ENABLED(PIDTEMPWATER) && ENABLED(PIDTEMPBED)
else {
#endif
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());
updatePID();
ECHO_SMV(OK, "p:", bedKp);
ECHO_MV(" i:", unscalePID_i(bedKi));
ECHO_EMV(" d:", unscalePID_d(bedKd));
#if ENABLED(PIDTEMPWATER) && ENABLED(PIDTEMPBED)
}
#endif
}
#endif // PIDTEMPBED
#endif // PIDTEMPBED || PIDTEMPWATER
#if HAS(MICROSTEPS)
// M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
......@@ -7933,7 +7952,7 @@ void process_next_command() {
gcode_M303(); break;
#endif
#if ENABLED(PIDTEMPBED)
#if ENABLED(PIDTEMPBED) || ENABLED(PIDTEMPWATER)
case 304: // M304
gcode_M304(); break;
#endif // PIDTEMPBED
......
......@@ -201,6 +201,21 @@
#error DEPENDENCY ERROR: Missing setting DEFAULT_bedKd
#endif
#endif
#if ENABLED(PIDTEMPWATER)
#if DISABLED(PID_WATER_INTEGRAL_DRIVE_MAX)
#error DEPENDENCY ERROR: Missing setting PID_WATER_INTEGRAL_DRIVE_MAX
#endif
#if DISABLED(DEFAULT_waterKp)
#error DEPENDENCY ERROR: Missing setting DEFAULT_waterKp
#endif
#if DISABLED(DEFAULT_waterKi)
#error DEPENDENCY ERROR: Missing setting DEFAULT_waterKi
#endif
#if DISABLED(DEFAULT_waterKd)
#error DEPENDENCY ERROR: Missing setting DEFAULT_waterKd
#endif
#endif
#if ENABLED(BED_LIMIT_SWITCHING)
#if DISABLED(BED_HYSTERESIS)
#error DEPENDENCY ERROR: Missing setting BED_HYSTERESIS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment