Commit a1a96e57 authored by MagoKimbra's avatar MagoKimbra

Add wait to serial command for any host!

parent 8f323a13
...@@ -22,13 +22,17 @@ ...@@ -22,13 +22,17 @@
#endif #endif
#define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control #define BED_CHECK_INTERVAL 5000 //ms between checks in bang-bang control
//// Heating sanity check: /**
// This waits for the watch period in milliseconds whenever an M104 or M109 increases the target temperature * Heating Sanity Check
// If the temperature has not increased at the end of that period, the target temperature is set to zero. *
// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature * Whenever an M104 or M109 increases the target temperature this will wait for WATCH_TEMP_PERIOD milliseconds,
// differ by at least 2x WATCH_TEMP_INCREASE * and if the temperature hasn't increased by WATCH_TEMP_INCREASE degrees, the machine is halted, requiring a
//#define WATCH_TEMP_PERIOD 40000 //40 seconds * hard reset. This test restarts with any M104/M109, but only if the current temperature is below the target
//#define WATCH_TEMP_INCREASE 10 //Heat up at least 10 degree in 20 seconds * by at least 2 * WATCH_TEMP_INCREASE degrees celsius.
*/
//#define WATCH_TEMP_PERIOD 16000 // 16 seconds
//#define WATCH_TEMP_INCREASE 4 // Heat up at least 4 degrees in 16 seconds
//automatic temperature: The hot end target temperature is calculated by all the buffered lines of gcode. //automatic temperature: The hot end target temperature is calculated by all the buffered lines of gcode.
//The maximum buffered steps/sec of the extruder motor are called "se". //The maximum buffered steps/sec of the extruder motor are called "se".
...@@ -280,7 +284,7 @@ ...@@ -280,7 +284,7 @@
//#define MENU_ADDAUTOSTART //#define MENU_ADDAUTOSTART
// Show a progress bar on HD44780 LCDs for SD printing // Show a progress bar on HD44780 LCDs for SD printing
//#define LCD_PROGRESS_BAR #define LCD_PROGRESS_BAR
#ifdef LCD_PROGRESS_BAR #ifdef LCD_PROGRESS_BAR
// Amount of time (ms) to show the bar // Amount of time (ms) to show the bar
...@@ -322,8 +326,8 @@ ...@@ -322,8 +326,8 @@
// //
// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K * cubic mm per second ^ 2 // advance (steps) = STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K * cubic mm per second ^ 2
// //
// Hooke's law says: force = k * distance // Hooke's law says: force = k * distance
// Bernoulli's principle says: v ^ 2 / 2 + g . h + pressure / density = constant // Bernoulli's principle says: v ^ 2 / 2 + g . h + pressure / density = constant
// so: v ^ 2 is proportional to number of steps we advance the extruder // so: v ^ 2 is proportional to number of steps we advance the extruder
//#define ADVANCE //#define ADVANCE
...@@ -343,7 +347,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st ...@@ -343,7 +347,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
//#define HEATERS_PARALLEL //#define HEATERS_PARALLEL
//=========================================================================== //===========================================================================
//=============================Buffers ============================ //================================= Buffers =================================
//=========================================================================== //===========================================================================
// The number of linear motions that can be in the plan at any give time. // The number of linear motions that can be in the plan at any give time.
...@@ -359,6 +363,13 @@ const unsigned int dropsegments=5; //everything with less than this number of st ...@@ -359,6 +363,13 @@ const unsigned int dropsegments=5; //everything with less than this number of st
#define MAX_CMD_SIZE 96 #define MAX_CMD_SIZE 96
#define BUFSIZE 4 #define BUFSIZE 4
// Bad Serial-connections can miss a received command by sending an 'ok'
// Therefore some clients go after 30 seconds in a timeout. Some other clients start sending commands while receiving a 'wait'.
// This wait is only send when the buffer is empty. The timeout-length is in milliseconds. 1000 is a good value.
#define NO_TIMEOUTS 1000
// Some clients will have this feature soon. This could make the NO_TIMEOUTS unnecessary.
#define ADVANCED_OK
// Firmware based and LCD controlled retract // Firmware based and LCD controlled retract
// M207 and M208 can be used to define parameters for the retraction. // M207 and M208 can be used to define parameters for the retraction.
......
...@@ -172,6 +172,18 @@ void Stop(); ...@@ -172,6 +172,18 @@ void Stop();
void filrunout(); void filrunout();
#endif #endif
/**
* Debug flags - with repetier
*/
enum DebugFlags {
DEBUG_ECHO = BIT(0),
DEBUG_INFO = BIT(1),
DEBUG_ERRORS = BIT(2),
DEBUG_DRYRUN = BIT(3),
DEBUG_COMMUNICATION = BIT(4)
};
extern uint8_t debugLevel;
extern bool Running; extern bool Running;
inline bool IsRunning() { return Running; } inline bool IsRunning() { return Running; }
inline bool IsStopped() { return !Running; } inline bool IsStopped() { return !Running; }
...@@ -306,18 +318,6 @@ extern uint8_t active_driver; ...@@ -306,18 +318,6 @@ extern uint8_t active_driver;
extern void digipot_i2c_init(); extern void digipot_i2c_init();
#endif #endif
/**
* Debug with repetier
*/
enum DebugFlags {
DEBUG_ECHO = BIT(0),
DEBUG_INFO = BIT(1),
DEBUG_ERRORS = BIT(2),
DEBUG_DRYRUN = BIT(3),
DEBUG_COMMUNICATION = BIT(4)
};
extern uint8_t debugLevel;
#ifdef FIRMWARE_TEST #ifdef FIRMWARE_TEST
void FirmwareTest(); void FirmwareTest();
#endif #endif
......
...@@ -777,7 +777,7 @@ void loop() { ...@@ -777,7 +777,7 @@ void loop() {
if (card.logging) if (card.logging)
process_commands(); // The card is saving because it's logging process_commands(); // The card is saving because it's logging
else else
ECHO_EM(MSG_OK); ECHO_L(OK);
} }
} }
else else
...@@ -808,7 +808,17 @@ void loop() { ...@@ -808,7 +808,17 @@ void loop() {
void get_command() { void get_command() {
if (drain_queued_commands_P()) return; // priority is given to non-serial commands if (drain_queued_commands_P()) return; // priority is given to non-serial commands
#ifdef NO_TIMEOUTS
static millis_t last_command_time = 0;
millis_t ms = millis();
if (!MYSERIAL.available() && commands_in_queue == 0 && ms - last_command_time > NO_TIMEOUTS) {
ECHO_L(WT);
last_command_time = ms;
}
#endif
while (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) { while (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) {
serial_char = MYSERIAL.read(); serial_char = MYSERIAL.read();
...@@ -2424,7 +2434,10 @@ inline void set_destination_to_current() { memcpy(destination, current_position, ...@@ -2424,7 +2434,10 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
#endif //Z_PROBE_SLED #endif //Z_PROBE_SLED
inline void wait_heater() { inline void wait_heater() {
setWatch();
#ifdef WATCH_TEMP_PERIOD
start_watching_heater(target_extruder);
#endif
millis_t temp_ms = millis(); millis_t temp_ms = millis();
...@@ -4121,7 +4134,10 @@ inline void gcode_M104() { ...@@ -4121,7 +4134,10 @@ inline void gcode_M104() {
if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0) if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && target_extruder == 0)
setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset); setTargetHotend1(temp == 0.0 ? 0.0 : temp + duplicate_extruder_temp_offset);
#endif #endif
setWatch();
#ifdef WATCH_TEMP_PERIOD
start_watching_heater(target_extruder);
#endif
} }
} }
...@@ -4253,7 +4269,7 @@ inline void gcode_M112() { ...@@ -4253,7 +4269,7 @@ inline void gcode_M112() {
*/ */
inline void gcode_M114() { inline void gcode_M114() {
//MESSAGE for Host //MESSAGE for Host
ECHO_SMV(OK, "X:", current_position[X_AXIS]); ECHO_SMV(OK, " X:", current_position[X_AXIS]);
ECHO_MV(" Y:", current_position[Y_AXIS]); ECHO_MV(" Y:", current_position[Y_AXIS]);
ECHO_MV(" Z:", current_position[Z_AXIS]); ECHO_MV(" Z:", current_position[Z_AXIS]);
ECHO_MV(" E:", current_position[E_AXIS]); ECHO_MV(" E:", current_position[E_AXIS]);
...@@ -4264,7 +4280,7 @@ inline void gcode_M114() { ...@@ -4264,7 +4280,7 @@ inline void gcode_M114() {
#ifdef SCARA #ifdef SCARA
//MESSAGE for Host //MESSAGE for Host
ECHO_SMV(OK, "SCARA Theta:", delta[X_AXIS]); ECHO_SMV(OK, " SCARA Theta:", delta[X_AXIS]);
ECHO_EMV(" Psi+Theta:", delta[Y_AXIS]); ECHO_EMV(" Psi+Theta:", delta[Y_AXIS]);
ECHO_SMV(DB, "SCARA Cal - Theta:", delta[X_AXIS]+home_offset[X_AXIS]); ECHO_SMV(DB, "SCARA Cal - Theta:", delta[X_AXIS]+home_offset[X_AXIS]);
...@@ -4287,7 +4303,7 @@ inline void gcode_M114() { ...@@ -4287,7 +4303,7 @@ inline void gcode_M114() {
#ifdef SCARA #ifdef SCARA
//MESSAGE for User //MESSAGE for User
ECHO_SMV(OK, "SCARA Theta:", delta[X_AXIS]); ECHO_SMV(OK, " SCARA Theta:", delta[X_AXIS]);
ECHO_EMV(" Psi+Theta:", delta[Y_AXIS]); ECHO_EMV(" Psi+Theta:", delta[Y_AXIS]);
ECHO_SMV(DB, "SCARA Cal - Theta:", delta[X_AXIS]+home_offset[X_AXIS]); ECHO_SMV(DB, "SCARA Cal - Theta:", delta[X_AXIS]+home_offset[X_AXIS]);
...@@ -4820,21 +4836,22 @@ inline void gcode_M226() { ...@@ -4820,21 +4836,22 @@ inline void gcode_M226() {
#if NUM_SERVOS > 0 #if NUM_SERVOS > 0
/** /**
* M280: Set servo position absolute. P: servo index, S: angle or microseconds * M280: Get or set servo position. P<index> S<angle>
*/ */
inline void gcode_M280() { inline void gcode_M280() {
int servo_index = code_seen('P') ? code_value() : -1; int servo_index = code_seen('P') ? code_value_short() : -1;
int servo_position = 0; int servo_position = 0;
if (code_seen('S')) { if (code_seen('S')) {
servo_position = code_value(); servo_position = code_value_short();
if ((servo_index >= 0) && (servo_index < NUM_SERVOS)) { if (servo_index >= 0 && servo_index < NUM_SERVOS) {
Servo *srv = &servo[servo_index];
#if SERVO_LEVELING #if SERVO_LEVELING
servo[servo_index].attach(0); srv->attach(0);
#endif #endif
servo[servo_index].write(servo_position); srv->write(servo_position);
#if SERVO_LEVELING #if SERVO_LEVELING
delay(PROBE_SERVO_DEACTIVATION_DELAY); delay(PROBE_SERVO_DEACTIVATION_DELAY);
servo[servo_index].detach(); srv->detach();
#endif #endif
} }
else { else {
...@@ -4843,8 +4860,7 @@ inline void gcode_M226() { ...@@ -4843,8 +4860,7 @@ inline void gcode_M226() {
} }
} }
else if (servo_index >= 0) { else if (servo_index >= 0) {
ECHO_S(DB); ECHO_SMV(OK, " Servo ", servo_index);
ECHO_MV("Servo ", servo_index);
ECHO_EMV(": ", servo[servo_index].read()); ECHO_EMV(": ", servo[servo_index].read());
} }
} }
...@@ -5597,7 +5613,7 @@ inline void gcode_M999() { ...@@ -5597,7 +5613,7 @@ inline void gcode_M999() {
value = code_value(); value = code_value();
if (Z_PROBE_OFFSET_RANGE_MIN <= value && value <= Z_PROBE_OFFSET_RANGE_MAX) { if (Z_PROBE_OFFSET_RANGE_MIN <= value && value <= Z_PROBE_OFFSET_RANGE_MAX) {
zprobe_zoffset = -value; // compare w/ line 278 of ConfigurationStore.cpp zprobe_zoffset = -value; // compare w/ line 278 of ConfigurationStore.cpp
ECHO_LM(DB, MSG_ZPROBE_ZOFFSET " " MSG_OK); ECHO_LM(DB, MSG_ZPROBE_ZOFFSET " ok");
} }
else { else {
ECHO_S(DB, MSG_ZPROBE_ZOFFSET); ECHO_S(DB, MSG_ZPROBE_ZOFFSET);
...@@ -5935,7 +5951,7 @@ void process_commands() { ...@@ -5935,7 +5951,7 @@ void process_commands() {
gcode_M5(); break; gcode_M5(); break;
#endif //LASERBEAM #endif //LASERBEAM
#ifdef FILAMENT_END_SWITCH #if HAS_FILRUNOUT
case 11: //M11 - Start printing case 11: //M11 - Start printing
gcode_M11(); break; gcode_M11(); break;
#endif #endif
...@@ -6269,11 +6285,13 @@ void ClearToSend() { ...@@ -6269,11 +6285,13 @@ void ClearToSend() {
#ifdef SDSUPPORT #ifdef SDSUPPORT
if (fromsd[cmd_queue_index_r]) return; if (fromsd[cmd_queue_index_r]) return;
#endif #endif
ECHO_L(OK); ECHO_S(OK);
#ifdef ADVANCED_OK #ifdef ADVANCED_OK
ECHO_MV(" N", gcode_LastN); ECHO_MV(" N", gcode_LastN);
ECHO_EMV(" S", commands_in_queue); ECHO_MV(" P", int(BLOCK_BUFFER_SIZE - movesplanned() - 1));
ECHO_MV(" B", BUFSIZE - commands_in_queue);
#endif #endif
ECHO_E;
} }
void get_coordinates() { void get_coordinates() {
......
...@@ -40,8 +40,9 @@ ...@@ -40,8 +40,9 @@
#endif #endif
#define START "start" //start for host #define START "start" //start for host
#define OK "ok " //ok answer for host #define OK "ok" //ok answer for host
#define ER "Error:" //error for host #define ER "Error:" //error for host
#define WT "wait" //wait for host
#define DB "<MK4>: " //message for user #define DB "<MK4>: " //message for user
#define RS "Resend:" //resend for host #define RS "Resend:" //resend for host
#define PAUSE "//action:pause" //command for host that support action #define PAUSE "//action:pause" //command for host that support action
......
...@@ -96,8 +96,6 @@ ...@@ -96,8 +96,6 @@
#define MSG_CONFIGURATION_VER " Last Updated: " #define MSG_CONFIGURATION_VER " Last Updated: "
#define MSG_FREE_MEMORY " Free Memory: " #define MSG_FREE_MEMORY " Free Memory: "
#define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: " #define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: "
#define MSG_OK "ok"
#define MSG_WAIT "wait"
#define MSG_FILE_SAVED "Done saving file." #define MSG_FILE_SAVED "Done saving file."
#define MSG_ERR_LINE_NO "Line Number is not Last Line Number+1, Last Line: " #define MSG_ERR_LINE_NO "Line Number is not Last Line Number+1, Last Line: "
#define MSG_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line: " #define MSG_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line: "
......
...@@ -49,13 +49,13 @@ ...@@ -49,13 +49,13 @@
#define MSG_EXTRUDE "Extrusion" #define MSG_EXTRUDE "Extrusion"
#define MSG_RETRACT "Retraction" #define MSG_RETRACT "Retraction"
#define MSG_MOVE_AXIS "Deplacer un axe" #define MSG_MOVE_AXIS "Deplacer un axe"
#define MSG_MOVE_X "Move X" #define MSG_MOVE_X "Depl. X"
#define MSG_MOVE_Y "Move Y" #define MSG_MOVE_Y "Depl. Y"
#define MSG_MOVE_Z "Move Z" #define MSG_MOVE_Z "Depl. Z"
#define MSG_MOVE_E "Extruder" #define MSG_MOVE_E "Extruder"
#define MSG_MOVE_01MM "Move 0.1mm" #define MSG_MOVE_01MM "Depl. 0.1mm"
#define MSG_MOVE_1MM "Move 1mm" #define MSG_MOVE_1MM "Depl. 1mm"
#define MSG_MOVE_10MM "Move 10mm" #define MSG_MOVE_10MM "Depl. 10mm"
#define MSG_SPEED " Vitesse" #define MSG_SPEED " Vitesse"
#define MSG_NOZZLE "Buse" #define MSG_NOZZLE "Buse"
#define MSG_BED "Plateau" #define MSG_BED "Plateau"
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
#define MSG_CONTROL "Controler" #define MSG_CONTROL "Controler"
#define MSG_MIN " " STR_THERMOMETER " Min" #define MSG_MIN " " STR_THERMOMETER " Min"
#define MSG_MAX " " STR_THERMOMETER " Max" #define MSG_MAX " " STR_THERMOMETER " Max"
#define MSG_FACTOR " " STR_THERMOMETER " Fact" #define MSG_FACTOR " " STR_THERMOMETER " Facteur"
#define MSG_AUTOTEMP "Temp. Auto." #define MSG_AUTOTEMP "Temp. Auto."
#define MSG_ON "Marche " #define MSG_ON "Marche "
#define MSG_OFF "Arret" #define MSG_OFF "Arret"
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
#define MSG_TEMPERATURE "Temperature" #define MSG_TEMPERATURE "Temperature"
#define MSG_MOTION "Mouvement" #define MSG_MOTION "Mouvement"
#define MSG_VOLUMETRIC "Filament" #define MSG_VOLUMETRIC "Filament"
#define MSG_VOLUMETRIC_ENABLED "E in mm" STR_h3 #define MSG_VOLUMETRIC_ENABLED "E in mm3"
#define MSG_FILAMENT_SIZE_EXTRUDER "Fil. Dia." #define MSG_FILAMENT_SIZE_EXTRUDER "Fil. Dia."
#define MSG_CONTRAST "Contraste LCD" #define MSG_CONTRAST "Contraste LCD"
#define MSG_STORE_EPROM "Sauver config" #define MSG_STORE_EPROM "Sauver config"
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
#define MSG_DWELL "Repos..." #define MSG_DWELL "Repos..."
#define MSG_USERWAIT "Atten. de l'util." #define MSG_USERWAIT "Atten. de l'util."
#define MSG_RESUMING "Repri. de l'impr." #define MSG_RESUMING "Repri. de l'impr."
#define MSG_PRINT_ABORTED "Print aborted" #define MSG_PRINT_ABORTED "Impr. Annulee"
#define MSG_NO_MOVE "Aucun mouvement." #define MSG_NO_MOVE "Aucun mouvement."
#define MSG_KILLED "MORT." #define MSG_KILLED "MORT."
#define MSG_STOPPED "STOPPE." #define MSG_STOPPED "STOPPE."
...@@ -135,6 +135,8 @@ ...@@ -135,6 +135,8 @@
#define MSG_BABYSTEP_Y "Babystep Y" #define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z" #define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Butee abandon" #define MSG_ENDSTOP_ABORT "Butee abandon"
#define MSG_END_HOUR "heures"
#define MSG_END_MINUTE "minutes"
#define MSG_HEATING_FAILED_LCD "Heating failed" #define MSG_HEATING_FAILED_LCD "Heating failed"
#define MSG_ERR_REDUNDANT_TEMP "Err: REDUNDANT TEMP ERROR" #define MSG_ERR_REDUNDANT_TEMP "Err: REDUNDANT TEMP ERROR"
......
...@@ -76,7 +76,7 @@ volatile long endstops_stepsTotal, endstops_stepsDone; ...@@ -76,7 +76,7 @@ volatile long endstops_stepsTotal, endstops_stepsDone;
static volatile bool endstop_x_hit = false; static volatile bool endstop_x_hit = false;
static volatile bool endstop_y_hit = false; static volatile bool endstop_y_hit = false;
static volatile bool endstop_z_hit = false; static volatile bool endstop_z_hit = false;
static volatile bool endstop_z_probe_hit = false; // Leaving this in even if Z_PROBE_ENDSTOP isn't defined, keeps code below cleaner. #ifdef it and usage below to save space. static volatile bool endstop_z_probe_hit = false;
#ifdef NPR2 #ifdef NPR2
static volatile bool endstop_e_hit = false; static volatile bool endstop_e_hit = false;
......
...@@ -93,7 +93,7 @@ unsigned char soft_pwm_bed; ...@@ -93,7 +93,7 @@ unsigned char soft_pwm_bed;
#endif #endif
//=========================================================================== //===========================================================================
//=============================private variables============================ //============================ private variables ============================
//=========================================================================== //===========================================================================
static volatile bool temp_meas_ready = false; static volatile bool temp_meas_ready = false;
...@@ -161,9 +161,9 @@ static float analog2tempBed(int raw); ...@@ -161,9 +161,9 @@ static float analog2tempBed(int raw);
static void updateTemperaturesFromRawValues(); static void updateTemperaturesFromRawValues();
#ifdef WATCH_TEMP_PERIOD #ifdef WATCH_TEMP_PERIOD
int watch_start_temp[HOTENDS] = { 0 }; int watch_target_temp[HOTENDS] = { 0 };
millis_t watchmillis[HOTENDS] = { 0 }; millis_t watch_heater_next_ms[HOTENDS] = { 0 };
#endif //WATCH_TEMP_PERIOD #endif
#ifndef SOFT_PWM_SCALE #ifndef SOFT_PWM_SCALE
#define SOFT_PWM_SCALE 0 #define SOFT_PWM_SCALE 0
...@@ -178,7 +178,7 @@ static void updateTemperaturesFromRawValues(); ...@@ -178,7 +178,7 @@ static void updateTemperaturesFromRawValues();
#endif #endif
//=========================================================================== //===========================================================================
//============================= Functions ============================ //================================ Functions ================================
//=========================================================================== //===========================================================================
void PID_autotune(float temp, int hotend, int ncycles) void PID_autotune(float temp, int hotend, int ncycles)
...@@ -444,15 +444,14 @@ void checkExtruderAutoFans() ...@@ -444,15 +444,14 @@ void checkExtruderAutoFans()
// //
// Temperature Error Handlers // Temperature Error Handlers
// //
inline void _temp_error(int e, const char *msg1, const char *msg2) { inline void _temp_error(int e, const char *serial_msg, const char *lcd_msg) {
if (IsRunning()) { if (IsRunning()) {
ECHO_S(ER); ECHO_S(ER);
if (e >= 0) ECHO_EV(e); if (e >= 0) ECHO_EV((int)e);
else ECHO_EV(MSG_TEMP_BED); PS_PGM(serial_msg);
PS_PGM(msg1);
ECHO_E; ECHO_E;
#ifdef ULTRA_LCD #ifdef ULTRA_LCD
lcd_setalertstatuspgm(msg2); lcd_setalertstatuspgm(lcd_msg);
#endif #endif
} }
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE #ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
...@@ -587,7 +586,7 @@ void manage_heater() { ...@@ -587,7 +586,7 @@ void manage_heater() {
float ct = current_temperature[0]; float ct = current_temperature[0];
if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0); if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0);
if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0); if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0);
#endif //HEATER_0_USES_MAX6675 #endif
#if defined(WATCH_TEMP_PERIOD) || !defined(PIDTEMPBED) || HAS_AUTO_FAN #if defined(WATCH_TEMP_PERIOD) || !defined(PIDTEMPBED) || HAS_AUTO_FAN
millis_t ms = millis(); millis_t ms = millis();
...@@ -605,25 +604,29 @@ void manage_heater() { ...@@ -605,25 +604,29 @@ void manage_heater() {
// Check if temperature is within the correct range // Check if temperature is within the correct range
soft_pwm[e] = current_temperature[e] > minttemp[e] && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0; soft_pwm[e] = current_temperature[e] > minttemp[e] && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0;
// Check if the temperature is failing to increase
#ifdef WATCH_TEMP_PERIOD #ifdef WATCH_TEMP_PERIOD
if (watchmillis[e] && ms > watchmillis[e] + WATCH_TEMP_PERIOD) { // Is it time to check this extruder's heater?
if (degHotend(e) < watch_start_temp[e] + WATCH_TEMP_INCREASE) { if (watch_heater_next_ms[e] && ms > watch_heater_next_ms[e]) {
setTargetHotend(0, e); // Has it failed to increase enough?
ECHO_LM(ER, MSG_HEATING_FAILED); if (degHotend(e) < watch_target_temp[e]) {
LCD_MESSAGEPGM(MSG_HEATING_FAILED_LCD); // Stop!
disable_all_heaters();
_temp_error(e, MSG_HEATING_FAILED, MSG_HEATING_FAILED_LCD);
} }
else { else {
watchmillis[e] = 0; // Only check once per M104/M109
watch_heater_next_ms[e] = 0;
} }
} }
#endif //WATCH_TEMP_PERIOD #endif // WATCH_TEMP_PERIOD
#ifdef TEMP_SENSOR_1_AS_REDUNDANT #ifdef TEMP_SENSOR_1_AS_REDUNDANT
if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) { if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
disable_all_heaters(); disable_all_heaters();
_temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP)); _temp_error(0, PSTR(MSG_EXTRUDER_SWITCHED_OFF), PSTR(MSG_ERR_REDUNDANT_TEMP));
} }
#endif //TEMP_SENSOR_1_AS_REDUNDANT #endif
} // Hotends Loop } // Hotends Loop
...@@ -700,7 +703,7 @@ static float analog2temp(int raw, uint8_t e) { ...@@ -700,7 +703,7 @@ static float analog2temp(int raw, uint8_t e) {
if (e >= EXTRUDERS) if (e >= EXTRUDERS)
#endif #endif
{ {
ECHO_LVM(ER, e, MSG_INVALID_EXTRUDER_NUM); ECHO_LVM(ER, (int)e, MSG_INVALID_EXTRUDER_NUM);
kill(); kill();
return 0.0; return 0.0;
} }
...@@ -1030,17 +1033,22 @@ void tp_init() { ...@@ -1030,17 +1033,22 @@ void tp_init() {
#endif //BED_MAXTEMP #endif //BED_MAXTEMP
} }
void setWatch() { #ifdef WATCH_TEMP_PERIOD
#ifdef WATCH_TEMP_PERIOD /**
millis_t ms = millis(); * Start Heating Sanity Check for hotends that are below
for (int e = 0; e < HOTENDS; e++) { * their target temperature by a configurable margin.
if (degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE * 2)) { * This is called when the temperature is set. (M104, M109)
watch_start_temp[e] = degHotend(e); */
watchmillis[e] = ms; void start_watching_heater(int e) {
} millis_t ms = millis() + WATCH_TEMP_PERIOD;
if (degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE * 2)) {
watch_target_temp[e] = degHotend(e) + WATCH_TEMP_INCREASE;
watch_heater_next_ms[e] = ms;
} }
#endif else
} watch_heater_next_ms[e] = 0;
}
#endif
#if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
...@@ -1462,6 +1470,7 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1462,6 +1470,7 @@ ISR(TIMER0_COMPB_vect) {
#define START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin) #define START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
#endif #endif
// Prepare or measure a sensor, each one every 14th frame
switch(temp_state) { switch(temp_state) {
case PrepareTemp_0: case PrepareTemp_0:
#if HAS_TEMP_0 #if HAS_TEMP_0
...@@ -1570,9 +1579,9 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1570,9 +1579,9 @@ ISR(TIMER0_COMPB_vect) {
temp_state = PrepareTemp_0; temp_state = PrepareTemp_0;
break; break;
default: //default:
ECHO_LM(ER, MSG_TEMP_READ_ERROR); // ECHO_LM(ER, MSG_TEMP_READ_ERROR);
break; // break;
} // switch(temp_state) } // switch(temp_state)
if (temp_count >= OVERSAMPLENR) { // 14 * 16 * 1/(16000000/64/256) if (temp_count >= OVERSAMPLENR) { // 14 * 16 * 1/(16000000/64/256)
......
...@@ -146,6 +146,10 @@ void PID_autotune(float temp, int extruder, int ncycles); ...@@ -146,6 +146,10 @@ void PID_autotune(float temp, int extruder, int ncycles);
void setExtruderAutoFanState(int pin, bool state); void setExtruderAutoFanState(int pin, bool state);
void checkExtruderAutoFans(); void checkExtruderAutoFans();
#ifdef WATCH_TEMP_PERIOD
void start_watching_heater(int e=0);
#endif
FORCE_INLINE void autotempShutdown() { FORCE_INLINE void autotempShutdown() {
#ifdef AUTOTEMP #ifdef AUTOTEMP
if (autotemp_enabled) { if (autotemp_enabled) {
......
...@@ -480,17 +480,12 @@ static void lcd_main_menu() { ...@@ -480,17 +480,12 @@ static void lcd_main_menu() {
} }
#endif #endif
/**
* Set the home offset based on the current_position
*/
void lcd_set_home_offsets() { void lcd_set_home_offsets() {
for (int8_t i=0; i < NUM_AXIS; i++) { // M428 Command
if (i != E_AXIS) { enqueuecommands_P(PSTR("M428"));
home_offset[i] -= current_position[i];
current_position[i] = 0.0;
}
}
plan_set_position(0.0, 0.0, 0.0, current_position[E_AXIS]);
// Audio feedback
enqueuecommands_P(PSTR("M300 S659 P200\nM300 S698 P200"));
lcd_return_to_status(); lcd_return_to_status();
} }
...@@ -591,7 +586,9 @@ void _lcd_preheat(int endnum, const float temph, const float tempb, const int fa ...@@ -591,7 +586,9 @@ void _lcd_preheat(int endnum, const float temph, const float tempb, const int fa
setTargetBed(tempb); setTargetBed(tempb);
fanSpeed = fan; fanSpeed = fan;
lcd_return_to_status(); lcd_return_to_status();
setWatch(); // heater sanity check timer #ifdef WATCH_TEMP_PERIOD
if (endnum >= 0) start_watching_heater(endnum);
#endif
} }
void lcd_preheat_pla0() { _lcd_preheat(0, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); } void lcd_preheat_pla0() { _lcd_preheat(0, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); }
void lcd_preheat_abs0() { _lcd_preheat(0, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); } void lcd_preheat_abs0() { _lcd_preheat(0, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); }
......
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