From 8f032ad122df43b1f74be4c2ec47a58310bb2f4e Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Fri, 8 Jun 2018 09:44:58 +0200 Subject: [PATCH 1/7] Fix MK3 compilation issue with Arduino 1.8.x see https://github.com/prusa3d/Prusa-Firmware/issues/614#issuecomment-385034066 --- Firmware/xyzcal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/xyzcal.cpp b/Firmware/xyzcal.cpp index ed3d3210d..a59f48978 100644 --- a/Firmware/xyzcal.cpp +++ b/Firmware/xyzcal.cpp @@ -32,7 +32,7 @@ #define _PI 3.14159265F -extern long count_position[NUM_AXIS]; +extern volatile long count_position[NUM_AXIS]; uint8_t check_pinda_0(); uint8_t check_pinda_1(); From ae7561bb2765a4ad05570fe480718761ffb41065 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 3 Aug 2018 15:26:39 +0200 Subject: [PATCH 2/7] M600 fix: set hotend temperature to correct value, manage_response function fix: now works in case that user presses button on mmu unit before he is asked to do it, compiler warnings (uninitialized variables) fixed --- Firmware/Marlin.h | 2 +- Firmware/Marlin_main.cpp | 105 ++++++++++++++++++--------------------- 2 files changed, 50 insertions(+), 57 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index d8ccc92ec..9a5e7968f 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -468,7 +468,7 @@ void gcode_M701(); void proc_commands(); void manage_response(); -bool mmu_get_response(bool timeout); +bool mmu_get_response(bool timeout, bool clear); void mmu_not_responding(); void mmu_load_to_nozzle(); void M600_load_filament(); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 699368ec3..9af5507a7 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3092,8 +3092,9 @@ void gcode_M600(bool automatic, float x_position, float y_position, float z_shif //First backup current position and settings feedmultiplyBckp=feedmultiply; - float HotendTempBckp = degTargetHotend(active_extruder); - int fanSpeedBckp = fanSpeed; + HotendTempBckp = degTargetHotend(active_extruder); + fanSpeedBckp = fanSpeed; + lastpos[X_AXIS]=current_position[X_AXIS]; lastpos[Y_AXIS]=current_position[Y_AXIS]; lastpos[Z_AXIS]=current_position[Z_AXIS]; @@ -8868,11 +8869,14 @@ static void print_time_remaining_init() { print_percent_done_silent = PRINT_PERCENT_DONE_INIT; } -bool mmu_get_response(bool timeout) { +bool mmu_get_response(bool timeout, bool clear) { + //waits for "ok" from mmu + //function returns true if "ok" was received + //if timeout is set to true function return false if there is no "ok" received before timeout bool response = true; LongTimer mmu_get_reponse_timeout; - uart2_rx_clr(); - + if (clear) uart2_rx_clr(); + KEEPALIVE_STATE(IN_PROCESS); mmu_get_reponse_timeout.start(); while (!uart2_rx_ok()) { @@ -8887,15 +8891,18 @@ bool mmu_get_response(bool timeout) { 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; + float hotend_temp_bckp = degTargetHotend(active_extruder); + float z_position_bckp = current_position[Z_AXIS]; + float x_position_bckp = current_position[X_AXIS]; + float y_position_bckp = current_position[Y_AXIS]; while(!response) { - response = mmu_get_response(true); - if (!response) { - if (!mmu_print_saved) { //first occurence + response = mmu_get_response(true, !mmu_print_saved); //wait for "ok" from mmu + if (!response) { //no "ok" was received in reserved time frame, user will fix the issue on mmu unit + if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater if (lcd_update_enabled) { lcd_update_was_enabled = true; lcd_update_enable(false); @@ -8921,15 +8928,16 @@ void manage_response() { 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 needs user attention. Please press knob to resume nozzle target temperature.")); + setTargetHotend(hotend_temp_bckp, active_extruder); + while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) { + delay_keep_alive(1000); + lcd_wait_for_heater(); + } } - printf_P(PSTR("MMU not responding\n")); - lcd_show_fullscreen_message_and_wait_P(_i("MMU needs user attention. Please press knob to resume nozzle target temperature.")); - setTargetHotend(hotend_temp_bckp, active_extruder); - while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) { - delay_keep_alive(1000); - lcd_wait_for_heater(); - } - lcd_display_message_fullscreen_P(_i("Now check MMU. Fix the issue and then press knob on MMU unit.")); + lcd_display_message_fullscreen_P(_i("Check MMU. Fix the issue and then press button on MMU unit.")); } else if (mmu_print_saved) { printf_P(PSTR("MMU start responding\n")); @@ -8948,17 +8956,6 @@ void manage_response() { } void mmu_load_to_nozzle() { - /*bool saved_e_relative_mode = axis_relative_modes[E_AXIS]; - if (!saved_e_relative_mode) { - enquecommand_front_P(PSTR("M82")); // set extruder to relative mode - } - enquecommand_front_P((PSTR("G1 E7.2000 F562"))); - enquecommand_front_P((PSTR("G1 E14.4000 F871"))); - enquecommand_front_P((PSTR("G1 E36.0000 F1393"))); - enquecommand_front_P((PSTR("G1 E14.4000 F871"))); - if (!saved_e_relative_mode) { - enquecommand_front_P(PSTR("M83")); // set extruder to relative mode - }*/ st_synchronize(); bool saved_e_relative_mode = axis_relative_modes[E_AXIS]; @@ -9022,45 +9019,41 @@ void M600_check_state() { } void M600_wait_for_user() { + //Beep, manage nozzle heater and wait for user to start unload filament + KEEPALIVE_STATE(PAUSED_FOR_USER); - int counterBeep = 0; - + int counterBeep = 0; unsigned long waiting_start_time = millis(); uint8_t wait_for_user_state = 0; lcd_display_message_fullscreen_P(_T(MSG_PRESS_TO_UNLOAD)); - //-// bool bFirst=true; - - while (!(wait_for_user_state == 0 && lcd_clicked())){ - + while (!(wait_for_user_state == 0 && lcd_clicked())){ manage_heater(); manage_inactivity(true); - #if BEEPER > 0 - if (counterBeep == 500) { - counterBeep = 0; - } - SET_OUTPUT(BEEPER); - if (counterBeep == 0) { - //-// - //if(eSoundMode==e_SOUND_MODE_LOUD) - if((eSoundMode==e_SOUND_MODE_LOUD)||((eSoundMode==e_SOUND_MODE_ONCE)&&bFirst)) - { - bFirst=false; - WRITE(BEEPER, HIGH); - } - } - if (counterBeep == 20) { - WRITE(BEEPER, LOW); + #if BEEPER > 0 + if (counterBeep == 500) { + counterBeep = 0; + } + SET_OUTPUT(BEEPER); + if (counterBeep == 0) { + if((eSoundMode==e_SOUND_MODE_LOUD)||((eSoundMode==e_SOUND_MODE_ONCE)&&bFirst)) + { + bFirst=false; + WRITE(BEEPER, HIGH); } + } + if (counterBeep == 20) { + WRITE(BEEPER, LOW); + } - counterBeep++; -#endif + counterBeep++; + #endif //BEEPER > 0 switch (wait_for_user_state) { - case 0: + case 0: //nozzle is hot, waiting for user to press the knob to unload filament delay_keep_alive(4); if (millis() > waiting_start_time + (unsigned long)M600_TIMEOUT * 1000) { @@ -9075,7 +9068,7 @@ void M600_wait_for_user() { disable_e2(); } break; - case 1: + case 1: //nozzle target temperature is set to zero, waiting for user to start nozzle preheat delay_keep_alive(4); if (lcd_clicked()) { @@ -9085,7 +9078,7 @@ void M600_wait_for_user() { wait_for_user_state = 2; } break; - case 2: + case 2: //waiting for nozzle to reach target temperature if (abs(degTargetHotend(active_extruder) - degHotend(active_extruder)) < 1) { lcd_display_message_fullscreen_P(_T(MSG_PRESS_TO_UNLOAD)); From dd4c4b39b4359d61a3329c54bea58df119a731c6 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 3 Aug 2018 15:33:41 +0200 Subject: [PATCH 3/7] Added support for the upstream Marlin interpretation of the M204 code: M204 S.. T..: T is interpreted the old way (as acceleration when retracting) only if an S code is found at the same line. This allows PrusaResearch to interpret the legacy G-codes generated by our older Slic3r with older Slic3r profiles. M204 P.. R.. T..: T is ignored, P is interpreted as acceleration when extruding, R is interpreted as acceleration when retracting. This will be the format the Slic3r 1.41.0 will produce from the Machine Limits page. In the future both MK3 firmware and Slic3r will likely be extended to support the separate travel acceleration. This change will help us to solve the following Slic3r issue: https://github.com/prusa3d/Slic3r/issues/1089 --- Firmware/Marlin_main.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 1c8683cfa..7d9ad5df1 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5932,10 +5932,31 @@ Sigma_Exit: } } break; - case 204: // M204 acclereration S normal moves T filmanent only moves + case 204: + // M204 acclereration settings. + // Supporting old format: M204 S[normal moves] T[filmanent only moves] + // and new format: M204 P[printing moves] R[filmanent only moves] T[travel moves] (as of now T is ignored) { - if(code_seen('S')) acceleration = code_value() ; - if(code_seen('T')) retract_acceleration = code_value() ; + if(code_seen('S')) { + // Legacy acceleration format. This format is used by the legacy Marlin, MK2 or MK3 firmware, + // and it is also generated by Slic3r to control acceleration per extrusion type + // (there is a separate acceleration settings in Slicer for perimeter, first layer etc). + acceleration = code_value(); + // Interpret the T value as retract acceleration in the old Marlin format. + if(code_seen('T')) + retract_acceleration = code_value(); + } else { + // New acceleration format, compatible with the upstream Marlin. + if(code_seen('P')) + acceleration = code_value(); + if(code_seen('R')) + retract_acceleration = code_value(); + if(code_seen('T')) { + // Interpret the T value as the travel acceleration in the new Marlin format. + //FIXME Prusa3D firmware currently does not support travel acceleration value independent from the extruding acceleration value. + // travel_acceleration = code_value(); + } + } } break; case 205: //M205 advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk From 5824da8310b6e55ecb7a3e02140e4948b8f99585 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 3 Aug 2018 15:42:06 +0200 Subject: [PATCH 4/7] add more extrusion to M600 load filament --- Firmware/Marlin_main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 9af5507a7..f18042543 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9125,6 +9125,10 @@ void mmu_M600_load_filament(bool automatic) { snmm_extruder = tmp_extruder; //filament change is finished mmu_load_to_nozzle(); + + st_synchronize(); + current_position[E_AXIS]+= FILAMENTCHANGE_FINALFEED ; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2, active_extruder); #endif } From a1f69e09246e95aa620c236cad057bc7526f23bf Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 3 Aug 2018 18:37:52 +0200 Subject: [PATCH 5/7] manage response update --- Firmware/Marlin.h | 2 +- Firmware/Marlin_main.cpp | 78 ++++++++++++++++++++++------------------ Firmware/ultralcd.cpp | 8 ++--- 3 files changed, 48 insertions(+), 40 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 9a5e7968f..2bbab9879 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -467,7 +467,7 @@ void gcode_M701(); void proc_commands(); -void manage_response(); +void manage_response(bool move_axes, bool turn_off_nozzle); bool mmu_get_response(bool timeout, bool clear); void mmu_not_responding(); void mmu_load_to_nozzle(); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f18042543..ac530d469 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6834,7 +6834,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) printf_P(PSTR("T code: %d \n"), tmp_extruder); fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder); - manage_response(); + manage_response(true, true); snmm_extruder = tmp_extruder; //filament change is finished @@ -8890,7 +8890,7 @@ bool mmu_get_response(bool timeout, bool clear) { } -void manage_response() { +void manage_response(bool move_axes, bool turn_off_nozzle) { bool response = false; mmu_print_saved = false; @@ -8911,31 +8911,34 @@ void manage_response() { 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 needs user attention. Please press knob to resume nozzle target temperature.")); - setTargetHotend(hotend_temp_bckp, active_extruder); - while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) { - delay_keep_alive(1000); - lcd_wait_for_heater(); - } + if (move_axes) { + 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(); + + //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(); + } + if (turn_off_nozzle) { + //set nozzle target temperature to 0 + setAllTargetHotends(0); + printf_P(PSTR("MMU not responding\n")); + lcd_show_fullscreen_message_and_wait_P(_i("MMU needs user attention. Please press knob to resume nozzle target temperature.")); + setTargetHotend(hotend_temp_bckp, active_extruder); + while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) { + delay_keep_alive(1000); + lcd_wait_for_heater(); + } + } } lcd_display_message_fullscreen_P(_i("Check MMU. Fix the issue and then press button on MMU unit.")); } @@ -8943,13 +8946,18 @@ void manage_response() { 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 (move_axes) { + 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(); + } + else { + delay_keep_alive(1000); //delay just for showing MMU OK message for a while in case that there are no xyz movements + } } } if (lcd_update_was_enabled) lcd_update_enable(true); @@ -9121,7 +9129,7 @@ void mmu_M600_load_filament(bool automatic) { printf_P(PSTR("T code: %d \n"), tmp_extruder); fprintf_P(uart2io, PSTR("T%d\n"), tmp_extruder); - manage_response(); + manage_response(false, true); snmm_extruder = tmp_extruder; //filament change is finished mmu_load_to_nozzle(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 4b20c9fb6..0ea695fb8 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3069,8 +3069,8 @@ bool lcd_wait_for_pinda(float temp) { } void lcd_wait_for_heater() { - lcd_display_message_fullscreen_P(_T(MSG_WIZARD_HEATING)); - + lcd_display_message_fullscreen_P(_T(MSG_WIZARD_HEATING)); + lcd_set_degree(); lcd_set_cursor(0, 4); lcd_print(LCD_STR_THERMOMETER[0]); lcd_print(ftostr3(degHotend(active_extruder))); @@ -5228,7 +5228,7 @@ void extr_adj(int extruder) //loading filament for SNMM lcd_print(snmm_extruder + 1); // get response - manage_response(); + manage_response(false, false); lcd_update_enable(true); @@ -5301,7 +5301,7 @@ void extr_unload() { //unload just current filament for multimaterial printers fprintf_P(uart2io, PSTR("U0\n")); // get response - manage_response(); + manage_response(false, true); lcd_update_enable(true); #else //SNMM_V2 From 0c2d0bebce54e427b76acea4d1080feda1da5edf Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 3 Aug 2018 19:14:17 +0200 Subject: [PATCH 6/7] merge with upstream fix --- Firmware/mmu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 2206e3dc2..6afa8229d 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -107,7 +107,7 @@ void extr_adj(int extruder) //loading filament for SNMM lcd_print(snmm_extruder + 1); // get response - manage_response(); + manage_response(false, false); lcd_update_enable(true); @@ -182,7 +182,7 @@ void extr_unload() fprintf_P(uart2io, PSTR("U0\n")); // get response - manage_response(); + manage_response(false, true); lcd_update_enable(true); #else //SNMM From d21e527c731de22c8faaa0ccd4363271505add74 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Sun, 5 Aug 2018 20:17:04 +0200 Subject: [PATCH 7/7] PRUSA Fir reports also buildnumber --- Firmware/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4d715588e..c0e103d45 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3515,7 +3515,7 @@ void process_commands() } else if(code_seen("Fir")){ - SERIAL_PROTOCOLLN(FW_VERSION); + SERIAL_PROTOCOLLN(FW_VERSION_FULL); } else if(code_seen("Rev")){