From a9ce38df711485778ae1090c81df69f46f24e724 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 26 Mar 2019 17:14:05 +0100 Subject: [PATCH 1/6] Function for decision if we have valid Z-calibration data in eeprom fixed, mesh bed leveling: possible crash fix, temporaty debug info on serial line. --- Firmware/Marlin_main.cpp | 39 ++++++++++++++++---------- Firmware/mesh_bed_calibration.cpp | 46 ++++++++++++++++++++++--------- 2 files changed, 58 insertions(+), 27 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 669008bd6..76d269895 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4438,7 +4438,10 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) bool clamped = world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); clamped ? SERIAL_PROTOCOLPGM("First calibration point clamped.\n") : SERIAL_PROTOCOLPGM("No clamping for first calibration point.\n"); } - #endif //SUPPORT_VERBOSITY + #else //SUPPORT_VERBOSITY + world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); + #endif //SUPPORT_VERBOSITY + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS] / 30, active_extruder); // Wait until the move is finished. st_synchronize(); @@ -4475,21 +4478,24 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) uint16_t z_offset_u = 0; if (nMeasPoints == 7) { z_offset_u = eeprom_read_word((uint16_t*)(EEPROM_BED_CALIBRATION_Z_JITTER + 2 * ((ix/3) + iy - 1))); + printf_P(PSTR("[%d;%d]: Z_offset = %d \n"), ix, iy, z_offset_u); } else { z_offset_u = eeprom_read_word((uint16_t*)(EEPROM_BED_CALIBRATION_Z_JITTER + 2 * (ix + iy * 3 - 1))); + printf_P(PSTR("[%d;%d]: Z_offset = %d \n"), ix, iy, z_offset_u); } z0 = mbl.z_values[0][0] + *reinterpret_cast(&z_offset_u) * 0.01; - #ifdef SUPPORT_VERBOSITY - if (verbosity_level >= 1) { + //#ifdef SUPPORT_VERBOSITY + //if (verbosity_level >= 1) { printf_P(PSTR("Bed leveling, point: %d, calibration Z stored in eeprom: %d, calibration z: %f \n"), mesh_point, z_offset_u, z0); - } - #endif // SUPPORT_VERBOSITY + //} + //#endif // SUPPORT_VERBOSITY } // Move Z up to MESH_HOME_Z_SEARCH. if((ix == 0) && (iy == 0)) current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; else current_position[Z_AXIS] += 2.f / nMeasPoints; //use relative movement from Z coordinate where PINDa triggered on previous point. This makes calibration faster. + float init_z_bckp = current_position[Z_AXIS]; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder); st_synchronize(); @@ -4497,43 +4503,48 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) current_position[X_AXIS] = BED_X(ix, nMeasPoints); current_position[Y_AXIS] = BED_Y(iy, nMeasPoints); - //printf_P(PSTR("[%f;%f]\n"), current_position[X_AXIS], current_position[Y_AXIS]); + printf_P(PSTR("[%f;%f]\n"), current_position[X_AXIS], current_position[Y_AXIS]); - world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); + #ifdef SUPPORT_VERBOSITY if (verbosity_level >= 1) { - + clamped = world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); SERIAL_PROTOCOL(mesh_point); clamped ? SERIAL_PROTOCOLPGM(": xy clamped.\n") : SERIAL_PROTOCOLPGM(": no xy clamping\n"); } + #else //SUPPORT_VERBOSITY + world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); #endif // SUPPORT_VERBOSITY + printf_P(PSTR("after clamping: [%f;%f]\n"), current_position[X_AXIS], current_position[Y_AXIS]); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], XY_AXIS_FEEDRATE, active_extruder); st_synchronize(); // Go down until endstop is hit const float Z_CALIBRATION_THRESHOLD = 1.f; if (!find_bed_induction_sensor_point_z((has_z && mesh_point > 0) ? z0 - Z_CALIBRATION_THRESHOLD : -10.f, nProbeRetry)) { //if we have data from z calibration max allowed difference is 1mm for each point, if we dont have data max difference is 10mm from initial point - printf_P(_T(MSG_BED_LEVELING_FAILED_POINT_LOW)); + //printf_P(_T(MSG_BED_LEVELING_FAILED_POINT_LOW)); + printf_P("Point too low 1 \n"); break; } - if (MESH_HOME_Z_SEARCH - current_position[Z_AXIS] < 0.1f) { //broken cable or initial Z coordinate too low. Go to MESH_HOME_Z_SEARCH and repeat last step (z-probe) again to distinguish between these two cases. - + if (init_z_bckp - current_position[Z_AXIS] < 0.1f) { //broken cable or initial Z coordinate too low. Go to MESH_HOME_Z_SEARCH and repeat last step (z-probe) again to distinguish between these two cases. + printf_P(PSTR("Another attempt! Current Z position: %f\n"), current_position[Z_AXIS]); current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder); st_synchronize(); if (!find_bed_induction_sensor_point_z((has_z && mesh_point > 0) ? z0 - Z_CALIBRATION_THRESHOLD : -10.f, nProbeRetry)) { //if we have data from z calibration max allowed difference is 1mm for each point, if we dont have data max difference is 10mm from initial point - printf_P(_T(MSG_BED_LEVELING_FAILED_POINT_LOW)); + //printf_P(_T(MSG_BED_LEVELING_FAILED_POINT_LOW)); + printf_P("Point too low 2 \n"); break; } if (MESH_HOME_Z_SEARCH - current_position[Z_AXIS] < 0.1f) { - printf_P(PSTR("Bed leveling failed. Sensor disconnected or cable broken. Waiting for reset.\n")); + printf_P(PSTR("Bed leveling failed. Sensor disconnected or cable broken.\n")); break; } } if (has_z && fabs(z0 - current_position[Z_AXIS]) > Z_CALIBRATION_THRESHOLD) { //if we have data from z calibration, max. allowed difference is 1mm for each point - printf_P(PSTR("Bed leveling failed. Sensor triggered too high. Waiting for reset.\n")); + printf_P(PSTR("Bed leveling failed. Sensor triggered too high.\n")); break; } #ifdef SUPPORT_VERBOSITY diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 0aca64a5f..e1cd51a9d 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -678,11 +678,13 @@ void reset_bed_offset_and_skew() bool is_bed_z_jitter_data_valid() // offsets of the Z heiths of the calibration points from the first point are saved as 16bit signed int, scaled to tenths of microns -{ - for (int8_t i = 0; i < 8; ++ i) - if (eeprom_read_word((uint16_t*)(EEPROM_BED_CALIBRATION_Z_JITTER+i*2)) == 0x0FFFF) - return false; - return true; +// if at least one 16bit integer has different value then -1 (0x0FFFF), data are considered valid and function returns true, otherwise it returns false +{ + bool data_valid = false; + for (int8_t i = 0; i < 8; ++i) { + if (eeprom_read_word((uint16_t*)(EEPROM_BED_CALIBRATION_Z_JITTER + i * 2)) != 0x0FFFF) data_valid = true; + } + return data_valid; } static void world2machine_update(const float vec_x[2], const float vec_y[2], const float cntr[2]) @@ -946,7 +948,7 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i #ifdef TMC2130 FORCE_HIGH_POWER_START; #endif - + printf_P(PSTR("Min. Z: %f\n"), minimum_z); #ifdef SUPPORT_VERBOSITY if(verbosity_level >= 10) SERIAL_ECHOLNPGM("find bed induction sensor point z"); #endif // SUPPORT_VERBOSITY @@ -961,9 +963,16 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i // we have to let the planner know where we are right now as it is not where we said to go. update_current_position_z(); if (! endstop_z_hit_on_purpose()) - goto error; + { + printf_P(PSTR("endstop not hit 1, current_pos[Z]: %f \n"), current_position[Z_AXIS]); + goto error; + } #ifdef TMC2130 - if (READ(Z_TMC2130_DIAG) != 0) goto error; //crash Z detected + if (READ(Z_TMC2130_DIAG) != 0) + { + printf_P(PSTR("crash detected 1, current_pos[Z]: %f \n"), current_position[Z_AXIS]); + goto error; //crash Z detected + } #endif //TMC2130 for (uint8_t i = 0; i < n_iter; ++ i) { @@ -973,12 +982,13 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i go_to_current(homing_feedrate[Z_AXIS]/60); // Move back down slowly to find bed. current_position[Z_AXIS] = minimum_z; + printf_P(PSTR("init Z = %f, min_z = %f\n"), z_bckp, minimum_z); go_to_current(homing_feedrate[Z_AXIS]/(4*60)); // we have to let the planner know where we are right now as it is not where we said to go. update_current_position_z(); //printf_P(PSTR("Zs: %f, Z: %f, delta Z: %f"), z_bckp, current_position[Z_AXIS], (z_bckp - current_position[Z_AXIS])); if (abs(current_position[Z_AXIS] - z_bckp) < 0.025) { - //printf_P(PSTR("PINDA triggered immediately, move Z higher and repeat measurement\n")); + printf_P(PSTR("PINDA triggered immediately, move Z higher and repeat measurement\n")); current_position[Z_AXIS] += 0.5; go_to_current(homing_feedrate[Z_AXIS]/60); current_position[Z_AXIS] = minimum_z; @@ -989,10 +999,16 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i - if (! endstop_z_hit_on_purpose()) - goto error; + if (!endstop_z_hit_on_purpose()) + { + printf_P(PSTR("i = %d, endstop not hit 2, current_pos[Z]: %f \n"), i, current_position[Z_AXIS]); + goto error; + } #ifdef TMC2130 - if (READ(Z_TMC2130_DIAG) != 0) goto error; //crash Z detected + if (READ(Z_TMC2130_DIAG) != 0) { + printf_P(PSTR("crash detected 2, current_pos[Z]: %f \n"), current_position[Z_AXIS]); + 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); @@ -1000,7 +1016,11 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i 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 + if (dz > 0.05) { + printf_P(PSTR("big deviation \n")); + goto error;//deviation > 50um + } + printf_P(PSTR("PINDA triggered at %f\n"), current_position[Z_AXIS]); } current_position[Z_AXIS] = z; if (n_iter > 1) From 58632975384acdc727dd95f9d60b3df294f0ac5d Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 27 Mar 2019 20:25:00 +0100 Subject: [PATCH 2/6] if deviation between current Z-probe and avg, value > 50um, enlarge Z-probe movements and repeat measurement --- Firmware/mesh_bed_calibration.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index e1cd51a9d..3ff92a427 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -945,6 +945,7 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i #endif //SUPPORT_VERBOSITY ) { + bool high_deviation_occured = false; #ifdef TMC2130 FORCE_HIGH_POWER_START; #endif @@ -977,12 +978,12 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i for (uint8_t i = 0; i < n_iter; ++ i) { - current_position[Z_AXIS] += 0.2; + current_position[Z_AXIS] += high_deviation_occured ? 0.5 : 0.2; float z_bckp = current_position[Z_AXIS]; go_to_current(homing_feedrate[Z_AXIS]/60); // Move back down slowly to find bed. current_position[Z_AXIS] = minimum_z; - printf_P(PSTR("init Z = %f, min_z = %f\n"), z_bckp, minimum_z); + printf_P(PSTR("init Z = %f, min_z = %f, i = %d\n"), z_bckp, minimum_z, i); go_to_current(homing_feedrate[Z_AXIS]/(4*60)); // we have to let the planner know where we are right now as it is not where we said to go. update_current_position_z(); @@ -1016,9 +1017,19 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i 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) { - printf_P(PSTR("big deviation \n")); - goto error;//deviation > 50um + printf_P(PSTR("Z- measurement deviation from avg value %f um\n"), dz); + if (dz > 0.05) { //deviation > 50um + if (high_deviation_occured == false) { //first occurence may be caused in some cases by mechanic resonance probably especially if printer is placed on unstable surface + printf_P(PSTR("high dev. first occurence\n")); + delay_keep_alive(500); //damping + //start measurement from the begining, but this time with higher movements in Z axis which should help to reduce mechanical resonance + high_deviation_occured = true; + i = -1; + z = 0; + } + else { + goto error; + } } printf_P(PSTR("PINDA triggered at %f\n"), current_position[Z_AXIS]); } From e259967991c5dbb9bdb29220569b4dcce83de59b Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 27 Mar 2019 20:41:45 +0100 Subject: [PATCH 3/6] remove / comment debug code --- Firmware/Marlin_main.cpp | 22 +++++++++------------- Firmware/mesh_bed_calibration.cpp | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 76d269895..63f4f298e 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4478,18 +4478,16 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) uint16_t z_offset_u = 0; if (nMeasPoints == 7) { z_offset_u = eeprom_read_word((uint16_t*)(EEPROM_BED_CALIBRATION_Z_JITTER + 2 * ((ix/3) + iy - 1))); - printf_P(PSTR("[%d;%d]: Z_offset = %d \n"), ix, iy, z_offset_u); } else { z_offset_u = eeprom_read_word((uint16_t*)(EEPROM_BED_CALIBRATION_Z_JITTER + 2 * (ix + iy * 3 - 1))); - printf_P(PSTR("[%d;%d]: Z_offset = %d \n"), ix, iy, z_offset_u); } z0 = mbl.z_values[0][0] + *reinterpret_cast(&z_offset_u) * 0.01; - //#ifdef SUPPORT_VERBOSITY - //if (verbosity_level >= 1) { + #ifdef SUPPORT_VERBOSITY + if (verbosity_level >= 1) { printf_P(PSTR("Bed leveling, point: %d, calibration Z stored in eeprom: %d, calibration z: %f \n"), mesh_point, z_offset_u, z0); - //} - //#endif // SUPPORT_VERBOSITY + } + #endif // SUPPORT_VERBOSITY } // Move Z up to MESH_HOME_Z_SEARCH. @@ -4503,7 +4501,7 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) current_position[X_AXIS] = BED_X(ix, nMeasPoints); current_position[Y_AXIS] = BED_Y(iy, nMeasPoints); - printf_P(PSTR("[%f;%f]\n"), current_position[X_AXIS], current_position[Y_AXIS]); + //printf_P(PSTR("[%f;%f]\n"), current_position[X_AXIS], current_position[Y_AXIS]); #ifdef SUPPORT_VERBOSITY @@ -4516,26 +4514,24 @@ if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)) world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); #endif // SUPPORT_VERBOSITY - printf_P(PSTR("after clamping: [%f;%f]\n"), current_position[X_AXIS], current_position[Y_AXIS]); + //printf_P(PSTR("after clamping: [%f;%f]\n"), current_position[X_AXIS], current_position[Y_AXIS]); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], XY_AXIS_FEEDRATE, active_extruder); st_synchronize(); // Go down until endstop is hit const float Z_CALIBRATION_THRESHOLD = 1.f; if (!find_bed_induction_sensor_point_z((has_z && mesh_point > 0) ? z0 - Z_CALIBRATION_THRESHOLD : -10.f, nProbeRetry)) { //if we have data from z calibration max allowed difference is 1mm for each point, if we dont have data max difference is 10mm from initial point - //printf_P(_T(MSG_BED_LEVELING_FAILED_POINT_LOW)); - printf_P("Point too low 1 \n"); + printf_P(_T(MSG_BED_LEVELING_FAILED_POINT_LOW)); break; } if (init_z_bckp - current_position[Z_AXIS] < 0.1f) { //broken cable or initial Z coordinate too low. Go to MESH_HOME_Z_SEARCH and repeat last step (z-probe) again to distinguish between these two cases. - printf_P(PSTR("Another attempt! Current Z position: %f\n"), current_position[Z_AXIS]); + //printf_P(PSTR("Another attempt! Current Z position: %f\n"), current_position[Z_AXIS]); current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder); st_synchronize(); if (!find_bed_induction_sensor_point_z((has_z && mesh_point > 0) ? z0 - Z_CALIBRATION_THRESHOLD : -10.f, nProbeRetry)) { //if we have data from z calibration max allowed difference is 1mm for each point, if we dont have data max difference is 10mm from initial point - //printf_P(_T(MSG_BED_LEVELING_FAILED_POINT_LOW)); - printf_P("Point too low 2 \n"); + printf_P(_T(MSG_BED_LEVELING_FAILED_POINT_LOW)); break; } if (MESH_HOME_Z_SEARCH - current_position[Z_AXIS] < 0.1f) { diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 3ff92a427..62bcca3c5 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -949,7 +949,7 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i #ifdef TMC2130 FORCE_HIGH_POWER_START; #endif - printf_P(PSTR("Min. Z: %f\n"), minimum_z); + //printf_P(PSTR("Min. Z: %f\n"), minimum_z); #ifdef SUPPORT_VERBOSITY if(verbosity_level >= 10) SERIAL_ECHOLNPGM("find bed induction sensor point z"); #endif // SUPPORT_VERBOSITY @@ -965,13 +965,13 @@ 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()) { - printf_P(PSTR("endstop not hit 1, current_pos[Z]: %f \n"), current_position[Z_AXIS]); + //printf_P(PSTR("endstop not hit 1, current_pos[Z]: %f \n"), current_position[Z_AXIS]); goto error; } #ifdef TMC2130 if (READ(Z_TMC2130_DIAG) != 0) { - printf_P(PSTR("crash detected 1, current_pos[Z]: %f \n"), current_position[Z_AXIS]); + //printf_P(PSTR("crash detected 1, current_pos[Z]: %f \n"), current_position[Z_AXIS]); goto error; //crash Z detected } #endif //TMC2130 @@ -983,13 +983,13 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i go_to_current(homing_feedrate[Z_AXIS]/60); // Move back down slowly to find bed. current_position[Z_AXIS] = minimum_z; - printf_P(PSTR("init Z = %f, min_z = %f, i = %d\n"), z_bckp, minimum_z, i); + //printf_P(PSTR("init Z = %f, min_z = %f, i = %d\n"), z_bckp, minimum_z, i); go_to_current(homing_feedrate[Z_AXIS]/(4*60)); // we have to let the planner know where we are right now as it is not where we said to go. update_current_position_z(); //printf_P(PSTR("Zs: %f, Z: %f, delta Z: %f"), z_bckp, current_position[Z_AXIS], (z_bckp - current_position[Z_AXIS])); if (abs(current_position[Z_AXIS] - z_bckp) < 0.025) { - printf_P(PSTR("PINDA triggered immediately, move Z higher and repeat measurement\n")); + //printf_P(PSTR("PINDA triggered immediately, move Z higher and repeat measurement\n")); current_position[Z_AXIS] += 0.5; go_to_current(homing_feedrate[Z_AXIS]/60); current_position[Z_AXIS] = minimum_z; @@ -1002,12 +1002,12 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i if (!endstop_z_hit_on_purpose()) { - printf_P(PSTR("i = %d, endstop not hit 2, current_pos[Z]: %f \n"), i, current_position[Z_AXIS]); + //printf_P(PSTR("i = %d, endstop not hit 2, current_pos[Z]: %f \n"), i, current_position[Z_AXIS]); goto error; } #ifdef TMC2130 if (READ(Z_TMC2130_DIAG) != 0) { - printf_P(PSTR("crash detected 2, current_pos[Z]: %f \n"), current_position[Z_AXIS]); + //printf_P(PSTR("crash detected 2, current_pos[Z]: %f \n"), current_position[Z_AXIS]); goto error; //crash Z detected } #endif //TMC2130 @@ -1017,10 +1017,10 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i 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)); - printf_P(PSTR("Z- measurement deviation from avg value %f um\n"), dz); + //printf_P(PSTR("Z- measurement deviation from avg value %f um\n"), dz); if (dz > 0.05) { //deviation > 50um if (high_deviation_occured == false) { //first occurence may be caused in some cases by mechanic resonance probably especially if printer is placed on unstable surface - printf_P(PSTR("high dev. first occurence\n")); + //printf_P(PSTR("high dev. first occurence\n")); delay_keep_alive(500); //damping //start measurement from the begining, but this time with higher movements in Z axis which should help to reduce mechanical resonance high_deviation_occured = true; @@ -1031,7 +1031,7 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i goto error; } } - printf_P(PSTR("PINDA triggered at %f\n"), current_position[Z_AXIS]); + //printf_P(PSTR("PINDA triggered at %f\n"), current_position[Z_AXIS]); } current_position[Z_AXIS] = z; if (n_iter > 1) From 02faadf0b9fe50c991a6a2c29fee906d4bea8384 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 28 Mar 2019 09:49:08 +0100 Subject: [PATCH 4/6] MMU mode renamed --- Firmware/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index bee46ca21..04f4d7639 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -5319,7 +5319,7 @@ do\ {\ if (mmu_enabled)\ {\ - if (SilentModeMenu_MMU == 0) MENU_ITEM_FUNCTION_P(_i("MMU Mode [Fast]"), lcd_silent_mode_mmu_set); \ + if (SilentModeMenu_MMU == 0) MENU_ITEM_FUNCTION_P(_i("MMU Mode [Normal]"), lcd_silent_mode_mmu_set); \ else MENU_ITEM_FUNCTION_P(_i("MMU Mode[Stealth]"), lcd_silent_mode_mmu_set); \ }\ }\ From d22793f2766a14d1c07609336baa843e9557f4cd Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 28 Mar 2019 12:02:46 +0100 Subject: [PATCH 5/6] Z-probe nr. states reduced to 1; 3; 5 --- Firmware/Marlin.h | 2 +- Firmware/Marlin_main.cpp | 2 +- Firmware/ultralcd.cpp | 30 ++++++++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 2477d1c21..1a278013b 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -21,7 +21,7 @@ #include "Configuration.h" #include "pins.h" #include "Timer.h" -extern int mbl_z_probe_nr; +extern uint8_t mbl_z_probe_nr; #ifndef AT90USB #define HardwareSerial_h // trick to disable the standard HWserial diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 67601fb1a..45a1d4012 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -167,7 +167,7 @@ CardReader card; unsigned long PingTime = _millis(); unsigned long NcTime; -int mbl_z_probe_nr = 3; //numer of Z measurements for each point in mesh bed leveling calibration +uint8_t mbl_z_probe_nr = 3; //numer of Z measurements for each point in mesh bed leveling calibration //used for PINDA temp calibration and pause print #define DEFAULT_RETRACTION 1 diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 04f4d7639..7a6581f86 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6688,6 +6688,17 @@ static void mbl_mesh_set() { eeprom_update_byte((uint8_t*)EEPROM_MBL_POINTS_NR, mesh_nr); } +static void mbl_probe_nr_set() { + mbl_z_probe_nr = eeprom_read_byte((uint8_t*)EEPROM_MBL_PROBE_NR); + switch (mbl_z_probe_nr) { + case 1: mbl_z_probe_nr = 3; break; + case 3: mbl_z_probe_nr = 5; break; + case 5: mbl_z_probe_nr = 1; break; + default: mbl_z_probe_nr = 3; break; + } + eeprom_update_byte((uint8_t*)EEPROM_MBL_PROBE_NR, mbl_z_probe_nr); +} + static void lcd_mesh_bed_leveling_settings() { @@ -6695,25 +6706,20 @@ static void lcd_mesh_bed_leveling_settings() uint8_t points_nr = eeprom_read_byte((uint8_t*)EEPROM_MBL_POINTS_NR); MENU_BEGIN(); - // leaving menu - this condition must be immediately before MENU_ITEM_BACK_P - if (((menu_item == menu_line) && menu_clicked && (lcd_encoder == menu_item)) || menu_leaving) - { - eeprom_update_byte((uint8_t*)EEPROM_MBL_PROBE_NR, (uint8_t)mbl_z_probe_nr); - } MENU_ITEM_BACK_P(_T(MSG_SETTINGS)); - if(points_nr == 3) MENU_ITEM_FUNCTION_P(_i("Mesh [3x3]"), mbl_mesh_set); - else MENU_ITEM_FUNCTION_P(_i("Mesh [7x7]"), mbl_mesh_set); - MENU_ITEM_EDIT_int3_P(_i("Z-probe nr."), &mbl_z_probe_nr, 1, 5); + if(points_nr == 3) MENU_ITEM_FUNCTION_P(_i("Mesh [3x3]"), mbl_mesh_set); ////MSG_MESH_3x3 c=18 r=0 + else MENU_ITEM_FUNCTION_P(_i("Mesh [7x7]"), mbl_mesh_set); ////MSG_MESH_7x7 c=18 r=0 + switch (mbl_z_probe_nr) { + case 1: MENU_ITEM_FUNCTION_P(_i("Z-probe nr. [1]"), mbl_probe_nr_set); break; ////MSG_Z_PROBE_NR_1 c=18 r=0 + case 5: MENU_ITEM_FUNCTION_P(_i("Z-probe nr. [5]"), mbl_probe_nr_set); break; ////MSG_Z_PROBE_NR_1 c=18 r=0 + default: MENU_ITEM_FUNCTION_P(_i("Z-probe nr. [3]"), mbl_probe_nr_set); break; ////MSG_Z_PROBE_NR_1 c=18 r=0 + } if (points_nr == 7) { if (magnet_elimination) MENU_ITEM_FUNCTION_P(_i("Magnets comp. [On]"), mbl_magnets_elimination_set); else MENU_ITEM_FUNCTION_P(_i("Magnets comp.[Off]"), mbl_magnets_elimination_set); } else menu_item_text_P(_i("Magnets comp.[N/A]")); MENU_END(); - /*if(menu_leaving) - { - eeprom_update_byte((uint8_t*)EEPROM_MBL_POINTS_NR, mbl_z_probe_nr); - }*/ //SETTINGS_MBL_MODE; } From 1dd486d86d4b35e49c51d146f56c1e72233cf891 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Thu, 28 Mar 2019 13:18:28 +0100 Subject: [PATCH 6/6] max length of menu item strings added --- Firmware/ultralcd.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 7a6581f86..5128c77ab 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6715,10 +6715,10 @@ static void lcd_mesh_bed_leveling_settings() default: MENU_ITEM_FUNCTION_P(_i("Z-probe nr. [3]"), mbl_probe_nr_set); break; ////MSG_Z_PROBE_NR_1 c=18 r=0 } if (points_nr == 7) { - if (magnet_elimination) MENU_ITEM_FUNCTION_P(_i("Magnets comp. [On]"), mbl_magnets_elimination_set); - else MENU_ITEM_FUNCTION_P(_i("Magnets comp.[Off]"), mbl_magnets_elimination_set); + if (magnet_elimination) MENU_ITEM_FUNCTION_P(_i("Magnets comp. [On]"), mbl_magnets_elimination_set); ////MSG_MAGNETS_COMP_ON c=18 r=0 + else MENU_ITEM_FUNCTION_P(_i("Magnets comp.[Off]"), mbl_magnets_elimination_set); ////MSG_MAGNETS_COMP_OFF c=18 r=0 } - else menu_item_text_P(_i("Magnets comp.[N/A]")); + else menu_item_text_P(_i("Magnets comp.[N/A]")); ////MSG_MAGNETS_COMP_NA c=18 r=0 MENU_END(); //SETTINGS_MBL_MODE; }