forked from zellneralex/klipper_config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhoming.cfg
119 lines (115 loc) · 4.49 KB
/
homing.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
#####################################################################
# Homing definition
#####################################################################
## USE either safe homing or homing override
#[safe_z_home]
#home_xy_position: 232,355
#speed: 100.0
#z_hop: 7.5
#z_hop_speed: 15.0
#move_to_previous: False
[homing_override]
axes: z
set_position_z: 0
gcode:
##### get user defines #####
# use -10 as default to insure it error in case the variable is not existing
{% set z_endstop = printer['gcode_macro _USER_VARIABLE'].z_endstop|default([-10,-10]) %}
{% set z_endstop_hop = printer['gcode_macro _USER_VARIABLE'].z_endstop_hop %}
{% set z_hop = printer['gcode_macro _USER_VARIABLE'].z_hop %}
##### end of definitions #####
SAVE_GCODE_STATE NAME=STATE_HOMING
G91 ; set relative
G0 Z{z_endstop_hop} F900 ; lift nozzle
G90 ; set absolute
## reduce current of Z motors
_SET_ACC VAL=HOME
_SET_Z_CURRENT VAL=HOME
# Home X and Y only for G28 or G28 XYZ
{% if 'Z' in params|upper %}
{% if "x" not in printer.toolhead.homed_axes %}
G28 X
{% endif %}
{% if "y" not in printer.toolhead.homed_axes %}
G28 Y
{% endif %}
{% else %}
G28 X Y
{% endif %}
## XY Location of the Z Endstop Switch
G0 X{z_endstop[0]} Y{z_endstop[1]} F7200
# Home Z
G28 Z
## move nozzle from pin
G0 Z2 F300
## return to org current settings
_SET_Z_CURRENT
_SET_ACC
# Lift Z
G0 Z{z_hop} F1800
RESTORE_GCODE_STATE NAME=STATE_HOMING
#####################################################################
# Macros
#####################################################################
## conditional home
[gcode_macro _CG28]
description: Helper: Conditional homing
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28
{% endif %}
[gcode_macro _SET_Z_CURRENT]
description: Helper: Set Z-drive motor current
variable_last_val: 'CONFIG'
gcode:
###### set default values #####
{% set default_respond = printer['gcode_macro _USER_VARIABLE'].respond_set_z_current|int %}
{% set val = params.VAL|default('CONFIG') %}
{% set respond = params.RESPOND|default(default_respond)|int %}
{% if val == 'HOME' %}
{% set z_run = printer['gcode_macro _USER_VARIABLE'].z_home_current %}
{% set z_hold = printer['gcode_macro _USER_VARIABLE'].z_home_current %}
{% else %}
{% if 'tmc2209 stepper_z' in printer.configfile.settings %}
{% set z_run = printer.configfile.settings['tmc2209 stepper_z'].run_current %}
{% set z_hold = printer.configfile.settings['tmc2209 stepper_z'].hold_current %}
{% elif 'tmc5160 stepper_z' in printer.configfile.settings %}
{% set z_run = printer.configfile.settings['tmc5160 stepper_z'].run_current %}
{% set z_hold = printer.configfile.settings['tmc5160 stepper_z'].hold_current %}
{% endif %}
{% endif %}
##### end of definition #####
{% if val != last_val %}
SET_GCODE_VARIABLE MACRO=_SET_Z_CURRENT VARIABLE=last_val VALUE='"{val}"'
{% if respond == 1 %}
{action_respond_info("Home&Probe: RunCur %.2fA rms HoldCur %.2fA rms" % (z_run|float, z_hold|float))}
{% endif %}
SET_TMC_CURRENT STEPPER=stepper_z CURRENT={z_run} HOLDCURRENT={z_hold}
SET_TMC_CURRENT STEPPER=stepper_z1 CURRENT={z_run} HOLDCURRENT={z_hold}
SET_TMC_CURRENT STEPPER=stepper_z2 CURRENT={z_run} HOLDCURRENT={z_hold}
SET_TMC_CURRENT STEPPER=stepper_z3 CURRENT={z_run} HOLDCURRENT={z_hold}
M400
{% endif %}
[gcode_macro _SET_ACC]
description: Helper: Set accel and accel_to_decel value
variable_last_val: 'CONFIG'
gcode:
##### set default value #####
{% set default_respond = printer['gcode_macro _USER_VARIABLE'].respond_set_acc|int %}
{% set val = params.VAL|default('CONFIG') %}
{% set respond = params.RESPOND|default(default_respond)|int %}
{% if val == 'HOME' %}
{% set accel = printer['gcode_macro _USER_VARIABLE'].home_accel %}
{% set accel_to_decel = printer['gcode_macro _USER_VARIABLE'].home_accel|int / 2 %}
{% else %}
{% set accel = printer.configfile.settings.printer.max_accel %}
{% set accel_to_decel = printer.configfile.settings.printer.max_accel_to_decel %}
{% endif %}
##### end of definition #####
{% if val != last_val %}
SET_GCODE_VARIABLE MACRO=_SET_ACC VARIABLE=last_val VALUE='"{val}"'
{% if respond == 1 %}
{action_respond_info("VELOCITY_LIMIT set ACCEL: %d ACCEL_TO_DECEL: %d" % (accel|int, accel_to_decel|int))}
{% endif %}
SET_VELOCITY_LIMIT ACCEL={accel} ACCEL_TO_DECEL={accel_to_decel}
{% endif %}