timeouts used when getting response from mmu, M600 improvements, no filament sensor in variants file

This commit is contained in:
PavelSindler 2018-07-31 19:00:42 +02:00
parent 04d0178150
commit 40da6deef8
4 changed files with 89 additions and 43 deletions

View File

@ -361,7 +361,7 @@ extern uint8_t print_percent_done_silent;
extern uint16_t print_time_remaining_silent; extern uint16_t print_time_remaining_silent;
#define PRINT_TIME_REMAINING_INIT 65535 #define PRINT_TIME_REMAINING_INIT 65535
#define PRINT_PERCENT_DONE_INIT 255 #define PRINT_PERCENT_DONE_INIT 255
#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == 4) || saved_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL) || card.paused) #define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == 4) || saved_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL) || card.paused || mmu_print_saved)
extern void calculate_extruder_multipliers(); extern void calculate_extruder_multipliers();
@ -464,7 +464,8 @@ void gcode_M701();
void proc_commands(); void proc_commands();
bool mmu_get_reponse(bool timeout); void manage_response();
bool mmu_get_response(bool timeout);
void mmu_not_responding(); void mmu_not_responding();
void mmu_load_to_nozzle(); void mmu_load_to_nozzle();
void M600_load_filament(); void M600_load_filament();

View File

@ -462,6 +462,9 @@ uint8_t saved_filament_type;
// save/restore printing // save/restore printing
bool saved_printing = false; bool saved_printing = false;
// save/restore printing in case that mmu was not responding
bool mmu_print_saved = false;
// storing estimated time to end of print counted by slicer // storing estimated time to end of print counted by slicer
uint8_t print_percent_done_normal = PRINT_PERCENT_DONE_INIT; uint8_t print_percent_done_normal = PRINT_PERCENT_DONE_INIT;
uint16_t print_time_remaining_normal = PRINT_TIME_REMAINING_INIT; //estimated remaining print time in minutes uint16_t print_time_remaining_normal = PRINT_TIME_REMAINING_INIT; //estimated remaining print time in minutes
@ -3073,7 +3076,7 @@ void gcode_M114()
SERIAL_PROTOCOLLN(""); SERIAL_PROTOCOLLN("");
} }
void gcode_M600(bool automatic, float x_position, float y_position, float z_shift, float e_shift, float e_shift_late, bool low_z) { void gcode_M600(bool automatic, float x_position, float y_position, float z_shift, float e_shift, float e_shift_late) {
st_synchronize(); st_synchronize();
float lastpos[4]; float lastpos[4];
@ -3138,33 +3141,26 @@ void gcode_M600(bool automatic, float x_position, float y_position, float z_shif
if(!automatic) M600_check_state(); if(!automatic) M600_check_state();
//Not let's go back to print //Not let's go back to print
fanSpeed = fanSpeedBckp; fanSpeed = fanSpeedBckp;
//Feed a little of filament to stabilize pressure //Feed a little of filament to stabilize pressure
current_position[E_AXIS]+= FILAMENTCHANGE_RECFEED; if (!automatic) {
current_position[E_AXIS] += FILAMENTCHANGE_RECFEED;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EXFEED, active_extruder); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_EXFEED, active_extruder);
}
//Retract
current_position[E_AXIS]+= FILAMENTCHANGE_FIRSTRETRACT;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_RFEED, active_extruder);
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 70, active_extruder); //should do nothing
//Move XY back //Move XY back
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_XYFEED, active_extruder); plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_XYFEED, active_extruder);
st_synchronize();
//Move Z back //Move Z back
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_ZFEED, active_extruder); plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_ZFEED, active_extruder);
st_synchronize();
current_position[E_AXIS]= current_position[E_AXIS] - FILAMENTCHANGE_FIRSTRETRACT;
//Unretract //Unretract
current_position[E_AXIS]= current_position[E_AXIS] - FILAMENTCHANGE_FIRSTRETRACT;
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_RFEED, active_extruder); plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], current_position[E_AXIS], FILAMENTCHANGE_RFEED, active_extruder);
st_synchronize();
//Set E position to original //Set E position to original
plan_set_e_position(lastpos[E_AXIS]); plan_set_e_position(lastpos[E_AXIS]);
@ -6374,7 +6370,6 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
float e_shift_init = 0; float e_shift_init = 0;
float e_shift_late = 0; float e_shift_late = 0;
bool automatic = false; bool automatic = false;
bool TooLowZ = false;
//Retract extruder //Retract extruder
if(code_seen('E')) if(code_seen('E'))
@ -6388,7 +6383,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
#endif #endif
} }
//currently don't work as we are using the same unload sequence as in M702, needs re-work
if (code_seen('L')) if (code_seen('L'))
{ {
e_shift_late = code_value(); e_shift_late = code_value();
@ -6409,12 +6404,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
{ {
#ifdef FILAMENTCHANGE_ZADD #ifdef FILAMENTCHANGE_ZADD
z_shift= FILAMENTCHANGE_ZADD ; z_shift= FILAMENTCHANGE_ZADD ;
if(current_position[Z_AXIS] < 25){ if(current_position[Z_AXIS] < 25) z_shift+= 25 ;
z_shift+= 25 ;
TooLowZ = true;
}else{
TooLowZ = false;
}
#endif #endif
} }
//Move XY to side //Move XY to side
@ -6445,7 +6435,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
} }
#endif //SNMM_V2 #endif //SNMM_V2
gcode_M600(automatic, x_position, y_position, z_shift, e_shift_init, e_shift_late, TooLowZ); gcode_M600(automatic, x_position, y_position, z_shift, e_shift_init, e_shift_late);
} }
break; break;
@ -6812,8 +6802,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
printf_P(PSTR("T code: %d \n"), tmp_extruder); printf_P(PSTR("T code: %d \n"), tmp_extruder);
fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder); fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder);
bool response = mmu_get_reponse(false); manage_response();
if (!response) mmu_not_responding();
snmm_extruder = tmp_extruder; //filament change is finished snmm_extruder = tmp_extruder; //filament change is finished
@ -8848,7 +8837,7 @@ static void print_time_remaining_init() {
print_percent_done_silent = PRINT_PERCENT_DONE_INIT; print_percent_done_silent = PRINT_PERCENT_DONE_INIT;
} }
bool mmu_get_reponse(bool timeout) { bool mmu_get_response(bool timeout) {
bool response = true; bool response = true;
LongTimer mmu_get_reponse_timeout; LongTimer mmu_get_reponse_timeout;
uart2_rx_clr(); uart2_rx_clr();
@ -8857,7 +8846,7 @@ bool mmu_get_reponse(bool timeout) {
while (!uart2_rx_ok()) while (!uart2_rx_ok())
{ {
delay_keep_alive(100); delay_keep_alive(100);
if (timeout && mmu_get_reponse_timeout.expired(180 * 1000ul)) { //3 minutes timeout if (timeout && mmu_get_reponse_timeout.expired(20 * 60 * 1000ul)) { //20 minutes timeout
response = false; response = false;
break; break;
} }
@ -8865,8 +8854,66 @@ bool mmu_get_reponse(bool timeout) {
return response; return response;
} }
void mmu_not_responding() {
printf_P(PSTR("MMU not responding")); void manage_response() {
bool response = false;
mmu_print_saved = false;
bool lcd_update_was_enabled = false;
float hotend_temp_bckp;
float z_position_bckp, x_position_bckp, y_position_bckp;
while(!response) {
response = mmu_get_response(true);
if (!response) {
if (!mmu_print_saved) { //first occurence
if (lcd_update_enabled) {
lcd_update_was_enabled = true;
lcd_update_enable(false);
}
st_synchronize();
mmu_print_saved = true;
hotend_temp_bckp = degTargetHotend(active_extruder);
z_position_bckp = current_position[Z_AXIS];
x_position_bckp = current_position[X_AXIS];
y_position_bckp = current_position[Y_AXIS];
//lift z
current_position[Z_AXIS] += Z_PAUSE_LIFT;
if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
st_synchronize();
//set nozzle target temperature to 0
setAllTargetHotends(0);
//Move XY to side
current_position[X_AXIS] = X_PAUSE_POS;
current_position[Y_AXIS] = Y_PAUSE_POS;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
st_synchronize();
}
printf_P(PSTR("MMU not responding\n"));
lcd_show_fullscreen_message_and_wait_P(_i("MMU was not responding. Pres knob to resume nozzle target temperature;"));
setTargetHotend(hotend_temp_bckp, active_extruder);
while (abs(degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) {
delay_keep_alive(1000);
lcd_wait_for_heater();
}
lcd_display_message_fullscreen_P(_i("Now check MMU."));
}
else if (mmu_print_saved) {
printf_P(PSTR("MMU start responding\n"));
lcd_clear();
lcd_display_message_fullscreen_P(_i("MMU OK. Resuming..."));
current_position[X_AXIS] = x_position_bckp;
current_position[Y_AXIS] = y_position_bckp;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
st_synchronize();
current_position[Z_AXIS] = z_position_bckp;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 15, active_extruder);
st_synchronize();
}
}
if (lcd_update_was_enabled) lcd_update_enable(true);
} }
void mmu_load_to_nozzle() { void mmu_load_to_nozzle() {
@ -9044,9 +9091,8 @@ void mmu_M600_load_filament(bool automatic) {
snmm_filaments_used |= (1 << tmp_extruder); //for stop print snmm_filaments_used |= (1 << tmp_extruder); //for stop print
printf_P(PSTR("T code: %d \n"), tmp_extruder); printf_P(PSTR("T code: %d \n"), tmp_extruder);
fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder); fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder);
response = mmu_get_reponse(false);
if (!response) mmu_not_responding();
manage_response();
snmm_extruder = tmp_extruder; //filament change is finished snmm_extruder = tmp_extruder; //filament change is finished
mmu_load_to_nozzle(); mmu_load_to_nozzle();

View File

@ -5308,8 +5308,8 @@ void extr_adj(int extruder) //loading filament for SNMM
lcd_print(snmm_extruder + 1); lcd_print(snmm_extruder + 1);
// get response // get response
bool response = mmu_get_reponse(false); manage_response();
if (!response) mmu_not_responding();
lcd_update_enable(true); lcd_update_enable(true);
@ -5381,8 +5381,7 @@ void extr_unload() { //unloads filament
fprintf_P(uart2io, PSTR("U0\n")); fprintf_P(uart2io, PSTR("U0\n"));
// get response // get response
bool response = mmu_get_reponse(false); manage_response();
if (!response) mmu_not_responding();
lcd_update_enable(true); lcd_update_enable(true);
#else //SNMM_V2 #else //SNMM_V2
@ -6165,7 +6164,7 @@ static void lcd_silent_mode_set_tune() {
static void lcd_colorprint_change() { static void lcd_colorprint_change() {
enquecommand_P(PSTR("M600 AUTO")); enquecommand_P(PSTR("M600"));
custom_message = true; custom_message = true;
custom_message_type = 2; //just print status message custom_message_type = 2; //just print status message

View File

@ -134,7 +134,7 @@
// Filament sensor // Filament sensor
#define PAT9125 #define PAT9125
#define FILAMENT_SENSOR //#define FILAMENT_SENSOR
// Backlash - // Backlash -
//#define BACKLASH_X //#define BACKLASH_X