forked from Rat-OS/RatOS-configuration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
homing.cfg
175 lines (164 loc) · 7.32 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
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
# WARNING: DO NOT EDIT THIS FILE
# To override settings from this file, you can copy and paste the relevant
# sections into your printer.cfg and change it there.
[ratos_homing]
axes: xyz
z_hop: 15
z_hop_speed: 15
gcode:
{% set x_homed = 'x' in printer.toolhead.homed_axes %}
{% set y_homed = 'y' in printer.toolhead.homed_axes %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printer.toolhead.axis_maximum.x / 2 %}
{% endif %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printer.toolhead.axis_maximum.y / 2 %}
{% endif %}
{% set z_probe = printer["gcode_macro RatOS"].z_probe|lower %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set z_hop = printer.configfile.config.ratos_homing.z_hop|float %}
{% set z_hop_speed = printer.configfile.config.ratos_homing.z_hop_speed|float * 60 %}
{% set homing_x = printer["gcode_macro RatOS"].homing_x|lower %}
{% set homing_y = printer["gcode_macro RatOS"].homing_y|lower %}
{% set homing = printer["gcode_macro RatOS"].homing|lower %}
{% set prev_stop_on_error = printer["gcode_macro RatOS"].stowable_probe_stop_on_error %}
# Make stowable probe assertion failures cause an emergency stop
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE=True
M400 # Wait for moves to finish
G90 # Absolute positioning
{% if params.X is defined or params.Y is not defined and params.Z is not defined %}
{% if homing_x == 'endstop' or homing == 'endstops' %}
G28 X
{% elif homing_x == 'sensorless' or homing == 'sensorless' %}
HOME_X_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_x to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_x, homing)) }
{% endif %}
{% set x_homed = True %}
G0 X{safe_home_x} F{speed}
{% endif %}
{% if params.Y is defined or params.X is not defined and params.Z is not defined %}
{% if homing_y == 'endstop' or homing == 'endstops' %}
G28 Y
{% elif homing_y == 'sensorless' or homing == 'sensorless' %}
HOME_Y_SENSORLESS
{% else %}
{ action_emergency_stop("expected RatOS variable_homing_y to be 'sensorless' 'endstop' or variable_homing to be 'sensorless' or 'endstops' but found {} and {}".format(homing_y, homing)) }
{% endif %}
{% set y_homed = True %}
G0 Y{safe_home_y} F{speed}
{% endif %}
{% if params.Z is defined or params.Y is not defined and params.X is not defined %}
RESPOND MSG="Homing Z"
{% if x_homed == False or y_homed == False %}
M118 X and Y must be homed before homing Z
{ action_emergency_stop("X and Y must be homed before homing Z") }
{% else %}
{% if z_probe == "stowable" %}
DEPLOY_PROBE
G0 X{safe_home_x} Y{safe_home_y} F{speed}
G28 Z
G0 Z{z_hop} F{z_hop_speed}
STOW_PROBE
{% else %}
G0 X{safe_home_x} Y{safe_home_y} F{speed}
G28 Z
G0 Z{z_hop} F{z_hop_speed}
{% endif %}
{% endif %}
{% endif %}
# Reset stowable probe stop on error state
SET_GCODE_VARIABLE MACRO=RatOS VARIABLE=stowable_probe_stop_on_error VALUE={prev_stop_on_error}
[gcode_macro HOME_X_SENSORLESS]
gcode:
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
{% set safe_home_x = printer["gcode_macro RatOS"].safe_home_x %}
{% if safe_home_x is not defined or safe_home_x|lower == 'middle' %}
{% set safe_home_x = printer.toolhead.axis_maximum.x / 2 %}
{% endif %}
M204 S1000 # Set homing acceleration (important!)
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_x_current}
G4 P300 # Wait for currents to settle
G28 X
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config["tmc2209 stepper_x"].run_current}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config["tmc2209 stepper_y"].run_current}
G4 P300 # Wait for currents to settle
# Restore acceleration
M204 S{printer.configfile.config.printer.max_accel}
[gcode_macro HOME_Y_SENSORLESS]
gcode:
{% set safe_home_y = printer["gcode_macro RatOS"].safe_home_y %}
{% if safe_home_y is not defined or safe_home_y|lower == 'middle' %}
{% set safe_home_y = printer.toolhead.axis_maximum.y / 2 %}
{% endif %}
{% set speed = printer["gcode_macro RatOS"].macro_travel_speed|float * 60 %}
M204 S1000 # Set homing acceleration (important!)
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro RatOS"].sensorless_y_current}
G4 P300 # Wait for currents to settle
G28 Y
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer.configfile.config["tmc2209 stepper_x"].run_current}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer.configfile.config["tmc2209 stepper_y"].run_current}
G4 P300 # Wait for currents to settle
# Restore acceleration
M204 S{printer.configfile.config.printer.max_accel}
[gcode_macro MAYBE_HOME]
description: Only home unhomed axis
variable_is_kinematic_position_overriden: False
gcode:
{% if printer["gcode_macro MAYBE_HOME"].is_kinematic_position_overriden|lower == 'true' %}
RESPOND MSG="SET_CENTER_KINEMATIC_POSITION has been abused. Homing all axes. Please refrain from using SET_CENTER_KINEMATIC_POSITION outside of debugging purposes."
G28
SET_GCODE_VARIABLE MACRO=MAYBE_HOME VARIABLE=is_kinematic_position_overriden VALUE=False
{% else %}
{% set axes = '' %}
{% set isHomed = true %}
{% set axesToHome = '' %}
{% if params.X is defined %}
{% set axes = axes ~ 'X ' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% endif %}
{% if params.Y is defined %}
{% set axes = axes ~ 'Y ' %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% endif %}
{% if params.Z is defined %}
{% set axes = axes ~ 'Z ' %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if params.X is not defined and params.Y is not defined and params.Z is not defined %}
{% set axes = '' %}
{% if 'x' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'X ' %}
{% endif %}
{% if 'y' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Y ' %}
{% endif %}
{% if 'z' not in printer.toolhead.homed_axes %}
{% set isHomed = false %}
{% set axesToHome = axesToHome ~ 'Z ' %}
{% endif %}
{% endif %}
{% if isHomed is false %}
M117 Homing {axesToHome}
RESPOND MSG="Homing {axesToHome}"
G28 {axesToHome}
{% else %}
RESPOND MSG="All requested axes already homed, skipping.."
{% endif %}
{% endif %}