From 31ae097dba53eca01cb5e07cdb7650486d460aa2 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 18 Apr 2018 17:09:12 +0200 Subject: [PATCH 1/6] 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 82b31e8552babb5cbe70af58b05cbb96252812d9 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Fri, 20 Apr 2018 15:01:11 +0200 Subject: [PATCH 2/6] 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 cccd8246abd42d790012ce3b0f7287317378b1cd Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 23 Apr 2018 20:15:33 +0200 Subject: [PATCH 3/6] 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 4/6] 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 5/6] 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 6/6] 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)