-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
demon_homing_control_v1.4.cfg
447 lines (331 loc) · 16.7 KB
/
demon_homing_control_v1.4.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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
###################################################
#######>>>>>>>>>> 3DPrintDemon <<<<<<<<<<<#######
####### https://github.com/3DPrintDemon #######
# IF YOU USE & LIKE THESE MACROS PLEASE CONSIDER SUPPORTING MY EFFORTS AT
# https://ko-fi.com/3dprintdemon
## IF USING KLICKY PROBE COMMENT OUT EVERYTHING FROM HERE TO LINE 151!!
[homing_override]
axes: xyz
gcode:
{% set start_vars = printer["gcode_macro _START_VARIABLES"] %}
{% set driver_vars = printer["gcode_macro _DRIVER_VARS"] %}
{% set home_all = 'X' not in params and 'Y' not in params and 'Z' not in params %}
{% if start_vars.klicky_probe == True %}
{ action_raise_error("You appear to be using Klicky_probe but homing_override is defined in your demon_homing_control.cfg. Please comment out the entire [homing_override] macro to continue") }
{% else %}
_HOME_POWER_SAFETY
RESPOND TYPE=COMMAND MSG="Homing requested"
{% if driver_vars.definer_executed == False %}
_DRIVER_DEFINER
{% else %}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="XY Drivers previously defined"
{% endif %}
{% endif %}
{% if start_vars.neopixel_led == True %}
STATUS_HOMING
{% endif %}
_SET_Z_PARK
{% if 'z' not in printer.toolhead.homed_axes %}
{% if 'x' not in printer.toolhead.homed_axes or 'y' not in printer.toolhead.homed_axes %}
{% if 'Z' in params %}
{ action_raise_error("Request denied, operation cancelled! Home X & Y axes first before requesting homing Z") }
{% else %}
{% if 'x' in printer.toolhead.homed_axes or 'y' in printer.toolhead.homed_axes %}
{% else %}
# RESPOND TYPE=COMMAND MSG="Raising Z axis for safe clearance prior to homing"
_Z_LIFT
{% endif %}
{% endif %}
{% endif %}
{% else %}
{% if printer.toolhead.position.z|float < 5 %}
RESPOND TYPE=COMMAND MSG="Z axis <5mm. Raising for safe clearance prior to homing"
_Z_LIFT
{% endif %}
{% endif %}
{% if start_vars.home_y_first == True %}
{% if home_all or 'Y' in params %}
_HOME_Y
{% endif %}
{% if home_all or 'X' in params %}
_HOME_X
{% endif %}
{% else %}
{% if home_all or 'X' in params %}
_HOME_X
{% endif %}
{% if home_all or 'Y' in params %}
_HOME_Y
{% endif %}
{% endif %}
{% if home_all or 'Z' in params %}
{% if start_vars.aes_system == True %}
SET_GCODE_VARIABLE MACRO=_AES_SYS VARIABLE=e_stop_armed VALUE=True
_AES_READ
{% endif %}
{% if printer.configfile.settings.stepper_z.endstop_pin == 'probe:z_virtual_endstop' %}
G90
{% if start_vars.set_probe_point_default == True %}
G0 X{printer.toolhead.axis_maximum.x|float / 2} Y{printer.toolhead.axis_maximum.y|float / 2} F{start_vars.homing_movement_travel_speed|int * 60}
{% else %}
G0 X{start_vars.set_probe_custom_x|float} Y{start_vars.set_probe_custom_y|float} F{start_vars.homing_movement_travel_speed|int * 60}
{% endif %}
{% else %}
G90
G0 X{start_vars.z_endstop_loaction_x|float} Y{start_vars.z_endstop_loaction_y|float} F{start_vars.homing_movement_travel_speed|int * 60}
{% endif %}
G28 Z
M400
{% if printer.configfile.settings.stepper_z.endstop_pin == 'probe:z_virtual_endstop' %}
G0 Z10 F3600
{% if 'mcu eddy' in printer.configfile.config or 'probe_eddy_current btt_eddy' in printer %}
PROBE
SET_Z_FROM_PROBE
_Z_PARK
{% else %}
_Z_PARK
{% endif %}
{% else %}
{% if start_vars.post_z_switch_backoff == True %}
G0 Z{start_vars.post_z_switch_backoff_height|int} F{start_vars.z_lift_speed|int * 60}
G91
G0 Y-{start_vars.post_z_switch_backoff_y_dist|int} F{start_vars.homing_movement_travel_speed|int * 60}
G90
{% endif %}
{% endif %}
{% if start_vars.aes_system == True %}
SET_GCODE_VARIABLE MACRO=_AES_SYS VARIABLE=e_stop_armed VALUE=False
_AES_READ
{% endif %}
M400
_SAVE
{% if start_vars.z_tracker_reduced_monitoring == False %}
UPDATE_DELAYED_GCODE ID=_ACTIVE_Z_MONITOR DURATION=1
{% endif %}
{% endif %}
{% if start_vars.neopixel_led == True %}
STATUS_READY
{% endif %}
M117
{% endif %}
G90
## IF USING KLICKY PROBE COMMENT OUT EVERYTHING FROM THE TOP TO HERE!!
[gcode_macro _HOME_X]
gcode:
{% set start_vars = printer["gcode_macro _START_VARIABLES"] %}
{% set driver_vars = printer["gcode_macro _DRIVER_VARS"] %}
{% if driver_vars.definer_executed == False %}
{action_raise_error("Home_X cancelled. You appear to not have run the _DRIVER_DEFINER macro. This happens when you comment out the demon_homing_control_vx.x.cfg [homing_override] macro, example when using Klicky Probe. Please add _DRIVER_DEFINER to your currently active [homing_override] macro to continue")}
{% elif driver_vars.definer_executed == True %}
{% if driver_vars.tmc_found_x == True %}
_HOME_POWER_SAFETY
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={start_vars.home_power|float}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={start_vars.home_power|float}
G28 X
G91
{% if printer.configfile.settings.stepper_x.homing_positive_dir == False %}
G0 X{start_vars.axis_backoff_distance|int} F{start_vars.axis_backoff_speed|int * 60}
{% else %}
G0 X-{start_vars.axis_backoff_distance|int} F{start_vars.axis_backoff_speed|int * 60}
{% endif %}
G4 P{start_vars.axis_register_clear_wait|float * 1000}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={driver_vars.run_x|float}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={driver_vars.run_y|float}
{% else %}
G28 X
G91
{% if printer.configfile.settings.stepper_x.homing_positive_dir == False %}
G0 X{start_vars.axis_backoff_distance|int} F{start_vars.axis_backoff_speed|int * 60}
{% else %}
G0 X-{start_vars.axis_backoff_distance|int} F{start_vars.axis_backoff_speed|int * 60}
{% endif %}
{% endif %}
G90
{% endif %}
[gcode_macro _HOME_Y]
gcode:
{% set start_vars = printer["gcode_macro _START_VARIABLES"] %}
{% set driver_vars = printer["gcode_macro _DRIVER_VARS"] %}
{% if driver_vars.definer_executed == False %}
{action_raise_error("Home_Y cancelled. You appear to not have run the _DRIVER_DEFINER macro. This happens when you comment out the demon_homing_control_vx.x.cfg [homing_override] macro, example when using Klicky Probe. Please add _DRIVER_DEFINER to your currently active [homing_override] macro to continue")}
{% elif driver_vars.definer_executed == True %}
{% if driver_vars.tmc_found_y == True %}
_HOME_POWER_SAFETY
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={start_vars.home_power|float}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={start_vars.home_power|float}
G28 Y
G91
{% if printer.configfile.settings.stepper_y.homing_positive_dir == False %}
G0 Y{start_vars.axis_backoff_distance|int} F{start_vars.axis_backoff_speed|int * 60}
{% else %}
G0 Y-{start_vars.axis_backoff_distance|int} F{start_vars.axis_backoff_speed|int * 60}
{% endif %}
G4 P{start_vars.axis_register_clear_wait|float * 1000}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={driver_vars.run_x|float}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={driver_vars.run_y|float}
{% else %}
G28 Y
G91
{% if printer.configfile.settings.stepper_y.homing_positive_dir == False %}
G0 Y{start_vars.axis_backoff_distance|int} F{start_vars.axis_backoff_speed|int * 60}
{% else %}
G0 Y-{start_vars.axis_backoff_distance|int} F{start_vars.axis_backoff_speed|int * 60}
{% endif %}
{% endif %}
G90
{% endif %}
[gcode_macro _DRIVER_DEFINER]
gcode:
{% set driver_vars = printer["gcode_macro _DRIVER_VARS"] %}
{% set cf = printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=definer_executed VALUE=True
{% if 'tmc2209 stepper_x' not in cf and 'tmc5160 stepper_x' not in cf and 'tmc2208 stepper_x' not in cf and 'tmc2226 stepper_x' not in cf and 'tmc2225 stepper_x'
not in cf and 'tmc2130 stepper_x' not in cf and 'tmc2240 stepper_x' not in cf and 'tmc2660 stepper_x' not in cf %}
RESPOND TYPE=COMMAND MSG="DRIVER_DEFINER: No supported UART connected TMC X axis driver detected"
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=tmc_found_x VALUE=False
{% endif %}
{% if 'tmc2209 stepper_y' not in cf and 'tmc5160 stepper_y' not in cf and 'tmc2208 stepper_y' not in cf and 'tmc2226 stepper_y' not in cf and 'tmc2225 stepper_y'
not in cf and 'tmc2130 stepper_y' not in cf and 'tmc2240 stepper_y' not in cf and 'tmc2660 stepper_y' not in cf %}
RESPOND TYPE=COMMAND MSG="DRIVER_DEFINER: No supported UART connected TMC Y axis driver detected"
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=tmc_found_y VALUE=False
{% endif %}
{% if 'tmc2209 stepper_x' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_x VALUE={printer.configfile.config['tmc2209 stepper_x'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2209 driver X axis"
{% endif %}
{% elif 'tmc5160 stepper_x' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_x VALUE={printer.configfile.config['tmc5160 stepper_x'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC5160 driver X axis"
{% endif %}
{% elif 'tmc2208 stepper_x' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_x VALUE={printer.configfile.config['tmc2208 stepper_x'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2208 driver X axis"
{% endif %}
{% elif 'tmc2226 stepper_x' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_x VALUE={printer.configfile.config['tmc2226 stepper_x'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2226 driver X axis"
{% endif %}
{% elif 'tmc2225 stepper_x' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_x VALUE={printer.configfile.config['tmc2225 stepper_x'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2225 driver X axis"
{% endif %}
{% elif 'tmc2130 stepper_x' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_x VALUE={printer.configfile.config['tmc2130 stepper_x'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2130 driver X axis"
{% endif %}
{% elif 'tmc2240 stepper_x' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_x VALUE={printer.configfile.config['tmc2240 stepper_x'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2240 driver X axis"
{% endif %}
{% elif 'tmc2660 stepper_x' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_x VALUE={printer.configfile.config['tmc2660 stepper_x'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2660 driver X axis"
{% endif %}
{% endif %}
{% if 'tmc2209 stepper_y' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_y VALUE={printer.configfile.config['tmc2209 stepper_y'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2209 driver Y axis"
{% endif %}
{% elif 'tmc5160 stepper_y' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_y VALUE={printer.configfile.config['tmc5160 stepper_y'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC5160 driver Y axis"
{% endif %}
{% elif 'tmc2208 stepper_y' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_y VALUE={printer.configfile.config['tmc2208 stepper_y'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2208 driver Y axis"
{% endif %}
{% elif 'tmc2226 stepper_y' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_y VALUE={printer.configfile.config['tmc2226 stepper_y'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2226 driver Y axis"
{% endif %}
{% elif 'tmc2225 stepper_y' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_y VALUE={printer.configfile.config['tmc2225 stepper_y'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2225 driver Y axis"
{% endif %}
{% elif 'tmc2130 stepper_y' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_y VALUE={printer.configfile.config['tmc2130 stepper_y'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2130 driver Y axis"
{% endif %}
{% elif 'tmc2240 stepper_y' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_y VALUE={printer.configfile.config['tmc2240 stepper_y'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2240 driver Y axis"
{% endif %}
{% elif 'tmc2660 stepper_y' in printer.configfile.config %}
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=run_y VALUE={printer.configfile.config['tmc2660 stepper_y'].run_current|float}
{% if driver_vars.readback == True %}
RESPOND TYPE=COMMAND MSG="Defined TMC2660 driver Y axis"
{% endif %}
{% endif %}
[gcode_macro _Z_LIFT]
gcode:
{% set start_vars = printer["gcode_macro _START_VARIABLES"] %}
{% set core_vars = printer["gcode_macro _CORE_VARS"] %}
{% set driver_vars = printer["gcode_macro _DRIVER_VARS"] %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% if core_vars.last_known_z <= (printer.toolhead.axis_maximum.z|int - start_vars.pre_home_lift|int) - 20 %}
RESPOND TYPE=COMMAND MSG="Raising Z axis for safe clearance prior to homing"
RESPOND TYPE=COMMAND MSG="WARNING AXES RESET FOR Z LIFT!!"
SET_KINEMATIC_POSITION Z=0
SET_GCODE_VARIABLE MACRO=_DRIVER_VARS VARIABLE=z_lift_move VALUE=True
M400
G90
{% if start_vars.pre_home_lift|int in range (0, 21) and start_vars.z_lift_speed|int in range (1, 26) %}
G0 Z{start_vars.pre_home_lift|int} F{start_vars.z_lift_speed|int * 60}
M400
# RESPOND TYPE=COMMAND MSG="Disabling axes"
M84
{% else %}
M84
{ action_raise_error("Request denied, operation cancelled! Lift height or speed not in range. See demon_user_settings.cfg DEMON HOME CONTROL SETTINGS") }
{% endif %}
{% else %}
RESPOND TYPE=COMMAND MSG="Z Axis near maximum, lift skipped"
{% endif %}
{% else %}
{% if printer.toolhead.position.z <= (printer.toolhead.axis_maximum.z|int - start_vars.pre_home_lift|int) - 20 %}
G90
{% if start_vars.pre_home_lift|int in range (0, 21) and start_vars.z_lift_speed|int in range (1, 26) %}
RESPOND TYPE=COMMAND MSG="Raising Z axis for safe clearance prior to homing"
G0 Z{start_vars.pre_home_lift|int} F{start_vars.z_lift_speed|int * 60}
M400
{% else %}
{ action_raise_error("Request denied, operation cancelled! Lift height or speed not in range. See demon_user_settings.cfg DEMON HOME CONTROL SETTINGS") }
{% endif %}
{% else %}
RESPOND TYPE=COMMAND MSG="Z Axis near maximum, lift skipped"
{% endif %}
{% endif %}
[gcode_macro _HOME_POWER_SAFETY]
gcode:
{% set start_vars = printer["gcode_macro _START_VARIABLES"] %}
{% if start_vars.override_home_power_safety == False and start_vars.home_power|float > 1.0 %}
{ action_raise_error("Request denied, the operation has been cancelled! Your soft home power levels are too high! See demon_user_settings.cfg DEMON HOME CONTROL SETTINGS where you can override this message if you wish") }
{% endif %}
[gcode_macro _DRIVER_VARS]
variable_readback: True
variable_definer_executed: False
variable_tmc_found_x: True
variable_tmc_found_y: True
variable_run_x: 0.8
variable_run_y: 0.8
variable_z_lift_move: False
gcode:
[gcode_macro _HOME_VERSION]
variable_demon_home_ver: 1.4
gcode: