Skip to content

STEAPP-542:added a new algorithm for measuring the difference between two points for the A axis. #135

Merged
merged 7 commits into from
Jun 23, 2023
21 changes: 21 additions & 0 deletions klippy/extras/a_axis_offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@ 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)
Expand Down
26 changes: 26 additions & 0 deletions stereotech_config/probe.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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:
Expand Down
25 changes: 25 additions & 0 deletions stereotech_config/probe_2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down