From 1df91e56565dd66857a4843dc1966c8537708c52 Mon Sep 17 00:00:00 2001 From: Christoph Stahl Date: Fri, 9 Mar 2018 20:46:07 +0100 Subject: [PATCH 01/38] MK3 Add Gcode to wait for minimum PINDA temp The PINDA temperature compensation is defined for values above 35C. To achieve an optimal first layer consistently it is vital to start the print with a temperature of >= 35C on the pinda probe. When doing a manual pinda temperature calibration it is necessary to begin homing and mesh bed leveling at an exact temperature. This gcode is perfect for this. Example startup code: G28 W ; home all without mesh bed level G0 Z50 ; raise Z to not heat PINDA before bed is warm M104 S215 ; set extruder temp M140 S60 ; set bed temp M190 S60 ; wait for bed temp M109 S215 ; wait for extruder temp G0 X50 Y50 Z0.15 ; this is a good PINDA heating position M666 S35 ; the new code - wait until PINDA is >= 35C G28 W ; home all without mesh bed level G80 ; mesh bed leveling See my forum post later for more explaination on my manual temperature calibration procedure. I will link it then. --- Firmware/Marlin_main.cpp | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 7360ab9a..1d6a47e6 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -226,6 +226,7 @@ // M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] // M605 - Set dual x-carriage movement mode: S [ X R ] +// M666 - Wait for PINDA thermistor to reach target temperature. // M900 - Set LIN_ADVANCE options, if enabled. See Configuration_adv.h for details. // M907 - Set digital trimpot motor current using axis codes. // M908 - Control digital trimpot directly. @@ -4806,6 +4807,48 @@ Sigma_Exit: #endif break; +#ifdef PINDA_THERMISTOR +case 666: // M666 - Wait for PINDA thermistor to reach target temperature. + { + int setTargetPinda = 0; + + if (code_seen('S')) { + setTargetPinda = code_value(); + } else { + break; + } + + LCD_MESSAGERPGM(MSG_PLEASE_WAIT); + + SERIAL_PROTOCOLPGM("Wait for PINDA target temperature:"); + SERIAL_PROTOCOL(setTargetPinda); + SERIAL_PROTOCOLLN(""); + + codenum = millis(); + cancel_heatup = false; + + KEEPALIVE_STATE(NOT_BUSY); + + while ( (!cancel_heatup) && current_temperature_pinda < setTargetPinda) { + if(( millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while waiting. + { + SERIAL_PROTOCOLPGM("P:"); + SERIAL_PROTOCOL_F(current_temperature_pinda,1); + SERIAL_PROTOCOLPGM("/"); + SERIAL_PROTOCOL(setTargetPinda); + SERIAL_PROTOCOLLN(""); + codenum = millis(); + } + manage_heater(); + manage_inactivity(); + lcd_update(); + } + LCD_MESSAGERPGM(MSG_OK); + + break; + } +#endif //PINDA_THERMISTOR + #if defined(FAN_PIN) && FAN_PIN > -1 case 106: //M106 Fan On if (code_seen('S')){ From 02fda70529573aafec9350c8fd9b6f7f42079bfc Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 10 Apr 2018 14:07:44 +0200 Subject: [PATCH 02/38] farm mode: preheat menu updated --- Firmware/Configuration_prusa.h | 2 +- Firmware/ultralcd.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Firmware/Configuration_prusa.h b/Firmware/Configuration_prusa.h index 9279dbf4..216990f4 100644 --- a/Firmware/Configuration_prusa.h +++ b/Firmware/Configuration_prusa.h @@ -462,7 +462,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o *------------------------------------*/ #define FARM_PREHEAT_HOTEND_TEMP 250 -#define FARM_PREHEAT_HPB_TEMP 40 +#define FARM_PREHEAT_HPB_TEMP 60 #define FARM_PREHEAT_FAN_SPEED 0 #define PLA_PREHEAT_HOTEND_TEMP 215 diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 7e4a742e..e67549f6 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1752,10 +1752,10 @@ static void lcd_preheat_menu() MENU_ITEM(back, MSG_MAIN, 0); if (farm_mode) { - MENU_ITEM(function, PSTR("farm - " STRINGIFY(FARM_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(FARM_PREHEAT_HPB_TEMP)), lcd_preheat_farm); - MENU_ITEM(function, PSTR("nozzle - " STRINGIFY(FARM_PREHEAT_HOTEND_TEMP) "/0"), lcd_preheat_farm_nozzle); + MENU_ITEM(function, PSTR("farm - " STRINGIFY(FARM_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(FARM_PREHEAT_HPB_TEMP)), lcd_preheat_farm); + MENU_ITEM(function, PSTR("nozzle - " STRINGIFY(FARM_PREHEAT_HOTEND_TEMP) "/0"), lcd_preheat_farm_nozzle); MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown); - MENU_ITEM(function, PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)), lcd_preheat_abs); + MENU_ITEM(function, PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)), lcd_preheat_abs); } else { MENU_ITEM(function, PSTR("PLA - " STRINGIFY(PLA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PLA_PREHEAT_HPB_TEMP)), lcd_preheat_pla); MENU_ITEM(function, PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PET_PREHEAT_HPB_TEMP)), lcd_preheat_pet); From 8da2330b935aeddd4276f13472d1ef59e2acb06d Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Wed, 11 Apr 2018 16:03:54 +0200 Subject: [PATCH 03/38] FSensor PAT9125 - i2c ACK check + two attempts in init function (PFW). ultralcd_implementation_hitachi - fixed link --- Firmware/fsensor.cpp | 26 ++++++++++++---- Firmware/pat9125.cpp | 31 ++++++++++++++++++- .../ultralcd_implementation_hitachi_HD44780.h | 2 +- 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 359d2e10..bebcf810 100644 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -63,7 +63,7 @@ bool fsensor_enable() { // puts_P(PSTR("fsensor_enable\n")); int pat9125 = pat9125_init(); -// printf_P(PSTR("PAT9125_init:%d\n"), pat9125); + printf_P(PSTR("PAT9125_init:%d\n"), pat9125); if (pat9125) fsensor_not_responding = false; else @@ -74,6 +74,7 @@ bool fsensor_enable() fsensor_err_cnt = 0; eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, fsensor_enabled?0x01:0x00); FSensorStateMenu = fsensor_enabled?1:0; +// printf_P(PSTR("fsensor_enable - end %d\n"), fsensor_enabled?1:0); return fsensor_enabled; } @@ -108,7 +109,14 @@ void fsensor_setup_interrupt() void fsensor_autoload_check_start(void) { // puts_P(PSTR("fsensor_autoload_check_start\n")); - pat9125_update_y(); //update sensor + if (!pat9125_update_y()) //update sensor + { + puts_P(PSTR("pat9125 not responding (3).\n")); + fsensor_disable(); + fsensor_not_responding = true; + fsensor_autoload_enabled = false; + return; + } fsensor_autoload_y = pat9125_y; //save current y value fsensor_autoload_c = 0; //reset number of changes counter fsensor_autoload_sum = 0; @@ -130,7 +138,13 @@ bool fsensor_check_autoload(void) uint8_t fsensor_autoload_c_old = fsensor_autoload_c; if ((millis() - fsensor_autoload_last_millis) < 25) return false; fsensor_autoload_last_millis = millis(); - pat9125_update_y(); //update sensor + if (!pat9125_update_y()) + { + puts_P(PSTR("pat9125 not responding (2).\n")); + fsensor_disable(); + fsensor_not_responding = true; + return false; //update sensor + } int16_t dy = fsensor_autoload_y - pat9125_y; if (dy) //? y value is different { @@ -170,9 +184,9 @@ ISR(PCINT2_vect) *digitalPinToPCMSK(fsensor_int_pin) |= bit(digitalPinToPCMSKbit(fsensor_int_pin));*/ if (!pat9125_update_y()) { -#ifdef DEBUG_FSENSOR_LOG - puts_P(PSTR("pat9125 not responding.\n")); -#endif //DEBUG_FSENSOR_LOG +//#ifdef DEBUG_FSENSOR_LOG + puts_P(PSTR("pat9125 not responding (1).\n")); +//#endif //DEBUG_FSENSOR_LOG fsensor_disable(); fsensor_not_responding = true; } diff --git a/Firmware/pat9125.cpp b/Firmware/pat9125.cpp index 9af8e03a..4894c85f 100755 --- a/Firmware/pat9125.cpp +++ b/Firmware/pat9125.cpp @@ -92,7 +92,10 @@ int pat9125_init() // pat9125_PID2 = 0x91; if ((pat9125_PID1 != 0x31) || (pat9125_PID2 != 0x91)) { - return 0; + pat9125_PID1 = pat9125_rd_reg(PAT9125_PID1); + pat9125_PID2 = pat9125_rd_reg(PAT9125_PID2); + if ((pat9125_PID1 != 0x31) || (pat9125_PID2 != 0x91)) + return 0; } // Switch to bank0, not allowed to perform OTS_RegWriteRead. pat9125_wr_reg(PAT9125_BANK_SELECTION, 0); @@ -132,6 +135,9 @@ int pat9125_init() pat9125_wr_reg(PAT9125_BANK_SELECTION, 0x00); // Enable write protect. pat9125_wr_reg(PAT9125_WP, 0x00); + + pat9125_PID1 = pat9125_rd_reg(PAT9125_PID1); + pat9125_PID2 = pat9125_rd_reg(PAT9125_PID2); return 1; } @@ -142,11 +148,13 @@ int pat9125_update() unsigned char ucMotion = pat9125_rd_reg(PAT9125_MOTION); pat9125_b = pat9125_rd_reg(PAT9125_FRAME); pat9125_s = pat9125_rd_reg(PAT9125_SHUTTER); + if (pat9125_PID1 == 0xff) return 0; if (ucMotion & 0x80) { unsigned char ucXL = pat9125_rd_reg(PAT9125_DELTA_XL); unsigned char ucYL = pat9125_rd_reg(PAT9125_DELTA_YL); unsigned char ucXYH = pat9125_rd_reg(PAT9125_DELTA_XYH); + if (pat9125_PID1 == 0xff) return 0; int iDX = ucXL | ((ucXYH << 4) & 0xf00); int iDY = ucYL | ((ucXYH << 8) & 0xf00); if (iDX & 0x800) iDX -= 4096; @@ -164,10 +172,12 @@ int pat9125_update_y() if ((pat9125_PID1 == 0x31) && (pat9125_PID2 == 0x91)) { unsigned char ucMotion = pat9125_rd_reg(PAT9125_MOTION); + if (pat9125_PID1 == 0xff) return 0; if (ucMotion & 0x80) { unsigned char ucYL = pat9125_rd_reg(PAT9125_DELTA_YL); unsigned char ucXYH = pat9125_rd_reg(PAT9125_DELTA_XYH); + if (pat9125_PID1 == 0xff) return 0; int iDY = ucYL | ((ucXYH << 8) & 0xf00); if (iDY & 0x800) iDY -= 4096; pat9125_y -= iDY; //negative number, because direction switching does not work @@ -179,6 +189,7 @@ int pat9125_update_y() unsigned char pat9125_rd_reg(unsigned char addr) { +// printf_P(PSTR("pat9125_rd_reg 0x%hhx "), addr); unsigned char data = 0; #ifdef PAT9125_SWSPI swspi_start(); @@ -188,6 +199,14 @@ unsigned char pat9125_rd_reg(unsigned char addr) #endif //PAT9125_SWSPI #ifdef PAT9125_SWI2C int iret = swi2c_readByte_A8(PAT9125_I2C_ADDR, addr, &data); + if (!iret) //NO ACK error + { + pat9125_PID1 = 0xff; + pat9125_PID2 = 0xff; +// printf_P(PSTR("ERR\n")); + return 0; + } +// printf_P(PSTR("0x%hhx OK\n"), data); #endif //PAT9125_SWI2C #ifdef PAT9125_HWI2C Wire.beginTransmission(PAT9125_I2C_ADDR); @@ -202,6 +221,7 @@ unsigned char pat9125_rd_reg(unsigned char addr) void pat9125_wr_reg(unsigned char addr, unsigned char data) { +// printf_P(PSTR("pat9125_wr_reg 0x%hhx 0x%hhx "), addr, data); #ifdef PAT9125_SWSPI swspi_start(); swspi_tx(addr | 0x80); @@ -210,6 +230,15 @@ void pat9125_wr_reg(unsigned char addr, unsigned char data) #endif //PAT9125_SWSPI #ifdef PAT9125_SWI2C int iret = swi2c_writeByte_A8(PAT9125_I2C_ADDR, addr, &data); + if (!iret) //NO ACK error + { + pat9125_PID1 = 0xff; + pat9125_PID2 = 0xff; +// printf_P(PSTR("ERR\n")); + return; + } +// printf_P(PSTR("OK\n")); + #endif //PAT9125_SWI2C #ifdef PAT9125_HWI2C Wire.beginTransmission(PAT9125_I2C_ADDR); diff --git a/Firmware/ultralcd_implementation_hitachi_HD44780.h b/Firmware/ultralcd_implementation_hitachi_HD44780.h index 60e6ed07..cfffeb36 100644 --- a/Firmware/ultralcd_implementation_hitachi_HD44780.h +++ b/Firmware/ultralcd_implementation_hitachi_HD44780.h @@ -194,7 +194,7 @@ extern volatile uint16_t buttons; //an extended version of the last checked but LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT); // 2 wire Non-latching LCD SR from: -// https://bitbucket.org/fmalpartida/new-LiquidCrystal_Prusa/wiki/schematics#!shiftregister-connection +// https://bitbucket.org/fmalpartida/new-LiquidCrystal/wiki/schematics#!shiftregister-connection #elif defined(SR_LCD_2W_NL) extern "C" void __cxa_pure_virtual() { while (1); } From 919fba531a6d8d347c2a28e977010ce8aba63106 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 11 Apr 2018 16:48:47 +0200 Subject: [PATCH 04/38] wait for PINDA gcode changed --- Firmware/Marlin_main.cpp | 87 ++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index dbbca14d..f1c17588 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -232,7 +232,7 @@ // M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] // M605 - Set dual x-carriage movement mode: S [ X R ] -// M666 - Wait for PINDA thermistor to reach target temperature. +// M860 - Wait for PINDA thermistor to reach target temperature. // M900 - Set LIN_ADVANCE options, if enabled. See Configuration_adv.h for details. // M907 - Set digital trimpot motor current using axis codes. // M908 - Control digital trimpot directly. @@ -4968,48 +4968,6 @@ Sigma_Exit: #endif break; -#ifdef PINDA_THERMISTOR -case 666: // M666 - Wait for PINDA thermistor to reach target temperature. - { - int setTargetPinda = 0; - - if (code_seen('S')) { - setTargetPinda = code_value(); - } else { - break; - } - - LCD_MESSAGERPGM(MSG_PLEASE_WAIT); - - SERIAL_PROTOCOLPGM("Wait for PINDA target temperature:"); - SERIAL_PROTOCOL(setTargetPinda); - SERIAL_PROTOCOLLN(""); - - codenum = millis(); - cancel_heatup = false; - - KEEPALIVE_STATE(NOT_BUSY); - - while ( (!cancel_heatup) && current_temperature_pinda < setTargetPinda) { - if(( millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while waiting. - { - SERIAL_PROTOCOLPGM("P:"); - SERIAL_PROTOCOL_F(current_temperature_pinda,1); - SERIAL_PROTOCOLPGM("/"); - SERIAL_PROTOCOL(setTargetPinda); - SERIAL_PROTOCOLLN(""); - codenum = millis(); - } - manage_heater(); - manage_inactivity(); - lcd_update(); - } - LCD_MESSAGERPGM(MSG_OK); - - break; - } -#endif //PINDA_THERMISTOR - #if defined(FAN_PIN) && FAN_PIN > -1 case 106: //M106 Fan On if (code_seen('S')){ @@ -6264,6 +6222,49 @@ case 666: // M666 - Wait for PINDA thermistor to reach target temperature. } break; +#ifdef PINDA_THERMISTOR + case 860: // M860 - Wait for PINDA thermistor to reach target temperature. + { + int setTargetPinda = 0; + + if (code_seen('S')) { + setTargetPinda = code_value(); + } + else { + break; + } + + LCD_MESSAGERPGM(MSG_PLEASE_WAIT); + + SERIAL_PROTOCOLPGM("Wait for PINDA target temperature:"); + SERIAL_PROTOCOL(setTargetPinda); + SERIAL_PROTOCOLLN(""); + + codenum = millis(); + cancel_heatup = false; + + KEEPALIVE_STATE(NOT_BUSY); + + while ((!cancel_heatup) && current_temperature_pinda < setTargetPinda) { + if ((millis() - codenum) > 1000) //Print Temp Reading every 1 second while waiting. + { + SERIAL_PROTOCOLPGM("P:"); + SERIAL_PROTOCOL_F(current_temperature_pinda, 1); + SERIAL_PROTOCOLPGM("/"); + SERIAL_PROTOCOL(setTargetPinda); + SERIAL_PROTOCOLLN(""); + codenum = millis(); + } + manage_heater(); + manage_inactivity(); + lcd_update(); + } + LCD_MESSAGERPGM(MSG_OK); + + break; + } +#endif //PINDA_THERMISTOR + #ifdef LIN_ADVANCE case 900: // M900: Set LIN_ADVANCE options. gcode_M900(); From 89efcb84b1ee8600261641c89fabf1e12cc74b3d Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Wed, 11 Apr 2018 17:32:31 +0200 Subject: [PATCH 05/38] removed Configuration_prusa.h fixed - compilation for MK25 --- Firmware/Configuration_prusa.h | 616 --------------------------------- Firmware/Marlin_main.cpp | 4 +- 2 files changed, 2 insertions(+), 618 deletions(-) delete mode 100644 Firmware/Configuration_prusa.h diff --git a/Firmware/Configuration_prusa.h b/Firmware/Configuration_prusa.h deleted file mode 100644 index 3f12358f..00000000 --- a/Firmware/Configuration_prusa.h +++ /dev/null @@ -1,616 +0,0 @@ -#ifndef CONFIGURATION_PRUSA_H -#define CONFIGURATION_PRUSA_H - -/*------------------------------------ - GENERAL SETTINGS - *------------------------------------*/ - -// Printer revision -#define PRINTER_TYPE PRINTER_MK3 -#define FILAMENT_SIZE "1_75mm_MK3" -#define NOZZLE_TYPE "E3Dv6full" - -// Developer flag -#define DEVELOPER - -// Printer name -#define CUSTOM_MENDEL_NAME "Prusa i3 MK3" - -// Electronics -#define MOTHERBOARD BOARD_EINSY_1_0a -#define STEEL_SHEET -#define HAS_SECOND_SERIAL_PORT - - -// Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier) -//#define E3D_PT100_EXTRUDER_WITH_AMP -//#define E3D_PT100_EXTRUDER_NO_AMP -//#define E3D_PT100_BED_WITH_AMP -//#define E3D_PT100_BED_NO_AMP - - -/*------------------------------------ - AXIS SETTINGS - *------------------------------------*/ - -// Steps per unit {X,Y,Z,E} -//#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,140} -#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,280} -//#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,560} - -// Endstop inverting -const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. -const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. -const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. - -// Direction inverting -#define INVERT_X_DIR true // for Mendel set to false, for Orca set to true -#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false -#define INVERT_Z_DIR true // for Mendel set to false, for Orca set to true -#define INVERT_E0_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false -#define INVERT_E1_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false -#define INVERT_E2_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false - -// Home position -#define MANUAL_X_HOME_POS 0 -#define MANUAL_Y_HOME_POS -2.2 -#define MANUAL_Z_HOME_POS 0.2 - -// Travel limits after homing -#define X_MAX_POS 255 -#define X_MIN_POS 0 -#define Y_MAX_POS 210 -#define Y_MIN_POS -4 //orig -4 -#define Z_MAX_POS 210 -#define Z_MIN_POS 0.15 - -// Canceled home position -#define X_CANCEL_POS 50 -#define Y_CANCEL_POS 190 - -//Pause print position -#define X_PAUSE_POS 50 -#define Y_PAUSE_POS 190 -#define Z_PAUSE_LIFT 20 - -#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E -#define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000 - -#define DEFAULT_MAX_FEEDRATE {200, 200, 12, 120} // (mm/sec) max feedrate (M203) -#define DEFAULT_MAX_ACCELERATION {1000, 1000, 200, 5000} // (mm/sec^2) max acceleration (M201) - - -#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 MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min) - -//Silent mode limits -#define SILENT_MAX_ACCEL 960 // max axxeleration in silent mode in mm/s^2 -#define SILENT_MAX_ACCEL_ST (100*SILENT_MAX_ACCEL) // max accel in steps/s^2 -#define SILENT_MAX_FEEDRATE 172 //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min) - -//Normal mode limits -#define NORMAL_MAX_ACCEL 2500 // Y-axis max axxeleration in normal mode in mm/s^2 -#define NORMAL_MAX_ACCEL_ST (100*NORMAL_MAX_ACCEL) // max accel in steps/s^2 -#define NORMAL_MAX_FEEDRATE 200 //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min) - -//#define SIMPLE_ACCEL_LIMIT //new limitation method for normal/silent - -//number of bytes from end of the file to start check -#define END_FILE_SECTION 10000 - -#define Z_AXIS_ALWAYS_ON 1 - -// Automatic recovery after crash is detected -#define AUTOMATIC_RECOVERY_AFTER_CRASH - -// New XYZ calibration -#define NEW_XYZCAL - -// Do not use Arduino SPI -#define NEW_SPI - -// Watchdog support -#define WATCHDOG - -// Power panic -#define UVLO_SUPPORT - -// Fan check -#define FANCHECK - -// Safety timer -#define SAFETYTIMER - -// Filament sensor -#define PAT9125 - - -// Disable some commands -#define _DISABLE_M42_M226 - -// Minimum ambient temperature limit to start triggering MINTEMP errors [C] -// this value is litlebit higher that real limit, because ambient termistor is on the board and is temperated from it, -// temperature inside the case is around 31C for ambient temperature 25C, when the printer is powered on long time and idle -// the real limit is 15C (same as MINTEMP limit), this is because 15C is end of scale for both used thermistors (bed, heater) -#define MINTEMP_MINAMBIENT 25 -#define MINTEMP_MINAMBIENT_RAW 978 - -//#define DEBUG_BUILD -#ifdef DEBUG_BUILD -//#define _NO_ASM -#define DEBUG_DCODES //D codes -#define DEBUG_STACK_MONITOR //Stack monitor in stepper ISR -//#define DEBUG_FSENSOR_LOG //Reports fsensor status to serial -//#define DEBUG_CRASHDET_COUNTERS //Display crash-detection counters on LCD -//#define DEBUG_RESUME_PRINT //Resume/save print debug enable -//#define DEBUG_UVLO_AUTOMATIC_RECOVER // Power panic automatic recovery debug output -//#define DEBUG_DISABLE_XMINLIMIT //x min limit ignored -//#define DEBUG_DISABLE_XMAXLIMIT //x max limit ignored -//#define DEBUG_DISABLE_YMINLIMIT //y min limit ignored -//#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored -//#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored -//#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored -#define DEBUG_DISABLE_STARTMSGS //no startup messages -//#define DEBUG_DISABLE_MINTEMP //mintemp error ignored -//#define DEBUG_DISABLE_SWLIMITS //sw limits ignored -//#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line -//#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed -//#define DEBUG_DISABLE_PRUSA_STATISTICS //disable prusa_statistics() mesages -//#define DEBUG_DISABLE_FORCE_SELFTEST //disable force selftest -//#define DEBUG_XSTEP_DUP_PIN 21 //duplicate x-step output to pin 21 (SCL on P3) -//#define DEBUG_YSTEP_DUP_PIN 21 //duplicate y-step output to pin 21 (SCL on P3) -//#define DEBUG_BLINK_ACTIVE -//#define DEBUG_DISABLE_FANCHECK //disable fan check (no ISR INT7, check disabled) -//#define DEBUG_DISABLE_FSENSORCHECK //disable fsensor check (no ISR INT7, check disabled) -#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line -#define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message. -#define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display. -#endif /* DEBUG_BUILD */ - -//#define EXPERIMENTAL_FEATURES -#define TMC2130_LINEARITY_CORRECTION -//#define TMC2130_VARIABLE_RESOLUTION - - - -/*------------------------------------ - TMC2130 default settings - *------------------------------------*/ - -#define TMC2130_FCLK 12000000 // fclk = 12MHz - -#define TMC2130_USTEPS_XY 16 // microstep resolution for XY axes -#define TMC2130_USTEPS_Z 16 // microstep resolution for Z axis -#define TMC2130_USTEPS_E 32 // microstep resolution for E axis -#define TMC2130_INTPOL_XY 1 // extrapolate 256 for XY axes -#define TMC2130_INTPOL_Z 1 // extrapolate 256 for Z axis -#define TMC2130_INTPOL_E 1 // extrapolate 256 for E axis - -#define TMC2130_PWM_GRAD_X 2 // PWMCONF -#define TMC2130_PWM_AMPL_X 230 // PWMCONF -#define TMC2130_PWM_AUTO_X 1 // PWMCONF -#define TMC2130_PWM_FREQ_X 2 // PWMCONF - -#define TMC2130_PWM_GRAD_Y 2 // PWMCONF -#define TMC2130_PWM_AMPL_Y 235 // PWMCONF -#define TMC2130_PWM_AUTO_Y 1 // PWMCONF -#define TMC2130_PWM_FREQ_Y 2 // PWMCONF - -#define TMC2130_PWM_GRAD_E 2 // PWMCONF -#define TMC2130_PWM_AMPL_E 235 // PWMCONF -#define TMC2130_PWM_AUTO_E 1 // PWMCONF -#define TMC2130_PWM_FREQ_E 2 // PWMCONF - -#define TMC2130_PWM_GRAD_Z 4 // PWMCONF -#define TMC2130_PWM_AMPL_Z 200 // PWMCONF -#define TMC2130_PWM_AUTO_Z 1 // PWMCONF -#define TMC2130_PWM_FREQ_Z 2 // PWMCONF - -#define TMC2130_PWM_GRAD_E 4 // PWMCONF -#define TMC2130_PWM_AMPL_E 240 // PWMCONF -#define TMC2130_PWM_AUTO_E 1 // PWMCONF -#define TMC2130_PWM_FREQ_E 2 // PWMCONF - -#define TMC2130_TOFF_XYZ 3 // CHOPCONF // fchop = 27.778kHz -#define TMC2130_TOFF_E 3 // CHOPCONF // fchop = 27.778kHz -//#define TMC2130_TOFF_E 4 // CHOPCONF // fchop = 21.429kHz -//#define TMC2130_TOFF_E 5 // CHOPCONF // fchop = 17.442kHz - -//#define TMC2130_STEALTH_E // Extruder stealthChop mode -//#define TMC2130_CNSTOFF_E // Extruder constant-off-time mode (similar to MK2) - -//#define TMC2130_PWM_DIV 683 // PWM frequency divider (1024, 683, 512, 410) -#define TMC2130_PWM_DIV 512 // PWM frequency divider (1024, 683, 512, 410) -#define TMC2130_PWM_CLK (2 * TMC2130_FCLK / TMC2130_PWM_DIV) // PWM frequency (23.4kHz, 35.1kHz, 46.9kHz, 58.5kHz for 12MHz fclk) - -#define TMC2130_TPWMTHRS 0 // TPWMTHRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode -#define TMC2130_THIGH 0 // THIGH - unused - -//#define TMC2130_TCOOLTHRS_X 450 // TCOOLTHRS - coolstep treshold -//#define TMC2130_TCOOLTHRS_Y 450 // TCOOLTHRS - coolstep treshold -#define TMC2130_TCOOLTHRS_X 430 // TCOOLTHRS - coolstep treshold -#define TMC2130_TCOOLTHRS_Y 430 // TCOOLTHRS - coolstep treshold -#define TMC2130_TCOOLTHRS_Z 500 // TCOOLTHRS - coolstep treshold -#define TMC2130_TCOOLTHRS_E 500 // TCOOLTHRS - coolstep treshold - -#define TMC2130_SG_HOMING 1 // stallguard homing -#define TMC2130_SG_THRS_X 3 // stallguard sensitivity for X axis -#define TMC2130_SG_THRS_Y 3 // stallguard sensitivity for Y axis -#define TMC2130_SG_THRS_Z 3 // stallguard sensitivity for Z axis -#define TMC2130_SG_THRS_E 3 // stallguard sensitivity for E axis - -//new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only) -#define TMC2130_CURRENTS_H {16, 20, 28, 36} // default holding currents for all axes -#define TMC2130_CURRENTS_R {16, 20, 28, 36} // default running currents for all axes -#define TMC2130_UNLOAD_CURRENT_R 12 // lowe current for M600 to protect filament sensor - -#define TMC2130_STEALTH_Z - -//#define TMC2130_DEBUG -//#define TMC2130_DEBUG_WR -//#define TMC2130_DEBUG_RD - - -/*------------------------------------ - EXTRUDER SETTINGS - *------------------------------------*/ - -// Mintemps -#define HEATER_0_MINTEMP 15 -#define HEATER_1_MINTEMP 5 -#define HEATER_2_MINTEMP 5 -#define BED_MINTEMP 15 - -// Maxtemps -#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) -#define HEATER_0_MAXTEMP 410 -#else -#define HEATER_0_MAXTEMP 305 -#endif -#define HEATER_1_MAXTEMP 305 -#define HEATER_2_MAXTEMP 305 -#define BED_MAXTEMP 125 - -#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) -// Define PID constants for extruder with PT100 -#define DEFAULT_Kp 21.70 -#define DEFAULT_Ki 1.60 -#define DEFAULT_Kd 73.76 -#else -// Define PID constants for extruder -//#define DEFAULT_Kp 40.925 -//#define DEFAULT_Ki 4.875 -//#define DEFAULT_Kd 86.085 -#define DEFAULT_Kp 16.13 -#define DEFAULT_Ki 1.1625 -#define DEFAULT_Kd 56.23 -#endif - -// Extrude mintemp -#define EXTRUDE_MINTEMP 190 - -// Extruder cooling fans -#define EXTRUDER_0_AUTO_FAN_PIN 8 -#define EXTRUDER_1_AUTO_FAN_PIN -1 -#define EXTRUDER_2_AUTO_FAN_PIN -1 -#define EXTRUDER_AUTO_FAN_TEMPERATURE 50 -#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed - - - -/*------------------------------------ - LOAD/UNLOAD FILAMENT SETTINGS - *------------------------------------*/ - -// Load filament commands -#define LOAD_FILAMENT_0 "M83" -#define LOAD_FILAMENT_1 "G1 E70 F400" -#define LOAD_FILAMENT_2 "G1 E40 F100" - -// Unload filament commands -#define UNLOAD_FILAMENT_0 "M83" -#define UNLOAD_FILAMENT_1 "G1 E-80 F7000" - -/*------------------------------------ - CHANGE FILAMENT SETTINGS - *------------------------------------*/ - -// Filament change configuration -#define FILAMENTCHANGEENABLE -#ifdef FILAMENTCHANGEENABLE -#define FILAMENTCHANGE_XPOS 211 -#define FILAMENTCHANGE_YPOS 0 -#define FILAMENTCHANGE_ZADD 2 -#define FILAMENTCHANGE_FIRSTRETRACT -2 -#define FILAMENTCHANGE_FINALRETRACT -80 - -#define FILAMENTCHANGE_FIRSTFEED 70 -#define FILAMENTCHANGE_FINALFEED 50 -#define FILAMENTCHANGE_RECFEED 5 - -#define FILAMENTCHANGE_XYFEED 50 -#define FILAMENTCHANGE_EFEED 20 -//#define FILAMENTCHANGE_RFEED 400 -#define FILAMENTCHANGE_RFEED 7000 / 60 -#define FILAMENTCHANGE_EXFEED 2 -#define FILAMENTCHANGE_ZFEED 15 - -#endif - -/*------------------------------------ - ADDITIONAL FEATURES SETTINGS - *------------------------------------*/ - -// Define Prusa filament runout sensor -//#define FILAMENT_RUNOUT_SUPPORT - -#ifdef FILAMENT_RUNOUT_SUPPORT -#define FILAMENT_RUNOUT_SENSOR 1 -#endif - -// temperature runaway -#define TEMP_RUNAWAY_BED_HYSTERESIS 5 -#define TEMP_RUNAWAY_BED_TIMEOUT 360 - -#define TEMP_RUNAWAY_EXTRUDER_HYSTERESIS 15 -#define TEMP_RUNAWAY_EXTRUDER_TIMEOUT 45 - -/*------------------------------------ - MOTOR CURRENT SETTINGS - *------------------------------------*/ - -// Motor Current setting for BIG RAMBo -#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A) -#define DIGIPOT_MOTOR_CURRENT_LOUD {135,135,135,135,135} - -// Motor Current settings for RAMBo mini PWM value = MotorCurrentSetting * 255 / range -#if MOTHERBOARD == 200 || MOTHERBOARD == 203 -#define MOTOR_CURRENT_PWM_RANGE 2000 -#define DEFAULT_PWM_MOTOR_CURRENT {400, 750, 750} // {XY,Z,E} -#define DEFAULT_PWM_MOTOR_CURRENT_LOUD {400, 750, 750} // {XY,Z,E} -#endif - -/*------------------------------------ - PAT9125 SETTINGS - *------------------------------------*/ - -#define PAT9125_XRES 0 -#define PAT9125_YRES 255 - -/*------------------------------------ - BED SETTINGS - *------------------------------------*/ - -// Define Mesh Bed Leveling system to enable it -#define MESH_BED_LEVELING -#ifdef MESH_BED_LEVELING - -#define MBL_Z_STEP 0.01 - -// Mesh definitions -#define MESH_MIN_X 35 -#define MESH_MAX_X 238 -#define MESH_MIN_Y 6 -#define MESH_MAX_Y 202 - -// Mesh upsample definition -#define MESH_NUM_X_POINTS 7 -#define MESH_NUM_Y_POINTS 7 -// Mesh measure definition -#define MESH_MEAS_NUM_X_POINTS 3 -#define MESH_MEAS_NUM_Y_POINTS 3 - -#define MESH_HOME_Z_CALIB 0.2 -#define MESH_HOME_Z_SEARCH 5 //Z lift for homing, mesh bed leveling etc. - -#define X_PROBE_OFFSET_FROM_EXTRUDER 23 // Z probe to nozzle X offset: -left +right -#define Y_PROBE_OFFSET_FROM_EXTRUDER 5 // Z probe to nozzle Y offset: -front +behind -#define Z_PROBE_OFFSET_FROM_EXTRUDER -0.4 // Z probe to nozzle Z offset: -below (always!) -#endif - -// Bed Temperature Control -// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis -// -// Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder. -// If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz, -// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating. -// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater. -// If your configuration is significantly different than this and you don't understand the issues involved, you probably -// shouldn't use bed PID until someone else verifies your hardware works. -// If this is enabled, find your own PID constants below. -#define PIDTEMPBED -// -//#define BED_LIMIT_SWITCHING - -// This sets the max power delivered to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option. -// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis) -// setting this to anything other than 255 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did, -// so you shouldn't use it unless you are OK with PWM on your bed. (see the comment on enabling PIDTEMPBED) -#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current - -// Bed temperature compensation settings -#define BED_OFFSET 10 -#define BED_OFFSET_START 40 -#define BED_OFFSET_CENTER 50 - - -#ifdef PIDTEMPBED -//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) -//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) -#if defined(E3D_PT100_BED_WITH_AMP) || defined(E3D_PT100_BED_NO_AMP) -// Define PID constants for extruder with PT100 -#define DEFAULT_bedKp 21.70 -#define DEFAULT_bedKi 1.60 -#define DEFAULT_bedKd 73.76 -#else -#define DEFAULT_bedKp 126.13 -#define DEFAULT_bedKi 4.30 -#define DEFAULT_bedKd 924.76 -#endif - -//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) -//from pidautotune -// #define DEFAULT_bedKp 97.1 -// #define DEFAULT_bedKi 1.41 -// #define DEFAULT_bedKd 1675.16 - -// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles. -#endif // PIDTEMPBED - - -/*----------------------------------- - PREHEAT SETTINGS - *------------------------------------*/ - -#define FARM_PREHEAT_HOTEND_TEMP 250 -#define FARM_PREHEAT_HPB_TEMP 40 -#define FARM_PREHEAT_FAN_SPEED 0 - -#define PLA_PREHEAT_HOTEND_TEMP 215 -#define PLA_PREHEAT_HPB_TEMP 60 -#define PLA_PREHEAT_FAN_SPEED 0 - -#define ABS_PREHEAT_HOTEND_TEMP 255 -#define ABS_PREHEAT_HPB_TEMP 100 -#define ABS_PREHEAT_FAN_SPEED 0 - -#define HIPS_PREHEAT_HOTEND_TEMP 220 -#define HIPS_PREHEAT_HPB_TEMP 100 -#define HIPS_PREHEAT_FAN_SPEED 0 - -#define PP_PREHEAT_HOTEND_TEMP 254 -#define PP_PREHEAT_HPB_TEMP 100 -#define PP_PREHEAT_FAN_SPEED 0 - -#define PET_PREHEAT_HOTEND_TEMP 230 -#define PET_PREHEAT_HPB_TEMP 85 -#define PET_PREHEAT_FAN_SPEED 0 - -#define FLEX_PREHEAT_HOTEND_TEMP 240 -#define FLEX_PREHEAT_HPB_TEMP 50 -#define FLEX_PREHEAT_FAN_SPEED 0 - -/*------------------------------------ - THERMISTORS SETTINGS - *------------------------------------*/ - -// -//--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table -// -//// Temperature sensor settings: -// -2 is thermocouple with MAX6675 (only for sensor 0) -// -1 is thermocouple with AD595 -// 0 is not used -// 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup) -// 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup) -// 3 is Mendel-parts thermistor (4.7k pullup) -// 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !! -// 5 is 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (4.7k pullup) -// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup) -// 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup) -// 71 is 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup) -// 8 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) -// 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup) -// 10 is 100k RS thermistor 198-961 (4.7k pullup) -// 11 is 100k beta 3950 1% thermistor (4.7k pullup) -// 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed) -// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE" -// 20 is the PT100 circuit found in the Ultimainboard V2.x -// 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950 -// -// 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k -// (but gives greater accuracy and more stable PID) -// 51 is 100k thermistor - EPCOS (1k pullup) -// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup) -// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup) -// -// 1047 is Pt1000 with 4k7 pullup -// 1010 is Pt1000 with 1k pullup (non standard) -// 147 is Pt100 with 4k7 pullup -// 148 is E3D Pt100 with 4k7 pullup and no PT100 Amplifier on a MiniRambo 1.3a -// 247 is Pt100 with 4k7 pullup and PT100 Amplifier -// 110 is Pt100 with 1k pullup (non standard) - -#if defined(E3D_PT100_EXTRUDER_WITH_AMP) -#define TEMP_SENSOR_0 247 -#elif defined(E3D_PT100_EXTRUDER_NO_AMP) -#define TEMP_SENSOR_0 148 -#else -#define TEMP_SENSOR_0 5 -#endif -#define TEMP_SENSOR_1 0 -#define TEMP_SENSOR_2 0 -#if defined(E3D_PT100_BED_WITH_AMP) -#define TEMP_SENSOR_BED 247 -#elif defined(E3D_PT100_BED_NO_AMP) -#define TEMP_SENSOR_BED 148 -#else -#define TEMP_SENSOR_BED 1 -#endif -#define TEMP_SENSOR_PINDA 1 -#define TEMP_SENSOR_AMBIENT 2000 - -#define STACK_GUARD_TEST_VALUE 0xA2A2 - -#define MAX_BED_TEMP_CALIBRATION 50 -#define MAX_HOTEND_TEMP_CALIBRATION 50 - -#define MAX_E_STEPS_PER_UNIT 250 -#define MIN_E_STEPS_PER_UNIT 100 - -#define Z_BABYSTEP_MIN -3999 -#define Z_BABYSTEP_MAX 0 - -#define PINDA_PREHEAT_X 20 -#define PINDA_PREHEAT_Y 60 -#define PINDA_PREHEAT_Z 0.15 -/* -#define PINDA_PREHEAT_X 70 -#define PINDA_PREHEAT_Y -3 -#define PINDA_PREHEAT_Z 1*/ -#define PINDA_HEAT_T 120 //time in s - -#define PINDA_MIN_T 50 -#define PINDA_STEP_T 10 -#define PINDA_MAX_T 100 - -#define PING_TIME 60 //time in s -#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid false triggering when dealing with long gcodes -#define PING_ALLERT_PERIOD 60 //time in s - -#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring -#define NC_BUTTON_LONG_PRESS 15 //time in s - -#define LONG_PRESS_TIME 1000 //time in ms for button long press -#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release - -#define DEFAULT_PID_TEMP 210 - -#define MIN_PRINT_FAN_SPEED 75 - -#ifdef SNMM -#define DEFAULT_RETRACTION 4 //used for PINDA temp calibration and pause print -#else -#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration and pause print -#endif - -// How much shall the print head be lifted on power panic? -// Ideally the Z axis will reach a zero phase of the stepper driver on power outage. To simplify this, -// UVLO_Z_AXIS_SHIFT shall be an integer multiply of the stepper driver cycle, that is 4x full step. -// For example, the Prusa i3 MK2 with 16 microsteps per full step has Z stepping of 400 microsteps per mm. -// At 400 microsteps per mm, a full step lifts the Z axis by 0.04mm, and a stepper driver cycle is 0.16mm. -// The following example, 12 * (4 * 16 / 400) = 12 * 0.16mm = 1.92mm. -//#define UVLO_Z_AXIS_SHIFT 1.92 -#define UVLO_Z_AXIS_SHIFT 0.64 -// If power panic occured, and the current temperature is higher then target temperature before interrupt minus this offset, print will be recovered automatically. -#define AUTOMATIC_UVLO_BED_TEMP_OFFSET 5 - -#define HEATBED_V2 - -#define M600_TIMEOUT 600 //seconds - -//#define SUPPORT_VERBOSITY - -#endif //__CONFIGURATION_PRUSA_H diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index dbbd5434..1c3f3be5 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2544,7 +2544,7 @@ void process_commands() lcd_setstatus(strchr_pointer + 5); } -//#ifdef TMC2130 +#ifdef TMC2130 else if (strncmp_P(CMDBUFFER_CURRENT_STRING, PSTR("CRASH_"), 6) == 0) { if(code_seen("CRASH_DETECTED")) @@ -2573,7 +2573,7 @@ void process_commands() tmc2130_goto_step(E_AXIS, step & (4*res - 1), 2, 1000, res); } } -//#endif //TMC2130 +#endif //TMC2130 else if(code_seen("PRUSA")){ if (code_seen("Ping")) { //PRUSA Ping From 0ba7850146df98e576b33b16f26facb0e224530c Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 11 Apr 2018 17:40:04 +0200 Subject: [PATCH 06/38] pinda temp table changed back --- Firmware/Marlin_main.cpp | 69 ++++++++++++++++++++++++++++++++++++++++ Firmware/temperature.cpp | 2 +- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f1c17588..0c3736ba 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -233,6 +233,7 @@ // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] // M605 - Set dual x-carriage movement mode: S [ X R ] // M860 - Wait for PINDA thermistor to reach target temperature. +// M861 - Set / Read PINDA temperature compensation offsets // M900 - Set LIN_ADVANCE options, if enabled. See Configuration_adv.h for details. // M907 - Set digital trimpot motor current using axis codes. // M908 - Control digital trimpot directly. @@ -6263,6 +6264,74 @@ Sigma_Exit: break; } + case 861: // M861 - Set/Read PINDA temperature compensation offsets + if (code_seen('?')) { // ? - Print out current EEPRO offset values + uint8_t cal_status = calibration_status_pinda(); + cal_status ? SERIAL_PROTOCOLLN("PINDA cal status: 1") : SERIAL_PROTOCOLLN("PINDA cal status: 0"); + SERIAL_PROTOCOLLN("index, temp, ustep, um"); + for (uint8_t i = 0; i < 6; i++) + { + uint16_t usteps = 0; + if (i > 0) usteps = eeprom_read_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + (i - 1)); + float mm = ((float)usteps) / axis_steps_per_unit[Z_AXIS]; + i == 0 ? SERIAL_PROTOCOLPGM("n/a") : SERIAL_PROTOCOL(i - 1); + SERIAL_PROTOCOLPGM(", "); + SERIAL_PROTOCOL(35 + (i * 5)); + SERIAL_PROTOCOLPGM(", "); + SERIAL_PROTOCOL(usteps); + SERIAL_PROTOCOLPGM(", "); + SERIAL_PROTOCOL(mm * 1000); + SERIAL_PROTOCOLLN(""); + } + } + else if (code_seen('!')) { // ! - Set factory default values + eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 0, 8); //40C - 20um - 8usteps + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 1, 24); //45C - 60um - 24usteps + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 2, 48); //50C - 120um - 48usteps + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 3, 80); //55C - 200um - 80usteps + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 120); //60C - 300um - 120usteps + SERIAL_PROTOCOLLN("factory restored"); + } + else if (code_seen('Z')) { // Z - Set all values to 0 (effectively disabling PINDA temperature compensation) + eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 0, 0); + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 1, 0); + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 2, 0); + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 3, 0); + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 0); + SERIAL_PROTOCOLLN("zerorized"); + } + else if (code_seen('S')) { // Sxxx Iyyy - Set compensation ustep value S for compensation table index I + uint16_t usteps = code_value(); + if (code_seen('I')) { + byte index = code_value(); + if ((index >= 0) && (index < 5)) { + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + index, usteps); + SERIAL_PROTOCOLLN("OK"); + SERIAL_PROTOCOLLN("index, temp, ustep, um"); + for (uint8_t i = 0; i < 6; i++) + { + uint16_t usteps = 0; + if (i > 0) usteps = eeprom_read_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + (i - 1)); + float mm = ((float)usteps) / axis_steps_per_unit[Z_AXIS]; + i == 0 ? SERIAL_PROTOCOLPGM("n/a") : SERIAL_PROTOCOL(i - 1); + SERIAL_PROTOCOLPGM(", "); + SERIAL_PROTOCOL(35 + (i * 5)); + SERIAL_PROTOCOLPGM(", "); + SERIAL_PROTOCOL(usteps); + SERIAL_PROTOCOLPGM(", "); + SERIAL_PROTOCOL(mm * 1000); + SERIAL_PROTOCOLLN(""); + } + } + } + } + else { + SERIAL_PROTOCOLPGM("no valid command"); + } + break; + #endif //PINDA_THERMISTOR #ifdef LIN_ADVANCE diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index aff97303..50d47db1 100644 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -985,7 +985,7 @@ static void updateTemperaturesFromRawValues() } #ifdef PINDA_THERMISTOR - current_temperature_pinda = analog2tempPINDA(current_temperature_raw_pinda); + current_temperature_pinda = analog2tempBed(current_temperature_raw_pinda); #endif #ifdef AMBIENT_THERMISTOR From 47eab97d2da08e41a562c4913a436a9759ede6e0 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 11 Apr 2018 18:16:16 +0200 Subject: [PATCH 07/38] temp. calibration is automaticly activated after calibration process --- Firmware/Marlin_main.cpp | 5 +++++ Firmware/language_all.cpp | 4 ++-- Firmware/language_cz.h | 2 +- Firmware/language_en.h | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 0c3736ba..715b9b4e 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3556,6 +3556,9 @@ void process_commands() setTargetBed(0); //set bed target temperature back to 0 // setTargetHotend(0,0); //set hotend target temperature back to 0 lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CALIBRATION_DONE); + temp_cal_active = true; + eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, 1); + lcd_update_enable(true); lcd_update(2); break; @@ -3669,6 +3672,8 @@ void process_commands() disable_e2(); setTargetBed(0); //set bed target temperature back to 0 lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CALIBRATION_DONE); + temp_cal_active = true; + eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, 1); lcd_update_enable(true); lcd_update(2); diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index ea499cf5..713a81d2 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -2197,8 +2197,8 @@ const char * const MSG_TEMP_CALIBRATION_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_TEMP_CALIBRATION_CZ }; -const char MSG_TEMP_CALIBRATION_DONE_EN[] PROGMEM = "Temperature calibration is finished. Click to continue."; -const char MSG_TEMP_CALIBRATION_DONE_CZ[] PROGMEM = "Teplotni kalibrace dokoncena. Pokracujte stiskem tlacitka."; +const char MSG_TEMP_CALIBRATION_DONE_EN[] PROGMEM = "Temperature calibration is finished and active. Temp. calibration can be disabled in menu Settings->Temp. cal."; +const char MSG_TEMP_CALIBRATION_DONE_CZ[] PROGMEM = "Teplotni kalibrace dokoncena a je nyni aktivni. Teplotni kalibraci je mozno deaktivovat v menu Nastaveni->Tepl. kal."; const char * const MSG_TEMP_CALIBRATION_DONE_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_TEMP_CALIBRATION_DONE_EN, MSG_TEMP_CALIBRATION_DONE_CZ diff --git a/Firmware/language_cz.h b/Firmware/language_cz.h index a332770a..0ce9233d 100644 --- a/Firmware/language_cz.h +++ b/Firmware/language_cz.h @@ -303,7 +303,7 @@ #define MSG_PINDA_NOT_CALIBRATED "Tiskarna nebyla teplotne zkalibrovana" #define MSG_PINDA_PREHEAT "Nahrivani PINDA" #define MSG_TEMP_CALIBRATION "Tepl. kal. " -#define MSG_TEMP_CALIBRATION_DONE "Teplotni kalibrace dokoncena. Pokracujte stiskem tlacitka." +#define MSG_TEMP_CALIBRATION_DONE "Teplotni kalibrace dokoncena a je nyni aktivni. Teplotni kalibraci je mozno deaktivovat v menu Nastaveni->Tepl. kal." #define MSG_TEMP_CALIBRATION_ON "Tepl. kal. [zap]" #define MSG_TEMP_CALIBRATION_OFF "Tepl. kal. [vyp]" #define MSG_PREPARE_FILAMENT "Pripravte filament" diff --git a/Firmware/language_en.h b/Firmware/language_en.h index 661aaf8c..88510854 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -303,7 +303,7 @@ #define(length=20, lines=4) MSG_PINDA_NOT_CALIBRATED "Temperature calibration has not been run yet" #define(length=20, lines=1) MSG_PINDA_PREHEAT "PINDA Heating" #define(length=20, lines=1) MSG_TEMP_CALIBRATION "Temp. cal. " -#define(length=20, lines=4) MSG_TEMP_CALIBRATION_DONE "Temperature calibration is finished. Click to continue." +#define(length=20, lines=12) MSG_TEMP_CALIBRATION_DONE "Temperature calibration is finished and active. Temp. calibration can be disabled in menu Settings->Temp. cal." #define(length=20, lines=1) MSG_TEMP_CALIBRATION_ON "Temp. cal. [on]" #define(length=20, lines=1) MSG_TEMP_CALIBRATION_OFF "Temp. cal. [off]" #define(length=20, lines=1) MSG_PREPARE_FILAMENT "Prepare new filament" From 52de4891fe775ba2f94b84801a8ca4f18c39bdf6 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 11 Apr 2018 18:32:27 +0200 Subject: [PATCH 08/38] typo fixed --- Firmware/ultralcd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 7e4a742e..4b4cb7cc 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1834,9 +1834,9 @@ static void lcd_support_menu() MENU_ITEM(submenu, MSG_MENU_TEMPERATURES, lcd_menu_temperatures); -#if defined (VOLT_BED_PIN) || defined (VOLT_BED_PIN) +#if defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) MENU_ITEM(submenu, MSG_MENU_VOLTAGES, lcd_menu_voltages); -#endif //defined VOLT_BED_PIN || defined VOLT_BED_PIN +#endif //defined VOLT_BED_PIN || defined VOLT_PWR_PIN #ifdef DEBUG_BUILD MENU_ITEM(submenu, PSTR("Debug"), lcd_menu_debug); From ce666993401b14370577648e1ac7511da40432e0 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 11 Apr 2018 18:36:38 +0200 Subject: [PATCH 09/38] dont use default temp table for new printers and dont automaticly activate temp. cal. (new pinda probes have different characteristics) --- Firmware/Marlin_main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 715b9b4e..c254dcbb 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1270,13 +1270,13 @@ void setup() if (eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA) == 255) { //eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); - eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 0, 8); //40C - 20um - 8usteps - eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 1, 24); //45C - 60um - 24usteps - eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 2, 48); //50C - 120um - 48usteps - eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 3, 80); //55C - 200um - 80usteps - eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 120); //60C - 300um - 120usteps + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 0, 0); //40C + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 1, 0); //45C + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 2, 0); //50C + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 3, 0); //55C + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 0); //60C - eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 1); + eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0); temp_cal_active = true; } if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 255) { From 45d1dbbfe0a0c10ce999e6a95eb8567abf6e142d Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 11 Apr 2018 18:37:07 +0200 Subject: [PATCH 10/38] temp cal. active set to false --- 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 c254dcbb..d1c145ed 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1277,7 +1277,7 @@ void setup() eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 0); //60C eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0); - temp_cal_active = true; + temp_cal_active = false; } if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 255) { eeprom_write_byte((uint8_t*)EEPROM_UVLO, 0); From 78245ce566862b79a64855fd4c41d94db3cfa5ee Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 11 Apr 2018 18:54:27 +0200 Subject: [PATCH 11/38] farm preheat temperature for heatbed --- Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 3f12358f..9d302af7 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -465,7 +465,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o *------------------------------------*/ #define FARM_PREHEAT_HOTEND_TEMP 250 -#define FARM_PREHEAT_HPB_TEMP 40 +#define FARM_PREHEAT_HPB_TEMP 60 #define FARM_PREHEAT_FAN_SPEED 0 #define PLA_PREHEAT_HOTEND_TEMP 215 From 591cb881cc24e99bcc715bb822686ddf3b5f66d2 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 12 Apr 2018 18:24:30 +0200 Subject: [PATCH 12/38] selftest: false fan error fix, added message in case that manual fan error fails --- Firmware/ultralcd.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index ad69f627..a56d5a1c 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6167,6 +6167,11 @@ bool lcd_selftest() _result = lcd_selftest_fan_dialog(0); #else //defined(TACH_0) _result = lcd_selftest_manual_fan_check(0, false); + if (!_result) + { + const char *_err; + lcd_selftest_error(7, _err, _err); //extruder fan not spinning + } #endif //defined(TACH_0) @@ -6177,6 +6182,12 @@ bool lcd_selftest() _result = lcd_selftest_fan_dialog(1); #else //defined(TACH_1) _result = lcd_selftest_manual_fan_check(1, false); + if (!_result) + { + const char *_err; + lcd_selftest_error(6, _err, _err); //print fan not spinning + } + #endif //defined(TACH_1) } @@ -6883,6 +6894,8 @@ static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite) int8_t enc_dif = 0; KEEPALIVE_STATE(PAUSED_FOR_USER); + + button_pressed = false; do { switch (_fan) From 08740356b8003c40a9565b8507fa56698109152a Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 12 Apr 2018 18:41:11 +0200 Subject: [PATCH 13/38] Move "PRUSA SN" gcode to separate function. --- Firmware/Marlin_main.cpp | 60 ++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 5d0bcb3a..c9c487f0 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2506,6 +2506,38 @@ void gcode_M701() #endif } +/** + * @brief Get serial number from 32U2 processor + */ +static void gcode_PRUSA_SN() +{ + if (farm_mode) { + selectedSerialPort = 0; + MSerial.write(";S"); + // S/N is:CZPX0917X003XC13518 + int numbersRead = 0; + + while (numbersRead < 19) { + while (MSerial.available() > 0) { + uint8_t serial_char = MSerial.read(); + selectedSerialPort = 1; + MSerial.write(serial_char); + numbersRead++; + selectedSerialPort = 0; + } + } + selectedSerialPort = 1; + MSerial.write('\n'); + /*for (int b = 0; b < 3; b++) { + tone(BEEPER, 110); + delay(50); + noTone(BEEPER); + delay(50); + }*/ + } else { + MYSERIAL.println("Not in farm mode."); + } +} void process_commands() { @@ -2625,33 +2657,7 @@ void process_commands() prusa_sd_card_upload = true; card.openFile(strchr_pointer+4,false); } else if (code_seen("SN")) { - if (farm_mode) { - selectedSerialPort = 0; - MSerial.write(";S"); - // S/N is:CZPX0917X003XC13518 - int numbersRead = 0; - - while (numbersRead < 19) { - while (MSerial.available() > 0) { - uint8_t serial_char = MSerial.read(); - selectedSerialPort = 1; - MSerial.write(serial_char); - numbersRead++; - selectedSerialPort = 0; - } - } - selectedSerialPort = 1; - MSerial.write('\n'); - /*for (int b = 0; b < 3; b++) { - tone(BEEPER, 110); - delay(50); - noTone(BEEPER); - delay(50); - }*/ - } else { - MYSERIAL.println("Not in farm mode."); - } - + gcode_PRUSA_SN(); } else if(code_seen("Fir")){ SERIAL_PROTOCOLLN(FW_VERSION); From 388d6eea36a409a156a83e0b02388c79534bdd60 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 12 Apr 2018 18:44:33 +0200 Subject: [PATCH 14/38] Fix printer resets in farm mode if command "PRUSA SN" is received and 32U2 processor is not responding. --- Firmware/Marlin_main.cpp | 64 ++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index c9c487f0..d4b2b985 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2508,35 +2508,49 @@ void gcode_M701() } /** * @brief Get serial number from 32U2 processor + * + * Typical format of S/N is:CZPX0917X003XC13518 + * + * Command operates only in farm mode, if not in farm mode, "Not in farm mode." is written to MYSERIAL. + * + * Send command ;S to serial port 0 to retrieve serial number stored in 32U2 processor, + * reply is transmitted to serial port 1 character by character. + * Operation takes typically 23 ms. If the retransmit is not finished until 100 ms, + * it is interrupted, so less, or no characters are retransmitted, only newline character is send + * in any case. */ static void gcode_PRUSA_SN() { - if (farm_mode) { - selectedSerialPort = 0; - MSerial.write(";S"); - // S/N is:CZPX0917X003XC13518 - int numbersRead = 0; + if (farm_mode) { + selectedSerialPort = 0; + MSerial.write(";S"); + int numbersRead = 0; + Timer timeout; + timeout.start(); - while (numbersRead < 19) { - while (MSerial.available() > 0) { - uint8_t serial_char = MSerial.read(); - selectedSerialPort = 1; - MSerial.write(serial_char); - numbersRead++; - selectedSerialPort = 0; - } - } - selectedSerialPort = 1; - MSerial.write('\n'); - /*for (int b = 0; b < 3; b++) { - tone(BEEPER, 110); - delay(50); - noTone(BEEPER); - delay(50); - }*/ - } else { - MYSERIAL.println("Not in farm mode."); - } + while (numbersRead < 19) { + while (MSerial.available() > 0) { + uint8_t serial_char = MSerial.read(); + selectedSerialPort = 1; + MSerial.write(serial_char); + numbersRead++; + selectedSerialPort = 0; + } + if (timeout.expired(100)) break; + } + selectedSerialPort = 1; + MSerial.write('\n'); +#if 0 + for (int b = 0; b < 3; b++) { + tone(BEEPER, 110); + delay(50); + noTone(BEEPER); + delay(50); + } +#endif + } else { + MYSERIAL.println("Not in farm mode."); + } } void process_commands() From f3209e1aec35191f709db9e4148673ac44985aa7 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 13 Apr 2018 10:27:55 +0200 Subject: [PATCH 15/38] fixed possible feedmultiply change cause by entering main menu with negative encoder position --- Firmware/MenuStack.cpp | 2 +- Firmware/MenuStack.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Firmware/MenuStack.cpp b/Firmware/MenuStack.cpp index 5e17a7d9..94d74543 100644 --- a/Firmware/MenuStack.cpp +++ b/Firmware/MenuStack.cpp @@ -9,7 +9,7 @@ * @param menu * @param position selected position in menu being pushed */ -void MenuStack::push(menuFunc_t menu, uint8_t position) +void MenuStack::push(menuFunc_t menu, int8_t position) { if (m_index >= max_depth) return; m_stack[m_index].menu = menu; diff --git a/Firmware/MenuStack.h b/Firmware/MenuStack.h index 04754449..ef320543 100644 --- a/Firmware/MenuStack.h +++ b/Firmware/MenuStack.h @@ -19,10 +19,10 @@ public: struct Record { menuFunc_t menu; - uint8_t position; + int8_t position; }; MenuStack():m_stack(),m_index(0) {} - void push(menuFunc_t menu, uint8_t position); + void push(menuFunc_t menu, int8_t position); Record pop(); void reset(){m_index = 0;} private: From 03d03aeac4f7ae1898902a253331c599bb08b339 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Apr 2018 16:51:47 +0200 Subject: [PATCH 16/38] Return to main menu from filament unloading. --- Firmware/ultralcd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 68392dfd..ce63b0b6 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1877,7 +1877,7 @@ void lcd_unLoadFilament() lcd_implementation_clear(); } - lcd_return_to_status(); + menu_action_back(); } void lcd_change_filament() { @@ -5635,7 +5635,7 @@ static void lcd_main_menu() else #endif //PAT9125 MENU_ITEM(function, MSG_LOAD_FILAMENT, lcd_LoadFilament); - MENU_ITEM(function, MSG_UNLOAD_FILAMENT, lcd_unLoadFilament); + MENU_ITEM(submenu, MSG_UNLOAD_FILAMENT, lcd_unLoadFilament); #endif #ifdef SNMM MENU_ITEM(submenu, MSG_LOAD_FILAMENT, fil_load_menu); From 6f985d23d65fa0091fa3aa3ea18826610e04b391 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Apr 2018 17:20:30 +0200 Subject: [PATCH 17/38] Fix returning from Fail stats menu. --- Firmware/ultralcd.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 68392dfd..cb066e5b 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -1595,8 +1595,7 @@ static void lcd_menu_fails_stats_total() if (lcd_clicked()) { lcd_quick_feedback(); - //lcd_return_to_status(); - lcd_goto_menu(lcd_menu_fails_stats, 4); + menu_action_back(); } } @@ -1616,8 +1615,7 @@ static void lcd_menu_fails_stats_print() if (lcd_clicked()) { lcd_quick_feedback(); - //lcd_return_to_status(); - lcd_goto_menu(lcd_menu_fails_stats, 2); + menu_action_back(); } } /** From c88f0108af00c73bd5e325c887b1b4d110367996 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Apr 2018 19:30:08 +0200 Subject: [PATCH 18/38] Fix safety timer. Constant parameter greater than 16 bits must by stated as unsigned long. --- 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 09117542..48182e10 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -7102,7 +7102,7 @@ static void handleSafetyTimer() { safetyTimer.start(); } - else if (safetyTimer.expired(15*60*1000)) + else if (safetyTimer.expired(900000ul)) { setTargetBed(0); setTargetHotend(0, 0); From af6c1f8acb5f673df91570f6e49e14614fb10429 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 13 Apr 2018 19:53:51 +0200 Subject: [PATCH 19/38] Update version. --- Firmware/Configuration.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 0a898b8b..fedb4f2a 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -7,8 +7,8 @@ #define STR(x) STR_HELPER(x) // Firmware version -#define FW_VERSION "3.2.0-alpha" -#define FW_COMMIT_NR 370 +#define FW_VERSION "3.2.0-RC1" +#define FW_COMMIT_NR 461 // FW_VERSION_UNKNOWN means this is an unofficial build. // The firmware should only be checked into github with this symbol. #define FW_DEV_VERSION FW_VERSION_UNKNOWN From 5791d9f0d8d9aead6f9e696259c8529cf5627c31 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 18 Apr 2018 14:11:42 +0200 Subject: [PATCH 20/38] EEPROM address conflict fix; forcing selftest can happen only in case that we have TMC2130 drivers --- Firmware/Configuration.h | 8 +++----- Firmware/Marlin_main.cpp | 9 +++++---- Firmware/util.cpp | 4 ++++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index fedb4f2a..34d526f9 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -7,7 +7,7 @@ #define STR(x) STR_HELPER(x) // Firmware version -#define FW_VERSION "3.2.0-RC1" +#define FW_VERSION "3.2.0-RC2" #define FW_COMMIT_NR 461 // FW_VERSION_UNKNOWN means this is an unofficial build. // The firmware should only be checked into github with this symbol. @@ -132,10 +132,6 @@ // Power loss errors (total) #define EEPROM_POWER_COUNT_TOT (EEPROM_FERROR_COUNT_TOT - 2) // uint16 -#define EEPROM_PRINTER_TYPE (EEPROM_POWER_COUNT_TOT - 2) // uint16 -#define EEPROM_BOARD_TYPE (EEPROM_PRINTER_TYPE - 2) // uint16 - - //////////////////////////////////////// // TMC2130 Accurate sensorless homing @@ -174,6 +170,8 @@ #define EEPROM_TMC2130_Z_MRES (EEPROM_TMC2130_Y_MRES - 1) // uint8 #define EEPROM_TMC2130_E_MRES (EEPROM_TMC2130_Z_MRES - 1) // uint8 +#define EEPROM_PRINTER_TYPE (EEPROM_TMC2130_E_MRES - 2) // uint16 +#define EEPROM_BOARD_TYPE (EEPROM_PRINTER_TYPE - 2) // uint16 //TMC2130 configuration #define EEPROM_TMC_AXIS_SIZE //axis configuration block size diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 48182e10..b16c81d2 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1336,7 +1336,8 @@ void setup() } if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 0) { //dont show calibration status messages if wizard is currently active if (calibration_status() == CALIBRATION_STATUS_ASSEMBLED || - calibration_status() == CALIBRATION_STATUS_UNKNOWN) { + calibration_status() == CALIBRATION_STATUS_UNKNOWN || + calibration_status() == CALIBRATION_STATUS_XYZ_CALIBRATION) { // Reset the babystepping values, so the printer will not move the Z axis up when the babystepping is enabled. eeprom_update_word((uint16_t*)EEPROM_BABYSTEP_Z, 0); // Show the message. @@ -1357,13 +1358,13 @@ void setup() } } -#ifndef DEBUG_DISABLE_FORCE_SELFTEST - if (force_selftest_if_fw_version() && calibration_status() < CALIBRATION_STATUS_ASSEMBLED ) { +#if !defined (DEBUG_DISABLE_FORCE_SELFTEST) && defined (TMC2130) + if (force_selftest_if_fw_version() && calibration_status() < CALIBRATION_STATUS_ASSEMBLED) { lcd_show_fullscreen_message_and_wait_P(MSG_FORCE_SELFTEST); update_current_firmware_version_to_eeprom(); lcd_selftest(); } -#endif //DEBUG_DISABLE_FORCE_SELFTEST +#endif //TMC2130 && !DEBUG_DISABLE_FORCE_SELFTEST KEEPALIVE_STATE(IN_PROCESS); #endif //DEBUG_DISABLE_STARTMSGS diff --git a/Firmware/util.cpp b/Firmware/util.cpp index 8aea54ab..ce0421a5 100644 --- a/Firmware/util.cpp +++ b/Firmware/util.cpp @@ -260,6 +260,10 @@ bool force_selftest_if_fw_version() else if (ver_with_calibration[i] < ver_eeprom[i]) break; } + + //force selftest also in case that version used before flashing new firmware was 3.2.0-RC1 + if ((ver_eeprom[0] == 3) && (ver_eeprom[1] == 2) && (ver_eeprom[2] == 0) && (ver_eeprom[3] == 3)) force_selftest = true; + return force_selftest; } From 31ae097dba53eca01cb5e07cdb7650486d460aa2 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 18 Apr 2018 17:09:12 +0200 Subject: [PATCH 21/38] mesh bed leveling / auto home Y coordinates updated --- Firmware/mesh_bed_calibration.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 360ba181..9b2dd2fb 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -20,7 +20,7 @@ float world2machine_shift[2]; #define WEIGHT_FIRST_ROW_Y_LOW (0.0f) #define BED_ZERO_REF_X (- 22.f + X_PROBE_OFFSET_FROM_EXTRUDER) // -22 + 23 = 1 -#define BED_ZERO_REF_Y (- 0.6f + Y_PROBE_OFFSET_FROM_EXTRUDER) // -0.6 + 5 = 4.4 +#define BED_ZERO_REF_Y (- 0.6f + Y_PROBE_OFFSET_FROM_EXTRUDER + 4.f) // -0.6 + 5 + 4 = 8.4 // Scaling of the real machine axes against the programmed dimensions in the firmware. // The correction is tiny, here around 0.5mm on 250mm length. @@ -56,10 +56,10 @@ const float bed_skew_angle_extreme = (0.25f * M_PI / 180.f); // Positions of the bed reference points in the machine coordinates, referenced to the P.I.N.D.A sensor. // The points are the following: center front, center right, center rear, center left. const float bed_ref_points_4[] PROGMEM = { - 13.f - BED_ZERO_REF_X, 10.4f - 4.f - BED_ZERO_REF_Y, - 221.f - BED_ZERO_REF_X, 10.4f - 4.f - BED_ZERO_REF_Y, - 221.f - BED_ZERO_REF_X, 202.4f - 4.f - BED_ZERO_REF_Y, - 13.f - BED_ZERO_REF_X, 202.4f - 4.f - BED_ZERO_REF_Y + 13.f - BED_ZERO_REF_X, 10.4f - BED_ZERO_REF_Y, + 221.f - BED_ZERO_REF_X, 10.4f - BED_ZERO_REF_Y, + 221.f - BED_ZERO_REF_X, 202.4f - BED_ZERO_REF_Y, + 13.f - BED_ZERO_REF_X, 202.4f - BED_ZERO_REF_Y }; const float bed_ref_points[] PROGMEM = { From 043c8c66be1cb269f58ed432f915fe9208421b9f Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 19 Apr 2018 16:55:00 +0200 Subject: [PATCH 22/38] waiting for pinda probe cooling --- Firmware/Marlin_main.cpp | 4 ++++ Firmware/language_all.cpp | 7 +++++++ Firmware/language_all.h | 2 ++ Firmware/language_cz.h | 1 + Firmware/language_en.h | 1 + Firmware/ultralcd.cpp | 19 +++++++++++++++++++ Firmware/ultralcd.h | 1 + 7 files changed, 35 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 48182e10..c3e561cb 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3459,6 +3459,10 @@ void process_commands() st_synchronize(); lcd_show_fullscreen_message_and_wait_P(MSG_REMOVE_STEEL_SHEET); } + if ((current_temperature_pinda > 35) && (farm_mode == false)) { + //waiting for PIDNA probe to cool down in case that we are not in farm mode + lcd_wait_for_pinda(35); + } lcd_update_enable(true); KEEPALIVE_STATE(NOT_BUSY); //no need to print busy messages as we print current temperatures periodicaly SERIAL_ECHOLNPGM("PINDA probe calibration start"); diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index 713a81d2..98ee8ec6 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -2354,6 +2354,13 @@ const char * const MSG_WAITING_TEMP_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_WAITING_TEMP_CZ }; +const char MSG_WAITING_TEMP_PINDA_EN[] PROGMEM = "Waiting for PINDA probe cooling"; +const char MSG_WAITING_TEMP_PINDA_CZ[] PROGMEM = "Cekani na zchladnuti PINDA"; +const char * const MSG_WAITING_TEMP_PINDA_LANG_TABLE[LANG_NUM] PROGMEM = { + MSG_WAITING_TEMP_PINDA_EN, + MSG_WAITING_TEMP_PINDA_CZ +}; + const char MSG_WATCH_EN[] PROGMEM = "Info screen"; const char MSG_WATCH_CZ[] PROGMEM = "Informace"; const char * const MSG_WATCH_LANG_TABLE[LANG_NUM] PROGMEM = { diff --git a/Firmware/language_all.h b/Firmware/language_all.h index 1b82353b..ae827873 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -770,6 +770,8 @@ extern const char* const MSG_VTRAV_MIN_LANG_TABLE[1]; #define MSG_VTRAV_MIN LANG_TABLE_SELECT_EXPLICIT(MSG_VTRAV_MIN_LANG_TABLE, 0) extern const char* const MSG_WAITING_TEMP_LANG_TABLE[LANG_NUM]; #define MSG_WAITING_TEMP LANG_TABLE_SELECT(MSG_WAITING_TEMP_LANG_TABLE) +extern const char* const MSG_WAITING_TEMP_PINDA_LANG_TABLE[LANG_NUM]; +#define MSG_WAITING_TEMP_PINDA LANG_TABLE_SELECT(MSG_WAITING_TEMP_PINDA_LANG_TABLE) extern const char* const MSG_WATCH_LANG_TABLE[LANG_NUM]; #define MSG_WATCH LANG_TABLE_SELECT(MSG_WATCH_LANG_TABLE) extern const char* const MSG_WATCHDOG_RESET_LANG_TABLE[1]; diff --git a/Firmware/language_cz.h b/Firmware/language_cz.h index 0ce9233d..f7eb4f1b 100644 --- a/Firmware/language_cz.h +++ b/Firmware/language_cz.h @@ -414,3 +414,4 @@ #define MSG_CHANGED_MOTHERBOARD "Varovani: doslo ke zmene typu motherboardu." #define MSG_CHANGED_PRINTER "Varovani: doslo ke zmene typu tiskarny." #define MSG_CHANGED_BOTH "Varovani: doslo ke zmene typu tiskarny a motherboardu." +#define MSG_WAITING_TEMP_PINDA "Cekani na zchladnuti PINDA" diff --git a/Firmware/language_en.h b/Firmware/language_en.h index 88510854..4cb5b20c 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -422,3 +422,4 @@ #define(length=20, lines=4) MSG_CHANGED_MOTHERBOARD "Warning: motherboard type changed." #define(length=20, lines=4) MSG_CHANGED_PRINTER "Warning: printer type changed." #define(length=20, lines=4) MSG_CHANGED_BOTH "Warning: both printer type and motherboard type changed." +#define(length=20, lines=3) MSG_WAITING_TEMP_PINDA "Waiting for PINDA probe cooling" \ No newline at end of file diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index e5d69227..5996272b 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2600,6 +2600,25 @@ void lcd_adjust_z() { } +void lcd_wait_for_pinda(uint8_t temp) { + lcd_set_custom_characters_degree(); + setTargetHotend(0, 0); + setTargetBed(0); + while (current_temperature_pinda > temp){ + lcd_display_message_fullscreen_P(MSG_WAITING_TEMP_PINDA); + + lcd.setCursor(0, 4); + lcd.print(LCD_STR_THERMOMETER[0]); + lcd.print(ftostr3(current_temperature_pinda)); + lcd.print("/35"); + lcd.print(LCD_STR_DEGREE); + delay_keep_alive(1000); + serialecho_temperatures(); + } + lcd_set_custom_characters_arrows(); + lcd_update_enable(true); +} + void lcd_wait_for_heater() { lcd_display_message_fullscreen_P(MSG_WIZARD_HEATING); diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 6e20dc80..c53ac8b9 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -267,6 +267,7 @@ void lcd_farm_sdcard_menu_w(); void lcd_wait_for_heater(); void lcd_wait_for_cool_down(); +void lcd_wait_for_pinda(uint8_t temp); void adjust_bed_reset(); void lcd_extr_cal_reset(); From 65aa62ebabf5b21e32906f6656af2c6219badb05 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Fri, 20 Apr 2018 13:17:18 +0200 Subject: [PATCH 23/38] XYZ cal fix (better histogram processing) --- Firmware/xyzcal.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Firmware/xyzcal.cpp b/Firmware/xyzcal.cpp index 4e4309b3..b8739640 100644 --- a/Firmware/xyzcal.cpp +++ b/Firmware/xyzcal.cpp @@ -384,8 +384,12 @@ void xyzcal_adjust_pixels(uint8_t* pixels, uint16_t* histo) for (l = 14; l > 8; l--) if (histo[l] >= 10) break; - uint8_t pix_min = (max_l << 4) / 2; + uint8_t pix_min = 0; uint8_t pix_max = l << 4; + if (histo[0] < (32*32 - 144)) + { + pix_min = (max_l << 4) / 2; + } uint8_t pix_dif = pix_max - pix_min; DBG(_n(" min=%d max=%d dif=%d\n"), pix_min, pix_max, pix_dif); for (int16_t i = 0; i < 32*32; i++) From 82b31e8552babb5cbe70af58b05cbb96252812d9 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 20 Apr 2018 15:01:11 +0200 Subject: [PATCH 24/38] Set [0;0] point offset for uncalibrated printer. --- Firmware/mesh_bed_calibration.cpp | 4 ++++ Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 9b2dd2fb..5a9bf4ee 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -707,7 +707,11 @@ void world2machine_reset() { const float vx[] = { 1.f, 0.f }; const float vy[] = { 0.f, 1.f }; +#ifdef DEFAULT_Y_OFFSET + const float cntr[] = { 0.f, DEFAULT_Y_OFFSET }; +#else const float cntr[] = { 0.f, 0.f }; +#endif world2machine_update(vx, vy, cntr); } diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 9d302af7..0a75c34a 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -76,6 +76,8 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E #define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000 +#define DEFAULT_Y_OFFSET 2.5f // Offset of [0;0] point, when the printer is not calibrated + #define DEFAULT_MAX_FEEDRATE {200, 200, 12, 120} // (mm/sec) max feedrate (M203) #define DEFAULT_MAX_ACCELERATION {1000, 1000, 200, 5000} // (mm/sec^2) max acceleration (M201) From 864284f043b724a9f77abb7cae17add43ffa6dec Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Mon, 23 Apr 2018 20:17:45 +0200 Subject: [PATCH 25/38] New current setting for MK3 X, Y: no change Z: +26.1% E: -28.5% --- Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 9d302af7..67174ea4 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -242,8 +242,8 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define TMC2130_SG_THRS_E 3 // stallguard sensitivity for E axis //new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only) -#define TMC2130_CURRENTS_H {16, 20, 28, 36} // default holding currents for all axes -#define TMC2130_CURRENTS_R {16, 20, 28, 36} // default running currents for all axes +#define TMC2130_CURRENTS_H {16, 20, 35, 26} // default holding currents for all axes +#define TMC2130_CURRENTS_R {16, 20, 35, 26} // default running currents for all axes #define TMC2130_UNLOAD_CURRENT_R 12 // lowe current for M600 to protect filament sensor #define TMC2130_STEALTH_Z From cccd8246abd42d790012ce3b0f7287317378b1cd Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 23 Apr 2018 20:15:33 +0200 Subject: [PATCH 26/38] Fix world2machine(const float &x, const float &y, float &out_x, float &out_y) not using input parameters if only WORLD2MACHINE_CORRECTION_SHIFT is applied. --- Firmware/Marlin_main.cpp | 11 +++++++++++ Firmware/mesh_bed_calibration.h | 27 +++++++-------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 48182e10..585c2557 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3107,7 +3107,18 @@ void process_commands() feedrate = homing_feedrate[Z_AXIS]/10; current_position[Z_AXIS] = 0; enable_endstops(false); +#ifdef DEBUG_BUILD + SERIAL_ECHOLNPGM("plan_set_position()"); + MYSERIAL.println(current_position[X_AXIS]);MYSERIAL.println(current_position[Y_AXIS]); + MYSERIAL.println(current_position[Z_AXIS]);MYSERIAL.println(current_position[E_AXIS]); +#endif plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); +#ifdef DEBUG_BUILD + SERIAL_ECHOLNPGM("plan_buffer_line()"); + MYSERIAL.println(destination[X_AXIS]);MYSERIAL.println(destination[Y_AXIS]); + MYSERIAL.println(destination[Z_AXIS]);MYSERIAL.println(destination[E_AXIS]); + MYSERIAL.println(feedrate);MYSERIAL.println(active_extruder); +#endif plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); st_synchronize(); current_position[X_AXIS] = destination[X_AXIS]; diff --git a/Firmware/mesh_bed_calibration.h b/Firmware/mesh_bed_calibration.h index 5dd2202e..349397a9 100644 --- a/Firmware/mesh_bed_calibration.h +++ b/Firmware/mesh_bed_calibration.h @@ -37,26 +37,6 @@ extern void world2machine_initialize(); // to current_position[x,y]. extern void world2machine_update_current(); -inline void world2machine(const float &x, const float &y, float &out_x, float &out_y) -{ - if (world2machine_correction_mode == WORLD2MACHINE_CORRECTION_NONE) { - // No correction. - out_x = x; - out_y = y; - } else { - if (world2machine_correction_mode & WORLD2MACHINE_CORRECTION_SKEW) { - // Firs the skew & rotation correction. - out_x = world2machine_rotation_and_skew[0][0] * x + world2machine_rotation_and_skew[0][1] * y; - out_y = world2machine_rotation_and_skew[1][0] * x + world2machine_rotation_and_skew[1][1] * y; - } - if (world2machine_correction_mode & WORLD2MACHINE_CORRECTION_SHIFT) { - // Then add the offset. - out_x += world2machine_shift[0]; - out_y += world2machine_shift[1]; - } - } -} - inline void world2machine(float &x, float &y) { if (world2machine_correction_mode == WORLD2MACHINE_CORRECTION_NONE) { @@ -77,6 +57,13 @@ inline void world2machine(float &x, float &y) } } +inline void world2machine(const float &x, const float &y, float &out_x, float &out_y) +{ + out_x = x; + out_y = y; + world2machine(out_x, out_y); +} + inline void machine2world(float x, float y, float &out_x, float &out_y) { if (world2machine_correction_mode == WORLD2MACHINE_CORRECTION_NONE) { From 9bd4d580d72e964efff7273408e72dbf0df1d9e3 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 23 Apr 2018 20:27:35 +0200 Subject: [PATCH 27/38] Use right calibration point. This change is only formal, as both original and new point have same coordinates. --- Firmware/Marlin_main.cpp | 2 +- Firmware/mesh_bed_calibration.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 585c2557..7e2ed58d 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3099,7 +3099,7 @@ void process_commands() } // 1st mesh bed leveling measurement point, corrected. world2machine_initialize(); - world2machine(pgm_read_float(bed_ref_points), pgm_read_float(bed_ref_points+1), destination[X_AXIS], destination[Y_AXIS]); + world2machine(pgm_read_float(bed_ref_points_4), pgm_read_float(bed_ref_points_4+1), destination[X_AXIS], destination[Y_AXIS]); world2machine_reset(); if (destination[Y_AXIS] < Y_MIN_POS) destination[Y_AXIS] = Y_MIN_POS; diff --git a/Firmware/mesh_bed_calibration.h b/Firmware/mesh_bed_calibration.h index 349397a9..305e473d 100644 --- a/Firmware/mesh_bed_calibration.h +++ b/Firmware/mesh_bed_calibration.h @@ -5,6 +5,7 @@ // The world coordinates match the machine coordinates only in case, when the machine // is built properly, the end stops are at the correct positions and the axes are perpendicular. extern const float bed_ref_points[] PROGMEM; +extern const float bed_ref_points_4[] PROGMEM; extern const float bed_skew_angle_mild; extern const float bed_skew_angle_extreme; From 37ebe5c35d6d74c6a0bfaaaa1d0b9057d8024849 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 23 Apr 2018 20:31:08 +0200 Subject: [PATCH 28/38] Move default correction matrix of not calibrated printer to world2machine_default() function. Use world2machine_reset() to uncorrected matrix. Call it from world2machine_revert_to_uncorrected() and from world2machine_default() if there is no default shift to remove code duplication. --- Firmware/mesh_bed_calibration.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 5a9bf4ee..9c5b1271 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -707,22 +707,26 @@ void world2machine_reset() { const float vx[] = { 1.f, 0.f }; const float vy[] = { 0.f, 1.f }; -#ifdef DEFAULT_Y_OFFSET - const float cntr[] = { 0.f, DEFAULT_Y_OFFSET }; -#else const float cntr[] = { 0.f, 0.f }; -#endif world2machine_update(vx, vy, cntr); } +static void world2machine_default() +{ +#ifdef DEFAULT_Y_OFFSET + const float vx[] = { 1.f, 0.f }; + const float vy[] = { 0.f, 1.f }; + const float cntr[] = { 0.f, DEFAULT_Y_OFFSET }; + world2machine_update(vx, vy, cntr); +#else + world2machine_reset(); +#endif +} + void world2machine_revert_to_uncorrected() { if (world2machine_correction_mode != WORLD2MACHINE_CORRECTION_NONE) { - // Reset the machine correction matrix. - const float vx[] = { 1.f, 0.f }; - const float vy[] = { 0.f, 1.f }; - const float cntr[] = { 0.f, 0.f }; - world2machine_update(vx, vy, cntr); + world2machine_reset(); // Wait for the motors to stop and update the current position with the absolute values. st_synchronize(); current_position[X_AXIS] = st_get_position_mm(X_AXIS); @@ -793,7 +797,7 @@ void world2machine_initialize() if (reset) { // SERIAL_ECHOLNPGM("Invalid bed correction matrix. Resetting to identity."); reset_bed_offset_and_skew(); - world2machine_reset(); + world2machine_default(); } else { world2machine_update(vec_x, vec_y, cntr); /* From 468645e92ef181bb501f46a7146c9772ba6d6790 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 23 Apr 2018 20:31:39 +0200 Subject: [PATCH 29/38] Set DEFAULT_Y_OFFSET to 4 mm for MK3 printer. --- Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 0a75c34a..39d4154c 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -76,7 +76,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o #define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E #define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000 -#define DEFAULT_Y_OFFSET 2.5f // Offset of [0;0] point, when the printer is not calibrated +#define DEFAULT_Y_OFFSET 4.f // Offset of [0;0] point, when the printer is not calibrated #define DEFAULT_MAX_FEEDRATE {200, 200, 12, 120} // (mm/sec) max feedrate (M203) #define DEFAULT_MAX_ACCELERATION {1000, 1000, 200, 5000} // (mm/sec^2) max acceleration (M201) From 010ceceff969e406b6e1e11370de50ea3992335b Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 24 Apr 2018 13:43:51 +0200 Subject: [PATCH 30/38] add another homing after steel sheet is removed; added timeout for pinda cooling; if PINDA doesn't trigger before reaching Z = -1mm, temp. calibration fails --- Firmware/Marlin_main.cpp | 478 +++++++++++++++++++------------------- Firmware/language_all.cpp | 7 + Firmware/language_all.h | 2 + Firmware/language_cz.h | 1 + Firmware/language_en.h | 3 +- Firmware/ultralcd.cpp | 45 +++- Firmware/ultralcd.h | 5 +- 7 files changed, 299 insertions(+), 242 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index c3e561cb..33ad8295 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2959,254 +2959,254 @@ void process_commands() #endif //FWRETRACT case 28: //G28 Home all Axis one at a time { - st_synchronize(); + st_synchronize(); #if 0 - SERIAL_ECHOPGM("G28, initial "); print_world_coordinates(); - SERIAL_ECHOPGM("G28, initial "); print_physical_coordinates(); + SERIAL_ECHOPGM("G28, initial "); print_world_coordinates(); + SERIAL_ECHOPGM("G28, initial "); print_physical_coordinates(); #endif - // Flag for the display update routine and to disable the print cancelation during homing. - homing_flag = true; - - // Which axes should be homed? - bool home_x = code_seen(axis_codes[X_AXIS]); - bool home_y = code_seen(axis_codes[Y_AXIS]); - bool home_z = code_seen(axis_codes[Z_AXIS]); - // calibrate? - bool calib = code_seen('C'); - // Either all X,Y,Z codes are present, or none of them. - bool home_all_axes = home_x == home_y && home_x == home_z; - if (home_all_axes) - // No X/Y/Z code provided means to home all axes. - home_x = home_y = home_z = true; + // Flag for the display update routine and to disable the print cancelation during homing. + homing_flag = true; + + // Which axes should be homed? + bool home_x = code_seen(axis_codes[X_AXIS]); + bool home_y = code_seen(axis_codes[Y_AXIS]); + bool home_z = code_seen(axis_codes[Z_AXIS]); + // calibrate? + bool calib = code_seen('C'); + // Either all X,Y,Z codes are present, or none of them. + bool home_all_axes = home_x == home_y && home_x == home_z; + if (home_all_axes) + // No X/Y/Z code provided means to home all axes. + home_x = home_y = home_z = true; #ifdef ENABLE_AUTO_BED_LEVELING - plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data) + plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data) #endif //ENABLE_AUTO_BED_LEVELING - - // Reset world2machine_rotation_and_skew and world2machine_shift, therefore - // the planner will not perform any adjustments in the XY plane. - // Wait for the motors to stop and update the current position with the absolute values. - world2machine_revert_to_uncorrected(); - // For mesh bed leveling deactivate the matrix temporarily. - // It is necessary to disable the bed leveling for the X and Y homing moves, so that the move is performed - // in a single axis only. - // In case of re-homing the X or Y axes only, the mesh bed leveling is restored after G28. + // Reset world2machine_rotation_and_skew and world2machine_shift, therefore + // the planner will not perform any adjustments in the XY plane. + // Wait for the motors to stop and update the current position with the absolute values. + world2machine_revert_to_uncorrected(); + + // For mesh bed leveling deactivate the matrix temporarily. + // It is necessary to disable the bed leveling for the X and Y homing moves, so that the move is performed + // in a single axis only. + // In case of re-homing the X or Y axes only, the mesh bed leveling is restored after G28. #ifdef MESH_BED_LEVELING - uint8_t mbl_was_active = mbl.active; - mbl.active = 0; - current_position[Z_AXIS] = st_get_position_mm(Z_AXIS); + uint8_t mbl_was_active = mbl.active; + mbl.active = 0; + current_position[Z_AXIS] = st_get_position_mm(Z_AXIS); #endif - // Reset baby stepping to zero, if the babystepping has already been loaded before. The babystepsTodo value will be - // consumed during the first movements following this statement. - if (home_z) - babystep_undo(); + // Reset baby stepping to zero, if the babystepping has already been loaded before. The babystepsTodo value will be + // consumed during the first movements following this statement. + if (home_z) + babystep_undo(); - saved_feedrate = feedrate; - saved_feedmultiply = feedmultiply; - feedmultiply = 100; - previous_millis_cmd = millis(); + saved_feedrate = feedrate; + saved_feedmultiply = feedmultiply; + feedmultiply = 100; + previous_millis_cmd = millis(); - enable_endstops(true); + enable_endstops(true); - memcpy(destination, current_position, sizeof(destination)); - feedrate = 0.0; + memcpy(destination, current_position, sizeof(destination)); + feedrate = 0.0; - #if Z_HOME_DIR > 0 // If homing away from BED do Z first - if(home_z) - homeaxis(Z_AXIS); - #endif +#if Z_HOME_DIR > 0 // If homing away from BED do Z first + if(home_z) + homeaxis(Z_AXIS); +#endif - #ifdef QUICK_HOME - // In the quick mode, if both x and y are to be homed, a diagonal move will be performed initially. - if(home_x && home_y) //first diagonal move - { - current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0; +#ifdef QUICK_HOME + // In the quick mode, if both x and y are to be homed, a diagonal move will be performed initially. + if(home_x && home_y) //first diagonal move + { + current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0; - int x_axis_home_dir = home_dir(X_AXIS); + int x_axis_home_dir = home_dir(X_AXIS); - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS); - feedrate = homing_feedrate[X_AXIS]; - if(homing_feedrate[Y_AXIS] max_length(Y_AXIS)) { - feedrate *= sqrt(pow(max_length(Y_AXIS) / max_length(X_AXIS), 2) + 1); - } else { - feedrate *= sqrt(pow(max_length(X_AXIS) / max_length(Y_AXIS), 2) + 1); - } - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); - st_synchronize(); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS); + feedrate = homing_feedrate[X_AXIS]; + if(homing_feedrate[Y_AXIS] max_length(Y_AXIS)) { + feedrate *= sqrt(pow(max_length(Y_AXIS) / max_length(X_AXIS), 2) + 1); + } else { + feedrate *= sqrt(pow(max_length(X_AXIS) / max_length(Y_AXIS), 2) + 1); + } + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); + st_synchronize(); - axis_is_at_home(X_AXIS); - axis_is_at_home(Y_AXIS); - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[X_AXIS] = current_position[X_AXIS]; - destination[Y_AXIS] = current_position[Y_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); - feedrate = 0.0; - st_synchronize(); - endstops_hit_on_purpose(); + axis_is_at_home(X_AXIS); + axis_is_at_home(Y_AXIS); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + destination[X_AXIS] = current_position[X_AXIS]; + destination[Y_AXIS] = current_position[Y_AXIS]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); + feedrate = 0.0; + st_synchronize(); + endstops_hit_on_purpose(); - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; - current_position[Z_AXIS] = destination[Z_AXIS]; - } - #endif /* QUICK_HOME */ + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; + current_position[Z_AXIS] = destination[Z_AXIS]; + } +#endif /* QUICK_HOME */ #ifdef TMC2130 - if(home_x) - { - if (!calib) - homeaxis(X_AXIS); - else - tmc2130_home_calibrate(X_AXIS); - } + if(home_x) + { + if (!calib) + homeaxis(X_AXIS); + else + tmc2130_home_calibrate(X_AXIS); + } - if(home_y) - { - if (!calib) - homeaxis(Y_AXIS); - else - tmc2130_home_calibrate(Y_AXIS); - } + if(home_y) + { + if (!calib) + homeaxis(Y_AXIS); + else + tmc2130_home_calibrate(Y_AXIS); + } #endif //TMC2130 - if(code_seen(axis_codes[X_AXIS]) && code_value_long() != 0) - current_position[X_AXIS]=code_value()+add_homing[X_AXIS]; + if(code_seen(axis_codes[X_AXIS]) && code_value_long() != 0) + current_position[X_AXIS]=code_value()+add_homing[X_AXIS]; - if(code_seen(axis_codes[Y_AXIS]) && code_value_long() != 0) - current_position[Y_AXIS]=code_value()+add_homing[Y_AXIS]; + if(code_seen(axis_codes[Y_AXIS]) && code_value_long() != 0) + current_position[Y_AXIS]=code_value()+add_homing[Y_AXIS]; - #if Z_HOME_DIR < 0 // If homing towards BED do Z last - #ifndef Z_SAFE_HOMING - if(home_z) { - #if defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) - destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed - feedrate = max_feedrate[Z_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); - #endif // defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) - #if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) // If Mesh bed leveling, moxve X&Y to safe position for home - if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] )) - { - homeaxis(X_AXIS); - homeaxis(Y_AXIS); - } - // 1st mesh bed leveling measurement point, corrected. - world2machine_initialize(); - world2machine(pgm_read_float(bed_ref_points), pgm_read_float(bed_ref_points+1), destination[X_AXIS], destination[Y_AXIS]); - world2machine_reset(); - if (destination[Y_AXIS] < Y_MIN_POS) - destination[Y_AXIS] = Y_MIN_POS; - destination[Z_AXIS] = MESH_HOME_Z_SEARCH; // Set destination away from bed - feedrate = homing_feedrate[Z_AXIS]/10; - current_position[Z_AXIS] = 0; - enable_endstops(false); - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; - enable_endstops(true); - endstops_hit_on_purpose(); - homeaxis(Z_AXIS); - #else // MESH_BED_LEVELING - homeaxis(Z_AXIS); - #endif // MESH_BED_LEVELING - } - #else // defined(Z_SAFE_HOMING): Z Safe mode activated. - if(home_all_axes) { - destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER); - destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER); - destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed - feedrate = XY_TRAVEL_SPEED/60; - current_position[Z_AXIS] = 0; +#if Z_HOME_DIR < 0 // If homing towards BED do Z last +#ifndef Z_SAFE_HOMING + if(home_z) { +#if defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) + destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed + feedrate = max_feedrate[Z_AXIS]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); +#endif // defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) +#if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) // If Mesh bed leveling, moxve X&Y to safe position for home + if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] )) + { + homeaxis(X_AXIS); + homeaxis(Y_AXIS); + } + // 1st mesh bed leveling measurement point, corrected. + world2machine_initialize(); + world2machine(pgm_read_float(bed_ref_points), pgm_read_float(bed_ref_points+1), destination[X_AXIS], destination[Y_AXIS]); + world2machine_reset(); + if (destination[Y_AXIS] < Y_MIN_POS) + destination[Y_AXIS] = Y_MIN_POS; + destination[Z_AXIS] = MESH_HOME_Z_SEARCH; // Set destination away from bed + feedrate = homing_feedrate[Z_AXIS]/10; + current_position[Z_AXIS] = 0; + enable_endstops(false); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; + enable_endstops(true); + endstops_hit_on_purpose(); + homeaxis(Z_AXIS); +#else // MESH_BED_LEVELING + homeaxis(Z_AXIS); +#endif // MESH_BED_LEVELING + } +#else // defined(Z_SAFE_HOMING): Z Safe mode activated. + if(home_all_axes) { + destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER); + destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER); + destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed + feedrate = XY_TRAVEL_SPEED/60; + current_position[Z_AXIS] = 0; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; - homeaxis(Z_AXIS); - } - // Let's see if X and Y are homed and probe is inside bed area. - if(home_z) { - if ( (axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]) \ - && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER >= X_MIN_POS) \ - && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER <= X_MAX_POS) \ - && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER >= Y_MIN_POS) \ - && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) { + homeaxis(Z_AXIS); + } + // Let's see if X and Y are homed and probe is inside bed area. + if(home_z) { + if ( (axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]) \ + && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER >= X_MIN_POS) \ + && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER <= X_MAX_POS) \ + && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER >= Y_MIN_POS) \ + && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) { - current_position[Z_AXIS] = 0; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed - feedrate = max_feedrate[Z_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); + current_position[Z_AXIS] = 0; + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed + feedrate = max_feedrate[Z_AXIS]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); - homeaxis(Z_AXIS); - } else if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { - LCD_MESSAGERPGM(MSG_POSITION_UNKNOWN); - SERIAL_ECHO_START; - SERIAL_ECHOLNRPGM(MSG_POSITION_UNKNOWN); - } else { - LCD_MESSAGERPGM(MSG_ZPROBE_OUT); - SERIAL_ECHO_START; - SERIAL_ECHOLNRPGM(MSG_ZPROBE_OUT); - } - } - #endif // Z_SAFE_HOMING - #endif // Z_HOME_DIR < 0 + homeaxis(Z_AXIS); + } else if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { + LCD_MESSAGERPGM(MSG_POSITION_UNKNOWN); + SERIAL_ECHO_START; + SERIAL_ECHOLNRPGM(MSG_POSITION_UNKNOWN); + } else { + LCD_MESSAGERPGM(MSG_ZPROBE_OUT); + SERIAL_ECHO_START; + SERIAL_ECHOLNRPGM(MSG_ZPROBE_OUT); + } + } +#endif // Z_SAFE_HOMING +#endif // Z_HOME_DIR < 0 - if(code_seen(axis_codes[Z_AXIS]) && code_value_long() != 0) - current_position[Z_AXIS]=code_value()+add_homing[Z_AXIS]; - #ifdef ENABLE_AUTO_BED_LEVELING - if(home_z) - current_position[Z_AXIS] += zprobe_zoffset; //Add Z_Probe offset (the distance is negative) - #endif - - // Set the planner and stepper routine positions. - // At this point the mesh bed leveling and world2machine corrections are disabled and current_position - // contains the machine coordinates. - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - - #ifdef ENDSTOPS_ONLY_FOR_HOMING - enable_endstops(false); - #endif - - feedrate = saved_feedrate; - feedmultiply = saved_feedmultiply; - previous_millis_cmd = millis(); - endstops_hit_on_purpose(); -#ifndef MESH_BED_LEVELING - // If MESH_BED_LEVELING is not active, then it is the original Prusa i3. - // Offer the user to load the baby step value, which has been adjusted at the previous print session. - if(card.sdprinting && eeprom_read_word((uint16_t *)EEPROM_BABYSTEP_Z)) - lcd_adjust_z(); + if(code_seen(axis_codes[Z_AXIS]) && code_value_long() != 0) + current_position[Z_AXIS]=code_value()+add_homing[Z_AXIS]; +#ifdef ENABLE_AUTO_BED_LEVELING + if(home_z) + current_position[Z_AXIS] += zprobe_zoffset; //Add Z_Probe offset (the distance is negative) #endif - // Load the machine correction matrix - world2machine_initialize(); - // and correct the current_position XY axes to match the transformed coordinate system. - world2machine_update_current(); + // Set the planner and stepper routine positions. + // At this point the mesh bed leveling and world2machine corrections are disabled and current_position + // contains the machine coordinates. + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + +#ifdef ENDSTOPS_ONLY_FOR_HOMING + enable_endstops(false); +#endif + + feedrate = saved_feedrate; + feedmultiply = saved_feedmultiply; + previous_millis_cmd = millis(); + endstops_hit_on_purpose(); +#ifndef MESH_BED_LEVELING + // If MESH_BED_LEVELING is not active, then it is the original Prusa i3. + // Offer the user to load the baby step value, which has been adjusted at the previous print session. + if(card.sdprinting && eeprom_read_word((uint16_t *)EEPROM_BABYSTEP_Z)) + lcd_adjust_z(); +#endif + + // Load the machine correction matrix + world2machine_initialize(); + // and correct the current_position XY axes to match the transformed coordinate system. + world2machine_update_current(); #if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) - if (code_seen(axis_codes[X_AXIS]) || code_seen(axis_codes[Y_AXIS]) || code_seen('W') || code_seen(axis_codes[Z_AXIS])) + if (code_seen(axis_codes[X_AXIS]) || code_seen(axis_codes[Y_AXIS]) || code_seen('W') || code_seen(axis_codes[Z_AXIS])) { - if (! home_z && mbl_was_active) { - // Re-enable the mesh bed leveling if only the X and Y axes were re-homed. - mbl.active = true; - // and re-adjust the current logical Z axis with the bed leveling offset applicable at the current XY position. - current_position[Z_AXIS] -= mbl.get_z(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS)); - } + if (! home_z && mbl_was_active) { + // Re-enable the mesh bed leveling if only the X and Y axes were re-homed. + mbl.active = true; + // and re-adjust the current logical Z axis with the bed leveling offset applicable at the current XY position. + current_position[Z_AXIS] -= mbl.get_z(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS)); + } } - else + else { st_synchronize(); homing_flag = false; @@ -3214,18 +3214,18 @@ void process_commands() // There shall be always enough space reserved for these commands. // enquecommand_front_P((PSTR("G80"))); goto case_G80; - } + } #endif - if (farm_mode) { prusa_statistics(20); }; + if (farm_mode) { prusa_statistics(20); }; - homing_flag = false; + homing_flag = false; #if 0 - SERIAL_ECHOPGM("G28, final "); print_world_coordinates(); - SERIAL_ECHOPGM("G28, final "); print_physical_coordinates(); - SERIAL_ECHOPGM("G28, final "); print_mesh_bed_leveling_table(); + SERIAL_ECHOPGM("G28, final "); print_world_coordinates(); + SERIAL_ECHOPGM("G28, final "); print_physical_coordinates(); + SERIAL_ECHOPGM("G28, final "); print_mesh_bed_leveling_table(); #endif - break; + break; } #ifdef ENABLE_AUTO_BED_LEVELING case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points. @@ -3451,17 +3451,32 @@ void process_commands() } lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CAL_WARNING); bool result = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_STEEL_SHEET_CHECK, false, false); + if (result) { current_position[Z_AXIS] = 50; - current_position[Y_AXIS] = 190; + current_position[Y_AXIS] += 180; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); st_synchronize(); lcd_show_fullscreen_message_and_wait_P(MSG_REMOVE_STEEL_SHEET); + current_position[Y_AXIS] -= 180; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + st_synchronize(); + feedrate = homing_feedrate[Z_AXIS] / 10; + enable_endstops(true); + endstops_hit_on_purpose(); + homeaxis(Z_AXIS); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + enable_endstops(false); } if ((current_temperature_pinda > 35) && (farm_mode == false)) { //waiting for PIDNA probe to cool down in case that we are not in farm mode - lcd_wait_for_pinda(35); + current_position[Z_AXIS] = 100; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + if (lcd_wait_for_pinda(35) == false) { //waiting for PINDA probe to cool, if this takes more then time expected, temp. cal. fails + lcd_temp_cal_show_result(false); + break; + } } lcd_update_enable(true); KEEPALIVE_STATE(NOT_BUSY); //no need to print busy messages as we print current temperatures periodicaly @@ -3504,7 +3519,9 @@ void process_commands() plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); st_synchronize(); - find_bed_induction_sensor_point_z(-1.f); + bool find_z_result = find_bed_induction_sensor_point_z(-1.f); + if(find_z_result == false) lcd_temp_cal_show_result(find_z_result); + zero_z = current_position[Z_AXIS]; //current_position[Z_AXIS] @@ -3553,7 +3570,9 @@ void process_commands() current_position[Y_AXIS] = pgm_read_float(bed_ref_points + 1); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); st_synchronize(); - find_bed_induction_sensor_point_z(-1.f); + find_z_result = find_bed_induction_sensor_point_z(-1.f); + if (find_z_result == false) lcd_temp_cal_show_result(find_z_result); + z_shift = (int)((current_position[Z_AXIS] - zero_z)*axis_steps_per_unit[Z_AXIS]); SERIAL_ECHOLNPGM(""); @@ -3566,25 +3585,8 @@ void process_commands() EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); } - custom_message_type = 0; - custom_message = false; + lcd_temp_cal_show_result(true); - eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); - SERIAL_ECHOLNPGM("Temperature calibration done. Continue with pressing the knob."); - disable_x(); - disable_y(); - disable_z(); - disable_e0(); - disable_e1(); - disable_e2(); - setTargetBed(0); //set bed target temperature back to 0 -// setTargetHotend(0,0); //set hotend target temperature back to 0 - lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CALIBRATION_DONE); - temp_cal_active = true; - eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, 1); - - lcd_update_enable(true); - lcd_update(2); break; } #endif //PINDA_THERMISTOR diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index 98ee8ec6..18f742bf 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -2218,6 +2218,13 @@ const char * const MSG_TEMP_CALIBRATION_ON_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_TEMP_CALIBRATION_ON_CZ }; +const char MSG_TEMP_CAL_FAILED_EN[] PROGMEM = "Temperature calibration failed"; +const char MSG_TEMP_CAL_FAILED_CZ[] PROGMEM = "Teplotni kalibrace selhala"; +const char * const MSG_TEMP_CAL_FAILED_LANG_TABLE[LANG_NUM] PROGMEM = { + MSG_TEMP_CAL_FAILED_EN, + MSG_TEMP_CAL_FAILED_CZ +}; + const char MSG_TEMP_CAL_WARNING_EN[] PROGMEM = "Stable ambient temperature 21-26C is needed a rigid stand is required."; const char * const MSG_TEMP_CAL_WARNING_LANG_TABLE[1] PROGMEM = { MSG_TEMP_CAL_WARNING_EN diff --git a/Firmware/language_all.h b/Firmware/language_all.h index ae827873..e4711773 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -726,6 +726,8 @@ extern const char* const MSG_TEMP_CALIBRATION_OFF_LANG_TABLE[LANG_NUM]; #define MSG_TEMP_CALIBRATION_OFF LANG_TABLE_SELECT(MSG_TEMP_CALIBRATION_OFF_LANG_TABLE) extern const char* const MSG_TEMP_CALIBRATION_ON_LANG_TABLE[LANG_NUM]; #define MSG_TEMP_CALIBRATION_ON LANG_TABLE_SELECT(MSG_TEMP_CALIBRATION_ON_LANG_TABLE) +extern const char* const MSG_TEMP_CAL_FAILED_LANG_TABLE[LANG_NUM]; +#define MSG_TEMP_CAL_FAILED LANG_TABLE_SELECT(MSG_TEMP_CAL_FAILED_LANG_TABLE) extern const char* const MSG_TEMP_CAL_WARNING_LANG_TABLE[1]; #define MSG_TEMP_CAL_WARNING LANG_TABLE_SELECT_EXPLICIT(MSG_TEMP_CAL_WARNING_LANG_TABLE, 0) extern const char* const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE[1]; diff --git a/Firmware/language_cz.h b/Firmware/language_cz.h index f7eb4f1b..5069d802 100644 --- a/Firmware/language_cz.h +++ b/Firmware/language_cz.h @@ -415,3 +415,4 @@ #define MSG_CHANGED_PRINTER "Varovani: doslo ke zmene typu tiskarny." #define MSG_CHANGED_BOTH "Varovani: doslo ke zmene typu tiskarny a motherboardu." #define MSG_WAITING_TEMP_PINDA "Cekani na zchladnuti PINDA" +#define MSG_TEMP_CAL_FAILED "Teplotni kalibrace selhala" \ No newline at end of file diff --git a/Firmware/language_en.h b/Firmware/language_en.h index 4cb5b20c..84d58e66 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -422,4 +422,5 @@ #define(length=20, lines=4) MSG_CHANGED_MOTHERBOARD "Warning: motherboard type changed." #define(length=20, lines=4) MSG_CHANGED_PRINTER "Warning: printer type changed." #define(length=20, lines=4) MSG_CHANGED_BOTH "Warning: both printer type and motherboard type changed." -#define(length=20, lines=3) MSG_WAITING_TEMP_PINDA "Waiting for PINDA probe cooling" \ No newline at end of file +#define(length=20, lines=3) MSG_WAITING_TEMP_PINDA "Waiting for PINDA probe cooling" +#define(length=20, lines=8) MSG_TEMP_CAL_FAILED "Temperature calibration failed" \ No newline at end of file diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5996272b..25d65d74 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -9,6 +9,7 @@ #include "stepper.h" #include "ConfigurationStore.h" #include +#include "Timer.h" #include "util.h" #include "mesh_bed_leveling.h" @@ -2600,23 +2601,33 @@ void lcd_adjust_z() { } -void lcd_wait_for_pinda(uint8_t temp) { +bool lcd_wait_for_pinda(float temp) { lcd_set_custom_characters_degree(); setTargetHotend(0, 0); setTargetBed(0); + Timer pinda_timeout; + pinda_timeout.start(); + bool target_temp_reached = true; + while (current_temperature_pinda > temp){ lcd_display_message_fullscreen_P(MSG_WAITING_TEMP_PINDA); lcd.setCursor(0, 4); lcd.print(LCD_STR_THERMOMETER[0]); lcd.print(ftostr3(current_temperature_pinda)); - lcd.print("/35"); + lcd.print("/"); + lcd.print(ftostr3(temp)); lcd.print(LCD_STR_DEGREE); delay_keep_alive(1000); serialecho_temperatures(); + if (pinda_timeout.expired(8 * 60 * 1000ul)) { //PINDA cooling from 60 C to 35 C takes about 7 minutes + target_temp_reached = false; + break; + } } lcd_set_custom_characters_arrows(); lcd_update_enable(true); + return(target_temp_reached); } void lcd_wait_for_heater() { @@ -3063,6 +3074,36 @@ void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, ui } } +void lcd_temp_cal_show_result(bool result) { + + custom_message_type = 0; + custom_message = false; + disable_x(); + disable_y(); + disable_z(); + disable_e0(); + disable_e1(); + disable_e2(); + setTargetBed(0); //set bed target temperature back to 0 + + if (result == true) { + eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); + SERIAL_ECHOLNPGM("Temperature calibration done. Continue with pressing the knob."); + lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CALIBRATION_DONE); + temp_cal_active = true; + eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, 1); + } + else { + eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); + SERIAL_ECHOLNPGM("Temperature calibration failed. Continue with pressing the knob."); + lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CAL_FAILED); + temp_cal_active = false; + eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, 0); + } + lcd_update_enable(true); + lcd_update(2); +} + static void lcd_show_end_stops() { lcd.setCursor(0, 0); lcd_printPGM((PSTR("End stops diag"))); diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index c53ac8b9..79fc70d4 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -267,10 +267,13 @@ void lcd_farm_sdcard_menu_w(); void lcd_wait_for_heater(); void lcd_wait_for_cool_down(); -void lcd_wait_for_pinda(uint8_t temp); void adjust_bed_reset(); void lcd_extr_cal_reset(); +void lcd_temp_cal_show_result(bool result); +bool lcd_wait_for_pinda(float temp); + + union MenuData; void bowden_menu(); From cc74edfa13be38051f654fa95d07fdabb8564338 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 24 Apr 2018 14:23:52 +0200 Subject: [PATCH 31/38] whitespace --- Firmware/Marlin_main.cpp | 402 +++++++++++++++++++-------------------- 1 file changed, 201 insertions(+), 201 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 33ad8295..0609b739 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2959,273 +2959,273 @@ void process_commands() #endif //FWRETRACT case 28: //G28 Home all Axis one at a time { - st_synchronize(); + st_synchronize(); #if 0 - SERIAL_ECHOPGM("G28, initial "); print_world_coordinates(); - SERIAL_ECHOPGM("G28, initial "); print_physical_coordinates(); + SERIAL_ECHOPGM("G28, initial "); print_world_coordinates(); + SERIAL_ECHOPGM("G28, initial "); print_physical_coordinates(); #endif - // Flag for the display update routine and to disable the print cancelation during homing. - homing_flag = true; + // Flag for the display update routine and to disable the print cancelation during homing. + homing_flag = true; - // Which axes should be homed? - bool home_x = code_seen(axis_codes[X_AXIS]); - bool home_y = code_seen(axis_codes[Y_AXIS]); - bool home_z = code_seen(axis_codes[Z_AXIS]); - // calibrate? - bool calib = code_seen('C'); - // Either all X,Y,Z codes are present, or none of them. - bool home_all_axes = home_x == home_y && home_x == home_z; - if (home_all_axes) - // No X/Y/Z code provided means to home all axes. - home_x = home_y = home_z = true; + // Which axes should be homed? + bool home_x = code_seen(axis_codes[X_AXIS]); + bool home_y = code_seen(axis_codes[Y_AXIS]); + bool home_z = code_seen(axis_codes[Z_AXIS]); + // calibrate? + bool calib = code_seen('C'); + // Either all X,Y,Z codes are present, or none of them. + bool home_all_axes = home_x == home_y && home_x == home_z; + if (home_all_axes) + // No X/Y/Z code provided means to home all axes. + home_x = home_y = home_z = true; #ifdef ENABLE_AUTO_BED_LEVELING - plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data) + plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data) #endif //ENABLE_AUTO_BED_LEVELING - // Reset world2machine_rotation_and_skew and world2machine_shift, therefore - // the planner will not perform any adjustments in the XY plane. - // Wait for the motors to stop and update the current position with the absolute values. - world2machine_revert_to_uncorrected(); + // Reset world2machine_rotation_and_skew and world2machine_shift, therefore + // the planner will not perform any adjustments in the XY plane. + // Wait for the motors to stop and update the current position with the absolute values. + world2machine_revert_to_uncorrected(); - // For mesh bed leveling deactivate the matrix temporarily. - // It is necessary to disable the bed leveling for the X and Y homing moves, so that the move is performed - // in a single axis only. - // In case of re-homing the X or Y axes only, the mesh bed leveling is restored after G28. + // For mesh bed leveling deactivate the matrix temporarily. + // It is necessary to disable the bed leveling for the X and Y homing moves, so that the move is performed + // in a single axis only. + // In case of re-homing the X or Y axes only, the mesh bed leveling is restored after G28. #ifdef MESH_BED_LEVELING - uint8_t mbl_was_active = mbl.active; - mbl.active = 0; - current_position[Z_AXIS] = st_get_position_mm(Z_AXIS); + uint8_t mbl_was_active = mbl.active; + mbl.active = 0; + current_position[Z_AXIS] = st_get_position_mm(Z_AXIS); #endif - // Reset baby stepping to zero, if the babystepping has already been loaded before. The babystepsTodo value will be - // consumed during the first movements following this statement. - if (home_z) - babystep_undo(); + // Reset baby stepping to zero, if the babystepping has already been loaded before. The babystepsTodo value will be + // consumed during the first movements following this statement. + if (home_z) + babystep_undo(); - saved_feedrate = feedrate; - saved_feedmultiply = feedmultiply; - feedmultiply = 100; - previous_millis_cmd = millis(); + saved_feedrate = feedrate; + saved_feedmultiply = feedmultiply; + feedmultiply = 100; + previous_millis_cmd = millis(); - enable_endstops(true); + enable_endstops(true); - memcpy(destination, current_position, sizeof(destination)); - feedrate = 0.0; + memcpy(destination, current_position, sizeof(destination)); + feedrate = 0.0; #if Z_HOME_DIR > 0 // If homing away from BED do Z first - if(home_z) - homeaxis(Z_AXIS); + if(home_z) + homeaxis(Z_AXIS); #endif #ifdef QUICK_HOME - // In the quick mode, if both x and y are to be homed, a diagonal move will be performed initially. - if(home_x && home_y) //first diagonal move - { - current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0; + // In the quick mode, if both x and y are to be homed, a diagonal move will be performed initially. + if(home_x && home_y) //first diagonal move + { + current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0; - int x_axis_home_dir = home_dir(X_AXIS); + int x_axis_home_dir = home_dir(X_AXIS); - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS); - feedrate = homing_feedrate[X_AXIS]; - if(homing_feedrate[Y_AXIS] max_length(Y_AXIS)) { - feedrate *= sqrt(pow(max_length(Y_AXIS) / max_length(X_AXIS), 2) + 1); - } else { - feedrate *= sqrt(pow(max_length(X_AXIS) / max_length(Y_AXIS), 2) + 1); - } - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); - st_synchronize(); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS); + feedrate = homing_feedrate[X_AXIS]; + if(homing_feedrate[Y_AXIS] max_length(Y_AXIS)) { + feedrate *= sqrt(pow(max_length(Y_AXIS) / max_length(X_AXIS), 2) + 1); + } else { + feedrate *= sqrt(pow(max_length(X_AXIS) / max_length(Y_AXIS), 2) + 1); + } + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); + st_synchronize(); - axis_is_at_home(X_AXIS); - axis_is_at_home(Y_AXIS); - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[X_AXIS] = current_position[X_AXIS]; - destination[Y_AXIS] = current_position[Y_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); - feedrate = 0.0; - st_synchronize(); - endstops_hit_on_purpose(); + axis_is_at_home(X_AXIS); + axis_is_at_home(Y_AXIS); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + destination[X_AXIS] = current_position[X_AXIS]; + destination[Y_AXIS] = current_position[Y_AXIS]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); + feedrate = 0.0; + st_synchronize(); + endstops_hit_on_purpose(); - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; - current_position[Z_AXIS] = destination[Z_AXIS]; - } + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; + current_position[Z_AXIS] = destination[Z_AXIS]; + } #endif /* QUICK_HOME */ #ifdef TMC2130 - if(home_x) - { - if (!calib) - homeaxis(X_AXIS); - else - tmc2130_home_calibrate(X_AXIS); - } + if(home_x) + { + if (!calib) + homeaxis(X_AXIS); + else + tmc2130_home_calibrate(X_AXIS); + } - if(home_y) - { - if (!calib) - homeaxis(Y_AXIS); - else - tmc2130_home_calibrate(Y_AXIS); - } + if(home_y) + { + if (!calib) + homeaxis(Y_AXIS); + else + tmc2130_home_calibrate(Y_AXIS); + } #endif //TMC2130 - if(code_seen(axis_codes[X_AXIS]) && code_value_long() != 0) - current_position[X_AXIS]=code_value()+add_homing[X_AXIS]; + if(code_seen(axis_codes[X_AXIS]) && code_value_long() != 0) + current_position[X_AXIS]=code_value()+add_homing[X_AXIS]; - if(code_seen(axis_codes[Y_AXIS]) && code_value_long() != 0) - current_position[Y_AXIS]=code_value()+add_homing[Y_AXIS]; + if(code_seen(axis_codes[Y_AXIS]) && code_value_long() != 0) + current_position[Y_AXIS]=code_value()+add_homing[Y_AXIS]; #if Z_HOME_DIR < 0 // If homing towards BED do Z last #ifndef Z_SAFE_HOMING - if(home_z) { + if(home_z) { #if defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) - destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed - feedrate = max_feedrate[Z_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); + destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed + feedrate = max_feedrate[Z_AXIS]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); #endif // defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) #if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) // If Mesh bed leveling, moxve X&Y to safe position for home - if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] )) - { - homeaxis(X_AXIS); - homeaxis(Y_AXIS); - } - // 1st mesh bed leveling measurement point, corrected. - world2machine_initialize(); - world2machine(pgm_read_float(bed_ref_points), pgm_read_float(bed_ref_points+1), destination[X_AXIS], destination[Y_AXIS]); - world2machine_reset(); - if (destination[Y_AXIS] < Y_MIN_POS) - destination[Y_AXIS] = Y_MIN_POS; - destination[Z_AXIS] = MESH_HOME_Z_SEARCH; // Set destination away from bed - feedrate = homing_feedrate[Z_AXIS]/10; - current_position[Z_AXIS] = 0; - enable_endstops(false); - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; - enable_endstops(true); - endstops_hit_on_purpose(); - homeaxis(Z_AXIS); + if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] )) + { + homeaxis(X_AXIS); + homeaxis(Y_AXIS); + } + // 1st mesh bed leveling measurement point, corrected. + world2machine_initialize(); + world2machine(pgm_read_float(bed_ref_points), pgm_read_float(bed_ref_points+1), destination[X_AXIS], destination[Y_AXIS]); + world2machine_reset(); + if (destination[Y_AXIS] < Y_MIN_POS) + destination[Y_AXIS] = Y_MIN_POS; + destination[Z_AXIS] = MESH_HOME_Z_SEARCH; // Set destination away from bed + feedrate = homing_feedrate[Z_AXIS]/10; + current_position[Z_AXIS] = 0; + enable_endstops(false); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; + enable_endstops(true); + endstops_hit_on_purpose(); + homeaxis(Z_AXIS); #else // MESH_BED_LEVELING - homeaxis(Z_AXIS); + homeaxis(Z_AXIS); #endif // MESH_BED_LEVELING - } + } #else // defined(Z_SAFE_HOMING): Z Safe mode activated. - if(home_all_axes) { - destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER); - destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER); - destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed - feedrate = XY_TRAVEL_SPEED/60; - current_position[Z_AXIS] = 0; + if(home_all_axes) { + destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER); + destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER); + destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed + feedrate = XY_TRAVEL_SPEED/60; + current_position[Z_AXIS] = 0; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; - homeaxis(Z_AXIS); - } - // Let's see if X and Y are homed and probe is inside bed area. - if(home_z) { - if ( (axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]) \ - && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER >= X_MIN_POS) \ - && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER <= X_MAX_POS) \ - && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER >= Y_MIN_POS) \ - && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) { + homeaxis(Z_AXIS); + } + // Let's see if X and Y are homed and probe is inside bed area. + if(home_z) { + if ( (axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]) \ + && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER >= X_MIN_POS) \ + && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER <= X_MAX_POS) \ + && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER >= Y_MIN_POS) \ + && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) { - current_position[Z_AXIS] = 0; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed - feedrate = max_feedrate[Z_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); + current_position[Z_AXIS] = 0; + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed + feedrate = max_feedrate[Z_AXIS]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); - homeaxis(Z_AXIS); - } else if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { - LCD_MESSAGERPGM(MSG_POSITION_UNKNOWN); - SERIAL_ECHO_START; - SERIAL_ECHOLNRPGM(MSG_POSITION_UNKNOWN); - } else { - LCD_MESSAGERPGM(MSG_ZPROBE_OUT); - SERIAL_ECHO_START; - SERIAL_ECHOLNRPGM(MSG_ZPROBE_OUT); - } - } + homeaxis(Z_AXIS); + } else if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { + LCD_MESSAGERPGM(MSG_POSITION_UNKNOWN); + SERIAL_ECHO_START; + SERIAL_ECHOLNRPGM(MSG_POSITION_UNKNOWN); + } else { + LCD_MESSAGERPGM(MSG_ZPROBE_OUT); + SERIAL_ECHO_START; + SERIAL_ECHOLNRPGM(MSG_ZPROBE_OUT); + } + } #endif // Z_SAFE_HOMING #endif // Z_HOME_DIR < 0 - if(code_seen(axis_codes[Z_AXIS]) && code_value_long() != 0) - current_position[Z_AXIS]=code_value()+add_homing[Z_AXIS]; + if(code_seen(axis_codes[Z_AXIS]) && code_value_long() != 0) + current_position[Z_AXIS]=code_value()+add_homing[Z_AXIS]; #ifdef ENABLE_AUTO_BED_LEVELING - if(home_z) - current_position[Z_AXIS] += zprobe_zoffset; //Add Z_Probe offset (the distance is negative) + if(home_z) + current_position[Z_AXIS] += zprobe_zoffset; //Add Z_Probe offset (the distance is negative) #endif - // Set the planner and stepper routine positions. - // At this point the mesh bed leveling and world2machine corrections are disabled and current_position - // contains the machine coordinates. - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + // Set the planner and stepper routine positions. + // At this point the mesh bed leveling and world2machine corrections are disabled and current_position + // contains the machine coordinates. + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); #ifdef ENDSTOPS_ONLY_FOR_HOMING - enable_endstops(false); + enable_endstops(false); #endif - feedrate = saved_feedrate; - feedmultiply = saved_feedmultiply; - previous_millis_cmd = millis(); - endstops_hit_on_purpose(); + feedrate = saved_feedrate; + feedmultiply = saved_feedmultiply; + previous_millis_cmd = millis(); + endstops_hit_on_purpose(); #ifndef MESH_BED_LEVELING - // If MESH_BED_LEVELING is not active, then it is the original Prusa i3. - // Offer the user to load the baby step value, which has been adjusted at the previous print session. - if(card.sdprinting && eeprom_read_word((uint16_t *)EEPROM_BABYSTEP_Z)) - lcd_adjust_z(); + // If MESH_BED_LEVELING is not active, then it is the original Prusa i3. + // Offer the user to load the baby step value, which has been adjusted at the previous print session. + if(card.sdprinting && eeprom_read_word((uint16_t *)EEPROM_BABYSTEP_Z)) + lcd_adjust_z(); #endif - // Load the machine correction matrix - world2machine_initialize(); - // and correct the current_position XY axes to match the transformed coordinate system. - world2machine_update_current(); + // Load the machine correction matrix + world2machine_initialize(); + // and correct the current_position XY axes to match the transformed coordinate system. + world2machine_update_current(); #if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) - if (code_seen(axis_codes[X_AXIS]) || code_seen(axis_codes[Y_AXIS]) || code_seen('W') || code_seen(axis_codes[Z_AXIS])) - { - if (! home_z && mbl_was_active) { - // Re-enable the mesh bed leveling if only the X and Y axes were re-homed. - mbl.active = true; - // and re-adjust the current logical Z axis with the bed leveling offset applicable at the current XY position. - current_position[Z_AXIS] -= mbl.get_z(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS)); - } - } - else - { - st_synchronize(); - homing_flag = false; - // Push the commands to the front of the message queue in the reverse order! - // There shall be always enough space reserved for these commands. - // enquecommand_front_P((PSTR("G80"))); - goto case_G80; - } + if (code_seen(axis_codes[X_AXIS]) || code_seen(axis_codes[Y_AXIS]) || code_seen('W') || code_seen(axis_codes[Z_AXIS])) + { + if (! home_z && mbl_was_active) { + // Re-enable the mesh bed leveling if only the X and Y axes were re-homed. + mbl.active = true; + // and re-adjust the current logical Z axis with the bed leveling offset applicable at the current XY position. + current_position[Z_AXIS] -= mbl.get_z(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS)); + } + } + else + { + st_synchronize(); + homing_flag = false; + // Push the commands to the front of the message queue in the reverse order! + // There shall be always enough space reserved for these commands. + // enquecommand_front_P((PSTR("G80"))); + goto case_G80; + } #endif - if (farm_mode) { prusa_statistics(20); }; + if (farm_mode) { prusa_statistics(20); }; - homing_flag = false; + homing_flag = false; #if 0 - SERIAL_ECHOPGM("G28, final "); print_world_coordinates(); - SERIAL_ECHOPGM("G28, final "); print_physical_coordinates(); - SERIAL_ECHOPGM("G28, final "); print_mesh_bed_leveling_table(); + SERIAL_ECHOPGM("G28, final "); print_world_coordinates(); + SERIAL_ECHOPGM("G28, final "); print_physical_coordinates(); + SERIAL_ECHOPGM("G28, final "); print_mesh_bed_leveling_table(); #endif - break; + break; } #ifdef ENABLE_AUTO_BED_LEVELING case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points. From ffe93b2ca95c825c47a4199b460543e561e2e69c Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 24 Apr 2018 14:33:48 +0200 Subject: [PATCH 32/38] whitespace correction --- Firmware/Marlin_main.cpp | 398 +++++++++++++++++++-------------------- 1 file changed, 199 insertions(+), 199 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 0609b739..2a256e09 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2958,169 +2958,169 @@ void process_commands() break; #endif //FWRETRACT case 28: //G28 Home all Axis one at a time - { - st_synchronize(); + { + st_synchronize(); #if 0 - SERIAL_ECHOPGM("G28, initial "); print_world_coordinates(); - SERIAL_ECHOPGM("G28, initial "); print_physical_coordinates(); + SERIAL_ECHOPGM("G28, initial "); print_world_coordinates(); + SERIAL_ECHOPGM("G28, initial "); print_physical_coordinates(); #endif - // Flag for the display update routine and to disable the print cancelation during homing. - homing_flag = true; - - // Which axes should be homed? - bool home_x = code_seen(axis_codes[X_AXIS]); - bool home_y = code_seen(axis_codes[Y_AXIS]); - bool home_z = code_seen(axis_codes[Z_AXIS]); - // calibrate? - bool calib = code_seen('C'); - // Either all X,Y,Z codes are present, or none of them. - bool home_all_axes = home_x == home_y && home_x == home_z; - if (home_all_axes) - // No X/Y/Z code provided means to home all axes. - home_x = home_y = home_z = true; + // Flag for the display update routine and to disable the print cancelation during homing. + homing_flag = true; + + // Which axes should be homed? + bool home_x = code_seen(axis_codes[X_AXIS]); + bool home_y = code_seen(axis_codes[Y_AXIS]); + bool home_z = code_seen(axis_codes[Z_AXIS]); + // calibrate? + bool calib = code_seen('C'); + // Either all X,Y,Z codes are present, or none of them. + bool home_all_axes = home_x == home_y && home_x == home_z; + if (home_all_axes) + // No X/Y/Z code provided means to home all axes. + home_x = home_y = home_z = true; #ifdef ENABLE_AUTO_BED_LEVELING - plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data) + plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data) #endif //ENABLE_AUTO_BED_LEVELING + + // Reset world2machine_rotation_and_skew and world2machine_shift, therefore + // the planner will not perform any adjustments in the XY plane. + // Wait for the motors to stop and update the current position with the absolute values. + world2machine_revert_to_uncorrected(); - // Reset world2machine_rotation_and_skew and world2machine_shift, therefore - // the planner will not perform any adjustments in the XY plane. - // Wait for the motors to stop and update the current position with the absolute values. - world2machine_revert_to_uncorrected(); - - // For mesh bed leveling deactivate the matrix temporarily. - // It is necessary to disable the bed leveling for the X and Y homing moves, so that the move is performed - // in a single axis only. - // In case of re-homing the X or Y axes only, the mesh bed leveling is restored after G28. + // For mesh bed leveling deactivate the matrix temporarily. + // It is necessary to disable the bed leveling for the X and Y homing moves, so that the move is performed + // in a single axis only. + // In case of re-homing the X or Y axes only, the mesh bed leveling is restored after G28. #ifdef MESH_BED_LEVELING - uint8_t mbl_was_active = mbl.active; - mbl.active = 0; - current_position[Z_AXIS] = st_get_position_mm(Z_AXIS); + uint8_t mbl_was_active = mbl.active; + mbl.active = 0; + current_position[Z_AXIS] = st_get_position_mm(Z_AXIS); #endif - // Reset baby stepping to zero, if the babystepping has already been loaded before. The babystepsTodo value will be - // consumed during the first movements following this statement. - if (home_z) - babystep_undo(); + // Reset baby stepping to zero, if the babystepping has already been loaded before. The babystepsTodo value will be + // consumed during the first movements following this statement. + if (home_z) + babystep_undo(); - saved_feedrate = feedrate; - saved_feedmultiply = feedmultiply; - feedmultiply = 100; - previous_millis_cmd = millis(); + saved_feedrate = feedrate; + saved_feedmultiply = feedmultiply; + feedmultiply = 100; + previous_millis_cmd = millis(); - enable_endstops(true); + enable_endstops(true); - memcpy(destination, current_position, sizeof(destination)); - feedrate = 0.0; + memcpy(destination, current_position, sizeof(destination)); + feedrate = 0.0; -#if Z_HOME_DIR > 0 // If homing away from BED do Z first - if(home_z) - homeaxis(Z_AXIS); -#endif + #if Z_HOME_DIR > 0 // If homing away from BED do Z first + if(home_z) + homeaxis(Z_AXIS); + #endif -#ifdef QUICK_HOME - // In the quick mode, if both x and y are to be homed, a diagonal move will be performed initially. - if(home_x && home_y) //first diagonal move - { - current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0; + #ifdef QUICK_HOME + // In the quick mode, if both x and y are to be homed, a diagonal move will be performed initially. + if(home_x && home_y) //first diagonal move + { + current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0; - int x_axis_home_dir = home_dir(X_AXIS); + int x_axis_home_dir = home_dir(X_AXIS); - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS); - feedrate = homing_feedrate[X_AXIS]; - if(homing_feedrate[Y_AXIS] max_length(Y_AXIS)) { - feedrate *= sqrt(pow(max_length(Y_AXIS) / max_length(X_AXIS), 2) + 1); - } else { - feedrate *= sqrt(pow(max_length(X_AXIS) / max_length(Y_AXIS), 2) + 1); - } - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); - st_synchronize(); - - axis_is_at_home(X_AXIS); - axis_is_at_home(Y_AXIS); - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[X_AXIS] = current_position[X_AXIS]; - destination[Y_AXIS] = current_position[Y_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); - feedrate = 0.0; - st_synchronize(); - endstops_hit_on_purpose(); - - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; - current_position[Z_AXIS] = destination[Z_AXIS]; + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS); + feedrate = homing_feedrate[X_AXIS]; + if(homing_feedrate[Y_AXIS] max_length(Y_AXIS)) { + feedrate *= sqrt(pow(max_length(Y_AXIS) / max_length(X_AXIS), 2) + 1); + } else { + feedrate *= sqrt(pow(max_length(X_AXIS) / max_length(Y_AXIS), 2) + 1); } -#endif /* QUICK_HOME */ + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); + st_synchronize(); + + axis_is_at_home(X_AXIS); + axis_is_at_home(Y_AXIS); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + destination[X_AXIS] = current_position[X_AXIS]; + destination[Y_AXIS] = current_position[Y_AXIS]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); + feedrate = 0.0; + st_synchronize(); + endstops_hit_on_purpose(); + + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; + current_position[Z_AXIS] = destination[Z_AXIS]; + } + #endif /* QUICK_HOME */ #ifdef TMC2130 - if(home_x) - { - if (!calib) - homeaxis(X_AXIS); - else - tmc2130_home_calibrate(X_AXIS); - } + if(home_x) + { + if (!calib) + homeaxis(X_AXIS); + else + tmc2130_home_calibrate(X_AXIS); + } - if(home_y) - { - if (!calib) - homeaxis(Y_AXIS); - else - tmc2130_home_calibrate(Y_AXIS); - } + if(home_y) + { + if (!calib) + homeaxis(Y_AXIS); + else + tmc2130_home_calibrate(Y_AXIS); + } #endif //TMC2130 - if(code_seen(axis_codes[X_AXIS]) && code_value_long() != 0) - current_position[X_AXIS]=code_value()+add_homing[X_AXIS]; + if(code_seen(axis_codes[X_AXIS]) && code_value_long() != 0) + current_position[X_AXIS]=code_value()+add_homing[X_AXIS]; - if(code_seen(axis_codes[Y_AXIS]) && code_value_long() != 0) - current_position[Y_AXIS]=code_value()+add_homing[Y_AXIS]; + if(code_seen(axis_codes[Y_AXIS]) && code_value_long() != 0) + current_position[Y_AXIS]=code_value()+add_homing[Y_AXIS]; -#if Z_HOME_DIR < 0 // If homing towards BED do Z last -#ifndef Z_SAFE_HOMING - if(home_z) { -#if defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) - destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed - feedrate = max_feedrate[Z_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); -#endif // defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) -#if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) // If Mesh bed leveling, moxve X&Y to safe position for home - if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] )) - { + #if Z_HOME_DIR < 0 // If homing towards BED do Z last + #ifndef Z_SAFE_HOMING + if(home_z) { + #if defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) + destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed + feedrate = max_feedrate[Z_AXIS]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); + #endif // defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) + #if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) // If Mesh bed leveling, moxve X&Y to safe position for home + if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] )) + { homeaxis(X_AXIS); homeaxis(Y_AXIS); - } - // 1st mesh bed leveling measurement point, corrected. - world2machine_initialize(); - world2machine(pgm_read_float(bed_ref_points), pgm_read_float(bed_ref_points+1), destination[X_AXIS], destination[Y_AXIS]); - world2machine_reset(); - if (destination[Y_AXIS] < Y_MIN_POS) - destination[Y_AXIS] = Y_MIN_POS; - destination[Z_AXIS] = MESH_HOME_Z_SEARCH; // Set destination away from bed - feedrate = homing_feedrate[Z_AXIS]/10; - current_position[Z_AXIS] = 0; - enable_endstops(false); - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; - enable_endstops(true); - endstops_hit_on_purpose(); - homeaxis(Z_AXIS); -#else // MESH_BED_LEVELING - homeaxis(Z_AXIS); -#endif // MESH_BED_LEVELING - } -#else // defined(Z_SAFE_HOMING): Z Safe mode activated. - if(home_all_axes) { + } + // 1st mesh bed leveling measurement point, corrected. + world2machine_initialize(); + world2machine(pgm_read_float(bed_ref_points), pgm_read_float(bed_ref_points+1), destination[X_AXIS], destination[Y_AXIS]); + world2machine_reset(); + if (destination[Y_AXIS] < Y_MIN_POS) + destination[Y_AXIS] = Y_MIN_POS; + destination[Z_AXIS] = MESH_HOME_Z_SEARCH; // Set destination away from bed + feedrate = homing_feedrate[Z_AXIS]/10; + current_position[Z_AXIS] = 0; + enable_endstops(false); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; + enable_endstops(true); + endstops_hit_on_purpose(); + homeaxis(Z_AXIS); + #else // MESH_BED_LEVELING + homeaxis(Z_AXIS); + #endif // MESH_BED_LEVELING + } + #else // defined(Z_SAFE_HOMING): Z Safe mode activated. + if(home_all_axes) { destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER); destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER); destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed @@ -3134,23 +3134,23 @@ void process_commands() current_position[Y_AXIS] = destination[Y_AXIS]; homeaxis(Z_AXIS); - } - // Let's see if X and Y are homed and probe is inside bed area. - if(home_z) { + } + // Let's see if X and Y are homed and probe is inside bed area. + if(home_z) { if ( (axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]) \ - && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER >= X_MIN_POS) \ - && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER <= X_MAX_POS) \ - && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER >= Y_MIN_POS) \ - && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) { + && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER >= X_MIN_POS) \ + && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER <= X_MAX_POS) \ + && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER >= Y_MIN_POS) \ + && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) { - current_position[Z_AXIS] = 0; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed - feedrate = max_feedrate[Z_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); + current_position[Z_AXIS] = 0; + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed + feedrate = max_feedrate[Z_AXIS]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); - homeaxis(Z_AXIS); + homeaxis(Z_AXIS); } else if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { LCD_MESSAGERPGM(MSG_POSITION_UNKNOWN); SERIAL_ECHO_START; @@ -3160,72 +3160,72 @@ void process_commands() SERIAL_ECHO_START; SERIAL_ECHOLNRPGM(MSG_ZPROBE_OUT); } - } -#endif // Z_SAFE_HOMING -#endif // Z_HOME_DIR < 0 + } + #endif // Z_SAFE_HOMING + #endif // Z_HOME_DIR < 0 - if(code_seen(axis_codes[Z_AXIS]) && code_value_long() != 0) - current_position[Z_AXIS]=code_value()+add_homing[Z_AXIS]; -#ifdef ENABLE_AUTO_BED_LEVELING + if(code_seen(axis_codes[Z_AXIS]) && code_value_long() != 0) + current_position[Z_AXIS]=code_value()+add_homing[Z_AXIS]; + #ifdef ENABLE_AUTO_BED_LEVELING if(home_z) - current_position[Z_AXIS] += zprobe_zoffset; //Add Z_Probe offset (the distance is negative) -#endif + current_position[Z_AXIS] += zprobe_zoffset; //Add Z_Probe offset (the distance is negative) + #endif + + // Set the planner and stepper routine positions. + // At this point the mesh bed leveling and world2machine corrections are disabled and current_position + // contains the machine coordinates. + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - // Set the planner and stepper routine positions. - // At this point the mesh bed leveling and world2machine corrections are disabled and current_position - // contains the machine coordinates. - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - -#ifdef ENDSTOPS_ONLY_FOR_HOMING + #ifdef ENDSTOPS_ONLY_FOR_HOMING enable_endstops(false); -#endif + #endif - feedrate = saved_feedrate; - feedmultiply = saved_feedmultiply; - previous_millis_cmd = millis(); - endstops_hit_on_purpose(); + feedrate = saved_feedrate; + feedmultiply = saved_feedmultiply; + previous_millis_cmd = millis(); + endstops_hit_on_purpose(); #ifndef MESH_BED_LEVELING - // If MESH_BED_LEVELING is not active, then it is the original Prusa i3. - // Offer the user to load the baby step value, which has been adjusted at the previous print session. - if(card.sdprinting && eeprom_read_word((uint16_t *)EEPROM_BABYSTEP_Z)) - lcd_adjust_z(); + // If MESH_BED_LEVELING is not active, then it is the original Prusa i3. + // Offer the user to load the baby step value, which has been adjusted at the previous print session. + if(card.sdprinting && eeprom_read_word((uint16_t *)EEPROM_BABYSTEP_Z)) + lcd_adjust_z(); #endif - // Load the machine correction matrix - world2machine_initialize(); - // and correct the current_position XY axes to match the transformed coordinate system. - world2machine_update_current(); + // Load the machine correction matrix + world2machine_initialize(); + // and correct the current_position XY axes to match the transformed coordinate system. + world2machine_update_current(); #if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) - if (code_seen(axis_codes[X_AXIS]) || code_seen(axis_codes[Y_AXIS]) || code_seen('W') || code_seen(axis_codes[Z_AXIS])) - { - if (! home_z && mbl_was_active) { - // Re-enable the mesh bed leveling if only the X and Y axes were re-homed. - mbl.active = true; - // and re-adjust the current logical Z axis with the bed leveling offset applicable at the current XY position. - current_position[Z_AXIS] -= mbl.get_z(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS)); - } - } - else - { - st_synchronize(); - homing_flag = false; - // Push the commands to the front of the message queue in the reverse order! - // There shall be always enough space reserved for these commands. - // enquecommand_front_P((PSTR("G80"))); - goto case_G80; - } + if (code_seen(axis_codes[X_AXIS]) || code_seen(axis_codes[Y_AXIS]) || code_seen('W') || code_seen(axis_codes[Z_AXIS])) + { + if (! home_z && mbl_was_active) { + // Re-enable the mesh bed leveling if only the X and Y axes were re-homed. + mbl.active = true; + // and re-adjust the current logical Z axis with the bed leveling offset applicable at the current XY position. + current_position[Z_AXIS] -= mbl.get_z(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS)); + } + } + else + { + st_synchronize(); + homing_flag = false; + // Push the commands to the front of the message queue in the reverse order! + // There shall be always enough space reserved for these commands. + // enquecommand_front_P((PSTR("G80"))); + goto case_G80; + } #endif - if (farm_mode) { prusa_statistics(20); }; + if (farm_mode) { prusa_statistics(20); }; - homing_flag = false; + homing_flag = false; #if 0 - SERIAL_ECHOPGM("G28, final "); print_world_coordinates(); - SERIAL_ECHOPGM("G28, final "); print_physical_coordinates(); - SERIAL_ECHOPGM("G28, final "); print_mesh_bed_leveling_table(); + SERIAL_ECHOPGM("G28, final "); print_world_coordinates(); + SERIAL_ECHOPGM("G28, final "); print_physical_coordinates(); + SERIAL_ECHOPGM("G28, final "); print_mesh_bed_leveling_table(); #endif - break; + break; } #ifdef ENABLE_AUTO_BED_LEVELING case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points. From 8efe66ef99eb62710cb8e23d838d8301f804a64d Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 24 Apr 2018 14:34:49 +0200 Subject: [PATCH 33/38] remove tab --- 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 2a256e09..e7b9ba88 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2958,7 +2958,7 @@ void process_commands() break; #endif //FWRETRACT case 28: //G28 Home all Axis one at a time - { + { st_synchronize(); #if 0 From 1553e99d8eddaaf708f0f5c9d37f4cc9546945c0 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Tue, 24 Apr 2018 20:12:29 +0200 Subject: [PATCH 34/38] Meshbedleveling/MK3 - check crash Z after homeaxis (kill with message "debris on nozzle...") --- Firmware/Marlin_main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index b16c81d2..6cf620e4 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2075,6 +2075,9 @@ void homeaxis(int axis, uint8_t cnt, uint8_t* pstep) feedrate = homing_feedrate[axis]; plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); st_synchronize(); +#ifdef TMC2130 + if (READ(Z_TMC2130_DIAG) != 0) return; //Z crash +#endif //TMC2130 current_position[axis] = 0; plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); destination[axis] = -home_retract_mm(axis) * axis_home_dir; @@ -2084,6 +2087,9 @@ void homeaxis(int axis, uint8_t cnt, uint8_t* pstep) feedrate = homing_feedrate[axis]/2 ; plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); st_synchronize(); +#ifdef TMC2130 + if (READ(Z_TMC2130_DIAG) != 0) return; //Z crash +#endif //TMC2130 axis_is_at_home(axis); destination[axis] = current_position[axis]; feedrate = 0.0; @@ -3765,6 +3771,15 @@ void process_commands() #endif //MK1BP case_G80: { +#ifdef TMC2130 + //previously enqueued "G28 W0" failed (crash Z) + if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && !axis_known_position[Z_AXIS] && (READ(Z_TMC2130_DIAG) != 0)) + { + kill(MSG_BED_LEVELING_FAILED_POINT_LOW); + break; + } +#endif //TMC2130 + mesh_bed_leveling_flag = true; int8_t verbosity_level = 0; static bool run = false; From 3abfeb831f10e0b472cd538016de059baf2fe5dc Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 25 Apr 2018 12:21:20 +0200 Subject: [PATCH 35/38] Update documentation of mesh_bed_calibration.cpp. --- Firmware/mesh_bed_calibration.cpp | 67 ++++++++++++++++++++++++------- Firmware/mesh_bed_calibration.h | 19 +++++---- 2 files changed, 64 insertions(+), 22 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 9c5b1271..18b914e7 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -159,22 +159,29 @@ static inline float point_weight_y(const uint8_t i, const uint8_t npts, const fl } return w; } - -// Non-Linear Least Squares fitting of the bed to the measured induction points -// using the Gauss-Newton method. -// This method will maintain a unity length of the machine axes, -// which is the correct approach if the sensor points are not measured precisely. +/** + * @brief Calculate machine skew and offset + * + * Non-Linear Least Squares fitting of the bed to the measured induction points + * using the Gauss-Newton method. + * This method will maintain a unity length of the machine axes, + * which is the correct approach if the sensor points are not measured precisely. + * @param measured_pts Matrix of 2D points (maximum 18 floats) + * @param npts Number of points (maximum 9) + * @param true_pts + * @param [out] vec_x Resulting correction matrix. X axis vector + * @param [out] vec_y Resulting correction matrix. Y axis vector + * @param [out] cntr Resulting correction matrix. [0;0] pont offset + * @param verbosity_level + * @return BedSkewOffsetDetectionResultType + */ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS( - // Matrix of maximum 9 2D points (18 floats) const float *measured_pts, uint8_t npts, const float *true_pts, - // Resulting correction matrix. float *vec_x, float *vec_y, float *cntr, - // Temporary values, 49-18-(2*3)=25 floats - // , float *temp int8_t verbosity_level ) { @@ -649,6 +656,9 @@ BedSkewOffsetDetectionResultType calculate_machine_skew_and_offset_LS( return result; } +/** + * @brief Erase calibration data stored in EEPROM + */ void reset_bed_offset_and_skew() { eeprom_update_dword((uint32_t*)(EEPROM_BED_CALIBRATION_CENTER+0), 0x0FFFFFFFF); @@ -703,6 +713,12 @@ static void world2machine_update(const float vec_x[2], const float vec_y[2], con } } +/** + * @brief Set calibration matrix to identity + * + * In contrast with world2machine_revert_to_uncorrected(), it doesn't wait for finishing moves + * nor updates the current position with the absolute values. + */ void world2machine_reset() { const float vx[] = { 1.f, 0.f }; @@ -711,6 +727,11 @@ void world2machine_reset() world2machine_update(vx, vy, cntr); } +/** + * @brief Set calibration matrix to default value + * + * This is used if no valid calibration data can be read from EEPROM. + */ static void world2machine_default() { #ifdef DEFAULT_Y_OFFSET @@ -722,12 +743,15 @@ static void world2machine_default() world2machine_reset(); #endif } - +/** + * @brief Set calibration matrix to identity and update current position with absolute position + * + * Wait for the motors to stop and then update the current position with the absolute values. + */ void world2machine_revert_to_uncorrected() { if (world2machine_correction_mode != WORLD2MACHINE_CORRECTION_NONE) { world2machine_reset(); - // Wait for the motors to stop and update the current position with the absolute values. st_synchronize(); current_position[X_AXIS] = st_get_position_mm(X_AXIS); current_position[Y_AXIS] = st_get_position_mm(Y_AXIS); @@ -740,6 +764,15 @@ static inline bool vec_undef(const float v[2]) return vx[0] == 0x0FFFFFFFF || vx[1] == 0x0FFFFFFFF; } +/** + * @brief Read and apply calibration data from EEPROM + * + * If no calibration data has been stored in EEPROM or invalid, + * world2machine_default() is used. + * + * If stored calibration data is invalid, EEPROM storage is cleared. + * + */ void world2machine_initialize() { //SERIAL_ECHOLNPGM("world2machine_initialize"); @@ -818,10 +851,14 @@ void world2machine_initialize() } } -// When switching from absolute to corrected coordinates, -// this will get the absolute coordinates from the servos, -// applies the inverse world2machine transformation -// and stores the result into current_position[x,y]. +/** + * @brief Update current position after switching to corrected coordinates + * + * When switching from absolute to corrected coordinates, + * this will get the absolute coordinates from the servos, + * applies the inverse world2machine transformation + * and stores the result into current_position[x,y]. + */ void world2machine_update_current() { float x = current_position[X_AXIS] - world2machine_shift[0]; diff --git a/Firmware/mesh_bed_calibration.h b/Firmware/mesh_bed_calibration.h index 305e473d..ced77cf6 100644 --- a/Firmware/mesh_bed_calibration.h +++ b/Firmware/mesh_bed_calibration.h @@ -135,17 +135,22 @@ extern bool find_bed_induction_sensor_point_z(float minimum_z = -10.f, uint8_t n extern bool find_bed_induction_sensor_point_xy(int verbosity_level = 0); extern void go_home_with_z_lift(); -// Positive or zero: ok -// Negative: failed +/** + * @brief Bed skew and offest detection result + * + * Positive or zero: ok + * Negative: failed + */ + enum BedSkewOffsetDetectionResultType { // Detection failed, some point was not found. - BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND = -1, - BED_SKEW_OFFSET_DETECTION_FITTING_FAILED = -2, + BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND = -1, //!< Point not found. + BED_SKEW_OFFSET_DETECTION_FITTING_FAILED = -2, //!< Fitting failed // Detection finished with success. - BED_SKEW_OFFSET_DETECTION_PERFECT = 0, - BED_SKEW_OFFSET_DETECTION_SKEW_MILD = 1, - BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME = 2 + BED_SKEW_OFFSET_DETECTION_PERFECT = 0, //!< Perfect. + BED_SKEW_OFFSET_DETECTION_SKEW_MILD = 1, //!< Mildly skewed. + BED_SKEW_OFFSET_DETECTION_SKEW_EXTREME = 2 //!< Extremely skewed. }; extern BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level, uint8_t &too_far_mask); From 5f12289339cbef144aad57e5904d2d7b4a600d71 Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Wed, 25 Apr 2018 14:43:32 +0200 Subject: [PATCH 36/38] CalibrationZ/MK3 - check crash Z after homeaxis (kill with message "debris on nozzle...") --- Firmware/mesh_bed_calibration.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 9c5b1271..e8ed5cda 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -2683,6 +2683,15 @@ bool sample_mesh_and_store_reference() memcpy(destination, current_position, sizeof(destination)); enable_endstops(true); homeaxis(Z_AXIS); + +#ifdef TMC2130 + if (!axis_known_position[Z_AXIS] && (READ(Z_TMC2130_DIAG) != 0)) //Z crash + { + kill(MSG_BED_LEVELING_FAILED_POINT_LOW); + return false; + } +#endif //TMC2130 + enable_endstops(false); find_bed_induction_sensor_point_z(); mbl.set_z(0, 0, current_position[Z_AXIS]); From 0271ab364377596073145bd8e52580a4b9dfc9cf Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Wed, 25 Apr 2018 16:19:16 +0200 Subject: [PATCH 37/38] Meshbedleveling, calibration Z check crash Z (MK3) check deviation of Z-probe (>50um == error, all printers) kill with message "debris on nozzle..." --- Firmware/Marlin_main.cpp | 4 ++-- Firmware/mesh_bed_calibration.cpp | 29 +++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 7db28735..21c5dd6c 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2076,7 +2076,7 @@ void homeaxis(int axis, uint8_t cnt, uint8_t* pstep) plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); st_synchronize(); #ifdef TMC2130 - if (READ(Z_TMC2130_DIAG) != 0) return; //Z crash + if ((tmc2130_mode == TMC2130_MODE_NORMAL) && (READ(Z_TMC2130_DIAG) != 0)) return; //Z crash #endif //TMC2130 current_position[axis] = 0; plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); @@ -2088,7 +2088,7 @@ void homeaxis(int axis, uint8_t cnt, uint8_t* pstep) plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); st_synchronize(); #ifdef TMC2130 - if (READ(Z_TMC2130_DIAG) != 0) return; //Z crash + if ((tmc2130_mode == TMC2130_MODE_NORMAL) && (READ(Z_TMC2130_DIAG) != 0)) return; //Z crash #endif //TMC2130 axis_is_at_home(axis); destination[axis] = current_position[axis]; diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index e8ed5cda..946a623e 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -7,6 +7,10 @@ #include "stepper.h" #include "ultralcd.h" +#ifdef TMC2130 +#include "tmc2130.h" +#endif //TMC2130 + uint8_t world2machine_correction_mode; float world2machine_rotation_and_skew[2][2]; float world2machine_rotation_and_skew_inv[2][2]; @@ -880,8 +884,11 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i update_current_position_z(); if (! endstop_z_hit_on_purpose()) goto error; - - for (uint8_t i = 0; i < n_iter; ++ i) { +#ifdef TMC2130 + if ((tmc2130_mode == TMC2130_MODE_NORMAL) && (READ(Z_TMC2130_DIAG) != 0)) goto error; //crash Z detected +#endif //TMC2130 + for (uint8_t i = 0; i < n_iter; ++ i) + { // Move up the retract distance. current_position[Z_AXIS] += .5f; go_to_current(homing_feedrate[Z_AXIS]/60); @@ -892,10 +899,16 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i update_current_position_z(); if (! endstop_z_hit_on_purpose()) goto error; +#ifdef TMC2130 + if ((tmc2130_mode == TMC2130_MODE_NORMAL) && (READ(Z_TMC2130_DIAG) != 0)) goto error; //crash Z detected +#endif //TMC2130 // SERIAL_ECHOPGM("Bed find_bed_induction_sensor_point_z low, height: "); // MYSERIAL.print(current_position[Z_AXIS], 5); // SERIAL_ECHOLNPGM(""); + float dz = i?abs(current_position[Z_AXIS] - (z / i)):0; z += current_position[Z_AXIS]; +// printf_P(PSTR(" Z[%d] = %d, dz=%d\n"), i, (int)(current_position[Z_AXIS] * 1000), (int)(dz * 1000)); + if (dz > 0.05) goto error;//deviation > 50um } current_position[Z_AXIS] = z; if (n_iter > 1) @@ -2693,7 +2706,11 @@ bool sample_mesh_and_store_reference() #endif //TMC2130 enable_endstops(false); - find_bed_induction_sensor_point_z(); + if (!find_bed_induction_sensor_point_z()) //Z crash or deviation > 50um + { + kill(MSG_BED_LEVELING_FAILED_POINT_LOW); + return false; + } mbl.set_z(0, 0, current_position[Z_AXIS]); } for (int8_t mesh_point = 1; mesh_point != MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS; ++ mesh_point) { @@ -2711,7 +2728,11 @@ bool sample_mesh_and_store_reference() lcd_implementation_print_at(0, next_line, mesh_point+1); lcd_printPGM(MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2); #endif /* MESH_BED_CALIBRATION_SHOW_LCD */ - find_bed_induction_sensor_point_z(); + if (!find_bed_induction_sensor_point_z()) //Z crash or deviation > 50um + { + kill(MSG_BED_LEVELING_FAILED_POINT_LOW); + return false; + } // Get cords of measuring point int8_t ix = mesh_point % MESH_MEAS_NUM_X_POINTS; int8_t iy = mesh_point / MESH_MEAS_NUM_X_POINTS; From f2071457527b29dd508d5d15dc7553542f5ed502 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 25 Apr 2018 16:51:35 +0200 Subject: [PATCH 38/38] Return from Autoload filament and Load filament menu item to parent menu. Exception is Load filament, when temperature is sufficient to load filament, in such case, load filament is started and GUI returns to status screen. --- Firmware/Timer.cpp | 6 +++ Firmware/ultralcd.cpp | 85 +++++++++++++++++++++++++++++++------------ 2 files changed, 67 insertions(+), 24 deletions(-) diff --git a/Firmware/Timer.cpp b/Firmware/Timer.cpp index 78f47a45..29866a67 100644 --- a/Firmware/Timer.cpp +++ b/Firmware/Timer.cpp @@ -6,6 +6,12 @@ #include "Timer.h" #include "Arduino.h" +/** + * @brief construct Timer + * + * It is guaranteed, that construction is equivalent with zeroing all members. + * This property can be exploited in MenuData union. + */ Timer::Timer() : m_isRunning(false), m_started() { } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 25d65d74..19522eca 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -108,6 +108,11 @@ union MenuData // editMenuParentState is used when an edit menu is entered, so it knows // the return menu and encoder state. struct EditMenuParentState editMenuParentState; + + struct AutoLoadFilamentMenu + { + Timer timer; + } autoLoadFilamentMenu; }; // State of the currently active menu. @@ -188,6 +193,7 @@ unsigned char firstrun = 1; /** forward declarations **/ +static const char* lcd_display_message_fullscreen_nonBlocking_P(const char *msg, uint8_t &nlines); // void copy_and_scalePID_i(); // void copy_and_scalePID_d(); @@ -2069,39 +2075,50 @@ void lcd_alright() { } - - -void lcd_LoadFilament() -{ - if (degHotend0() > EXTRUDE_MINTEMP) - { #ifdef PAT9125 - if (filament_autoload_enabled && fsensor_enabled) - { - lcd_show_fullscreen_message_and_wait_P(MSG_AUTOLOADING_ENABLED); - return; - } +static void lcd_menu_AutoLoadFilament() +{ + if (degHotend0() > EXTRUDE_MINTEMP) + { + uint8_t nlines; + lcd_display_message_fullscreen_nonBlocking_P(MSG_AUTOLOADING_ENABLED,nlines); + } + else + { + if (!menuData.autoLoadFilamentMenu.timer.running()) menuData.autoLoadFilamentMenu.timer.start(); + lcd.setCursor(0, 0); + lcd_printPGM(MSG_ERROR); + lcd.setCursor(0, 2); + lcd_printPGM(MSG_PREHEAT_NOZZLE); + if (menuData.autoLoadFilamentMenu.timer.expired(2000ul)) menu_action_back(); + } + if (lcd_clicked()) menu_action_back(); +} #endif //PAT9125 - custom_message = true; - loading_flag = true; - enquecommand_P(PSTR("M701")); //load filament - SERIAL_ECHOLN("Loading filament"); + +static void lcd_LoadFilament() +{ + if (degHotend0() > EXTRUDE_MINTEMP) + { + custom_message = true; + loading_flag = true; + enquecommand_P(PSTR("M701")); //load filament + SERIAL_ECHOLN("Loading filament"); + lcd_return_to_status(); } - else + else { lcd_implementation_clear(); lcd.setCursor(0, 0); lcd_printPGM(MSG_ERROR); lcd.setCursor(0, 2); - lcd_printPGM(MSG_PREHEAT_NOZZLE); + lcd_printPGM(MSG_PREHEAT_NOZZLE); delay(2000); lcd_implementation_clear(); } - lcd_return_to_status(); } - void lcd_menu_statistics() { @@ -2777,11 +2794,16 @@ static inline bool pgm_is_interpunction(const char *c_addr) return c == '.' || c == ',' || c == ':'|| c == ';' || c == '?' || c == '!' || c == '/'; } -const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines) +/** + * @brief show full screen message + * + * This function is non-blocking + * @param msg message to be displayed from PROGMEM + * @param nlines + * @return rest of the text (to be displayed on next page) + */ +static const char* lcd_display_message_fullscreen_nonBlocking_P(const char *msg, uint8_t &nlines) { - // Disable update of the screen by the usual lcd_update() routine. - lcd_update_enable(false); - lcd_implementation_clear(); lcd.setCursor(0, 0); const char *msgend = msg; uint8_t row = 0; @@ -2834,6 +2856,21 @@ const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines) return multi_screen ? msgend : NULL; } +const char* lcd_display_message_fullscreen_P(const char *msg, uint8_t &nlines) +{ + // Disable update of the screen by the usual lcd_update() routine. + lcd_update_enable(false); + lcd_implementation_clear(); + return lcd_display_message_fullscreen_nonBlocking_P(msg, nlines); +} + + +/** + * @brief show full screen message and wait + * + * This function is blocking. + * @param msg message to be displayed from PROGMEM + */ void lcd_show_fullscreen_message_and_wait_P(const char *msg) { const char *msg_next = lcd_display_message_fullscreen_P(msg); @@ -5689,7 +5726,7 @@ static void lcd_main_menu() #ifndef SNMM #ifdef PAT9125 if ( ((filament_autoload_enabled == true) && (fsensor_enabled == true))) - MENU_ITEM(function, MSG_AUTOLOAD_FILAMENT, lcd_LoadFilament); + MENU_ITEM(submenu, MSG_AUTOLOAD_FILAMENT, lcd_menu_AutoLoadFilament); else #endif //PAT9125 MENU_ITEM(function, MSG_LOAD_FILAMENT, lcd_LoadFilament);