-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacros.cfg
257 lines (224 loc) · 9.34 KB
/
macros.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
[gcode_macro _CLIENT_VARIABLE]
variable_use_custom_pos : True ; use custom park coordinates for x,y [True/False]
variable_custom_park_x : 225.0 ; custom x position; value must be within your defined min and max of X
variable_custom_park_y : 200.0 ; custom y position; value must be within your defined min and max of Y
variable_custom_park_dz : 2.0 ; custom dz value; the value in mm to lift the nozzle when move to park position
variable_retract : 1.0 ; the value to retract while PAUSE
variable_cancel_retract : 5.0 ; the value to retract while CANCEL_PRINT
variable_speed_retract : 35.0 ; retract speed in mm/s
variable_unretract : 1.0 ; the value to unretract while RESUME
variable_speed_unretract : 35.0 ; unretract speed in mm/s
variable_speed_hop : 15.0 ; z move speed in mm/s
variable_speed_move : 120.0 ; move speed in mm/s
variable_park_at_cancel : True ; allow to move the toolhead to park while execute CANCEL_PRINT [True,False]
## !!! Caution [firmware_retraction] must be defined in the printer.cfg if you set use_fw_retract: True !!!
variable_use_fw_retract : True ; use fw_retraction instead of the manual version [True/False]
gcode:
[gcode_macro M600]
description: Filament change
gcode: PAUSE X=10 Y=10 Z_MIN=50
# Lighting Control
[gcode_macro lights_off]
gcode:
SET_PIN PIN=caselight VALUE=0
[gcode_macro lights_on]
gcode:
SET_PIN PIN=caselight VALUE=100
[gcode_macro lights_toggle]
gcode:
{% if printer["output_pin caselight"].value == 100 %}
lights_off
{% else %}
lights_on
{% endif %}
[gcode_macro START_PRINT]
gcode:
M104 S170 ; set temporary nozzle temp to prevent oozing during homing and auto bed leveling
G4 S10 ; allow partial nozzle warmup
{% set BED_TEMP = params.BED_TEMP|default(50)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(210)|float %}
M140 S{BED_TEMP} ; Start bed heating
G90 ; Use absolute coordinates
STATUS_HOMING
G28 ; Home all axes
STATUS_LEVELING
BED_MESH_CALIBRATE
G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
G1 X0.1 Y20 Z30 F5000.0 ; Move to start position
STATUS_HEATING
M190 S{BED_TEMP} ; Wait for bed to reach temperature
M109 S{EXTRUDER_TEMP} ; Set and wait for nozzle to reach temperature
STATUS_PRINTING
G1 Z0.28 F240
G92 E0
G1 Y140 E10 F1500 ; prime the nozzle
G1 X2.3 F5000
G92 E0
G1 Y10 E10 F1200 ; prime the nozzle
G92 E0
[gcode_macro END_PRINT]
gcode:
G92 E0
G1 E-4.0 F3600
M140 S0
M104 S0
M106 S0
G91
G1 Z25
G90
G0 X0 Y225 F3000
M84
[gcode_macro PID_EXTRUDER]
description: PID Tune for the Extruder
gcode:
{% set TARGET_TEMP = params.TARGET_TEMP|default(260)|float %}
PID_CALIBRATE HEATER=extruder TARGET={TARGET_TEMP}
TURN_OFF_HEATERS
SAVE_CONFIG
[gcode_macro PID_BED]
description: PID Tune for the Bed
gcode:
{% set TARGET_TEMP = params.TARGET_TEMP|default(70)|float %}
PID_CALIBRATE HEATER=heater_bed TARGET={TARGET_TEMP}
TURN_OFF_HEATERS
SAVE_CONFIG
[gcode_macro G29]
description: Bed Leveling
gcode:
STATUS_LEVELING
G28
bed_mesh_calibrate
G1 X0 Y0 Z10 F4200
[pause_resume]
recover_velocity: 25
[gcode_macro Set_Z_Offset] ]
description: start process because I'm forgetful
gcode:
STATUS_CALIBRATING_Z
G28
probe_calibrate
[homing_override]
axes: xyz
set_position_z: 0
gcode:
{% set home_all = 'X' not in params and 'Y' not in params and 'Z' not in params %}
STATUS_HOMING
{% if home_all or 'X' in params %}
G28 X
{% endif %}
{% if home_all or 'Y' in params %}
G28 Y
{% endif %}
{% if home_all or 'Z' in params %}
STATUS_CALIBRATING_Z
G90
G1 X110 Y85 Z10
G28 Z
G1 Z10
{% endif %}
{% if home_all %}
STATUS_READY
{% endif %}
[gcode_macro TEST_SPEED]
gcode:
# Speed
{% set speed = params.SPEED|default(printer.configfile.settings.printer.max_velocity)|int %}
# Iterations
{% set iterations = params.ITERATIONS|default(5)|int %}
# Acceleration
{% set accel = params.ACCEL|default(printer.configfile.settings.printer.max_accel)|int %}
# Bounding inset for large pattern (helps prevent slamming the toolhead into the sides after small skips, and helps to account for machines with imperfectly set dimensions)
{% set bound = params.BOUND|default(20)|int %}
# Size for small pattern box
{% set smallpatternsize = SMALLPATTERNSIZE|default(20)|int %}
# Large pattern
# Max positions, inset by BOUND
{% set x_min = printer.toolhead.axis_minimum.x + bound %}
{% set x_max = printer.toolhead.axis_maximum.x - bound %}
{% set y_min = printer.toolhead.axis_minimum.y + bound %}
{% set y_max = printer.toolhead.axis_maximum.y - bound %}
# Small pattern at center
# Find X/Y center point
{% set x_center = (printer.toolhead.axis_minimum.x|float + printer.toolhead.axis_maximum.x|float ) / 2 %}
{% set y_center = (printer.toolhead.axis_minimum.y|float + printer.toolhead.axis_maximum.y|float ) / 2 %}
# Set small pattern box around center point
{% set x_center_min = x_center - (smallpatternsize/2) %}
{% set x_center_max = x_center + (smallpatternsize/2) %}
{% set y_center_min = y_center - (smallpatternsize/2) %}
{% set y_center_max = y_center + (smallpatternsize/2) %}
# Save current gcode state (absolute/relative, etc)
SAVE_GCODE_STATE NAME=TEST_SPEED
# Output parameters to g-code terminal
{ action_respond_info("TEST_SPEED: starting %d iterations at speed %d, accel %d" % (iterations, speed, accel)) }
# Home and get position for comparison later:
G28
# QGL if not already QGLd (only if QGL section exists in config)
{% if printer.configfile.settings.quad_gantry_level %}
{% if printer.quad_gantry_level.applied == False %}
QUAD_GANTRY_LEVEL
G28 Z
{% endif %}
{% endif %}
# Move 50mm away from max position and home again (to help with hall effect endstop accuracy - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/24)
G90
G1 X{printer.toolhead.axis_maximum.x-50} Y{printer.toolhead.axis_maximum.y-50} F{30*60}
G28 X Y
G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
G4 P1000
GET_POSITION
# Go to starting position
G0 X{x_min} Y{y_min} Z{bound + 10} F{speed*60}
# Set new limits
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2}
{% for i in range(iterations) %}
# Large pattern
# Diagonals
G0 X{x_min} Y{y_min} F{speed*60}
G0 X{x_max} Y{y_max} F{speed*60}
G0 X{x_min} Y{y_min} F{speed*60}
G0 X{x_max} Y{y_min} F{speed*60}
G0 X{x_min} Y{y_max} F{speed*60}
G0 X{x_max} Y{y_min} F{speed*60}
# Box
G0 X{x_min} Y{y_min} F{speed*60}
G0 X{x_min} Y{y_max} F{speed*60}
G0 X{x_max} Y{y_max} F{speed*60}
G0 X{x_max} Y{y_min} F{speed*60}
# Small pattern
# Small diagonals
G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_max} Y{y_center_max} F{speed*60}
G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60}
G0 X{x_center_min} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60}
# Small box
G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_min} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60}
{% endfor %}
# Restore max speed/accel/accel_to_decel to their configured values
SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} ACCEL_TO_DECEL={printer.configfile.settings.printer.max_accel_to_decel}
# Re-home and get position again for comparison:
G28
# Go to XY home positions (in case your homing override leaves it elsewhere)
G90
G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
G4 P1000
GET_POSITION
# Restore previous gcode state (absolute/relative, etc)
RESTORE_GCODE_STATE NAME=TEST_SPEED
[gcode_macro configure_extruder]
gcode:
SET_TMC_FIELD STEPPER=extruder FIELD=pwm_meas_sd_enable VALUE=1
SET_TMC_FIELD STEPPER=extruder FIELD=sg4_filt_en VALUE=1
SET_TMC_FIELD STEPPER=extruder FIELD=freewheel VALUE=1
SET_TMC_FIELD STEPPER=extruder FIELD=SG4_THRS VALUE=10
SET_TMC_FIELD STEPPER=extruder FIELD=IHOLD VALUE=0
SET_TMC_FIELD STEPPER=extruder FIELD=THIGH VELOCITY=50
SET_TMC_FIELD STEPPER=extruder FIELD=TCOOLTHRS VALUE=4000
SET_TMC_FIELD STEPPER=extruder FIELD=TPWMTHRS VELOCITY=1
SET_TMC_FIELD STEPPER=extruder FIELD=OVERTEMPPREWARNING_VTH VALUE=2885 # 7.7 * 100 C + 2038
{% set v = (23.99/0.009732)|int %}
SET_TMC_FIELD STEPPER=extruder FIELD=OVERVOLTAGE_VTH VALUE={ v }