From bbe9e3b4eaebb6ba4f95a4d6fa4ac9e143bd4cf0 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Thu, 11 Jun 2020 20:00:55 +0200 Subject: [PATCH 1/7] Remove temp_cal_active variable. This saves 18B of FLASH and 1B of RAM memory. This variable was duplicate to EEPROM variable of the same name. --- Firmware/Marlin.h | 1 - Firmware/Marlin_main.cpp | 13 ++++--------- Firmware/ultralcd.cpp | 5 ++--- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 52444337a..5c03552bf 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -334,7 +334,6 @@ extern unsigned long stoptime; extern int bowden_length[4]; extern bool is_usb_printing; extern bool homing_flag; -extern bool temp_cal_active; extern bool loading_flag; extern unsigned int usb_printing_counter; diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 91594edc2..80bdd90f4 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -202,8 +202,6 @@ int bowden_length[4] = {385, 385, 385, 385}; bool is_usb_printing = false; bool homing_flag = false; -bool temp_cal_active = false; - unsigned long kicktime = _millis()+100000; unsigned int usb_printing_counter; @@ -1465,8 +1463,7 @@ void setup() if (eeprom_read_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE) == 255) { eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0); - temp_cal_active = false; - } else temp_cal_active = eeprom_read_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE); + } if (eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA) == 255) { //eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); @@ -1474,7 +1471,6 @@ void setup() int16_t z_shift = 0; for (uint8_t i = 0; i < 5; i++) EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0); - temp_cal_active = false; } if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 255) { eeprom_write_byte((uint8_t*)EEPROM_UVLO, 0); @@ -1547,7 +1543,7 @@ void setup() lcd_show_fullscreen_message_and_wait_P(_T(MSG_BABYSTEP_Z_NOT_SET)); lcd_update_enable(true); } - else if (calibration_status() == CALIBRATION_STATUS_CALIBRATED && temp_cal_active == true && calibration_status_pinda() == false) { + else if (calibration_status() == CALIBRATION_STATUS_CALIBRATED && eeprom_read_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE) && calibration_status_pinda() == false) { //lcd_show_fullscreen_message_and_wait_P(_i("Temperature calibration has not been run yet"));////MSG_PINDA_NOT_CALIBRATED c=20 r=4 lcd_update_enable(true); } @@ -4827,7 +4823,6 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) disable_e2(); setTargetBed(0); //set bed target temperature back to 0 lcd_show_fullscreen_message_and_wait_P(_T(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); @@ -5253,7 +5248,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) go_home_with_z_lift(); // SERIAL_ECHOLNPGM("Go home finished"); //unretract (after PINDA preheat retraction) - if (degHotend(active_extruder) > EXTRUDE_MINTEMP && temp_cal_active == true && calibration_status_pinda() == true && target_temperature_bed >= 50) { + if ((degHotend(active_extruder) > EXTRUDE_MINTEMP) && eeprom_read_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE) && calibration_status_pinda() && (target_temperature_bed >= 50)) { current_position[E_AXIS] += default_retraction; plan_buffer_line_curposXYZE(400); } @@ -10548,7 +10543,7 @@ float temp_comp_interpolation(float inp_temperature) { #ifdef PINDA_THERMISTOR float temp_compensation_pinda_thermistor_offset(float temperature_pinda) { - if (!temp_cal_active) return 0; + if (!eeprom_read_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE)) return 0; if (!calibration_status_pinda()) return 0; return temp_comp_interpolation(temperature_pinda) / cs.axis_steps_per_unit[Z_AXIS]; } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index fda0d1196..a4d2fd54e 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3920,14 +3920,12 @@ void lcd_temp_cal_show_result(bool result) { 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(_T(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(_i("Temperature calibration failed"));////MSG_TEMP_CAL_FAILED c=20 r=8 - temp_cal_active = false; eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, 0); } lcd_update_enable(true); @@ -4635,6 +4633,7 @@ void lcd_pinda_calibration_menu() } void lcd_temp_calibration_set() { + bool temp_cal_active = eeprom_read_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE); temp_cal_active = !temp_cal_active; eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, temp_cal_active); st_current_init(); @@ -5766,7 +5765,7 @@ static void lcd_settings_menu() MENU_ITEM_SUBMENU_P(_i("Lin. correction"), lcd_settings_linearity_correction_menu); #endif //LINEARITY_CORRECTION && TMC2130 - MENU_ITEM_TOGGLE_P(_T(MSG_TEMP_CALIBRATION), temp_cal_active ? _T(MSG_ON) : _T(MSG_OFF), lcd_temp_calibration_set); + MENU_ITEM_TOGGLE_P(_T(MSG_TEMP_CALIBRATION), eeprom_read_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE) ? _T(MSG_ON) : _T(MSG_OFF), lcd_temp_calibration_set); #ifdef HAS_SECOND_SERIAL_PORT MENU_ITEM_TOGGLE_P(_T(MSG_RPI_PORT), (selectedSerialPort == 0) ? _T(MSG_OFF) : _T(MSG_ON), lcd_second_serial_set); From bdf53387b1ef00c4b15707f08c4f1f1eddc5d661 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 16 Jun 2020 00:15:13 +0200 Subject: [PATCH 2/7] Disable temperature compensation and temperature calibration menu if superPINDA is detected. Even though functionality was added, 20B of flash memory has been saved. --- Firmware/ultralcd.cpp | 20 ++++++++++++++++--- .../variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 2 ++ .../variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index a4d2fd54e..13d8a1fb2 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -334,6 +334,15 @@ bool bSettings; // flag (i.e. 'fake parameter' const char STR_SEPARATOR[] PROGMEM = "------------"; +static bool has_temperature_compensation() +{ +#ifdef DETECT_SUPERPINDA + return (current_temperature_pinda >= PINDA_MINTEMP) ? true : false; +#else + return true; +#endif +} + static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* filename, char* longFilename) { @@ -5764,8 +5773,10 @@ static void lcd_settings_menu() #if defined (TMC2130) && defined (LINEARITY_CORRECTION) MENU_ITEM_SUBMENU_P(_i("Lin. correction"), lcd_settings_linearity_correction_menu); #endif //LINEARITY_CORRECTION && TMC2130 - - MENU_ITEM_TOGGLE_P(_T(MSG_TEMP_CALIBRATION), eeprom_read_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE) ? _T(MSG_ON) : _T(MSG_OFF), lcd_temp_calibration_set); + if(has_temperature_compensation()) + { + MENU_ITEM_TOGGLE_P(_T(MSG_TEMP_CALIBRATION), eeprom_read_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE) ? _T(MSG_ON) : _T(MSG_OFF), lcd_temp_calibration_set); + } #ifdef HAS_SECOND_SERIAL_PORT MENU_ITEM_TOGGLE_P(_T(MSG_RPI_PORT), (selectedSerialPort == 0) ? _T(MSG_OFF) : _T(MSG_ON), lcd_second_serial_set); @@ -5869,7 +5880,10 @@ static void lcd_calibration_menu() //MENU_ITEM_FUNCTION_P(MSG_RESET_CALIBRATE_E, lcd_extr_cal_reset); #endif #ifndef MK1BP - MENU_ITEM_SUBMENU_P(_i("Temp. calibration"), lcd_pinda_calibration_menu);////MSG_CALIBRATION_PINDA_MENU c=17 r=1 + if(has_temperature_compensation()) + { + MENU_ITEM_SUBMENU_P(_i("Temp. calibration"), lcd_pinda_calibration_menu);////MSG_CALIBRATION_PINDA_MENU c=17 r=1 + } #endif //MK1BP } diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 8215c48f3..b135d8d13 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -294,6 +294,8 @@ #if BED_MINTEMP_DELAY>USHRT_MAX #error "Check maximal allowed value @ ShortTimer (see BED_MINTEMP_DELAY definition)" #endif +#define DETECT_SUPERPINDA +#define PINDA_MINTEMP BED_MINTEMP // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h index f7d408a45..e618c54ef 100644 --- a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -296,6 +296,8 @@ #if BED_MINTEMP_DELAY>USHRT_MAX #error "Check maximal allowed value @ ShortTimer (see BED_MINTEMP_DELAY definition)" #endif +#define DETECT_SUPERPINDA +#define PINDA_MINTEMP BED_MINTEMP // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) From 23cc22bc229801fbcdd5db8480f9eb38dc8f7fdb Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 16 Jun 2020 00:41:21 +0200 Subject: [PATCH 3/7] Move has_temperature_compensation() into temperature.cpp. No change in FLASH usage. --- Firmware/temperature.cpp | 11 +++++++++++ Firmware/temperature.h | 1 + Firmware/ultralcd.cpp | 9 --------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index c019514c5..bd232cf57 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -2196,4 +2196,15 @@ float unscalePID_d(float d) #endif //PIDTEMP +#ifdef PINDA_THERMISTOR +bool has_temperature_compensation() +{ +#ifdef DETECT_SUPERPINDA + return (current_temperature_pinda >= PINDA_MINTEMP) ? true : false; +#else + return true; +#endif +} +#endif //PINDA_THERMISTOR + diff --git a/Firmware/temperature.h b/Firmware/temperature.h index 617b9cb6b..32ff6961a 100755 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -63,6 +63,7 @@ extern float current_temperature_bed; #ifdef PINDA_THERMISTOR extern uint16_t current_temperature_raw_pinda; extern float current_temperature_pinda; +bool has_temperature_compensation(); #endif #ifdef AMBIENT_THERMISTOR diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 13d8a1fb2..682a3b2ba 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -334,15 +334,6 @@ bool bSettings; // flag (i.e. 'fake parameter' const char STR_SEPARATOR[] PROGMEM = "------------"; -static bool has_temperature_compensation() -{ -#ifdef DETECT_SUPERPINDA - return (current_temperature_pinda >= PINDA_MINTEMP) ? true : false; -#else - return true; -#endif -} - static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* filename, char* longFilename) { From d398aa1e3fac215bf18ffad4b0591fef179d7d28 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 16 Jun 2020 00:44:59 +0200 Subject: [PATCH 4/7] Skip PINDA_THERMISTOR block in PINDA probe temperature calibration if PINDA_THERMISTOR is not detected. Costs 1328B of FLASH, something must be wrong. --- 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 80bdd90f4..c18da74c5 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4580,7 +4580,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) case 76: { #ifdef PINDA_THERMISTOR - if (true) + if (has_temperature_compensation()) { if (calibration_status() >= CALIBRATION_STATUS_XYZ_CALIBRATION) { From 40ffea64ab5a98d0c2594e626562d302c1903bc7 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 16 Jun 2020 01:09:40 +0200 Subject: [PATCH 5/7] Do not compile temperature compensation code for PINDAv1 if PINDA_THERMISTOR macro is defined. This saves nearly all of additional FLASH usage of previous commit. It is only 70B worse than if no skipping is done in temperature compensation gcode G76. --- Firmware/Marlin_main.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index c18da74c5..48636adaf 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4562,6 +4562,8 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) ### G76 - PINDA probe temperature calibration G76: PINDA probe temperature calibration This G-code is used to calibrate the temperature drift of the PINDA (inductive Sensor). + superPINDA sensor + The PINDAv2 sensor has a built-in thermistor which has the advantage that the calibration can be done once for all materials. The Original i3 Prusa MK2/s uses PINDAv1 and this calibration improves the temperature drift, but not as good as the PINDAv2. @@ -4580,8 +4582,13 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) case 76: { #ifdef PINDA_THERMISTOR - if (has_temperature_compensation()) + if (true) { + if (!has_temperature_compensation()) + { + SERIAL_ECHOLNPGM("No PINDA thermistor"); + break; + } if (calibration_status() >= CALIBRATION_STATUS_XYZ_CALIBRATION) { //we need to know accurate position of first calibration point @@ -4727,7 +4734,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) break; } -#endif //PINDA_THERMISTOR +#else //PINDA_THERMISTOR setTargetBed(PINDA_MIN_T); float zero_z; @@ -4828,7 +4835,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) lcd_update(2); - +#endif //PINDA_THERMISTOR } break; From d5feed1f6a7f38f21dca0be340e6f456ed74e4ea Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 16 Jun 2020 01:20:17 +0200 Subject: [PATCH 6/7] Refactor: Remove if(true) condition, redundant break statement and decrease indentation. --- Firmware/Marlin_main.cpp | 264 +++++++++++++++++++-------------------- 1 file changed, 130 insertions(+), 134 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 48636adaf..501b37d94 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4582,158 +4582,154 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) case 76: { #ifdef PINDA_THERMISTOR - if (true) - { - if (!has_temperature_compensation()) - { - SERIAL_ECHOLNPGM("No PINDA thermistor"); - break; - } + if (!has_temperature_compensation()) + { + SERIAL_ECHOLNPGM("No PINDA thermistor"); + break; + } - if (calibration_status() >= CALIBRATION_STATUS_XYZ_CALIBRATION) { - //we need to know accurate position of first calibration point - //if xyz calibration was not performed yet, interrupt temperature calibration and inform user that xyz cal. is needed - lcd_show_fullscreen_message_and_wait_P(_i("Please run XYZ calibration first.")); - break; - } - - if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])) - { - // We don't know where we are! HOME! - // Push the commands to the front of the message queue in the reverse order! - // There shall be always enough space reserved for these commands. - repeatcommand_front(); // repeat G76 with all its parameters - enquecommand_front_P((PSTR("G28 W0"))); - break; - } - lcd_show_fullscreen_message_and_wait_P(_i("Stable ambient temperature 21-26C is needed a rigid stand is required."));////MSG_TEMP_CAL_WARNING c=20 r=4 - bool result = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_STEEL_SHEET_CHECK), false, false); - - if (result) - { - current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; - plan_buffer_line_curposXYZE(3000 / 60); - current_position[Z_AXIS] = 50; - current_position[Y_AXIS] = 180; - plan_buffer_line_curposXYZE(3000 / 60); - st_synchronize(); - lcd_show_fullscreen_message_and_wait_P(_T(MSG_REMOVE_STEEL_SHEET)); - current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + 1); - current_position[X_AXIS] = pgm_read_float(bed_ref_points_4); - plan_buffer_line_curposXYZE(3000 / 60); - st_synchronize(); - gcode_G28(false, false, true); + if (calibration_status() >= CALIBRATION_STATUS_XYZ_CALIBRATION) { + //we need to know accurate position of first calibration point + //if xyz calibration was not performed yet, interrupt temperature calibration and inform user that xyz cal. is needed + lcd_show_fullscreen_message_and_wait_P(_i("Please run XYZ calibration first.")); + break; + } - } - if ((current_temperature_pinda > 35) && (farm_mode == false)) { - //waiting for PIDNA probe to cool down in case that we are not in farm mode - current_position[Z_AXIS] = 100; - plan_buffer_line_curposXYZE(3000 / 60); - 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 - SERIAL_ECHOLNPGM("PINDA probe calibration start"); + if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])) + { + // We don't know where we are! HOME! + // Push the commands to the front of the message queue in the reverse order! + // There shall be always enough space reserved for these commands. + repeatcommand_front(); // repeat G76 with all its parameters + enquecommand_front_P((PSTR("G28 W0"))); + break; + } + lcd_show_fullscreen_message_and_wait_P(_i("Stable ambient temperature 21-26C is needed a rigid stand is required."));////MSG_TEMP_CAL_WARNING c=20 r=4 + bool result = lcd_show_fullscreen_message_yes_no_and_wait_P(_T(MSG_STEEL_SHEET_CHECK), false, false); - float zero_z; - int z_shift = 0; //unit: steps - float start_temp = 5 * (int)(current_temperature_pinda / 5); - if (start_temp < 35) start_temp = 35; - if (start_temp < current_temperature_pinda) start_temp += 5; - printf_P(_N("start temperature: %.1f\n"), start_temp); + if (result) + { + current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; + plan_buffer_line_curposXYZE(3000 / 60); + current_position[Z_AXIS] = 50; + current_position[Y_AXIS] = 180; + plan_buffer_line_curposXYZE(3000 / 60); + st_synchronize(); + lcd_show_fullscreen_message_and_wait_P(_T(MSG_REMOVE_STEEL_SHEET)); + current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + 1); + current_position[X_AXIS] = pgm_read_float(bed_ref_points_4); + plan_buffer_line_curposXYZE(3000 / 60); + st_synchronize(); + gcode_G28(false, false, true); + + } + if ((current_temperature_pinda > 35) && (farm_mode == false)) { + //waiting for PIDNA probe to cool down in case that we are not in farm mode + current_position[Z_AXIS] = 100; + plan_buffer_line_curposXYZE(3000 / 60); + 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 + SERIAL_ECHOLNPGM("PINDA probe calibration start"); + + float zero_z; + int z_shift = 0; //unit: steps + float start_temp = 5 * (int)(current_temperature_pinda / 5); + if (start_temp < 35) start_temp = 35; + if (start_temp < current_temperature_pinda) start_temp += 5; + printf_P(_N("start temperature: %.1f\n"), start_temp); // setTargetHotend(200, 0); - setTargetBed(70 + (start_temp - 30)); + setTargetBed(70 + (start_temp - 30)); - custom_message_type = CustomMsg::TempCal; - custom_message_state = 1; - lcd_setstatuspgm(_T(MSG_TEMP_CALIBRATION)); - current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; - plan_buffer_line_curposXYZE(3000 / 60); - current_position[X_AXIS] = PINDA_PREHEAT_X; - current_position[Y_AXIS] = PINDA_PREHEAT_Y; - plan_buffer_line_curposXYZE(3000 / 60); - current_position[Z_AXIS] = PINDA_PREHEAT_Z; - plan_buffer_line_curposXYZE(3000 / 60); - st_synchronize(); + custom_message_type = CustomMsg::TempCal; + custom_message_state = 1; + lcd_setstatuspgm(_T(MSG_TEMP_CALIBRATION)); + current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; + plan_buffer_line_curposXYZE(3000 / 60); + current_position[X_AXIS] = PINDA_PREHEAT_X; + current_position[Y_AXIS] = PINDA_PREHEAT_Y; + plan_buffer_line_curposXYZE(3000 / 60); + current_position[Z_AXIS] = PINDA_PREHEAT_Z; + plan_buffer_line_curposXYZE(3000 / 60); + st_synchronize(); - while (current_temperature_pinda < start_temp) - { - delay_keep_alive(1000); - serialecho_temperatures(); - } + while (current_temperature_pinda < start_temp) + { + delay_keep_alive(1000); + serialecho_temperatures(); + } - eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); //invalidate temp. calibration in case that in will be aborted during the calibration process + eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); //invalidate temp. calibration in case that in will be aborted during the calibration process - current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; - plan_buffer_line_curposXYZE(3000 / 60); - current_position[X_AXIS] = pgm_read_float(bed_ref_points_4); - current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + 1); - plan_buffer_line_curposXYZE(3000 / 60); - st_synchronize(); + current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; + plan_buffer_line_curposXYZE(3000 / 60); + current_position[X_AXIS] = pgm_read_float(bed_ref_points_4); + current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + 1); + plan_buffer_line_curposXYZE(3000 / 60); + st_synchronize(); - 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); - break; - } - zero_z = current_position[Z_AXIS]; + 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); + break; + } + zero_z = current_position[Z_AXIS]; - printf_P(_N("\nZERO: %.3f\n"), current_position[Z_AXIS]); + printf_P(_N("\nZERO: %.3f\n"), current_position[Z_AXIS]); - int i = -1; for (; i < 5; i++) - { - float temp = (40 + i * 5); - printf_P(_N("\nStep: %d/6 (skipped)\nPINDA temperature: %d Z shift (mm):0\n"), i + 2, (40 + i*5)); - if (i >= 0) EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); - if (start_temp <= temp) break; - } + int i = -1; for (; i < 5; i++) + { + float temp = (40 + i * 5); + printf_P(_N("\nStep: %d/6 (skipped)\nPINDA temperature: %d Z shift (mm):0\n"), i + 2, (40 + i*5)); + if (i >= 0) EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); + if (start_temp <= temp) break; + } - for (i++; i < 5; i++) - { - float temp = (40 + i * 5); - printf_P(_N("\nStep: %d/6\n"), i + 2); - custom_message_state = i + 2; - setTargetBed(50 + 10 * (temp - 30) / 5); + for (i++; i < 5; i++) + { + float temp = (40 + i * 5); + printf_P(_N("\nStep: %d/6\n"), i + 2); + custom_message_state = i + 2; + setTargetBed(50 + 10 * (temp - 30) / 5); // setTargetHotend(255, 0); - current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; - plan_buffer_line_curposXYZE(3000 / 60); - current_position[X_AXIS] = PINDA_PREHEAT_X; - current_position[Y_AXIS] = PINDA_PREHEAT_Y; - plan_buffer_line_curposXYZE(3000 / 60); - current_position[Z_AXIS] = PINDA_PREHEAT_Z; - plan_buffer_line_curposXYZE(3000 / 60); - st_synchronize(); - while (current_temperature_pinda < temp) - { - delay_keep_alive(1000); - serialecho_temperatures(); - } - current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; - plan_buffer_line_curposXYZE(3000 / 60); - current_position[X_AXIS] = pgm_read_float(bed_ref_points_4); - current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + 1); - plan_buffer_line_curposXYZE(3000 / 60); - st_synchronize(); - find_z_result = find_bed_induction_sensor_point_z(-1.f); - if (find_z_result == false) { - lcd_temp_cal_show_result(find_z_result); - break; - } - z_shift = (int)((current_position[Z_AXIS] - zero_z)*cs.axis_steps_per_unit[Z_AXIS]); + current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; + plan_buffer_line_curposXYZE(3000 / 60); + current_position[X_AXIS] = PINDA_PREHEAT_X; + current_position[Y_AXIS] = PINDA_PREHEAT_Y; + plan_buffer_line_curposXYZE(3000 / 60); + current_position[Z_AXIS] = PINDA_PREHEAT_Z; + plan_buffer_line_curposXYZE(3000 / 60); + st_synchronize(); + while (current_temperature_pinda < temp) + { + delay_keep_alive(1000); + serialecho_temperatures(); + } + current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; + plan_buffer_line_curposXYZE(3000 / 60); + current_position[X_AXIS] = pgm_read_float(bed_ref_points_4); + current_position[Y_AXIS] = pgm_read_float(bed_ref_points_4 + 1); + plan_buffer_line_curposXYZE(3000 / 60); + st_synchronize(); + find_z_result = find_bed_induction_sensor_point_z(-1.f); + if (find_z_result == false) { + lcd_temp_cal_show_result(find_z_result); + break; + } + z_shift = (int)((current_position[Z_AXIS] - zero_z)*cs.axis_steps_per_unit[Z_AXIS]); - printf_P(_N("\nPINDA temperature: %.1f Z shift (mm): %.3f"), current_temperature_pinda, current_position[Z_AXIS] - zero_z); + printf_P(_N("\nPINDA temperature: %.1f Z shift (mm): %.3f"), current_temperature_pinda, current_position[Z_AXIS] - zero_z); - EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); + EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); - } - lcd_temp_cal_show_result(true); + } + lcd_temp_cal_show_result(true); - break; - } #else //PINDA_THERMISTOR setTargetBed(PINDA_MIN_T); From 9838be851200769d79b1b56b3685845e51b0ec2e Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 16 Jun 2020 02:02:12 +0200 Subject: [PATCH 7/7] Do not compile, if PINDA temperature compensation start point is lower than PINDA_MINTEMP. Document. --- Firmware/Marlin_main.cpp | 12 +++++++++--- Firmware/temperature.cpp | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 501b37d94..8dbc0d840 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4561,13 +4561,15 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) /*! ### G76 - PINDA probe temperature calibration G76: PINDA probe temperature calibration This G-code is used to calibrate the temperature drift of the PINDA (inductive Sensor). - - superPINDA sensor The PINDAv2 sensor has a built-in thermistor which has the advantage that the calibration can be done once for all materials. The Original i3 Prusa MK2/s uses PINDAv1 and this calibration improves the temperature drift, but not as good as the PINDAv2. + superPINDA sensor has internal temperature compensation and no thermistor output. There is no point of doing temperature calibration in such case. + If PINDA_THERMISTOR and DETECT_SUPERPINDA is defined during compilation, calibration is skipped with serial message "No PINDA thermistor". + This can be caused also if PINDA thermistor connection is broken or PINDA temperature is lower than PINDA_MINTEMP. + #### Example ``` @@ -10493,7 +10495,11 @@ float temp_comp_interpolation(float inp_temperature) { if (i>0) EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + (i-1) * 2, &shift[i]); //read shift in steps from EEPROM temp_C[i] = 50 + i * 10; //temperature in C #ifdef PINDA_THERMISTOR - temp_C[i] = 35 + i * 5; //temperature in C + constexpr int start_compensating_temp = 35; + temp_C[i] = start_compensating_temp + i * 5; //temperature in degrees C +#ifdef DETECT_SUPERPINDA + static_assert(start_compensating_temp >= PINDA_MINTEMP, "Temperature compensation start point is lower than PINDA_MINTEMP."); +#endif //DETECT_SUPERPINDA #else temp_C[i] = 50 + i * 10; //temperature in C #endif diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index bd232cf57..6e9b6985a 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -2197,6 +2197,11 @@ float unscalePID_d(float d) #endif //PIDTEMP #ifdef PINDA_THERMISTOR +//! @brief PINDA thermistor detected +//! +//! @retval true firmware should do temperature compensation and allow calibration +//! @retval false PINDA thermistor is not detected, disable temperature compensation and calibration +//! bool has_temperature_compensation() { #ifdef DETECT_SUPERPINDA