Continue to add code for cooler

parent 832050e2
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
/// #define HIGH_TO_FIRE /// #define HIGH_TO_FIRE
// Uncomment the following to enable the use of the PWM (the one for the extruder 0) to drive a peltier cell or any PWM driven cooler for the laser // Uncomment the following to enable the use of the PWM (the one for the extruder 0) to drive a peltier cell or any PWM driven cooler for the laser
#define LASER_WATER_COOLING #define COOLER
#define LASER_WATER_MAXTEMP 25 #define COOLER_MAXTEMP 25
// Uncomment the following to enable LASER_WATER_COOLING PWM instead of bang-bang // Uncomment the following to enable COOLER PWM instead of bang-bang
#define LASER_PWM #define COOLER_PWM
#define LASER_PWM_FREQUENCY 1000 // Frequency in Hz #define COOLER_PWM_FREQUENCY 1000 // Frequency in Hz
//// The following defines select which G codes tell the laser to fire. It's OK to uncomment more than one. //// The following defines select which G codes tell the laser to fire. It's OK to uncomment more than one.
#define LASER_FIRE_G1 10 // fire the laser on a G1 move, extinguish when the move ends #define LASER_FIRE_G1 10 // fire the laser on a G1 move, extinguish when the move ends
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#define LASER_RASTER_MM_PER_PULSE 0.2 //Can be overridden by providing an R value in M649 command : M649 S17 B2 D0 R0.1 F4000 #define LASER_RASTER_MM_PER_PULSE 0.2 //Can be overridden by providing an R value in M649 command : M649 S17 B2 D0 R0.1 F4000
//// Uncomment the following if the laser cutter is equipped with a peripheral relay board //// Uncomment the following if the laser cutter is equipped with a peripheral relay board
//// to control power to an exhaust fan, water pump, laser power supply, etc. //// to control power to an exhaust fan, cooler pump, laser power supply, etc.
//#define LASER_PERIPHERALS //#define LASER_PERIPHERALS
//#define LASER_PERIPHERALS_TIMEOUT 30000 // Number of milliseconds to wait for status signal from peripheral control board //#define LASER_PERIPHERALS_TIMEOUT 30000 // Number of milliseconds to wait for status signal from peripheral control board
...@@ -68,12 +68,12 @@ ...@@ -68,12 +68,12 @@
/*********************************************************************** /***********************************************************************
************************ PID Settings - WATER *************************** ************************ PID Settings - COOLER ************************
*********************************************************************** ***********************************************************************
* * * *
* PID Tuning Guide here: http://reprap.org/wiki/PID_Tuning * * PID Tuning Guide here: http://reprap.org/wiki/PID_Tuning *
* Select PID or bang-bang with PIDTEMPWATER. * * Select PID or bang-bang with PIDTEMPCOOLER. *
* If bang-bang, WATER_LIMIT_SWITCHING will enable hysteresis * * If bang-bang, COOLER_LIMIT_SWITCHING will enable hysteresis *
* * * *
***********************************************************************/ ***********************************************************************/
// Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder. // Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder.
...@@ -83,28 +83,28 @@ ...@@ -83,28 +83,28 @@
// If your configuration is significantly different than this and you don't understand the issues involved, you probably // 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. // shouldn't use bed PID until someone else verifies your hardware works.
// If this is enabled, find your own PID constants below. // If this is enabled, find your own PID constants below.
#define PIDTEMPWATER #define PIDTEMPCOOLER
//#define WATER_LIMIT_SWITCHING //#define COOLER_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 COOLER_HYSTERESIS 2 //only disable heating if T<target-COOLER_HYSTERESIS and enable heating if T<target+COOLER_HYSTERESIS (works only if COOLER_LIMIT_SWITCHING is enabled)
#define WATER_CHECK_INTERVAL 5000 //ms between checks in bang-bang control #define COOLER_CHECK_INTERVAL 5000 //ms between checks in bang-bang control
// This sets the max power delivered to the bed. // This sets the max power delivered to the bed.
// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis) // 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, // 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) // so you shouldn't use it unless you are OK with PWM on your bed. (see the comment on enabling PIDTEMPCOOLER)
#define MAX_WATER_POWER 255 // limits duty cycle to bed; 255=full current #define MAX_COOLER_POWER 255 // limits duty cycle to bed; 255=full current
#define PID_WATER_INTEGRAL_DRIVE_MAX MAX_WATER_POWER // limit for the integral term #define PID_COOLER_INTEGRAL_DRIVE_MAX MAX_COOLER_POWER // limit for the integral term
// 120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) // 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) // 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_coolerKp 10.00
#define DEFAULT_waterKi .023 #define DEFAULT_coolerKi .023
#define DEFAULT_waterKd 305.4 #define DEFAULT_coolerKd 305.4
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. // 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. //#define PID_COOLER_DEBUG // Sends debug data to the serial port.
/***********************************************************************/ /***********************************************************************/
......
...@@ -121,9 +121,9 @@ ...@@ -121,9 +121,9 @@
#define LASER_PERIPHERALS_PIN 11 #define LASER_PERIPHERALS_PIN 11
#define LASER_PERIPHERALS_STATUS_PIN 4 #define LASER_PERIPHERALS_STATUS_PIN 4
#endif // LASER_PERIPHERALS #endif // LASER_PERIPHERALS
#if ENABLED(LASER_WATER_COOLING) #if ENABLED(COOLER)
#define LASER_WATER_COOLING_PIN 2 // Digital pins 2, 3, 5, 6, 7, 8 are attached to timers we can use #define COOLER_PIN 2 // Digital pins 2, 3, 5, 6, 7, 8 are attached to timers we can use
#endif // LASER WATER_COOLING #endif // COOLER
#endif #endif
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
* *
* PIDTEMPBED: * PIDTEMPBED:
* M304 PID bedKp, bedKi, bedKd * M304 PID bedKp, bedKi, bedKd
* M304 L PID waterKp, waterKi, waterKd * M304 L PID coolerKp, coolerKi, coolerKd
* *
* DOGLCD: * DOGLCD:
* M250 C lcd_contrast * M250 C lcd_contrast
...@@ -211,10 +211,10 @@ void Config_StoreSettings() { ...@@ -211,10 +211,10 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR(i, bedKd); EEPROM_WRITE_VAR(i, bedKd);
#endif #endif
#if ENABLED(PIDTEMPWATER) #if ENABLED(PIDTEMPCOOLER)
EEPROM_WRITE_VAR(i, waterKp); EEPROM_WRITE_VAR(i, coolerKp);
EEPROM_WRITE_VAR(i, waterKi); EEPROM_WRITE_VAR(i, coolerKi);
EEPROM_WRITE_VAR(i, waterKd); EEPROM_WRITE_VAR(i, coolerKd);
#endif #endif
#if HASNT(LCD_CONTRAST) #if HASNT(LCD_CONTRAST)
...@@ -366,10 +366,10 @@ void Config_RetrieveSettings() { ...@@ -366,10 +366,10 @@ void Config_RetrieveSettings() {
EEPROM_READ_VAR(i, bedKd); EEPROM_READ_VAR(i, bedKd);
#endif #endif
#if ENABLED(PIDTEMPWATER) #if ENABLED(PIDTEMPCOOLER)
EEPROM_READ_VAR(i, waterKp); EEPROM_READ_VAR(i, coolerKp);
EEPROM_READ_VAR(i, waterKi); EEPROM_READ_VAR(i, coolerKi);
EEPROM_READ_VAR(i, waterKd); EEPROM_READ_VAR(i, coolerKd);
#endif #endif
...@@ -598,10 +598,10 @@ void Config_ResetDefault() { ...@@ -598,10 +598,10 @@ void Config_ResetDefault() {
bedKd = scalePID_d(DEFAULT_bedKd); bedKd = scalePID_d(DEFAULT_bedKd);
#endif #endif
#if ENABLED(PIDTEMPWATER) #if ENABLED(PIDTEMPCOOLER)
waterKp = DEFAULT_waterKp; coolerKp = DEFAULT_coolerKp;
waterKi = scalePID_i(DEFAULT_waterKi); coolerKi = scalePID_i(DEFAULT_coolerKi);
waterKd = scalePID_d(DEFAULT_waterKd); coolerKd = scalePID_d(DEFAULT_coolerKd);
#endif #endif
...@@ -807,7 +807,7 @@ void Config_ResetDefault() { ...@@ -807,7 +807,7 @@ void Config_ResetDefault() {
ECHO_EM(" (Material GUM)"); ECHO_EM(" (Material GUM)");
#endif // ULTIPANEL #endif // ULTIPANEL
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED) || ENABLED(PIDTEMPWATER) #if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED) || ENABLED(PIDTEMPCOOLER)
if (!forReplay) { if (!forReplay) {
ECHO_LM(CFG, "PID settings:"); ECHO_LM(CFG, "PID settings:");
} }
...@@ -831,10 +831,10 @@ void Config_ResetDefault() { ...@@ -831,10 +831,10 @@ void Config_ResetDefault() {
ECHO_MV(" I", unscalePID_i(bedKi)); ECHO_MV(" I", unscalePID_i(bedKi));
ECHO_EMV(" D", unscalePID_d(bedKd)); ECHO_EMV(" D", unscalePID_d(bedKd));
#endif #endif
#if ENABLED(PIDTEMPWATER) #if ENABLED(PIDTEMPCOOLER)
ECHO_SMV(CFG, " M304 L P", waterKp); // for compatibility with hosts, only echos values for E0 ECHO_SMV(CFG, " M304 L P", coolerKp); // for compatibility with hosts, only echos values for E0
ECHO_MV(" I", unscalePID_i(waterKi)); ECHO_MV(" I", unscalePID_i(coolerKi));
ECHO_EMV(" D", unscalePID_d(waterKd)); ECHO_EMV(" D", unscalePID_d(coolerKd));
#endif #endif
#endif #endif
......
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
* M301 - Set PID parameters P I D and C * M301 - Set PID parameters P I D and C
* M302 - Allow cold extrudes, or set the minimum extrude S<temperature>. * 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> U<Apply result> * M303 - PID relay autotune S<temperature> sets the target temperature (default target temperature = 150C). H<hotend> C<cycles> U<Apply result>
* M304 - Set bed PID parameters P I and D or Water cooling if L parameter * M304 - Set bed PID parameters P I and D or cooling if L parameter
* M350 - Set microstepping mode. * M350 - Set microstepping mode.
* M351 - Toggle MS1 MS2 pins directly. * M351 - Toggle MS1 MS2 pins directly.
* M380 - Activate solenoid on active extruder * M380 - Activate solenoid on active extruder
......
...@@ -6479,11 +6479,11 @@ inline void gcode_M226() { ...@@ -6479,11 +6479,11 @@ inline void gcode_M226() {
} }
#endif // PREVENT_DANGEROUS_EXTRUDE #endif // PREVENT_DANGEROUS_EXTRUDE
#if HAS(PID_HEATING) #if HAS(PID_HEATING) || HAS(PID_COOLING)
/** /**
* M303: PID relay autotune * M303: PID relay autotune
* S<temperature> sets the target temperature. (default target temperature = 150C) * S<temperature> sets the target temperature. (default target temperature = 150C)
* H<hotend> (-1 for the bed) (default 0) * H<hotend> (-1 for the bed, -2 for cooler) (default 0)
* C<cycles> * C<cycles>
* U<bool> with a non-zero value will apply the result to current settings * U<bool> with a non-zero value will apply the result to current settings
*/ */
...@@ -6504,23 +6504,23 @@ inline void gcode_M226() { ...@@ -6504,23 +6504,23 @@ inline void gcode_M226() {
} }
#endif #endif
#if ENABLED(PIDTEMPBED) || ENABLED(PIDTEMPWATER) #if ENABLED(PIDTEMPBED) || ENABLED(PIDTEMPCOOLER)
// M304: Set bed PID parameters P I and D // M304: Set bed PID parameters P I and D
inline void gcode_M304() { inline void gcode_M304() {
#if ENABLED(PIDTEMPWATER) #if ENABLED(PIDTEMPCOOLER)
if (code_seen('L')) { if (code_seen('L')) {
if (code_seen('P')) waterKp = code_value(); if (code_seen('P')) coolerKp = code_value();
if (code_seen('I')) waterKi = scalePID_i(code_value()); if (code_seen('I')) coolerKi = scalePID_i(code_value());
if (code_seen('D')) waterKd = scalePID_d(code_value()); if (code_seen('D')) coolerKd = scalePID_d(code_value());
updatePID(); updatePID();
ECHO_SMV(OK, " L p:", waterKp); ECHO_SMV(OK, " L p:", coolerKp);
ECHO_MV(" i:", unscalePID_i(waterKi)); ECHO_MV(" i:", unscalePID_i(coolerKi));
ECHO_EMV(" d:", unscalePID_d(waterKd)); ECHO_EMV(" d:", unscalePID_d(coolerKd));
} }
#endif #endif
#if ENABLED(PIDTEMPWATER) && ENABLED(PIDTEMPBED) #if ENABLED(PIDTEMPCOOLER) && ENABLED(PIDTEMPBED)
else { else {
#endif #endif
if (code_seen('P')) bedKp = code_value(); if (code_seen('P')) bedKp = code_value();
...@@ -6531,11 +6531,11 @@ inline void gcode_M226() { ...@@ -6531,11 +6531,11 @@ inline void gcode_M226() {
ECHO_SMV(OK, "p:", bedKp); ECHO_SMV(OK, "p:", bedKp);
ECHO_MV(" i:", unscalePID_i(bedKi)); ECHO_MV(" i:", unscalePID_i(bedKi));
ECHO_EMV(" d:", unscalePID_d(bedKd)); ECHO_EMV(" d:", unscalePID_d(bedKd));
#if ENABLED(PIDTEMPWATER) && ENABLED(PIDTEMPBED) #if ENABLED(PIDTEMPCOOLER) && ENABLED(PIDTEMPBED)
} }
#endif #endif
} }
#endif // PIDTEMPBED || PIDTEMPWATER #endif // PIDTEMPBED || PIDTEMPCOOLER
#if HAS(MICROSTEPS) #if HAS(MICROSTEPS)
// M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers. // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
...@@ -8318,7 +8318,7 @@ void process_next_command() { ...@@ -8318,7 +8318,7 @@ void process_next_command() {
gcode_M303(); break; gcode_M303(); break;
#endif #endif
#if ENABLED(PIDTEMPBED) || ENABLED(PIDTEMPWATER) #if ENABLED(PIDTEMPBED) || ENABLED(PIDTEMPCOOLER)
case 304: // M304 case 304: // M304
gcode_M304(); break; gcode_M304(); break;
#endif // PIDTEMPBED #endif // PIDTEMPBED
...@@ -9336,7 +9336,7 @@ void kill(const char* lcd_msg) { ...@@ -9336,7 +9336,7 @@ void kill(const char* lcd_msg) {
} }
#endif #endif
#if ENABLED(FAST_PWM_FAN) || ENABLED(LASER_WATER_COOLING) #if ENABLED(FAST_PWM_FAN) || ENABLED(LASER_COOLER_COOLING)
void setPwmFrequency(uint8_t pin, int val) { void setPwmFrequency(uint8_t pin, int val) {
val &= 0x07; val &= 0x07;
......
...@@ -117,7 +117,7 @@ void refresh_cmd_timeout(); ...@@ -117,7 +117,7 @@ void refresh_cmd_timeout();
extern void delay_ms(millis_t ms); extern void delay_ms(millis_t ms);
#if ENABLED(FAST_PWM_FAN) || ENABLED(LASER_WATER_COOLING) #if ENABLED(FAST_PWM_FAN) || ENABLED(COOLER_PWM)
void setPwmFrequency(uint8_t pin, int val); void setPwmFrequency(uint8_t pin, int val);
#endif #endif
......
...@@ -597,6 +597,7 @@ ...@@ -597,6 +597,7 @@
* Flags for PID handling * Flags for PID handling
*/ */
#define HAS_PID_HEATING (ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED)) #define HAS_PID_HEATING (ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED))
#define HAS_PID_HEATING (ENABLED(PIDTEMPCOOLER))
#define HAS_PID_FOR_BOTH (ENABLED(PIDTEMP) && ENABLED(PIDTEMPBED)) #define HAS_PID_FOR_BOTH (ENABLED(PIDTEMP) && ENABLED(PIDTEMPBED))
/** /**
...@@ -647,11 +648,13 @@ ...@@ -647,11 +648,13 @@
#define HAS_TEMP_2 (PIN_EXISTS(TEMP_2) && TEMP_SENSOR_2 != 0) #define HAS_TEMP_2 (PIN_EXISTS(TEMP_2) && TEMP_SENSOR_2 != 0)
#define HAS_TEMP_3 (PIN_EXISTS(TEMP_3) && TEMP_SENSOR_3 != 0) #define HAS_TEMP_3 (PIN_EXISTS(TEMP_3) && TEMP_SENSOR_3 != 0)
#define HAS_TEMP_BED (PIN_EXISTS(TEMP_BED) && TEMP_SENSOR_BED != 0) #define HAS_TEMP_BED (PIN_EXISTS(TEMP_BED) && TEMP_SENSOR_BED != 0)
#define HAS_TEMP_COOLER (PIN_EXISTS(TEMP_COOLER) && TEMP_SENSOR_COOLER != 0)
#define HAS_HEATER_0 (PIN_EXISTS(HEATER_0)) #define HAS_HEATER_0 (PIN_EXISTS(HEATER_0))
#define HAS_HEATER_1 (PIN_EXISTS(HEATER_1)) #define HAS_HEATER_1 (PIN_EXISTS(HEATER_1))
#define HAS_HEATER_2 (PIN_EXISTS(HEATER_2)) #define HAS_HEATER_2 (PIN_EXISTS(HEATER_2))
#define HAS_HEATER_3 (PIN_EXISTS(HEATER_3)) #define HAS_HEATER_3 (PIN_EXISTS(HEATER_3))
#define HAS_HEATER_BED (PIN_EXISTS(HEATER_BED)) #define HAS_HEATER_BED (PIN_EXISTS(HEATER_BED))
#define HAS_COOLER (PIN_EXISTS(COOLER))
#define HAS_AUTO_FAN_0 (ENABLED(EXTRUDER_AUTO_FAN) && PIN_EXISTS(EXTRUDER_0_AUTO_FAN)) #define HAS_AUTO_FAN_0 (ENABLED(EXTRUDER_AUTO_FAN) && PIN_EXISTS(EXTRUDER_0_AUTO_FAN))
#define HAS_AUTO_FAN_1 (ENABLED(EXTRUDER_AUTO_FAN) && PIN_EXISTS(EXTRUDER_1_AUTO_FAN)) #define HAS_AUTO_FAN_1 (ENABLED(EXTRUDER_AUTO_FAN) && PIN_EXISTS(EXTRUDER_1_AUTO_FAN))
#define HAS_AUTO_FAN_2 (ENABLED(EXTRUDER_AUTO_FAN) && PIN_EXISTS(EXTRUDER_2_AUTO_FAN)) #define HAS_AUTO_FAN_2 (ENABLED(EXTRUDER_AUTO_FAN) && PIN_EXISTS(EXTRUDER_2_AUTO_FAN))
......
...@@ -191,8 +191,9 @@ ...@@ -191,8 +191,9 @@
#define SERIAL_PID_AUTOTUNE "PID Autotune" #define SERIAL_PID_AUTOTUNE "PID Autotune"
#define SERIAL_PID_AUTOTUNE_START SERIAL_PID_AUTOTUNE " start" #define SERIAL_PID_AUTOTUNE_START SERIAL_PID_AUTOTUNE " start"
#define SERIAL_PID_AUTOTUNE_FAILED SERIAL_PID_AUTOTUNE " failed!" #define SERIAL_PID_AUTOTUNE_FAILED SERIAL_PID_AUTOTUNE " failed!"
#define SERIAL_PID_BAD_EXTRUDER_NUM SERIAL_PID_AUTOTUNE_FAILED " Bad extruder number" #define SERIAL_PID_BAD_TEMP_CONTROLLER_NUM SERIAL_PID_AUTOTUNE_FAILED " Bad temperature controller number"
#define SERIAL_PID_TEMP_TOO_HIGH SERIAL_PID_AUTOTUNE_FAILED " Temperature too high" #define SERIAL_PID_TEMP_TOO_HIGH SERIAL_PID_AUTOTUNE_FAILED " Temperature too high"
#define SERIAL_PID_TEMP_TOO_LOW SERIAL_PID_AUTOTUNE_FAILED " Temperature too low"
#define SERIAL_PID_TIMEOUT SERIAL_PID_AUTOTUNE_FAILED " timeout" #define SERIAL_PID_TIMEOUT SERIAL_PID_AUTOTUNE_FAILED " timeout"
#define SERIAL_BIAS " bias: " #define SERIAL_BIAS " bias: "
#define SERIAL_D " d: " #define SERIAL_D " d: "
...@@ -221,6 +222,7 @@ ...@@ -221,6 +222,7 @@
#define SERIAL_HEATER_BED "bed" #define SERIAL_HEATER_BED "bed"
#define SERIAL_STOPPED_HEATER ", system stopped! Heater_ID: " #define SERIAL_STOPPED_HEATER ", system stopped! Heater_ID: "
#define SERIAL_STOPPED_COOLER "system stopped! Cooler"
//#define SERIAL_REDUNDANCY "Heater switched off. Temperature difference between temp sensors is too high !" //#define SERIAL_REDUNDANCY "Heater switched off. Temperature difference between temp sensors is too high !"
#define SERIAL_T_HEATING_FAILED "Heating failed" #define SERIAL_T_HEATING_FAILED "Heating failed"
#define SERIAL_T_THERMAL_RUNAWAY "Thermal Runaway" #define SERIAL_T_THERMAL_RUNAWAY "Thermal Runaway"
......
...@@ -223,18 +223,18 @@ ...@@ -223,18 +223,18 @@
#error DEPENDENCY ERROR: Missing setting DEFAULT_bedKd #error DEPENDENCY ERROR: Missing setting DEFAULT_bedKd
#endif #endif
#endif #endif
#if ENABLED(PIDTEMPWATER) #if ENABLED(PIDTEMPCOOLER)
#if DISABLED(PID_WATER_INTEGRAL_DRIVE_MAX) #if DISABLED(PID_COOLER_INTEGRAL_DRIVE_MAX)
#error DEPENDENCY ERROR: Missing setting PID_WATER_INTEGRAL_DRIVE_MAX #error DEPENDENCY ERROR: Missing setting PID_COOLER_INTEGRAL_DRIVE_MAX
#endif #endif
#if DISABLED(DEFAULT_waterKp) #if DISABLED(DEFAULT_coolerKp)
#error DEPENDENCY ERROR: Missing setting DEFAULT_waterKp #error DEPENDENCY ERROR: Missing setting DEFAULT_coolerKp
#endif #endif
#if DISABLED(DEFAULT_waterKi) #if DISABLED(DEFAULT_coolerKi)
#error DEPENDENCY ERROR: Missing setting DEFAULT_waterKi #error DEPENDENCY ERROR: Missing setting DEFAULT_coolerKi
#endif #endif
#if DISABLED(DEFAULT_waterKd) #if DISABLED(DEFAULT_coolerKd)
#error DEPENDENCY ERROR: Missing setting DEFAULT_waterKd #error DEPENDENCY ERROR: Missing setting DEFAULT_coolerKd
#endif #endif
#endif #endif
......
This diff is collapsed.
...@@ -72,9 +72,12 @@ extern float current_temperature[4]; ...@@ -72,9 +72,12 @@ extern float current_temperature[4];
#if ENABLED(SHOW_TEMP_ADC_VALUES) #if ENABLED(SHOW_TEMP_ADC_VALUES)
extern int current_temperature_raw[4]; extern int current_temperature_raw[4];
extern int current_temperature_bed_raw; extern int current_temperature_bed_raw;
extern int current_temperature_cooler_raw;
#endif #endif
extern int target_temperature_bed; extern int target_temperature_bed;
extern float current_temperature_bed; extern float current_temperature_bed;
extern int target_temperature_cooler;
extern float current_temperature_cooler;
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
extern float redundant_temperature; extern float redundant_temperature;
#endif #endif
...@@ -92,7 +95,11 @@ extern float current_temperature_bed; ...@@ -92,7 +95,11 @@ extern float current_temperature_bed;
extern float bedKp, bedKi, bedKd; extern float bedKp, bedKi, bedKd;
#endif #endif
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED) #if ENABLED(PIDTEMPCOOLER)
extern float coolerKp, coolerKi, coolerKd;
#endif
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED) || ENABLED(PIDTEMPCOOLER)
float scalePID_i(float i); float scalePID_i(float i);
float scalePID_d(float d); float scalePID_d(float d);
float unscalePID_i(float i); float unscalePID_i(float i);
...@@ -114,14 +121,17 @@ extern float current_temperature_bed; ...@@ -114,14 +121,17 @@ extern float current_temperature_bed;
FORCE_INLINE float degHotend(uint8_t hotend) { return current_temperature[HOTEND_ARG]; } FORCE_INLINE float degHotend(uint8_t hotend) { return current_temperature[HOTEND_ARG]; }
FORCE_INLINE float degBed() { return current_temperature_bed; } FORCE_INLINE float degBed() { return current_temperature_bed; }
FORCE_INLINE float degCooler() { return current_temperature_cooler; }
#if ENABLED(SHOW_TEMP_ADC_VALUES) #if ENABLED(SHOW_TEMP_ADC_VALUES)
FORCE_INLINE float rawHotendTemp(uint8_t hotend) { return current_temperature_raw[HOTEND_ARG]; } FORCE_INLINE float rawHotendTemp(uint8_t hotend) { return current_temperature_raw[HOTEND_ARG]; }
FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; } FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }
FORCE_INLINE float rawCoolerTemp() { return current_temperature_cooler_raw; }
#endif #endif
FORCE_INLINE float degTargetHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG]; } FORCE_INLINE float degTargetHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG]; }
FORCE_INLINE float degTargetBed() { return target_temperature_bed; } FORCE_INLINE float degTargetBed() { return target_temperature_bed; }
FORCE_INLINE float degTargetCooler() { return target_temperature_cooler; }
#if ENABLED(THERMAL_PROTECTION_HOTENDS) #if ENABLED(THERMAL_PROTECTION_HOTENDS)
void start_watching_heater(int h = 0); void start_watching_heater(int h = 0);
...@@ -134,12 +144,15 @@ FORCE_INLINE void setTargetHotend(const float& celsius, uint8_t hotend) { ...@@ -134,12 +144,15 @@ FORCE_INLINE void setTargetHotend(const float& celsius, uint8_t hotend) {
#endif #endif
} }
FORCE_INLINE void setTargetBed(const float& celsius) { target_temperature_bed = celsius; } FORCE_INLINE void setTargetBed(const float& celsius) { target_temperature_bed = celsius; }
FORCE_INLINE void setTargetCooler(const float& celsius) { target_temperature_cooler = celsius; }
FORCE_INLINE bool isHeatingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] > current_temperature[HOTEND_ARG]; } FORCE_INLINE bool isHeatingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] > current_temperature[HOTEND_ARG]; }
FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; } FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
FORCE_INLINE bool isHeatingCooler() { return target_temperature_cooler > current_temperature_cooler; }
FORCE_INLINE bool isCoolingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] < current_temperature[HOTEND_ARG]; } FORCE_INLINE bool isCoolingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] < current_temperature[HOTEND_ARG]; }
FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; } FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
FORCE_INLINE bool isCoolingCooler() { return target_temperature_cooler < current_temperature_cooler; }
#define HOTEND_ROUTINES(NR) \ #define HOTEND_ROUTINES(NR) \
FORCE_INLINE float degHotend##NR() { return degHotend(NR); } \ FORCE_INLINE float degHotend##NR() { return degHotend(NR); } \
...@@ -165,11 +178,14 @@ HOTEND_ROUTINES(0); ...@@ -165,11 +178,14 @@ HOTEND_ROUTINES(0);
#endif #endif
int getHeaterPower(int heater); int getHeaterPower(int heater);
int getCoolerPower(void);
void disable_all_heaters(); void disable_all_heaters();
#define disable_all_coolers() setTargetCooler(0)
void updatePID(); void updatePID();
#if HAS(PID_HEATING) #if HAS(PID_HEATING) || HAS(PID_COOLING)
void PID_autotune(float temp, int hotend, int ncycles, bool set_result = false); void PID_autotune(float temp, int temp_controller, int ncycles, bool set_result = false);
#endif #endif
void setExtruderAutoFanState(int pin, bool state); void setExtruderAutoFanState(int pin, bool state);
......
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