From 764f389b90c9624444c573727016c6c7157bc2e4 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Mon, 19 Jun 2023 13:25:02 +0100 Subject: [PATCH 1/6] STEAPP-541: added load/save the sensor backlash. Added calculate backlash in to main logic --- klippy/extras/auto_wcs.py | 16 +++++++++++++--- stereotech_config/variables.cfg | 5 +++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/klippy/extras/auto_wcs.py b/klippy/extras/auto_wcs.py index e54e352201a9..3dd8b08be941 100644 --- a/klippy/extras/auto_wcs.py +++ b/klippy/extras/auto_wcs.py @@ -1,4 +1,5 @@ import math +import logging RAD_TO_DEG = 57.295779513 @@ -42,6 +43,9 @@ def __init__(self, config): self.gcode.register_command( 'SET_AUTO_WCS', self.cmd_SET_AUTO_WCS, desc=self.cmd_CALC_WCS_PARAMS_help) + self.gcode.register_command( + 'SET_PROBE_BACKLASH', self.cmd_SET_PROBE_BACKLASH, + desc=self.cmd_SET_PROBE_BACKLASH_help) def _calc_wcs_old_sensor(self, thickness, adj, gcmd): thickness = thickness / 2.0 @@ -136,7 +140,6 @@ def get_radius_1(self, gcmd): gcmd.respond_info('radius_tooling_1= %s,(backlash_y and X) centr_tool(%s;%s)' % ( self.tooling_radius_1, px, py)) return px, py, r - cmd_GET_RADIUS_TOOLING_help = "command for get the tooling radius from measuring points." def get_radius_2(self, gcmd): # calculate radius whis probe_backlash_y_2 @@ -176,7 +179,6 @@ def cmd_SAVE_WCS_CALC_POINT(self, gcmd): cmd_SAVE_WCS_CALC_POINT_help = "Save point for WCS calculation" - def cmd_CALC_WCS_PARAMS(self, gcmd): #todo: get thickness default 10 thickness = gcmd.get_float('THICKNESS', 10.) @@ -218,7 +220,15 @@ def cmd_SET_AUTO_WCS(self, gcmd): for axis, coord in enumerate(coords): self.wcs[point_idx][axis] = coord - cmd_CALC_WCS_PARAMS_help = "Perform WCS calculation" + def cmd_SET_PROBE_BACKLASH(self, gcmd): + self.probe_backlash_x = gcmd.get_float('BACKLASH_X', self.probe_backlash_x) + self.probe_backlash_y = gcmd.get_float('BACKLASH_Y', self.probe_backlash_y) + self.probe_backlash_y_2 = gcmd.get_float('BACKLASH_Y_2', self.probe_backlash_y_2) + logging.info( + 'Probe backlash is set:\nprobe_backlash_x=%f, probe_backlash_y=%f, probe_backlash_y_2=%f' % ( + self.probe_backlash_x, self.probe_backlash_y, self.probe_backlash_y_2) + ) + cmd_SET_PROBE_BACKLASH_help = "Set the sensor backlash for the current sensor." def get_status(self, eventtime=None): return { diff --git a/stereotech_config/variables.cfg b/stereotech_config/variables.cfg index d4d659f8b28a..b8b705e8b889 100644 --- a/stereotech_config/variables.cfg +++ b/stereotech_config/variables.cfg @@ -31,6 +31,7 @@ gcode: SKEW_PROFILE CHANGE={key} XY={svv[key ~ '_xy_skew']} XZ={svv[key ~ '_xz_skew']} YZ={svv[key ~ '_yz_skew']} {% endif %} {% endfor %} + SET_PROBE_BACKLASH BACKLASH_X={svv.probe_backlash_x|default(0.0)|float} BACKLASH_Y={svv.probe_backlash_y|default(0.0)|float} BACKLASH_Y_2={svv.probe_backlash_y_2|default(0.0)|float} {% endif %} {% if printer["filament_motion_sensor extruder_sensor"] %} SET_FILAMENT_SENSOR SENSOR=extruder_sensor ENABLE={svv['extruder_sensor']|default(1)} @@ -72,4 +73,8 @@ gcode: SAVE_VARIABLE VARIABLE=probe_offset_x VALUE={printer.probe.offsets[0]} SAVE_VARIABLE VARIABLE=probe_offset_y VALUE={printer.probe.offsets[1]} SAVE_VARIABLE VARIABLE=probe_offset_z VALUE={printer.probe.offsets[2]} + + SAVE_VARIABLE VARIABLE=probe_backlash_x VALUE={printer.auto_wcs.probe_backlash_x} + SAVE_VARIABLE VARIABLE=probe_backlash_y VALUE={printer.auto_wcs.probe_backlash_y} + SAVE_VARIABLE VARIABLE=probe_backlash_y_2 VALUE={printer.auto_wcs.probe_backlash_y_2} {% endif %} From 84ffc7b3a993dcdea1955e2c022346f7a63c2a80 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Mon, 19 Jun 2023 13:27:24 +0100 Subject: [PATCH 2/6] STEAPP-541: added calculate backlash in to main logic --- klippy/extras/auto_wcs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/klippy/extras/auto_wcs.py b/klippy/extras/auto_wcs.py index 3dd8b08be941..8a8b938ec801 100644 --- a/klippy/extras/auto_wcs.py +++ b/klippy/extras/auto_wcs.py @@ -187,6 +187,7 @@ def cmd_CALC_WCS_PARAMS(self, gcmd): if sensor_version: x, y, z = self._calc_wcs_new_sensor(thickness, adjustment_coeff, gcmd) x2, y2, z2 = self._calc_wcs_2_new_sensor(thickness, adjustment_coeff, gcmd) + self.calculate_probe_backlash(x, y, y2) delta_y = y - y2 delta_z = z - z2 avg_delta = (delta_y + delta_z) / 2.0 From 7dd9e8c3d9e136cabb7fa6f80ddb8ae3ba55fa78 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Mon, 19 Jun 2023 13:28:19 +0100 Subject: [PATCH 3/6] STEAPP-541: fixed bug in to apply radius for calculate wcs_2_z. --- klippy/extras/auto_wcs.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/klippy/extras/auto_wcs.py b/klippy/extras/auto_wcs.py index 8a8b938ec801..51f9dfd5d4c4 100644 --- a/klippy/extras/auto_wcs.py +++ b/klippy/extras/auto_wcs.py @@ -43,6 +43,9 @@ def __init__(self, config): self.gcode.register_command( 'SET_AUTO_WCS', self.cmd_SET_AUTO_WCS, desc=self.cmd_CALC_WCS_PARAMS_help) + self.gcode.register_command( + 'GET_RADIUS_TOOLING', self.cmd_GET_RADIUS_TOOLING, + desc=self.cmd_GET_RADIUS_TOOLING_help) self.gcode.register_command( 'SET_PROBE_BACKLASH', self.cmd_SET_PROBE_BACKLASH, desc=self.cmd_SET_PROBE_BACKLASH_help) From f35d32a02ac0b6a27174fdeb8ef47402c82dbf73 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Mon, 19 Jun 2023 13:45:50 +0100 Subject: [PATCH 4/6] STEAPP-541: Removed unnecessary save radius and backlash sensor commands because SAVE_VARIABLES does that. --- stereotech_config/probe.cfg | 23 +---------------------- stereotech_config/probe_2.cfg | 22 +--------------------- 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/stereotech_config/probe.cfg b/stereotech_config/probe.cfg index 7d831e714376..ff20aaf9ea8b 100644 --- a/stereotech_config/probe.cfg +++ b/stereotech_config/probe.cfg @@ -358,26 +358,6 @@ gcode: MOVE_TO_AUTO_WCS {% endif %} -[gcode_macro SAVE_PROBE_BACKLASH] -description: this macros save the sensor backlash. -gcode: - {% set probe_backlash_x = printer.auto_wcs.probe_backlash_x %} - {% set probe_backlash_y = printer.auto_wcs.probe_backlash_y %} - {% set probe_backlash_y_2 = printer.auto_wcs.probe_backlash_y_2 %} - SAVE_VARIABLE VARIABLE=probe_backlash_x VALUE={probe_backlash_x} - SAVE_VARIABLE VARIABLE=probe_backlash_y VALUE={probe_backlash_y} - SAVE_VARIABLE VARIABLE=probe_backlash_y_2 VALUE={probe_backlash_y_2} - {action_respond_info('save probe_backlash_x=%s' % probe_backlash_x)} - {action_respond_info('save probe_backlash_y=%s' % probe_backlash_y)} - {action_respond_info('save probe_backlash_y_2=%s' % probe_backlash_y_2)} - -[gcode_macro SAVE_RADIUS_TOOL] -description: this macros save the radius tool. -gcode: - SAVE_VARIABLE VARIABLE=tooling_radius VALUE={printer.auto_wcs.tooling_radius} - SAVE_VARIABLE VARIABLE=tooling_radius_1 VALUE={printer.auto_wcs.tooling_radius_1} - SAVE_VARIABLE VARIABLE=tooling_radius_2 VALUE={printer.auto_wcs.tooling_radius_2} - [gcode_macro MOVE_TO_AUTO_WCS] gcode: {% set set_xy = params.XY|default(0) %} @@ -540,7 +520,6 @@ gcode: SET_AUTO_WCS_POINT_RADIUS POINT={i} {% endfor %} GET_RADIUS_TOOLING - SAVE_RADIUS_TOOL [gcode_macro AUTO_BASEMENT_MOVE_MEASURE_RADIUS] description: measuring radius for geting wcs_2_z. @@ -609,7 +588,7 @@ gcode: {% set old_z = wcs_0[2] %} {% set old_y = wcs_1[1] %} {% set probe_sensor_version = printer.save_variables.variables.probe_sensor_version|default(0)|int %} - {% set probe_backlash_y = printer.save_variables.variables.probe_backlash_y|default(0.0)|float %} + {% set probe_backlash_y = printer.auto_wcs.probe_backlash_y|default(0.0)|float %} {% if wcs == 0 %} ; Mode SPIRAL-FULL {% if probe_sensor_version %} diff --git a/stereotech_config/probe_2.cfg b/stereotech_config/probe_2.cfg index 95397b5e3bc6..76f1ff5f8b1b 100644 --- a/stereotech_config/probe_2.cfg +++ b/stereotech_config/probe_2.cfg @@ -330,25 +330,6 @@ gcode: MOVE_TO_AUTO_WCS {% endif %} -[gcode_macro SAVE_PROBE_BACKLASH] -description: this macros save the sensor backlash. -gcode: - {% set probe_backlash_x = printer.auto_wcs.probe_backlash_x %} - {% set probe_backlash_y = printer.auto_wcs.probe_backlash_y %} - {% set probe_backlash_y_2 = printer.auto_wcs.probe_backlash_y_2 %} - SAVE_VARIABLE VARIABLE=probe_backlash_x VALUE={probe_backlash_x} - SAVE_VARIABLE VARIABLE=probe_backlash_y VALUE={probe_backlash_y} - SAVE_VARIABLE VARIABLE=probe_backlash_y_2 VALUE={probe_backlash_y_2} - {action_respond_info('probe_backlash_x=%s' % probe_backlash_x)} - {action_respond_info('probe_backlash_y=%s' % probe_backlash_y)} - {action_respond_info('probe_backlash_y_2=%s' % probe_backlash_y_2)} - -[gcode_macro SAVE_RADIUS_TOOL] -description: this macros save the radius tool. -gcode: - SAVE_VARIABLE VARIABLE=tooling_radius VALUE={printer.auto_wcs.tooling_radius} - SAVE_VARIABLE VARIABLE=tooling_radius_1 VALUE={printer.auto_wcs.tooling_radius_1} - SAVE_VARIABLE VARIABLE=tooling_radius_2 VALUE={printer.auto_wcs.tooling_radius_2} [gcode_macro MOVE_TO_AUTO_WCS] gcode: @@ -506,7 +487,6 @@ gcode: SET_AUTO_WCS_POINT_RADIUS POINT={i} {% endfor %} GET_RADIUS_TOOLING - SAVE_RADIUS_TOOL [gcode_macro AUTO_BASEMENT_MOVE_MEASURE_RADIUS] description: measuring radius for geting wcs_2_z. @@ -574,7 +554,7 @@ gcode: {% set wcs_1 = printer.gcode_move.wcs_offsets[4] %} {% set old_z = wcs_0[2] %} {% set old_y = wcs_1[1] %} - {% set probe_backlash_y = printer.save_variables.variables.probe_backlash_y|default(0.0)|float %} + {% set probe_backlash_y = printer.auto_wcs.probe_backlash_y|default(0.0)|float %} {% if wcs == 0 %} ; Mode SPIRAL-FULL ; apply measuring for the set wcs_2_z radius. From eaf754fc7fdabbeb90dfad13cf176c494a243f05 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Tue, 20 Jun 2023 12:34:03 +0100 Subject: [PATCH 5/6] STEAPP-542: added new algorithm for get difference meashuring between two points for axis A. --- klippy/extras/a_axis_offset.py | 20 ++++++++++++++++++++ stereotech_config/probe.cfg | 26 ++++++++++++++++++++++++++ stereotech_config/probe_2.cfg | 25 +++++++++++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/klippy/extras/a_axis_offset.py b/klippy/extras/a_axis_offset.py index 8e7de95032ab..32d1e3a5d992 100644 --- a/klippy/extras/a_axis_offset.py +++ b/klippy/extras/a_axis_offset.py @@ -20,6 +20,26 @@ def __init__(self, config): self.gcode.register_command( 'SAVE_A_AXIS_POINT', self.cmd_SAVE_A_AXIS_POINT, desc=self.cmd_SAVE_A_AXIS_POINT_help) + self.gcode.register_command( + 'INFO_CHECK_AXIS_A', self.cmd_INFO_CHECK_AXIS_A, + desc=self.cmd_INFO_CHECK_AXIS_A_help) + + def cmd_INFO_CHECK_AXIS_A(self, gcmd): + offset = abs(self.point_coords[0][2] - self.point_coords[1][2]) + gcmd.respond_info("difference the measuring axis A: %f." % offset) + + offset = self._calc_a_axis_offset( + self.point_coords[0], self.point_coords[1]) + homing_origin_a = self.gcode_move.get_status()['homing_origin'].a + if homing_origin_a + offset > 0.0: + offset = 0.0 + offset = offset * -1 + gcmd.respond_info("calculate offset for the axis A: %f.\nFor apply this params use command 'SET_GCODE_OFFSET A_ADJUST=%f'" % (offset, offset)) + # offset_gcmd = self.gcode.create_gcode_command( + # 'SET_GCODE_OFFSET', 'SET_GCODE_OFFSET', {'A_ADJUST': offset}) + # self.gcode_move.cmd_SET_GCODE_OFFSET(offset_gcmd) + + cmd_INFO_CHECK_AXIS_A_help = "Send info about difference the measuring." def cmd_SAVE_A_AXIS_POINT(self, gcmd): point_idx = gcmd.get_int('POINT', 0) diff --git a/stereotech_config/probe.cfg b/stereotech_config/probe.cfg index ff20aaf9ea8b..1e7d0f3a7453 100644 --- a/stereotech_config/probe.cfg +++ b/stereotech_config/probe.cfg @@ -456,6 +456,8 @@ gcode: AUTO_BASEMENT_WCS_TWO_Y_MOVE ; set wcs_2_y ADJUST_BASEMENT_WCS WCS=3 + ; checking axis A + CHECK_AXIS_A ; move and probing for measuring the wcs_2_z AUTO_BASEMENT_WCS_TWO_Z_MOVE {% else %} @@ -466,6 +468,30 @@ gcode: PROBE G0 Z150 F3600 +[gcode_macro CHECK_AXIS_A] +description: This macro moves, measures the a-axis, and gets the difference between the two measuring points. +gcode: + {% set debag = params.DEBAG|default(0)|int %} + {% if printer['gcode_macro AUTO_BASEMENT_WCS_TWO_Y_MOVE'].length_is_enough|int %} + {% set offsets = printer.probe.offsets %} + {% set wcs_offsets = printer.gcode_move.wcs_offsets[2] %} + {% set radius = printer.auto_wcs.tooling_radius %} + {% set x = wcs_offsets[0] - offsets[0] %} + {% set y = wcs_offsets[1] - offsets[1] %} + {% set z = wcs_offsets[2] + offsets[2] %} + G0 A90 F3600 + G0 Z150 F3600 + {% for i in range(1, 3) %} + G0 X{x} Y{y + (5 ** i)} F3600 + G0 Z{z + (radius + 10)} F3600 + PROBE + G0 Z{z + (radius + 10)} F3600 + SET_A_OFFSET_POINT POINT={i - 1} + {% endfor %} + G0 Z150 F3600 + INFO_CHECK_AXIS_A + {% endif %} + [gcode_macro AUTO_BASEMENT_WCS_MOVE] description: This macro does a move for measuring wcs_1_z and wcs_2_y-raw or wcs_2_y and wcs_1_z-raw. gcode: diff --git a/stereotech_config/probe_2.cfg b/stereotech_config/probe_2.cfg index 76f1ff5f8b1b..6a2ddd50960f 100644 --- a/stereotech_config/probe_2.cfg +++ b/stereotech_config/probe_2.cfg @@ -427,12 +427,37 @@ gcode: AUTO_BASEMENT_WCS_TWO_Y_MOVE ; set wcs_2_y ADJUST_BASEMENT_WCS WCS=3 + ; checking axis A + CHECK_AXIS_A ; move and probing for measuring the wcs_2_z AUTO_BASEMENT_WCS_TWO_Z_MOVE {% endif %} PROBE G0 Z150 F3600 +[gcode_macro CHECK_AXIS_A] +gcode: + {% set debag = params.DEBAG|default(0)|int %} + {% if printer['gcode_macro AUTO_BASEMENT_WCS_TWO_Y_MOVE'].length_is_enough|int %} + {% set offsets = printer.probe.offsets %} + {% set wcs_offsets = printer.gcode_move.wcs_offsets[2] %} + {% set radius = printer.auto_wcs.tooling_radius %} + {% set x = wcs_offsets[0] - offsets[0] %} + {% set y = wcs_offsets[1] - offsets[1] %} + {% set z = wcs_offsets[2] + offsets[2] %} + G0 A90 F3600 + G0 Z150 F3600 + {% for i in range(1, 3) %} + G0 X{x} Y{y + (5 ** i)} F3600 + G0 Z{z + (radius + 10)} F3600 + PROBE + G0 Z{z + (radius + 10)} F3600 + SET_A_OFFSET_POINT POINT={i - 1} + {% endfor %} + G0 Z150 F3600 + INFO_CHECK_AXIS_A + {% endif %} + [gcode_macro AUTO_BASEMENT_WCS_MOVE] description: This macro does a move for measuring wcs_1_z and wcs_2_y-raw or wcs_2_y and wcs_1_z-raw. gcode: From 396c8dfe159a6b9c66cf4d796e09806bf7294f51 Mon Sep 17 00:00:00 2001 From: sokolovjek Date: Tue, 20 Jun 2023 13:06:02 +0100 Subject: [PATCH 6/6] STEAPP-542: added new algorithm for get difference meashuring between two points for axis A. --- klippy/extras/a_axis_offset.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/klippy/extras/a_axis_offset.py b/klippy/extras/a_axis_offset.py index 32d1e3a5d992..c26b8d2f122f 100644 --- a/klippy/extras/a_axis_offset.py +++ b/klippy/extras/a_axis_offset.py @@ -34,7 +34,8 @@ def cmd_INFO_CHECK_AXIS_A(self, gcmd): if homing_origin_a + offset > 0.0: offset = 0.0 offset = offset * -1 - gcmd.respond_info("calculate offset for the axis A: %f.\nFor apply this params use command 'SET_GCODE_OFFSET A_ADJUST=%f'" % (offset, offset)) + gcmd.respond_info("""calculate offset for the axis A: %f.\nFor apply this + params use command 'SET_GCODE_OFFSET A_ADJUST=%f'""" % (offset, offset)) # offset_gcmd = self.gcode.create_gcode_command( # 'SET_GCODE_OFFSET', 'SET_GCODE_OFFSET', {'A_ADJUST': offset}) # self.gcode_move.cmd_SET_GCODE_OFFSET(offset_gcmd)