-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathnozzle_calibration.cfg
273 lines (227 loc) · 9.49 KB
/
nozzle_calibration.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
#############################################################################################################
#
# manual offset calibration macros
#
#############################################################################################################
# Configure this to draw 2 line segments perpendicular to the dual_carraige axis
# that meet in the middle of the bed. Both lines should have the same coordinate
# on the axis of the dual_carraige. If they don't print inline, adjust your endstop
# settings.
[gcode_macro set_separation]
gcode:
{% set svv = printer.save_variables.variables %}
{% set oldX = svv.xoffset|float %}
{% set oldY = svv.yoffset|float %}
{% set oldZ = svv.zoffset|float %}
{% if params.X is defined %}
SAVE_VARIABLE VARIABLE=xoffset VALUE={ params.X|float }
{% endif %}
{% if params.Y is defined %}
SAVE_VARIABLE VARIABLE=yoffset VALUE={ params.Y|float }
{% endif %}
{% if params.Z is defined %}
SAVE_VARIABLE VARIABLE=zoffset VALUE={ params.Z|float }
{% endif %}
{% if params.X_ADJUST is defined %}
{% set newX = params.X_ADJUST|float + oldX %}
SAVE_VARIABLE VARIABLE=xoffset VALUE={ newX|float }
{% endif %}
{% if params.Y_ADJUST is defined %}
{% set newY = params.Y_ADJUST|float + oldY %}
SAVE_VARIABLE VARIABLE=yoffset VALUE={ newY|float }
{% endif %}
{% if params.Z_ADJUST is defined %}
{% set newZ = params.Z_ADJUST|float + oldZ %}
SAVE_VARIABLE VARIABLE=yoffset VALUE={ newZ|float }
{% endif %}
[gcode_macro calibrate_separation]
gcode:
# config
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% set printable_x = printer["gcode_macro RatOS"].printable_x %}
{% set printable_y = printer["gcode_macro RatOS"].printable_y %}
{% set printable_center_x = (printable_x[1] - printable_x[0]) / 2 %}
{% set printable_center_y = (printable_y[1] - printable_y[0]) / 2 %}
MAYBE_HOME
G90
M83
G1 Z2 F{z_speed}
T1 X{printable_center_x} Y{printable_center_y - 50} S1
G1 X{printable_center_x} Y{printable_center_y - 50} F{speed}
G1 Z0.2 F{z_speed}
G1 Y{printable_center_y - 1} E4 F500
G1 Z2 F{z_speed}
G1 X{printable_center_x - 50} Y{printable_center_y} F{speed}
G1 Z0.2 F{z_speed}
G1 X{printable_center_x - 1} E4 F500
G1 Z2 F{z_speed}
T0 X{printable_center_x} Y{printable_center_y + 50} S1
G1 Z0.2 F{z_speed}
G1 Y{printable_center_y + 1} E4 F500
G1 Z2 F{z_speed}
G1 X{printable_center_x + 50} Y{printable_center_y} F{speed}
G1 Z0.2 F{z_speed}
G1 X{printable_center_x + 1} E4 F500
G1 Z15 F{z_speed}
G1 X{printable_center_x} Y{printable_center_y + 75} F{speed}
{% if printer["gcode_macro RatOS"].relative_extrusion|lower == 'true' %}
M83
{% else %}
M82
{% endif %}
T{printer["gcode_macro RatOS"].default_toolhead|default(0)|int} X{printable_center_x} Y{printable_center_y} S0
#############################################################################################################
#
# visual assisted offset calibration macros, called from the mainsail nozzle calibration UI
#
#############################################################################################################
[gcode_macro _NOZZLE_CALIBRATION_LOAD_TOOL]
gcode:
# parameters
{% set t = params.T|default(0)|int %}
# echo
M118 _NOZZLE_CALIBRATION_LOAD_TOOL T={t}
# ratos variables file
{% set svv = printer.save_variables.variables %}
# config
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
# load toolhead
{% set xcontrolpoint = svv.xcontrolpoint|default(150)|float %}
{% set ycontrolpoint = svv.ycontrolpoint|default(30)|float %}
{% set zcontrolpoint = svv.zcontrolpoint|default(50)|float %}
M118 Move T{t} to control point: X{xcontrolpoint} Y{ycontrolpoint} Z{zcontrolpoint}
T{t} X{xcontrolpoint} Y{ycontrolpoint}
G1 Z{zcontrolpoint} F{z_speed}
G1 X{xcontrolpoint} F{speed}
G1 Y{ycontrolpoint} F{speed}
[gcode_macro _NOZZLE_CALIBRATION_SET_TOOL]
gcode:
# ratos variables file
{% set svv = printer.save_variables.variables %}
# get IDEX mode
{% set idex_mode = 'none' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set t = 1 if idex_mode=='primary' else 0 %}
{% if t == printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
# set control point
{% set x = printer.toolhead.position.x|float %}
{% set y = printer.toolhead.position.y|float %}
{% set z = printer.toolhead.position.z|float %}
M118 set control point: X{x} Y{y} Z{z}
SAVE_VARIABLE VARIABLE=xcontrolpoint VALUE={x}
SAVE_VARIABLE VARIABLE=ycontrolpoint VALUE={y}
SAVE_VARIABLE VARIABLE=zcontrolpoint VALUE={z}
{% else %}
# set toolhead offset
{% set x = printer.toolhead.position.x|float - svv.xcontrolpoint|float %}
{% set y = printer.toolhead.position.y|float - svv.ycontrolpoint|float %}
{% set z = printer.toolhead.position.z|float - svv.zcontrolpoint|float %}
M118 set T{t} offset: X{x} Y{y} Z{z}
SAVE_VARIABLE VARIABLE=xoffset VALUE={x}
SAVE_VARIABLE VARIABLE=yoffset VALUE={y}
SAVE_VARIABLE VARIABLE=zoffset VALUE={z}
SET_GCODE_OFFSET X_ADJUST={0-svv.xoffset} Y_ADJUST={0-svv.yoffset} Z_ADJUST={0-svv.zoffset} MOVE=0
SET_GCODE_OFFSET X_ADJUST={x} Y_ADJUST={y} Z_ADJUST={z} MOVE=0
{% endif %}
[gcode_macro _NOZZLE_CALIBRATION_PROBE_Z_OFFSET]
gcode:
# get IDEX mode
{% set idex_mode = 'none' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set t = 1 if idex_mode=='primary' else 0 %}
# ratos variables file
{% set svv = printer.save_variables.variables %}
# config
{% set x_offset = printer["zoffsetprobe"].x_offset|default(0)|float %}
{% set y_offset = printer["zoffsetprobe"].y_offset|default(0)|float %}
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed * 60 %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
# probe z-offset
{% if printer["zoffsetprobe"] is defined %}
{% set xcontrolpoint = svv.xcontrolpoint|default(150)|float %}
{% set ycontrolpoint = svv.ycontrolpoint|default(30)|float %}
{% set zcontrolpoint = svv.zcontrolpoint|default(50)|float %}
G1 Z{zcontrolpoint} F{z_speed}
G1 X{xcontrolpoint + x_offset} Y{ycontrolpoint + y_offset} F{speed}
Z_OFFSET_PROBE
G0 Z{zcontrolpoint} F{z_speed}
G1 X{xcontrolpoint} Y{ycontrolpoint} F{speed}
UPDATE_DELAYED_GCODE ID=_NOZZLE_CALIBRATION_SET_Z_OFFSET DURATION=0.1
{% endif %}
[delayed_gcode _NOZZLE_CALIBRATION_SET_Z_OFFSET]
gcode:
# get IDEX mode
{% set idex_mode = 'none' %}
{% if printer["dual_carriage"] is defined %}
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}
{% endif %}
{% set t = 1 if idex_mode=='primary' else 0 %}
# ratos variables file
{% set svv = printer.save_variables.variables %}
# config
{% set last_z = printer["zoffsetprobe"].last_z_result|default(0)|float %}
{% set z_speed = printer["gcode_macro RatOS"].macro_z_speed|float * 60 %}
{% if printer["zoffsetprobe"] is defined %}
{% if t == printer["gcode_macro RatOS"].default_toolhead|default(0)|int %}
# set control point
M118 z-offset control point {last_z}
SAVE_VARIABLE VARIABLE=zoffsetcontrolpoint VALUE={last_z}
{% else %}
# set toolhead offset
{% set z = last_z - svv.zoffsetcontrolpoint|float %}
M118 set T{t} offset: Z{z}
SAVE_VARIABLE VARIABLE=zoffset VALUE={z}
SET_GCODE_OFFSET Z_ADJUST={0-svv.zoffset} MOVE=0
SET_GCODE_OFFSET Z_ADJUST={z} MOVE=0
G0 Z{svv.zcontrolpoint|float} F{z_speed}
{% endif %}
{% endif %}
[gcode_macro _NOZZLE_CALIBRATION_SWITCH_LED]
gcode:
{% if printer['neopixel nozzle_calibration_led'] is defined %}
{% if params.STATE|default(0)|int == 1 %}
NOZZLE_CALIBRATION_LIGHT_ON
{% else %}
NOZZLE_CALIBRATION_LIGHT_OFF
{% endif %}
{% endif %}
#############################################################################################################
#
# Nozzle Calibration LED
#
#############################################################################################################
[neopixel nozzle_calibration_led]
pin: PE15
chain_count: 4
color_order: GRB
initial_RED: 0.0
initial_GREEN: 0.0
[gcode_macro NOZZLE_CALIBRATION_LIGHT_ON]
gcode:
SET_LED LED=nozzle_calibration_led RED=1.0 GREEN=1.0 BLUE=1.0
[gcode_macro NOZZLE_CALIBRATION_LIGHT_OFF]
gcode:
SET_LED LED=nozzle_calibration_led RED=0.0 GREEN=0.0 BLUE=0.0
#############################################################################################################
#
# Nozzle Calibration Z-Offset Probe
#
#############################################################################################################
[zoffsetprobe]
pin: ^!PE7 # probe trigger pin
z_offset: 22.0 # probe height, used to limit the probe z-move
y_offset: 22.5 # probe y-offset, measured from the camera center
x_offset: 0 # probe x-offset, measured from the camera center
speed: 10
samples: 3
sample_retract_dist: 5
lift_speed: 10.0
samples_result: median
samples_tolerance: 0.2
samples_tolerance_retries: 5