diff --git a/.vscode/launch.json b/.vscode/launch.json index 2ce7f2d8a36a..12bab24e07b5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -32,6 +32,26 @@ // "-l", // "/tmp/dev_klipper_log.log" ] + }, + { + "name": "Run klipper ender", + "type": "python", + "request": "launch", + "env": { + "PYTHONPATH": "${workspaceRoot}" + }, + "stopOnEntry": false, + "console": "integratedTerminal", + "cwd": "${workspaceRoot}", + "program": "${workspaceFolder}/klippy/klippy.py", + "args": [ + "${workspaceFolder}/ENDER-23.cfg", + "-v", + "-a", + "/tmp/klipper_uds", + // "-l", + // "/tmp/dev_klipper_log.log" + ] } ] } \ No newline at end of file diff --git a/ENDER-23.cfg b/ENDER-23.cfg index dedbfa975375..66cd01310bf2 100644 --- a/ENDER-23.cfg +++ b/ENDER-23.cfg @@ -23,3 +23,5 @@ path: /home/ste/uploads [include stereotech_config/ender/print_macros.cfg] [include stereotech_config/ender/extruder_macros.cfg] [include stereotech_config/ender/variables.cfg] + +[include stereotech_config/ender/probe.cfg] diff --git a/stereotech_config/ender/kinematics.cfg b/stereotech_config/ender/kinematics.cfg index 9d614cf43114..a6c2ece07367 100644 --- a/stereotech_config/ender/kinematics.cfg +++ b/stereotech_config/ender/kinematics.cfg @@ -2,8 +2,8 @@ kinematics: cartesian_6axis max_velocity: 300 max_accel: 3000 -max_z_velocity: 40 -max_z_accel: 500 +max_z_velocity: 20 +max_z_accel: 100 square_corner_velocity: 2.50 [stepper_x] diff --git a/stereotech_config/ender/module_5d.cfg b/stereotech_config/ender/module_5d.cfg index 2c6055d96750..891ff929f1ae 100644 --- a/stereotech_config/ender/module_5d.cfg +++ b/stereotech_config/ender/module_5d.cfg @@ -6,31 +6,20 @@ press_gcode: QUERY_BUTTON BUTTON=five_axis_module [gcode_macro MOVE_WCS_ZERO] gcode: + {% set z_max = printer.toolhead.axis_maximum %} G54 - {% if printer.toolhead.axis_maximum[0] > 250 %} - G0 Z150 F6000 - {% else %} - G0 Z100 F6000 - {% endif %} + G0 Z{z_max[2]} F6000 {% set current_wcs = params.WCS|default(1)|int %} {% set offsets = printer.gcode_move.wcs_offsets[current_wcs] %} {% if offsets[0] == 0 and offsets[1] == 0 %} - {% if printer.toolhead.axis_maximum[0] > 250 %} - G0 X162 Y242 F6000 - {% else %} - G0 X107 Y137 F6000 - {% endif %} + G0 X125 Y50 F6000 {% else %} G0 X{offsets[0]} Y{offsets[1]} F6000 {% endif %} {% if current_wcs == 1 %} G0 A0 {% elif current_wcs == 2 %} - {% if printer.toolhead.axis_maximum[0] > 250 %} - G0 Y192 A90 F6000 - {% else %} - G0 Y87 A90 F6000 - {% endif %} + G0 Y87 A90 F6000 {% endif %} [gcode_macro SET_WCS_OFFSET] @@ -63,24 +52,34 @@ gcode: gcode: G54 {% set point = params.POINT|default(0)|int %} - {% set x = 162 if printer.toolhead.axis_maximum[0] > 250 else 108 %} - {% set y = 242 if printer.toolhead.axis_maximum[0] > 250 else 137 %} + {% set x = 108 %} + {% set y = 80 %} + {% if point == 3 or point == 4 %} - {% set y = 192 if printer.toolhead.axis_maximum[0] > 250 else 87 %} + {% set y = 87 %} {% endif %} + {% if point == 1 %} - {% set x = 112 if printer.toolhead.axis_maximum[0] > 250 else 58 %} + {% set x = 58 %} {% endif %} + {% if point == 2 %} - {% set x = 212 if printer.toolhead.axis_maximum[0] > 250 else 158 %} + {% set x = 158 %} {% endif %} G0 A0 - G0 X{x} Y{y} Z110 F3600 + # G0 X{x} Y{y} Z110 F3600 + # point0 + # G0 X108 Y80 Z130 F600 + # point1 + # G0 X58 Y80 Z130 F600 + # point2 + # G0 X158 Y80 Z130 F600 + # point4 + # G0 X158 Y87 Z130 F600 {% if point > 3 %} - G0 Z70 A90 F3600 + G0 Z150 A90 F600 {% endif %} - [gcode_macro SET_A_AXIS_OFFSET_POINT] gcode: {% set point = params.POINT|default(0)|int %} diff --git a/stereotech_config/ender/probe.cfg b/stereotech_config/ender/probe.cfg new file mode 100644 index 000000000000..6e7a392d424e --- /dev/null +++ b/stereotech_config/ender/probe.cfg @@ -0,0 +1,526 @@ +[probe] +pin: !PG13 +samples: 4 +samples_tolerance_retries: 1 +samples_result: median +lift_speed: 10.0 +x_offset: -42.3 +y_offset: -48.14 +z_offset: 0.0 + +[auto_wcs] +# [skew_correction] +# [b_axis_compensation] + +# [bed_mesh] +# speed: 120 +# horizontal_move_z: 50 +# mesh_min: 20, 20 +# mesh_max: 261, 245 +# probe_count: 5, 5 +# fade_start: 1 +# fade_end: 10 +# fade_target: 0 + +# [bed_mesh module_3d] +# version = 1 +# points = +# 0.0, 0.0, 0.0, 0.0, 0.0 +# 0.0, 0.0, 0.0, 0.0, 0.0 +# 0.0, 0.0, 0.0, 0.0, 0.0 +# 0.0, 0.0, 0.0, 0.0, 0.0 +# 0.0, 0.0, 0.0, 0.0, 0.0 +# x_count = 5 +# y_count = 5 +# mesh_x_pps = 2 +# mesh_y_pps = 2 +# algo = lagrange +# tension = 0.2 +# min_x = 10.0 +# max_x = 261.0 +# min_y = 10.0 +# max_y = 253.0 + +# [gcode_macro SET_PROBE_SENSOR] +# description: Set offsets for new sensor and set sensor version. +# gcode: +# {% set probe_sensor_version = params.PROBE_VERSION|default(0)|int %} +# {% if probe_sensor_version > 0 %} +# {% set x_offset = -40.0 %} +# {% set y_offset = -34.0 %} +# {% set z_offset = 0.0 %} +# {% else %} +# {% set x_offset = -42.3 %} +# {% set y_offset = -48.14 %} +# {% set z_offset = 0.0 %} +# {% endif %} +# Z_OFFSET_APPLY_PROBE X={x_offset} Y={y_offset} Z={z_offset} +# SAVE_VARIABLE VARIABLE=probe_sensor_version VALUE={probe_sensor_version} +# SAVE_VARIABLE VARIABLE=probe_offset_x VALUE={x_offset} +# SAVE_VARIABLE VARIABLE=probe_offset_y VALUE={y_offset} +# SAVE_VARIABLE VARIABLE=probe_offset_z VALUE={z_offset} +# {action_respond_info("Apply offset for new sensor: x_offset= %s, y_offset= %s, z_offset= %s" % (x_offset, y_offset, z_offset))} + +# [gcode_macro TEST_PROBE] +# gcode: +# QUERY_PROBE +# UPDATE_DELAYED_GCODE ID=test_probe_loop DURATION=1.0 + +# [gcode_macro CANCEL_TEST_PROBE] +# gcode: +# UPDATE_DELAYED_GCODE ID=test_probe_loop DURATION=0.0 +# {action_respond_info('Abort check loop')} + +# [delayed_gcode test_probe_loop] +# gcode: +# {% if printer["probe"].last_query %} +# UPDATE_DELAYED_GCODE ID=test_probe_loop DURATION=0.0 +# {action_respond_info('Probe pressed, abort check loop')} +# {% else %} +# {action_respond_info('Probe not pressed')} +# QUERY_PROBE +# UPDATE_DELAYED_GCODE ID=test_probe_loop DURATION=1.0 +# {% endif %} + +# [gcode_macro CALIBRATE_MODULE_THREE_D] +# description: 3D module calibration +# gcode: +# {% if printer["gcode_button five_axis_module"].state == "RELEASED" %} +# G0 X197 Y195 F6000 +# PROBE +# G91 +# G0 Z30 F600 +# G90 +# MODULE_THREE_D_MESH_CALIBRATE +# G91 +# G0 Z30 F600 +# G90 +# G0 X150 Y50 F3600 +# {% endif %} + +# [gcode_macro MODULE_THREE_D_MESH_CALIBRATE] +# description: 3D module calibration +# gcode: +# {% if printer["gcode_button five_axis_module"].state == "RELEASED" %} +# Z_OFFSET_APPLY_PROBE Z={printer.probe.last_result[2]} +# BED_MESH_CALIBRATE PROFILE=module_3d +# BED_MESH_CLEAR +# {% endif %} + +# [gcode_macro CALIBRATE_MODULE_FIVE_D] +# description: 5D module calibration +# gcode: +# {% if printer["gcode_button five_axis_module"].state == "PRESSED" %} +# G28 A +# M204 S500 +# G0 C0.1 +# G0 C0 +# {% set probe_sensor_version = printer.save_variables.variables.probe_sensor_version|default(0)|int %} +# ADJUST_TEMPLATE_HEIGHT +# PROBE_TEMPLATE_POINT POINT=AY +# SET_C_ALIGN_POINT POINT=0 +# PROBE_TEMPLATE_POINT POINT=BY +# SET_C_ALIGN_POINT POINT=1 +# CALC_C_AXIS_ALIGN +# PROBE_TEMPLATE_POINT POINT=AY +# SET_C_ALIGN_POINT POINT=0 +# PROBE_TEMPLATE_POINT POINT=BY +# SET_C_ALIGN_POINT POINT=1 +# CALC_C_AXIS_ALIGN + +# PROBE_TEMPLATE_POINT POINT=O +# SET_A_OFFSET_POINT POINT=0 +# PROBE_TEMPLATE_POINT POINT=CZ +# SET_A_OFFSET_POINT POINT=1 +# CALC_A_AXIS_OFFSET +# PROBE_TEMPLATE_POINT POINT=O +# SET_A_OFFSET_POINT POINT=0 +# PROBE_TEMPLATE_POINT POINT=CZ +# SET_A_OFFSET_POINT POINT=1 +# CALC_A_AXIS_OFFSET + +# ; PROBE_TEMPLATE_POINT POINT=CZ +# ; SET_B_COMPENSATION_POINT POINT=0 +# ; PROBE_TEMPLATE_POINT POINT=CZ1 +# ; SET_B_COMPENSATION_POINT POINT=1 +# ; PROBE_TEMPLATE_POINT POINT=AZ +# ; SET_B_COMPENSATION_POINT POINT=2 +# ; PROBE_TEMPLATE_POINT POINT=BZ +# ; SET_B_COMPENSATION_POINT POINT=3 +# ; PROBE_TEMPLATE_POINT POINT=AX +# ; SET_B_COMPENSATION_POINT POINT=4 +# ; PROBE_TEMPLATE_POINT POINT=BX +# ; SET_B_COMPENSATION_POINT POINT=5 +# ; CALC_B_AXIS_COMPENSATION ENABLE=0 + +# ; skew corection +# ; xy skew +# ;PROBE_TEMPLATE_POINT POINT=AX +# ;SET_SKEW_COMPENSATION_POINT POINT=0 +# ;PROBE_TEMPLATE_POINT POINT=BX +# ;SET_SKEW_COMPENSATION_POINT POINT=1 +# ;PROBE_TEMPLATE_POINT POINT=XY1 +# ;SET_SKEW_COMPENSATION_POINT POINT=2 +# ;PROBE_TEMPLATE_POINT POINT=XY2 +# ;SET_SKEW_COMPENSATION_POINT POINT=3 +# ;CALC_SKEW_COMPENSATION FACTOR=XY +# ; xz skew +# ;PROBE_TEMPLATE_POINT POINT=BX +# ;SET_SKEW_COMPENSATION_POINT POINT=0 +# ;PROBE_TEMPLATE_POINT POINT=AX +# ;SET_SKEW_COMPENSATION_POINT POINT=1 +# ;PROBE_TEMPLATE_POINT POINT=XZ3 +# ;SET_SKEW_COMPENSATION_POINT POINT=2 +# ;PROBE_TEMPLATE_POINT POINT=XZ4 +# ;SET_SKEW_COMPENSATION_POINT POINT=3 +# ;CALC_SKEW_COMPENSATION FACTOR=XZ +# ; yz skew +# ;PROBE_TEMPLATE_POINT POINT=YZ1 +# ;SET_SKEW_COMPENSATION_POINT POINT=0 +# ;PROBE_TEMPLATE_POINT POINT=YZ2 +# ;SET_SKEW_COMPENSATION_POINT POINT=1 +# ;PROBE_TEMPLATE_POINT POINT=YZ3 +# ;SET_SKEW_COMPENSATION_POINT POINT=2 +# ;CALC_SKEW_COMPENSATION FACTOR=YZ +# ; save profile 5d +# ;SKEW_PROFILE SAVE=module_5d + + +# {% if probe_sensor_version > 0 %} +# AUTO_WCS_OFFSET_NEW_SENSOR +# {% else %} +# AUTO_WCS_OFFSET_OLD_SERNSOR +# {% endif %} +# M204 S1500 +# {% endif %} + +# [gcode_macro SET_C_ALIGN_POINT] +# gcode: +# {% set point = printer.probe.last_result %} +# {% set offsets = printer.probe.offsets %} +# {% set x = point[0] + offsets[0] - printer.gcode_move.homing_origin.x %} +# {% set y = point[1] + offsets[1] - printer.gcode_move.homing_origin.y %} +# {% set z = point[2] - offsets[2] - printer.gcode_move.homing_origin.z %} +# {% set index = params.POINT|default(0) %} +# SAVE_C_AXIS_POINT POINT={index} COORDS='{x},{y},{z}' + +# [gcode_macro SET_A_OFFSET_POINT] +# gcode: +# {% set point = printer.probe.last_result %} +# {% set offsets = printer.probe.offsets %} +# {% set x = point[0] + offsets[0] - printer.gcode_move.homing_origin.x %} +# {% set y = point[1] + offsets[1] - printer.gcode_move.homing_origin.y %} +# {% set z = point[2] - offsets[2] - printer.gcode_move.homing_origin.z %} +# {% set index = params.POINT|default(0) %} +# SAVE_A_AXIS_POINT POINT={index} COORDS='{x},{y},{z}' + +# [gcode_macro SET_B_COMPENSATION_POINT] +# gcode: +# {% set point = printer.probe.last_result %} +# {% set offsets = printer.probe.offsets %} +# {% set x = point[0] + offsets[0] - printer.gcode_move.homing_origin.x %} +# {% set y = point[1] + offsets[1] - printer.gcode_move.homing_origin.y %} +# {% set z = point[2] - offsets[2] - printer.gcode_move.homing_origin.z %} +# {% set index = params.POINT|default(0) %} +# SAVE_B_AXIS_POINT POINT={index} COORDS='{x},{y},{z}' + +# [gcode_macro SET_SKEW_COMPENSATION_POINT] +# description: saved value about probe for align skew +# gcode: +# {% set point = printer.probe.last_result %} +# {% set offsets = printer.probe.offsets %} +# {% set x = point[0] + offsets[0] - printer.gcode_move.homing_origin.x %} +# {% set y = point[1] + offsets[1] - printer.gcode_move.homing_origin.y %} +# {% set z = point[2] - offsets[2] - printer.gcode_move.homing_origin.z %} +# {% set index = params.POINT|default(0) %} +# SAVE_SKEW_POINT POINT={index} COORDS='{x},{y},{z}' + +# [gcode_macro ADJUST_TEMPLATE_HEIGHT] +# gcode: +# PROBE_TEMPLATE_POINT +# SET_TEMPLATE_HEIGHT + +# [gcode_macro SET_TEMPLATE_HEIGHT] +# gcode: +# SET_GCODE_VARIABLE MACRO=PROBE_TEMPLATE_POINT VARIABLE=probe_z VALUE={printer.probe.last_result[2] - printer.gcode_move.homing_origin.z} + +# [c_axis_align] + + +# [skew_correction module_3d] +# xy_skew = 0.0 +# xz_skew = 0.0 +# yz_skew = 0.0 + +# [skew_correction module_5d] +# xy_skew = 0.0 +# xz_skew = 0.0 +# yz_skew = 0.0 + +# [gcode_macro SET_AUTO_WCS_POINT] +# gcode: +# {% set point = printer.probe.last_result %} +# {% set offsets = printer.probe.offsets %} +# {% set x = point[0] + offsets[0] - printer.gcode_move.homing_origin.x %} +# {% set y = point[1] + offsets[1] - printer.gcode_move.homing_origin.y %} +# {% set z = point[2] - offsets[2] - printer.gcode_move.homing_origin.z %} +# # checking the axes that they are within the allowable range +# {% set home_min = printer.toolhead.axis_minimum %} +# {% set home_max = printer.toolhead.axis_maximum %} +# {% if x < home_min[0] or x > home_max[0] %} +# {action_raise_error('axis x=%f out of range (%f - %f)' % (x, home_min[0], home_max[0]))} +# {% elif y < home_min[1] or y > home_max[1] %} +# {action_raise_error('axis y=%f out of range (%f - %f)' % (y, home_min[1], home_max[1]))} +# {% elif z < home_min[2] or z > home_max[2] %} +# {action_raise_error('axis z=%f out of range (%f - %f)' % (z, home_min[2], home_max[2]))} +# {% endif %} +# {% set index = params.POINT|default(0) %} +# SAVE_WCS_CALC_POINT POINT={index} COORDS='{x},{y},{z}' + +# [gcode_macro AUTO_WCS_OFFSET_OLD_SERNSOR] +# gcode: +# {% if printer["gcode_button five_axis_module"].state == "PRESSED" %} +# {% set probe_sensor_version = printer.save_variables.variables.probe_sensor_version|default(0)|int %} +# G0 C0.1 +# G0 C0 +# ADJUST_TEMPLATE_HEIGHT +# PROBE_TEMPLATE_POINT POINT=AY +# SET_C_ALIGN_POINT POINT=0 +# PROBE_TEMPLATE_POINT POINT=BY +# SET_C_ALIGN_POINT POINT=1 +# CALC_C_AXIS_ALIGN +# ADJUST_TEMPLATE_HEIGHT +# SET_AUTO_WCS_POINT POINT=0 +# PROBE_TEMPLATE_POINT POINT=AY1 +# SET_AUTO_WCS_POINT POINT=1 +# PROBE_TEMPLATE_POINT POINT=AY2 +# SET_AUTO_WCS_POINT POINT=7 +# PROBE_TEMPLATE_POINT POINT=AX +# SET_AUTO_WCS_POINT POINT=2 +# PROBE_TEMPLATE_POINT POINT=BX +# SET_AUTO_WCS_POINT POINT=3 +# PROBE_TEMPLATE_POINT POINT=DZ +# SET_AUTO_WCS_POINT POINT=4 +# PROBE_TEMPLATE_POINT POINT=DY +# SET_AUTO_WCS_POINT POINT=5 +# PROBE_TEMPLATE_POINT POINT=EY +# SET_AUTO_WCS_POINT POINT=6 +# {% set template_thickness = printer.save_variables.variables.template_thickness|default(10.0)|float %} +# {% set auto_wcs_adj = printer.save_variables.variables.auto_wcs_adj|default(0.25)|float %} +# CALC_WCS_PARAMS THICKNESS={ template_thickness } ADJUSTMENT={ auto_wcs_adj } SENSOR_VERSION={probe_sensor_version} +# PROBE_TEMPLATE_POINT POINT=AY +# SET_C_ALIGN_POINT POINT=0 +# PROBE_TEMPLATE_POINT POINT=BY +# SET_C_ALIGN_POINT POINT=1 +# CALC_C_AXIS_ALIGN +# MOVE_TO_AUTO_WCS +# {% endif %} + +# [gcode_macro AUTO_WCS_OFFSET_NEW_SENSOR] +# gcode: +# {% if printer["gcode_button five_axis_module"].state == "PRESSED" %} +# {% set probe_sensor_version = printer.save_variables.variables.probe_sensor_version|default(0)|int %} +# G0 C0.1 +# G0 C0 +# ADJUST_TEMPLATE_HEIGHT +# PROBE_TEMPLATE_POINT POINT=AY +# SET_C_ALIGN_POINT POINT=0 +# PROBE_TEMPLATE_POINT POINT=BY +# SET_C_ALIGN_POINT POINT=1 +# CALC_C_AXIS_ALIGN +# ADJUST_TEMPLATE_HEIGHT +# SET_AUTO_WCS_POINT POINT=0 +# PROBE_TEMPLATE_POINT POINT=AY2_2 +# SET_AUTO_WCS_POINT POINT=7 +# PROBE_TEMPLATE_POINT POINT=AY1_2 +# SET_AUTO_WCS_POINT POINT=1 +# PROBE_TEMPLATE_POINT POINT=BX +# SET_AUTO_WCS_POINT POINT=3 +# PROBE_TEMPLATE_POINT POINT=AX +# SET_AUTO_WCS_POINT POINT=2 +# PROBE_TEMPLATE_POINT POINT=DZ_2 +# SET_AUTO_WCS_POINT POINT=4 +# PROBE_TEMPLATE_POINT POINT=EY_2 +# SET_AUTO_WCS_POINT POINT=6 +# PROBE_TEMPLATE_POINT POINT=DY_2 +# SET_AUTO_WCS_POINT POINT=5 +# PROBE_TEMPLATE_POINT POINT=CX1 +# SET_AUTO_WCS_POINT POINT=8 +# PROBE_TEMPLATE_POINT POINT=CX2 +# SET_AUTO_WCS_POINT POINT=9 +# {% set template_thickness = printer.save_variables.variables.template_thickness|default(10.0)|float %} +# {% set auto_wcs_adj = printer.save_variables.variables.auto_wcs_adj|default(0.3)|float %} +# CALC_WCS_PARAMS THICKNESS={ template_thickness } ADJUSTMENT={ auto_wcs_adj } SENSOR_VERSION={probe_sensor_version} +# PROBE_TEMPLATE_POINT POINT=AY +# SET_C_ALIGN_POINT POINT=0 +# PROBE_TEMPLATE_POINT POINT=BY +# SET_C_ALIGN_POINT POINT=1 +# CALC_C_AXIS_ALIGN +# MOVE_TO_AUTO_WCS +# {% endif %} + +# [gcode_macro MOVE_TO_AUTO_WCS] +# gcode: +# {% set set_xy = params.XY|default(0) %} +# {% set y_shift = 50 if set_xy else 7 %} +# {% if printer["gcode_button five_axis_module"].state == "PRESSED" %} +# G0 X{printer.auto_wcs.wcs[0][0]} Y{printer.auto_wcs.wcs[0][1] - y_shift} Z{printer.auto_wcs.wcs[0][2] + 10} F3600 +# {% endif %} + +# [gcode_macro ADJUST_PROBE_OFFSET_Z] +# gcode: +# {% if printer["gcode_button five_axis_module"].state == "PRESSED" %} +# {% set wcs_0 = printer.auto_wcs.wcs[0] %} +# {% set wcs_1 = printer.auto_wcs.wcs[1] %} +# {% set offsets = printer.probe.offsets %} +# {% set coord_z = printer.gcode_move.position.z - printer.gcode_move.homing_origin.z %} +# {% set delta_z = wcs_0[2] - coord_z %} +# Z_OFFSET_APPLY_PROBE Z={(offsets[2] + delta_z)|abs} +# {% if params.ADJUST_CALIBRATION|default(0) %} +# {% set b_axis_params = printer.b_axis_compensation %} +# B_AXIS_COMPENSATION_VARS Z={b_axis_params.rot_center_z - delta_z} +# {% endif %} +# {% if params.ADJUST_WCS|default(0) %} +# {% set auto_wcs_params = printer.auto_wcs.wcs %} +# {% set x0 = auto_wcs_params[0][0] %} +# {% set y0 = auto_wcs_params[0][1] %} +# {% set z0 = auto_wcs_params[0][2] - delta_z %} +# SET_AUTO_WCS WCS=0 COORDS='{x0},{y0},{z0}' +# {% set x1 = auto_wcs_params[1][0] %} +# {% set y1 = auto_wcs_params[1][1] %} +# {% set z1 = auto_wcs_params[1][2] - delta_z %} +# SET_AUTO_WCS WCS=1 COORDS='{x1},{y1},{z1}' +# {% endif %} +# {% endif %} + + +# [gcode_macro ADJUST_PROBE_OFFSET_XY] +# gcode: +# {% if printer["gcode_button five_axis_module"].state == "PRESSED" %} +# {% set y_shift = 50 %} +# {% set wcs_0 = printer.auto_wcs.wcs[0] %} +# {% set wcs_1 = printer.auto_wcs.wcs[1] %} +# {% set offsets = printer.probe.offsets %} +# {% set coord_x = printer.gcode_move.position.x - printer.gcode_move.homing_origin.x %} +# {% set coord_y = printer.gcode_move.position.y + y_shift - printer.gcode_move.homing_origin.y %} +# {% set delta_x = wcs_0[0] - coord_x %} +# {% set delta_y = wcs_0[1] - coord_y %} +# Z_OFFSET_APPLY_PROBE X={offsets[0] - delta_x} Y={offsets[1] - delta_y} +# {% if params.ADJUST_CALIBRATION|default(0) %} +# {% set b_axis_params = printer.b_axis_compensation %} +# B_AXIS_COMPENSATION_VARS X={b_axis_params.rot_center_x - delta_x} +# {% endif %} +# {% if params.ADJUST_WCS|default(0) %} +# {% set auto_wcs_params = printer.auto_wcs.wcs %} +# {% set x0 = auto_wcs_params[0][0] - delta_x %} +# {% set y0 = auto_wcs_params[0][1] - delta_y %} +# {% set z0 = auto_wcs_params[0][2] %} +# SET_AUTO_WCS WCS=0 COORDS='{x0},{y0},{z0}' +# {% set x1 = auto_wcs_params[1][0] - delta_x %} +# {% set y1 = auto_wcs_params[1][1] - delta_y %} +# {% set z1 = auto_wcs_params[1][2] %} +# SET_AUTO_WCS WCS=1 COORDS='{x1},{y1},{z1}' +# {% endif %} +# {% endif %} + +[gcode_macro SET_WCS_FROM_AUTO_WCS] +gcode: + {% set auto_wcs_params = printer.auto_wcs.wcs %} + {% set max_x = printer.toolhead.axis_maximum[0] %} + G10 L2 P2 X{auto_wcs_params[0][0]} Y{auto_wcs_params[0][1]} Z{auto_wcs_params[0][2]} + G10 L2 P4 X{auto_wcs_params[0][0]} Y{auto_wcs_params[0][1]} Z{auto_wcs_params[0][2]} + G10 L2 P3 X{auto_wcs_params[1][0]} Y{auto_wcs_params[1][1]} Z{auto_wcs_params[1][2]} + G10 L2 P5 X{auto_wcs_params[1][0]} Y{auto_wcs_params[1][1]} Z{auto_wcs_params[1][2]} + G90 + G0 Z245 F1500 + G54 + G0 X{max_x / 2.0} Y50 F3600 + +# [gcode_macro AUTO_BASEMENT_WCS] +# description: This macro performs move based on the required measuring(wcs1_z, wcs2_y, wcs2_z), and takes measurements. +# gcode: +# {% set wcs = params.WCS|default(0)|int %} +# {% set probe_sensor_version = printer.save_variables.variables.probe_sensor_version|default(0)|int %} +# {% if wcs == 0 %} +# ; move for measuring wcs_1_z +# AUTO_BASEMENT_WCS_MOVE +# PROBE +# {% else %} +# PROBE +# {% endif %} +# G0 Z245 F3600 + +# [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: +# {% set wcs = params.WCS|default(0)|int %} +# {% set offsets = printer.probe.offsets %} +# {% set wcs_offsets = printer.gcode_move.wcs_offsets[wcs + 3] %} +# {% set x = wcs_offsets[0] - offsets[0] %} +# {% set y = wcs_offsets[1] - offsets[1] %} +# {% set z = wcs_offsets[2] + offsets[2] %} +# {% set a = '0' if wcs == 0 else '90' %} +# G28 A +# G0 A{a} F3600 +# G0 Z150 F3600 +# G0 X{x} Y{y} F3600 + +# [gcode_macro CHECK_AXIS_A] +# description: This macro moves, measures the a-axis, and gets the difference between the two measuring points and apply offset. +# gcode: +# PROBE_TOOL_POINT POINT=Z_2_0 WCS=2 +# SET_A_OFFSET_POINT POINT=1 +# PROBE_TOOL_POINT POINT=Z_2_1 WCS=2 +# SET_A_OFFSET_POINT POINT=0 +# ; calculate and apply offset for axis A +# CALC_A_AXIS_OFFSET + +# [gcode_macro GET_TOOL_LENGTH] +# description: This macro calculate length tool. +# variable_length_is_enough: 0 +# gcode: +# {% set old_y = printer.gcode_move.wcs_offsets[4][1] %} +# {% set template_thickness = printer.save_variables.variables.template_thickness|default(10.0)|float %} +# {% set wcs_2_y = printer.gcode_move.wcs_offsets[2][1] %} +# {% set tool_length = old_y + template_thickness - wcs_2_y %} +# {% if tool_length > 35.0 %} +# SET_GCODE_VARIABLE MACRO=GET_TOOL_LENGTH VARIABLE=length_is_enough VALUE=1 +# {action_respond_info('tool length=%s' % tool_length)} +# {% endif %} + +# [gcode_macro TOOL_RADIUS] +# description: moved to measure tool radius and calculate it. +# gcode: +# PROBE_TOOL_POINT POINT=Y_1 WCS=1 +# SET_AUTO_WCS_POINT POINT=0 +# GET_RADIUS_TOOLING ADVANCE=1 +# PROBE_TOOL_POINT POINT=X_1_0 WCS=1 +# SET_AUTO_WCS_POINT POINT=1 +# PROBE_TOOL_POINT POINT=X_1_1 WCS=1 +# SET_AUTO_WCS_POINT POINT=2 +# GET_RADIUS_TOOLING + +[gcode_macro ADJUST_BASEMENT_WCS] +description: macro needed for set wcs based selected mode the manager calibrate. +gcode: + {% set wcs = params.WCS|default(0)|int %} + {% set point = printer.probe.last_result %} + {% set offsets = printer.probe.offsets %} + {% set wcs_0 = printer.gcode_move.wcs_offsets[3] %} + {% set x = point[0] + offsets[0] - printer.gcode_move.homing_origin.x %} + {% set y = point[1] + offsets[1] - printer.gcode_move.homing_origin.y %} + {% set z = point[2] - offsets[2] - printer.gcode_move.homing_origin.z %} + {% set wcs_1 = printer.gcode_move.wcs_offsets[4] %} + {% set old_z = wcs_0[2] %} + {% set old_y = wcs_1[1] %} + {% if wcs == 0 %} + ; Mode SPIRAL-FULL + ; apply measuring for the set wcs_1_z and wcs_2_y. + G10 L2 P2 Z{z} + G10 L2 P3 Y{old_y - (z - old_z)} + {% elif wcs == 1 %} + ; Mode SPIRAL + ; apply measuring for the set wcs_2_y and wcs_1_z(raw). + G10 L2 P3 Y{y} + G10 L2 P2 Z{old_z - (y - old_y)} + {% endif %}