-
Notifications
You must be signed in to change notification settings - Fork 18
/
MACRO-EUCLID_NOZZLE-COMP.cfg
146 lines (131 loc) · 6.77 KB
/
MACRO-EUCLID_NOZZLE-COMP.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# ! ! ! Following is just a general idea, not tested at all - don't trust it ! ! !
# This is for when Euclid and Nozzle/Z-Endstop are run in series. Since they are both
# normally closed, when either of the is depressed it will cause the path to open and
# the probe signal will trigger. Even if using canbus toolhead board, run signal wire
# from Euclid to Nozzle/Z-Endstop, and then to main printer board as normal. GND and
# V+ can be provided by the canbus toolhead board.
# Inspired by https://github.com/protoloft/klipper_z_calibration#what-it-does
# Why? I'd rather not have to install a python plugin for this to function. I also like
# to keep things as simple as possible, where it is easier for others to modify and
# improve upon.
# Notes: My particular G28 has extra options whereas you can tell it to keep the Euclid
# probe on after performing G28 (G28 KEEP_PROBE:TRUE). For your macro setup you may need
# to issue M401 and also M402 at the end.
[gcode_macro _VARIABLES]
# USER CONFIGURABLE VARIABLES
variable_switchoffset: 0.2
variable_zprobespeed: 5.0
variable_zprobesamples: 7
variable_zprobetolerance: 0.05
variable_zproberetract: 2.5
variable_xeuclidbodyoverendstop: XX
variable_yeuclidbodyoverendstop: XX
variable_xnozzleoverendstop: XX
variable_ynozzleoverendstop:XX
# SYSTEM VARIABLES, THEY ARE USED INTERNALLY
variable_zcenterprobing: 0
variable_znozzleprobing: 0
variable_zeuclidbodyprobing: 0
variable_lastzoffsetcalculated: 0
gcode:
[gcode_macro ZAUTO]
gcode:
{% set X_MID = printer.configfile.config["stepper_x"]["position_max"]|float / 2.0 %}
{% set X_PROBEOFFSET = printer.configfile.config["probe"]["x_offset"]|float %}
{% set Y_MID = printer.configfile.config["stepper_y"]["position_max"]|float / 2.0 %}
{% set Y_PROBEOFFSET = printer.configfile.config["probe"]["y_offset"]|float %}
{% set ZSpeed = printer["gcode_macro _VARIABLES"].zprobespeed|float %}
{% set ZSamples = printer["gcode_macro _VARIABLES"].zprobesamples|int %}
{% set ZTolerance = printer["gcode_macro _VARIABLES"].zprobetolerance|float %}
{% set ZRetract = printer["gcode_macro _VARIABLES"].zproberetract|float %}
{% set S_Retries = printer.configfile.config["probe"]["samples_tolerance_retries"]|int %}
BED_MESH_CLEAR
G28 KEEP_PROBE:TRUE
QUAD_GANTRY_LEVEL_ORIGINAL
G0 Z15 F3600
G0 X{(X_MID - X_PROBEOFFSET)} Y{(Y_MID - Y_PROBEOFFSET)} F4000
M118 Moving to probe bed center with Euclid.
PROBE samples_result=median samples={ZSamples} speed={ZSpeed} samples_tolerance={ZTolerance} samples_tolerance_retries={S_Retries} sample_retract_dist={ZRetract}
_ZAUTO2
[gcode_macro _ZAUTO2]
gcode:
{% set ProbeResult = printer.probe.last_z_result %}
SET_GCODE_VARIABLE MACRO=_VARIABLES VARIABLE=zcenterprobing VALUE={ProbeResult}
{% set ZSpeed = printer["gcode_macro _VARIABLES"].zprobespeed|float %}
{% set ZSamples = printer["gcode_macro _VARIABLES"].zprobesamples|int %}
{% set ZTolerance = printer["gcode_macro _VARIABLES"].zprobetolerance|float %}
{% set ZRetract = printer["gcode_macro _VARIABLES"].zproberetract|float %}
{% set S_Retries = printer.configfile.config["probe"]["samples_tolerance_retries"]|int %}
{% set X_EUCLIDBODYOVERENDSTOP = printer["gcode_macro _VARIABLES"].xeuclidbodyoverendstop|float %}
{% set Y_EUCLIDBODYOVERENDSTOP = printer["gcode_macro _VARIABLES"].yeuclidbodyoverendstop|float %}
G0 Z15 F3600
G0 X{X_EUCLIDBODYOVERENDSTOP} Y{Y_EUCLIDBODYOVERENDSTOP} F4000
M118 Moving to probe Euclid switch body to Z-Endstop.
PROBE samples_result=median samples={ZSamples} speed={ZSpeed} samples_tolerance={ZTolerance} samples_tolerance_retries={S_Retries} sample_retract_dist={ZRetract}
_ZAUTO3
[gcode_macro _ZAUTO3]
gcode:
{% set ProbeResult = printer.probe.last_z_result %}
SET_GCODE_VARIABLE MACRO=_VARIABLES VARIABLE=zeuclidbodyprobing VALUE={ProbeResult}
{% set ZSpeed = printer["gcode_macro _VARIABLES"].zprobespeed|float %}
{% set ZSamples = printer["gcode_macro _VARIABLES"].zprobesamples|int %}
{% set ZTolerance = printer["gcode_macro _VARIABLES"].zprobetolerance|float %}
{% set ZRetract = printer["gcode_macro _VARIABLES"].zproberetract|float %}
{% set S_Retries = printer.configfile.config["probe"]["samples_tolerance_retries"]|int %}
{% set X_NOZZLEOVERENDSTOP = printer["gcode_macro _VARIABLES"].xnozzleoverendstop|float %}
{% set Y_NOZZLEOVERENDSTOP = printer["gcode_macro _VARIABLES"].ynozzleoverendstop|float %}
G0 Z15 F3600
G0 X{X_NOZZLEOVERENDSTOP} Y{Y_NOZZLEOVERENDSTOP} F4000
M118 Moving to probe Nozzle to Z-Endstop.
PROBE samples_result=median samples={ZSamples} speed={ZSpeed} samples_tolerance={ZTolerance} samples_tolerance_retries={S_Retries} sample_retract_dist={ZRetract}
_ZAUTO4
[gcode_macro _ZAUTO4]
gcode:
{% set ProbeResult = printer.probe.last_z_result %}
SET_GCODE_VARIABLE MACRO=_VARIABLES VARIABLE=znozzleprobing VALUE={ProbeResult}
G0 Z15 F3600
QUERY_PROBE
{% if not printer.probe.last_query %}
M118 Stowing Euclid Probe.
_PROBE_STOW
{% else %}
M118 ?!Probe is not attached.
{% endif %}
_ZAUTO5
[gcode_macro _ZAUTO5]
gcode:
{% set Z_CONF = printer.configfile.config["probe"]["z_offset"]|float %}
{% set Z_POS = printer.toolhead.position.z|float %}
{% set zcenterprobing = printer["gcode_macro _VARIABLES"].zcenterprobing %}
{% set znozzleprobing = printer["gcode_macro _VARIABLES"].znozzleprobing %}
{% set zeuclidbodyprobing = printer["gcode_macro _VARIABLES"].zeuclidbodyprobing %}
{% set zendstopswtitchoffset = printer["gcode_macro _VARIABLES"].zendstopswtitchoffset %}
{% set nozzleswitchoffset = zeuclidbodyprobing - znozzleprobing + switchoffset %}
M118 NozzleSwitchOffset =
M118 EuclidBodyProbing: {zeuclidbodyprobing}
M118 -
M118 NozzleProbing: {znozzleprobing}
M118 +
M118 SwitchOffset: {switchoffset}
M118 =
M118 NozzleSwitchOffset: {nozzleswitchoffset}
M118
{% set zoffsetcalculated = zcenterprobing - nozzleswitchoffset %}
M118 zOffsetCalculated =
M118 zCenterProbing: {zcenterprobing}
M118 -
M118 NozzleSwitchOffset: {nozzleswitchoffset}
M118 =
M118 zOffsetCalculated: {zoffsetcalculated}
SET_GCODE_VARIABLE MACRO=_VARIABLES VARIABLE=lastzoffsetcalculated VALUE={zoffsetcalculated}
# Move nozzle with regard to zoffsetcalculated
# ! ! ! Following is just a general idea, not tested at all - don't trust it ! ! !
{% set Z_DIFFERENCE = zoffsetcalculated - ZP_CONF|float %}
{% set NEW_CURRENT_Z = (Z_POS - Z_DIFFERENCE) %}
M118 CONFIG Z-Probe Offset is: {Z_CONF}
M118 Difference: {Z_DIFFERENCE}
M118 Setting current Z_Height of {Z_POS} to {NEW_CURRENT_Z}
SET_KINEMATIC_POSITION Z={NEW_CURRENT_Z}
G4 P100
M118 Moving nozzle to newly adjusted Z15.
G0 Z15 F500