From 8a27b6abdb556307070c6f5bf2f76711d0436286 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Thu, 7 Jan 2021 11:45:40 +0100 Subject: [PATCH 01/12] Move Z up before xy home running xyz calibration to prevent scratches on bed and sheet --- Firmware/Marlin_main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index c6f9e4b74..a4123ded8 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2974,6 +2974,8 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level) //set_destination_to_current(); int l_feedmultiply = setup_for_endstop_move(); lcd_display_message_fullscreen_P(_T(MSG_AUTO_HOME)); + raise_z_above(MESH_HOME_Z_SEARCH); + st_synchronize(); home_xy(); enable_endstops(false); From 2f4119a6d723fc1e0e7b148aed73101cb89c5369 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 2 Feb 2021 13:21:16 +0200 Subject: [PATCH 02/12] M552 - Printer IP address --- Firmware/Marlin.h | 2 ++ Firmware/Marlin_main.cpp | 19 +++++++++++++++++++ Firmware/ultralcd.cpp | 31 +++++++++++++++++++------------ Firmware/util.cpp | 7 +++++++ Firmware/util.h | 3 +++ 5 files changed, 50 insertions(+), 12 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 307b8c91b..17fce2713 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -501,4 +501,6 @@ void raise_z_above(float target, bool plan=true); extern "C" void softReset(); +extern uint32_t IP_address; + #endif diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 9deb51055..61e5a33ce 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -321,6 +321,8 @@ uint16_t print_time_remaining_normal = PRINT_TIME_REMAINING_INIT; //estimated re uint8_t print_percent_done_silent = PRINT_PERCENT_DONE_INIT; uint16_t print_time_remaining_silent = PRINT_TIME_REMAINING_INIT; //estimated remaining print time in minutes +uint32_t IP_address = 0; + //=========================================================================== //=============================Private Variables============================= //=========================================================================== @@ -8003,6 +8005,23 @@ Sigma_Exit: break; } #endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET + case 552: + { + if (code_seen('P')) + { + uint8_t valCnt = 0; + IP_address = 0; + do + { + *strchr_pointer = '*'; + ((uint8_t*)&IP_address)[valCnt] = code_value_short(); + valCnt++; + } while ((valCnt < 4) && code_seen('.')); + + if (valCnt != 4) + IP_address = 0; + } + } break; #ifdef FILAMENTCHANGEENABLE diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d7976d277..0f6bc1fa3 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2057,8 +2057,8 @@ static void lcd_support_menu() { // 22bytes total int8_t status; // 1byte bool is_flash_air; // 1byte - uint8_t ip[4]; // 4bytes - char ip_str[3*4+3+1]; // 16bytes + uint32_t ip; // 4bytes + char ip_str[IP4_STR_SIZE]; // 16bytes } _menu_data_t; static_assert(sizeof(menu_data)>= sizeof(_menu_data_t),"_menu_data_t doesn't fit into menu_data"); _menu_data_t* _md = (_menu_data_t*)&(menu_data[0]); @@ -2069,17 +2069,10 @@ static void lcd_support_menu() _md->status = 1; _md->is_flash_air = card.ToshibaFlashAir_isEnabled(); if (_md->is_flash_air) { - card.ToshibaFlashAir_GetIP(_md->ip); // ip[4] filled with 0 if it failed - // Prepare IP string from ip[4] - sprintf_P(_md->ip_str, PSTR("%d.%d.%d.%d"), - _md->ip[0], _md->ip[1], - _md->ip[2], _md->ip[3]); + card.ToshibaFlashAir_GetIP((uint8_t*)(&_md->ip)); // ip == 0 if it failed } - } else if (_md->is_flash_air && - _md->ip[0] == 0 && _md->ip[1] == 0 && - _md->ip[2] == 0 && _md->ip[3] == 0 && - ++ _md->status == 16) - { + } else if (_md->is_flash_air && _md->ip == 0 && ++ _md->status == 16) + { // Waiting for the FlashAir card to get an IP address from a router. Force an update. _md->status = 0; } @@ -2143,6 +2136,20 @@ static void lcd_support_menu() MENU_ITEM_BACK_P(PSTR(" ")); if (((menu_item - 1) == menu_line) && lcd_draw_update) { lcd_set_cursor(2, menu_row); + ip4_to_str(_md->ip_str, (uint8_t*)(&_md->ip)); + lcd_printf_P(PSTR("%s"), _md->ip_str); + } + } + + // Show the printer IP address, if it is available. + if (IP_address) { + + MENU_ITEM_BACK_P(STR_SEPARATOR); + MENU_ITEM_BACK_P(PSTR("Printer IP Addr:")); //c=18 r=1 + MENU_ITEM_BACK_P(PSTR(" ")); + if (((menu_item - 1) == menu_line) && lcd_draw_update) { + lcd_set_cursor(2, menu_row); + ip4_to_str(_md->ip_str, (uint8_t*)(&IP_address)); lcd_printf_P(PSTR("%s"), _md->ip_str); } } diff --git a/Firmware/util.cpp b/Firmware/util.cpp index e335793a0..a25efd359 100644 --- a/Firmware/util.cpp +++ b/Firmware/util.cpp @@ -4,6 +4,7 @@ #include "sound.h" #include "language.h" #include "util.h" +#include // Allocate the version string in the program memory. Otherwise the string lands either on the stack or in the global RAM. const char FW_VERSION_STR[] PROGMEM = FW_VERSION; @@ -604,3 +605,9 @@ else { sPrinterName=_sPrinterName; } } + + +void ip4_to_str(char* dest, uint8_t* IP) +{ + sprintf_P(dest, PSTR("%u.%u.%u.%u"), IP[0], IP[1], IP[2], IP[3]); +} diff --git a/Firmware/util.h b/Firmware/util.h index f25749de0..6d34aa081 100644 --- a/Firmware/util.h +++ b/Firmware/util.h @@ -110,4 +110,7 @@ void gcode_level_check(uint16_t nGcodeLevel); void fSetMmuMode(bool bMMu); +#define IP4_STR_SIZE 16 +extern void ip4_to_str(char* dest, uint8_t* IP); + #endif /* UTIL_H */ From 647cde0caeb3365e66d65cf1d558168c2ae2dc29 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 2 Feb 2021 13:38:20 +0200 Subject: [PATCH 03/12] Add documentation --- Firmware/Marlin_main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 61e5a33ce..777a05ff4 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3734,6 +3734,7 @@ extern uint8_t st_backlash_y; //!@n M503 - print the current settings (from memory not from EEPROM) //!@n M509 - force language selection on next restart //!@n M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) +//!@n M552 - Set IP address //!@n M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] //!@n M605 - Set dual x-carriage movement mode: S [ X R ] //!@n M860 - Wait for PINDA thermistor to reach target temperature. @@ -8005,6 +8006,19 @@ Sigma_Exit: break; } #endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET + + /*! + ### M552 - Set IP address M552: Set IP address, enable/disable network interface" + Sets the printer IP address that is shown in the support menu. Designed to be used with the help of host software. + If P is not specified nothing happens. + If the structure of the IP address is invalid, 0.0.0.0 is assumed and nothing is shown on the screen in the Support menu. + #### Usage + + M552 [ P ] + + #### Parameters + - `P` - The IP address in xxx.xxx.xxx.xxx format. Eg: P192.168.1.14 + */ case 552: { if (code_seen('P')) From 5c9d202871c0bdb63323b77d5ed88827588d9533 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 2 Feb 2021 19:08:19 +0200 Subject: [PATCH 04/12] Change MAX_DIR_DEPTH from 10 to 6 You can't run M23 with so many directories as the length of the command will exceed the maximum allowed by cmdqueue --- Firmware/cardreader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/cardreader.h b/Firmware/cardreader.h index 524454002..9bf9bd0a6 100644 --- a/Firmware/cardreader.h +++ b/Firmware/cardreader.h @@ -3,7 +3,7 @@ #ifdef SDSUPPORT -#define MAX_DIR_DEPTH 10 +#define MAX_DIR_DEPTH 6 #include "SdFile.h" enum LsAction {LS_SerialPrint,LS_SerialPrint_LFN,LS_Count,LS_GetFilename}; From f6ae3790770d39d3df71911c5112485edc04582b Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 2 Feb 2021 19:08:44 +0200 Subject: [PATCH 05/12] Fix dir_names array definition. Prevents overrun --- Firmware/Marlin.h | 2 +- Firmware/Marlin_main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 17fce2713..aa057bc5b 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -352,7 +352,7 @@ extern bool mesh_bed_run_from_menu; extern bool sortAlpha; -extern char dir_names[3][9]; +extern char dir_names[MAX_DIR_DEPTH][9]; extern int8_t lcd_change_fil_state; // save/restore printing diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 777a05ff4..4e0511c19 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -228,7 +228,7 @@ bool fan_state[2]; int fan_edge_counter[2]; int fan_speed[2]; -char dir_names[3][9]; +char dir_names[MAX_DIR_DEPTH][9]; bool sortAlpha = false; From 896f4e1dd1b55bc14e77cd63996aab87267a4464 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 2 Feb 2021 19:14:05 +0200 Subject: [PATCH 06/12] Fix compile error --- Firmware/Marlin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index aa057bc5b..1ed5e0bd3 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -352,7 +352,7 @@ extern bool mesh_bed_run_from_menu; extern bool sortAlpha; -extern char dir_names[MAX_DIR_DEPTH][9]; +extern char dir_names[][9]; extern int8_t lcd_change_fil_state; // save/restore printing From 1c76152e62e9aa6fd3dafbc8eecb800cab6003f6 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 20 Sep 2020 18:15:27 +0200 Subject: [PATCH 07/12] Implement separate travel acceleration (M204 T) Allow to separate extrusion and travel acceleration settings using M204, as Marlin 1.1.x and 2.x does using M204 T. This allows to reduce the number of instructions required during printing, since resetting the acceleration for travel moves is no longer required and can be done a single time during the print. Provision for this parameter was pre-existing, but not implemented. M204 has two forms: the lagacy format (Marlin <1.1): M204 S[print-acc] T[retract-acc] and the newer format: M204 P[print-acc] R[retract-acc] T[travel-acc] The distinction in the MK3 FW is done based on the presence of the P parameter. If P is seen, the new format is adoped. In the new format however, M204 T was ignored until this change. To keep backward compatibility, M204 S[acc] will set both print and travel acceleration, which is identical in behavior to recent versions of Marlin. --- Firmware/ConfigurationStore.cpp | 3 ++- Firmware/ConfigurationStore.h | 1 + Firmware/Marlin_main.cpp | 11 +++-------- Firmware/planner.cpp | 3 ++- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index 0bd13a3a1..009a90248 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -184,7 +184,7 @@ static_assert (false, "zprobe_zoffset was not initialized in printers in field t "0.0, if this is not acceptable, increment EEPROM_VERSION to force use default_conf"); #endif -static_assert (sizeof(M500_conf) == 192, "sizeof(M500_conf) has changed, ensure that EEPROM_VERSION has been incremented, " +static_assert (sizeof(M500_conf) == 196, "sizeof(M500_conf) has changed, ensure that EEPROM_VERSION has been incremented, " "or if you added members in the end of struct, ensure that historically uninitialized values will be initialized." "If this is caused by change to more then 8bit processor, decide whether make this struct packed to save EEPROM," "leave as it is to keep fast code, or reorder struct members to pack more tightly."); @@ -232,6 +232,7 @@ static const M500_conf default_conf PROGMEM = #else // TMC2130 {16,16,16,16}, #endif + DEFAULT_TRAVEL_ACCELERATION, }; //! @brief Read M500 configuration diff --git a/Firmware/ConfigurationStore.h b/Firmware/ConfigurationStore.h index b9dca3685..3e3caf725 100644 --- a/Firmware/ConfigurationStore.h +++ b/Firmware/ConfigurationStore.h @@ -38,6 +38,7 @@ typedef struct float max_feedrate_silent[4]; //!< max speeds for silent mode unsigned long max_acceleration_units_per_sq_second_silent[4]; unsigned char axis_ustep_resolution[4]; + float travel_acceleration; //!< travel acceleration mm/s^2 } M500_conf; extern M500_conf cs; diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4e0511c19..f25b5aebf 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7258,7 +7258,7 @@ Sigma_Exit: // 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). - cs.acceleration = code_value(); + cs.acceleration = cs.travel_acceleration = code_value(); // Interpret the T value as retract acceleration in the old Marlin format. if(code_seen('T')) cs.retract_acceleration = code_value(); @@ -7268,13 +7268,8 @@ Sigma_Exit: cs.acceleration = code_value(); if(code_seen('R')) cs.retract_acceleration = code_value(); - if(code_seen('T')) { - // Interpret the T value as the travel acceleration in the new Marlin format. - /*! - @todo Prusa3D firmware currently does not support travel acceleration value independent from the extruding acceleration value. - */ - // travel_acceleration = code_value(); - } + if(code_seen('T')) + cs.travel_acceleration = code_value(); } } break; diff --git a/Firmware/planner.cpp b/Firmware/planner.cpp index 2615ef66e..ba3791ae8 100644 --- a/Firmware/planner.cpp +++ b/Firmware/planner.cpp @@ -1082,7 +1082,8 @@ Having the real displacement of the head, we can calculate the total movement le } else { - block->acceleration_st = ceil(cs.acceleration * steps_per_mm); // convert to: acceleration steps/sec^2 + float acceleration = (block->steps_e.wide == 0? cs.travel_acceleration: cs.acceleration); + block->acceleration_st = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2 #ifdef LIN_ADVANCE /** From 5589954b77dd35042ed743f8aa8d94c2d717d44f Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 20 Sep 2020 19:03:05 +0200 Subject: [PATCH 08/12] Add DEFAULT_TRAVEL_ACCELERATION in all variants Use the same value as DEFAULT_ACCELERATION for compatibility. --- Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h | 3 ++- Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h | 3 ++- Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h | 5 +++-- Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h | 5 +++-- Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h | 5 +++-- Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h | 5 +++-- Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 5 +++-- Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h | 5 +++-- 8 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h index a74b69482..4c20082e9 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h @@ -90,8 +90,9 @@ AXIS SETTINGS #define DEFAULT_MAX_ACCELERATION {9000,9000,500,10000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot. #define DEFAULT_MAX_ACCELERATION_SILENT {960, 960, 200, 5000} // (mm/sec^2) max acceleration (M201), silent mode -#define DEFAULT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves +#define DEFAULT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves #define DEFAULT_RETRACT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for retracts +#define DEFAULT_TRAVEL_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for travels #define MANUAL_FEEDRATE {3000, 3000, 1000, 100} // set the speeds for manual moves (mm/min) diff --git a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h index 72ac605fd..35313a412 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h @@ -90,8 +90,9 @@ AXIS SETTINGS #define DEFAULT_MAX_ACCELERATION {9000,9000,500,10000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot. #define DEFAULT_MAX_ACCELERATION_SILENT {960, 960, 200, 5000} // (mm/sec^2) max acceleration (M201), silent mode -#define DEFAULT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves +#define DEFAULT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves #define DEFAULT_RETRACT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for retracts +#define DEFAULT_TRAVEL_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for travels #define MANUAL_FEEDRATE {3000, 3000, 1000, 100} // set the speeds for manual moves (mm/min) diff --git a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h index ba40e0468..acd7883dd 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h @@ -94,8 +94,9 @@ #define DEFAULT_MAX_ACCELERATION {1000, 1000, 200, 5000} // (mm/sec^2) max acceleration (M201) #define DEFAULT_MAX_ACCELERATION_SILENT {960, 960, 200, 5000} // (mm/sec^2) max acceleration (M201), silent mode -#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204S) -#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204T) +#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204P) +#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204R) +#define DEFAULT_TRAVEL_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for travels (M204T) #define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) diff --git a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h index 33bb47170..ddf7e77a0 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h @@ -95,8 +95,9 @@ #define DEFAULT_MAX_ACCELERATION_SILENT {960, 960, 200, 5000} // (mm/sec^2) max acceleration (M201), silent mode -#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204S) -#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204T) +#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204P) +#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204R) +#define DEFAULT_TRAVEL_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for travels (M204T) #define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) diff --git a/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h index 19b2c76fd..e7b114d96 100644 --- a/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h @@ -94,8 +94,9 @@ #define DEFAULT_MAX_ACCELERATION {1000, 1000, 200, 5000} // (mm/sec^2) max acceleration (M201) #define DEFAULT_MAX_ACCELERATION_SILENT {960, 960, 200, 5000} // (mm/sec^2) max acceleration (M201), silent mode -#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204S) -#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204T) +#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204P) +#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204R) +#define DEFAULT_TRAVEL_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for travels (M204T) #define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) diff --git a/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h index cc02867dd..cde812498 100644 --- a/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h @@ -95,8 +95,9 @@ #define DEFAULT_MAX_ACCELERATION_SILENT {960, 960, 200, 5000} // (mm/sec^2) max acceleration (M201), silent mode -#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204S) -#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204T) +#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204P) +#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204R) +#define DEFAULT_TRAVEL_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for travels (M204T) #define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 65f7ae997..2c62f2fdd 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -99,8 +99,9 @@ #define DEFAULT_MAX_ACCELERATION_SILENT {960, 960, 200, 5000} // (mm/sec^2) max acceleration (M201), silent mode -#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204S) -#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204T) +#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204P) +#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204R) +#define DEFAULT_TRAVEL_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for travels (M204T) #define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h index c7ab7508e..d74d75d54 100644 --- a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -101,8 +101,9 @@ #define DEFAULT_MAX_ACCELERATION_SILENT {960, 960, 200, 5000} // (mm/sec^2) max acceleration (M201), silent mode -#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204S) -#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204T) +#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204P) +#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204R) +#define DEFAULT_TRAVEL_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for travels (M204T) #define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) From 45811f82aa04b58dadd93990298fef36747ea82d Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 20 Sep 2020 19:04:08 +0200 Subject: [PATCH 09/12] Initialize default travel_acceleration from EEPROM When reading uninitialized memory, preset the travel acceleration to be the same as the default acceleration. --- Firmware/ConfigurationStore.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index 009a90248..c8548564a 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -235,6 +235,18 @@ static const M500_conf default_conf PROGMEM = DEFAULT_TRAVEL_ACCELERATION, }; + +static bool is_uninitialized(void* addr, uint8_t len) +{ + while(len--) + { + if(reinterpret_cast(addr)[len] != 0xff) + return false; + } + return true; +} + + //! @brief Read M500 configuration //! @retval true Succeeded. Stored settings retrieved or default settings retrieved in case EEPROM has been erased. //! @retval false Failed. Default settings has been retrieved, because of older version or corrupted data. @@ -294,6 +306,9 @@ bool Config_RetrieveSettings() tmc2130_set_res(E_AXIS, cs.axis_ustep_resolution[E_AXIS]); #endif //TMC2130 + if(is_uninitialized(&cs.travel_acceleration, sizeof(cs.travel_acceleration))) + cs.travel_acceleration = cs.acceleration; + reset_acceleration_rates(); // Call updatePID (similar to when we have processed M301) From 76911f67dbd69c22558beb84f45b85f643515372 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 20 Sep 2020 19:05:19 +0200 Subject: [PATCH 10/12] Take advantage of the new is_uninitialized function Save some space and perform some cleanup --- Firmware/ConfigurationStore.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index c8548564a..dc8126acd 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -270,13 +270,9 @@ bool Config_RetrieveSettings() for (uint8_t i = 0; i < (sizeof(cs.max_feedrate_silent)/sizeof(cs.max_feedrate_silent[0])); ++i) { const uint32_t erased = 0xffffffff; - bool initialized = false; - - for(uint8_t j = 0; j < sizeof(float); ++j) - { - if(0xff != reinterpret_cast(&(cs.max_feedrate_silent[i]))[j]) initialized = true; + if (is_uninitialized(&(cs.max_feedrate_silent[i]), sizeof(float))) { + memcpy_P(&cs.max_feedrate_silent[i],&default_conf.max_feedrate_silent[i], sizeof(cs.max_feedrate_silent[i])); } - if (!initialized) memcpy_P(&cs.max_feedrate_silent[i],&default_conf.max_feedrate_silent[i], sizeof(cs.max_feedrate_silent[i])); if (erased == cs.max_acceleration_units_per_sq_second_silent[i]) { memcpy_P(&cs.max_acceleration_units_per_sq_second_silent[i],&default_conf.max_acceleration_units_per_sq_second_silent[i],sizeof(cs.max_acceleration_units_per_sq_second_silent[i])); } From f7542aa0644b8ea6d9928e8dbe64e527e686599f Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 20 Sep 2020 19:06:15 +0200 Subject: [PATCH 11/12] Report travel acceleration in M503 Use the new M204 format consistently also in M503's output --- Firmware/ConfigurationStore.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index dc8126acd..adccb3999 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -96,7 +96,7 @@ void Config_PrintSettings(uint8_t level) "%SMaximum feedrates - stealth (mm/s):\n%S M203 X%.2f Y%.2f Z%.2f E%.2f\n" "%SMaximum acceleration - normal (mm/s2):\n%S M201 X%lu Y%lu Z%lu E%lu\n" "%SMaximum acceleration - stealth (mm/s2):\n%S M201 X%lu Y%lu Z%lu E%lu\n" - "%SAcceleration: S=acceleration, T=retract acceleration\n%S M204 S%.2f T%.2f\n" + "%SAcceleration: P=print, R=retract, T=travel\n%S M204 P%.2f R%.2f T%.2f\n" "%SAdvanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)\n%S M205 S%.2f T%.2f B%.2f X%.2f Y%.2f Z%.2f E%.2f\n" "%SHome offset (mm):\n%S M206 X%.2f Y%.2f Z%.2f\n" ), @@ -106,7 +106,7 @@ void Config_PrintSettings(uint8_t level) echomagic, echomagic, cs.max_feedrate_silent[X_AXIS], cs.max_feedrate_silent[Y_AXIS], cs.max_feedrate_silent[Z_AXIS], cs.max_feedrate_silent[E_AXIS], echomagic, echomagic, cs.max_acceleration_units_per_sq_second_normal[X_AXIS], cs.max_acceleration_units_per_sq_second_normal[Y_AXIS], cs.max_acceleration_units_per_sq_second_normal[Z_AXIS], cs.max_acceleration_units_per_sq_second_normal[E_AXIS], echomagic, echomagic, cs.max_acceleration_units_per_sq_second_silent[X_AXIS], cs.max_acceleration_units_per_sq_second_silent[Y_AXIS], cs.max_acceleration_units_per_sq_second_silent[Z_AXIS], cs.max_acceleration_units_per_sq_second_silent[E_AXIS], - echomagic, echomagic, cs.acceleration, cs.retract_acceleration, + echomagic, echomagic, cs.acceleration, cs.retract_acceleration, cs.travel_acceleration, echomagic, echomagic, cs.minimumfeedrate, cs.mintravelfeedrate, cs.minsegmenttime, cs.max_jerk[X_AXIS], cs.max_jerk[Y_AXIS], cs.max_jerk[Z_AXIS], cs.max_jerk[E_AXIS], echomagic, echomagic, cs.add_homing[X_AXIS], cs.add_homing[Y_AXIS], cs.add_homing[Z_AXIS] #else //TMC2130 @@ -114,14 +114,14 @@ void Config_PrintSettings(uint8_t level) "%SSteps per unit:\n%S M92 X%.2f Y%.2f Z%.2f E%.2f\n" "%SMaximum feedrates (mm/s):\n%S M203 X%.2f Y%.2f Z%.2f E%.2f\n" "%SMaximum acceleration (mm/s2):\n%S M201 X%lu Y%lu Z%lu E%lu\n" - "%SAcceleration: S=acceleration, T=retract acceleration\n%S M204 S%.2f T%.2f\n" + "%SAcceleration: P=print, R=retract, T=travel\n%S M204 P%.2f R%.2f T%.2f\n" "%SAdvanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)\n%S M205 S%.2f T%.2f B%.2f X%.2f Y%.2f Z%.2f E%.2f\n" "%SHome offset (mm):\n%S M206 X%.2f Y%.2f Z%.2f\n" ), echomagic, echomagic, cs.axis_steps_per_unit[X_AXIS], cs.axis_steps_per_unit[Y_AXIS], cs.axis_steps_per_unit[Z_AXIS], cs.axis_steps_per_unit[E_AXIS], echomagic, echomagic, max_feedrate[X_AXIS], max_feedrate[Y_AXIS], max_feedrate[Z_AXIS], max_feedrate[E_AXIS], echomagic, echomagic, max_acceleration_units_per_sq_second[X_AXIS], max_acceleration_units_per_sq_second[Y_AXIS], max_acceleration_units_per_sq_second[Z_AXIS], max_acceleration_units_per_sq_second[E_AXIS], - echomagic, echomagic, cs.acceleration, cs.retract_acceleration, + echomagic, echomagic, cs.acceleration, cs.retract_acceleration, cs.travel_acceleration, echomagic, echomagic, cs.minimumfeedrate, cs.mintravelfeedrate, cs.minsegmenttime, cs.max_jerk[X_AXIS], cs.max_jerk[Y_AXIS], cs.max_jerk[Z_AXIS], cs.max_jerk[E_AXIS], echomagic, echomagic, cs.add_homing[X_AXIS], cs.add_homing[Y_AXIS], cs.add_homing[Z_AXIS] #endif //TMC2130 From 186ce0f4b32dda9d5a2fa8e0e2649cc130d2cfca Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 1 Feb 2021 00:02:49 +0100 Subject: [PATCH 12/12] Handle acceleration settings in UVLO/power panic Acceleration settings need to be saved in UVLO, since these are often changed/set during a print. This is especially important for travel and retract acceleration, which is usually set once per-print. Saving and restoring is not 100% correct. We save the current front-end value, which might ahead of the backend when UVLO is triggered. Print acceleration, likely the most significant, should be saved in the block buffer to be accurate. Acceleration needs to be restored after the UVLO Z repositioning is performed, using an M204 command. This is correct, however we don't save the _temporary_ max acceleration limits set via M201, which could be higher than the saved limits (via M500). This could result in lower clamped values compared to the original print. Maximum acceleration/jerk/feedrate limits should _all_ be saved in UVLO in the future. --- Firmware/Marlin_main.cpp | 11 +++++++++++ Firmware/eeprom.h | 11 +++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f25b5aebf..780a0bca3 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -10963,6 +10963,10 @@ void uvlo_() #endif eeprom_update_word((uint16_t*)(EEPROM_EXTRUDEMULTIPLY), (uint16_t)extrudemultiply); + eeprom_update_float((float*)(EEPROM_UVLO_ACCELL), cs.acceleration); + eeprom_update_float((float*)(EEPROM_UVLO_RETRACT_ACCELL), cs.retract_acceleration); + eeprom_update_float((float*)(EEPROM_UVLO_TRAVEL_ACCELL), cs.travel_acceleration); + // Store the saved target eeprom_update_float((float*)(EEPROM_UVLO_SAVED_TARGET+0*4), saved_target[X_AXIS]); eeprom_update_float((float*)(EEPROM_UVLO_SAVED_TARGET+1*4), saved_target[Y_AXIS]); @@ -11307,6 +11311,13 @@ void restore_print_from_eeprom(bool mbl_was_active) { sprintf_P(cmd, PSTR("G1 Z%f"), eeprom_read_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z))); enquecommand(cmd); + // Restore acceleration settings + float acceleration = eeprom_read_float((float*)(EEPROM_UVLO_ACCELL)); + float retract_acceleration = eeprom_read_float((float*)(EEPROM_UVLO_RETRACT_ACCELL)); + float travel_acceleration = eeprom_read_float((float*)(EEPROM_UVLO_TRAVEL_ACCELL)); + sprintf_P(cmd, PSTR("M204 P%f R%f T%f"), acceleration, retract_acceleration, travel_acceleration); + enquecommand(cmd); + // Unretract. sprintf_P(cmd, PSTR("G1 E%0.3f F2700"), default_retraction); enquecommand(cmd); diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 03af214f2..f9f93b7d8 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -319,8 +319,10 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | ^ | ^ | ^ | 00h 0 | ^ | PINDA has no temp compensation PINDA v1/2 | ^ | ^ | ^ | ^ | ^ | 01h 1 | ^ | PINDA has temp compensation aka SuperPINDA | ^ | ^ | 0x0D15 3349 | char[20] | EEPROM_PRUSA_SN | SN[19] == 0 | ffffffffffffffff... | PRUSA Serial number string | PRUSA SN | D3 Ax0d15 C20 +| 0x0D11 3345 | float | EEPROM_UVLO_ACCELL | ??? | ff ff ff ffh | Power panic saved normal acceleration | ??? | D3 Ax0d11 C4 +| 0x0D0D 3341 | float | EEPROM_UVLO_RETRACT_ACCELL | ??? | ff ff ff ffh | Power panic saved retract acceleration | ??? | D3 Ax0d0d C4 +| 0x0D09 3337 | float | EEPROM_UVLO_TRAVEL_ACCELL | ??? | ff ff ff ffh | Power panic saved travel acceleration | ??? | D3 Ax0d09 C4 - | Address begin | Bit/Type | Name | Valid values | Default/FactoryReset | Description | Gcode/Function| Debug code | :--: | :--: | :--: | :--: | :--: | :--: | :--: | :--: | 0x0012 18 | uint16 | EEPROM_FIRMWARE_VERSION_END | ??? | ff ffh 65535 | ??? | ??? | D3 Ax0012 C2 @@ -525,8 +527,13 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE); #define EEPROM_EXPERIMENTAL_VISIBILITY (EEPROM_ALTFAN_OVERRIDE-1) //uint8 #define EEPROM_PINDA_TEMP_COMPENSATION (EEPROM_EXPERIMENTAL_VISIBILITY-1) //uint8 #define EEPROM_PRUSA_SN (EEPROM_PINDA_TEMP_COMPENSATION-20) //char[20] + +#define EEPROM_UVLO_ACCELL (EEPROM_PRUSA_SN-4) // float +#define EEPROM_UVLO_RETRACT_ACCELL (EEPROM_UVLO_ACCELL-4) // float +#define EEPROM_UVLO_TRAVEL_ACCELL (EEPROM_UVLO_RETRACT_ACCELL-4) // float + //This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items. -#define EEPROM_LAST_ITEM EEPROM_PRUSA_SN +#define EEPROM_LAST_ITEM EEPROM_UVLO_TRAVEL_ACCELL // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!!