-
Notifications
You must be signed in to change notification settings - Fork 0
/
euclid.cfg
307 lines (234 loc) · 10.4 KB
/
euclid.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# |
# | * Probe Ready Position
# | X150 Y150
# |
# | * Dock Re-entry staging position
# | X0 Y70
# |
# |
# | * Dock Exit Position
# | X0 Y40
# |
# | X0 Y0 X30 Y0 X100 Y0
# | * Dock * Dock Side * Dock Preflight
# |_____________________________________________________________
#
# With the coupling magnets +/- 2mm of the nozzle the probe trigger height is on
# the order of 12mm, so 15mm is used as a safe height.
[gcode_macro EuclidProbe]
description: config vars for Euclid probe deploy/stow
## how much space to put between the bed and nozzle for homing
variable_bed_clearance: 15
## where to put the probe during deployment steps
variable_position_preflight: [ 100, -4 ]
variable_position_side: [ 30, -4 ]
variable_position_dock: [ 0, -4 ]
## exit/re-entry staging
variable_position_exit: [ 0, 40 ]
# 300 * 60
variable_move_speeds: 18000
variable_batch_mode_enabled: False
variable_probe_state: None
gcode:
RESPOND TYPE=command MSG="{ printer['gcode_macro EuclidProbe'] }"
[probe]
pin: ^PG15
## w/ MFBS mods
x_offset: -44.49
y_offset: -17
## if live-z is positive, subtract from z_offset
z_offset: 9.455
speed: 5 ; probing speed of 5mm/second ideal is <10mm/sec
lift_speed: 30
samples: 2 ; number of probes to perform per sample
samples_result: average ; normalization method: see config reference
sample_retract_dist: 5.0
samples_tolerance: 0.050
samples_tolerance_retries: 3
[homing_override]
axes: z
set_position_z: -5
gcode:
{% set euclid_probe = printer["gcode_macro EuclidProbe"] %}
G90
;; force bed to move 15mm down
SET_KINEMATIC_POSITION Z=0
G0 Z{ euclid_probe.bed_clearance } F500
;; home Y and X, Y first to avoid running into the dock
{% if "y" not in (printer.toolhead.homed_axes | lower) %}
G28 Y
{% endif %}
{% if "x" not in (printer.toolhead.homed_axes | lower) %}
G28 X
{% endif %}
DEPLOY_PROBE
;; home Z at bed center
G0 X{ printer.toolhead.axis_maximum.x/2 } Y{ printer.toolhead.axis_maximum.y/2 } F{ euclid_probe.move_speeds }
G28 Z
;; after 'G28 Z' the probe stays in contact with the bed; move it away.
G0 Z{ euclid_probe.bed_clearance }
STOW_PROBE
[gcode_macro _ASSERT_PROBE_STATE]
description: ensures probe is in a known state; QUERY_PROBE must have been called before this macro!
gcode:
## QUERY_PROBE manually-verified results, when microswitch not depressed
## "TRIGGERED" -> 1 :: probe stowed
## "open" -> 0 :: probe deployed
{% set last_query_state = "stowed" if printer.probe.last_query == 1 else "deployed" %}
{% if params.MUST_BE != last_query_state %}
{ action_raise_error("expected probe state to be {} but is {} ({})".format(params.MUST_BE, last_query_state, printer.probe.last_query)) }
{% else %}
## all good; update state
SET_GCODE_VARIABLE MACRO=EuclidProbe VARIABLE=probe_state VALUE="'{ last_query_state }'"
{% endif %}
[gcode_macro ASSERT_PROBE_DEPLOYED]
description: error if probe not deployed
gcode:
; wait for moves to finish, then pause 0.25s for detection
M400
G4 P250
QUERY_PROBE
_ASSERT_PROBE_STATE MUST_BE=deployed
[gcode_macro ASSERT_PROBE_STOWED]
description: error if probe not stowed
gcode:
; wait for moves to finish, then pause 0.25s for detection
M400
G4 P250
QUERY_PROBE
_ASSERT_PROBE_STATE MUST_BE=stowed
[gcode_macro EUCLID_PROBE_BEGIN_BATCH]
description: begin euclid probe batch mode
gcode:
SET_GCODE_VARIABLE MACRO=EuclidProbe VARIABLE=batch_mode_enabled VALUE=True
RESPOND TYPE=command MSG="Probe batch mode enabled"
[gcode_macro EUCLID_PROBE_END_BATCH]
description: end euclid probe batch mode and stow probe
gcode:
SET_GCODE_VARIABLE MACRO=EuclidProbe VARIABLE=batch_mode_enabled VALUE=False
RESPOND TYPE=command MSG="Probe batch mode disabled"
STOW_PROBE
[gcode_macro DEPLOY_PROBE]
description: deploy Euclid probe
gcode:
{% set euclid_probe = printer["gcode_macro EuclidProbe"] %}
{% if euclid_probe.batch_mode_enabled and euclid_probe.probe_state == "deployed" %}
; RESPOND TYPE=command MSG="Probe batch mode enabled: already deployed"
G4 P0
{% else %}
RESPOND TYPE=command MSG="Deploying probe"
; ensure the probe is currently stowed; can't deploy what isn't stowed.
ASSERT_PROBE_STOWED
G90
; set approach elevation to clear probe over bed on fixed gantry machine
G0 Z{ euclid_probe.bed_clearance } F500
; move the carraige to safe position to start probe pickup
G0 X{ euclid_probe.position_preflight[0] } Y{ euclid_probe.position_preflight[1] } F{ euclid_probe.move_speeds }
; move to the side of the dock
G0 X{ euclid_probe.position_side[0] } Y{ euclid_probe.position_side[1] } F{ euclid_probe.move_speeds }
; wait 1/4 second
M400
G4 P250
; move sideways over the dock to pick up probe
G0 X{ euclid_probe.position_dock[0] } Y{ euclid_probe.position_dock[1] } F1500
; confirm deploy was successful
ASSERT_PROBE_DEPLOYED
; move out of the dock in a straight line
G0 X{ euclid_probe.position_exit[0] } Y{ euclid_probe.position_exit[1] } F{ euclid_probe.move_speeds }
{% endif %}
[gcode_macro STOW_PROBE]
description: stow Euclid probe
gcode:
{% set euclid_probe = printer["gcode_macro EuclidProbe"] %}
{% if euclid_probe.batch_mode_enabled %}
; RESPOND TYPE=command MSG="Probe batch mode enabled: not stowing"
G4 P0
{% else %}
RESPOND TYPE=command MSG="Stowing probe"
; ensure the probe is currently deployed; can't stow what isn't deployed.
ASSERT_PROBE_DEPLOYED
G90
; set approach elevation for fixed gantry system to clear probe over bed
G0 Z{ euclid_probe.bed_clearance } F3000
; move to the exit/re-entry staging position
G0 X{ euclid_probe.position_exit[0] } Y{ euclid_probe.position_exit[1] } F{ euclid_probe.move_speeds }
; slowly move into dock
G0 X{ euclid_probe.position_dock[0] } Y{ euclid_probe.position_dock[1] } F3000
; wait for moves to finish, pause to force 90deg travel swipe
M400
G4 P250
; quick swipe off
G0 X{ euclid_probe.position_side[0] } Y{ euclid_probe.position_side[1] } F{ euclid_probe.move_speeds }
; confirm stowing was successful
ASSERT_PROBE_STOWED
{% endif %}
; # Macro to perform a bed mesh calibration by wrapping it in DEPLOY_PROBE/STOW_PROBE macros
; [gcode_macro BED_MESH_CALIBRATE]
; rename_existing: BED_MESH_CALIBRATE_ORIG
; gcode:
; DEPLOY_PROBE
; BED_MESH_CALIBRATE_ORIG
; STOW_PROBE
[gcode_macro BED_MESH_CALIBRATE]
rename_existing: BED_MESH_CALIBRATE_ORIG
variable_buffer: 20
gcode:
{% set start_print = printer["gcode_macro START_PRINT"] %}
{% set bed_mesh = printer.configfile.settings.bed_mesh %}
{% set probe_config = printer.configfile.settings.probe %}
{% if start_print.first_layer_min_xy and start_print.first_layer_max_xy %}
{ action_respond_info("print_min: {}".format(start_print.first_layer_min_xy)) }
{ action_respond_info("print_max: {}".format(start_print.first_layer_max_xy)) }
{% set print_min_x = (start_print.first_layer_min_xy[0] | float) + probe_config.x_offset %}
{% set print_min_y = (start_print.first_layer_min_xy[1] | float) + probe_config.y_offset %}
{% set print_max_x = (start_print.first_layer_max_xy[0] | float) - probe_config.x_offset %}
{% set print_max_y = (start_print.first_layer_max_xy[1] | float) - probe_config.y_offset %}
DEPLOY_PROBE
{% if (print_min_x < print_max_x) and (print_min_y < print_max_y) %}
{% set minimum_probe_count = 5 if bed_mesh.algorithm == "bicubic" else 3 %}
# bed_mesh.probe_count is a tuple
{% set probe_count = bed_mesh.probe_count %}
{% set probe_count_x = probe_count[0] %}
{% set probe_count_y = probe_count[1] if (probe_count | length) == 2 else probe_count_x %}
# -1 is the effective, undocumented default
{% set relative_reference_index = bed_mesh.relative_reference_index | default(-1, true) %}
{% set mesh_min_x, mesh_min_y = bed_mesh.mesh_min %}
{% set mesh_max_x, mesh_max_y = bed_mesh.mesh_max %}
# If print area X is smaller than 50% of the bed size, use the
# minimum probe count for X instead of the default
{% if (print_max_x - print_min_x) < (mesh_max_x - mesh_min_x)/2 %}
{% set probe_count_x = minimum_probe_count %}
{% endif %}
# If print area Y is smaller than 50% of the bed size, use the
# minimum probe count for Y instead of the default
{% if (print_max_y - print_min_y) < (mesh_max_y - mesh_min_y)/2 %}
{% set probe_count_y = minimum_probe_count %}
{% endif %}
{% if relative_reference_index > 0 %}
{% set relative_reference_index = ((probe_count_x * probe_count_y - 1) / 2)|int %}
{% endif %}
{% set mesh_min_x = [print_min_x - buffer, mesh_min_x] | max %}
{% set mesh_min_y = [print_min_y - buffer, mesh_min_y] | max %}
{% set mesh_max_x = [print_max_x + buffer, mesh_max_x] | min %}
{% set mesh_max_y = [print_max_y + buffer, mesh_max_y] | min %}
{ action_respond_info("mesh_min: ({}, {})".format(mesh_min_x, mesh_min_y)) }
{ action_respond_info("mesh_max: ({}, {})".format(mesh_max_x, mesh_max_y)) }
{ action_respond_info("probe_count: ({}, {})".format(probe_count_x,probe_count_y)) }
{ action_respond_info("relative_reference_index: {}".format(relative_reference_index)) }
BED_MESH_CALIBRATE_ORIG mesh_min={mesh_min_x},{mesh_min_y} mesh_max={mesh_max_x},{mesh_max_y} probe_count={probe_count_x},{probe_count_y} relative_reference_index={relative_reference_index}
{% else %}
BED_MESH_CALIBRATE_ORIG
{% endif %}
STOW_PROBE
{% else %}
DEPLOY_PROBE
BED_MESH_CALIBRATE_ORIG
STOW_PROBE
{% endif %}
# Macro to perform a modified z_tilt by wrapping it in DEPLOY_PROBE/STOW_PROBE macros
[gcode_macro Z_TILT_ADJUST]
rename_existing: Z_TILT_ADJUST_ORIG
gcode:
DEPLOY_PROBE
Z_TILT_ADJUST_ORIG
STOW_PROBE