-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathklipper-gcode.cfg
279 lines (269 loc) · 10.7 KB
/
klipper-gcode.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
[gcode_macro PRINT_START]
# Use PRINT_START for the slicer starting script - please customise for your slicer of choice
gcode:
{% set EXTRUDER_TEMP = params.EXTRUDER|default(190)|float %}
{% set CHAMBER_TEMP = params.CHAMBER|default(0)|float %}
{% set FRAME_TEMP = params.FRAME|default(0)|float %}
{% set BED_TEMP = params.BED|default(0)|float %}
{% set SOAK_TIME = params.SOAK|default(0)|float %}
{% set FILAMENT = params.FTYPE|default("ABS")|string %}
; Reset everything to a known state
RESETALL
; Don't waste any time before getting that bed warming...
M140 S{BED_TEMP}
; Home so we can move
status_homing
G28
status_busy
; Move to middle of print volume
G0 X{((printer.configfile.settings.stepper_x.position_max - printer.configfile.settings.stepper_x.position_min) / 2)|string} Y{((printer.configfile.settings.stepper_y.position_max - printer.configfile.settings.stepper_y.position_min) / 2)|string} Z{((printer.configfile.settings.stepper_z.position_max - printer.configfile.settings.stepper_z.position_min) / 2)|string} F3600
ECHO FILAMENT="{FILAMENT}"
status_heating
; Turn on part fan at full for warmup
M106 S255
; Warm up nozzle, but not enough to ooze, and don't wait
M104 S150
; Warm up bed, don't wait
{% if BED_TEMP > 0 %}
{% if FRAME_TEMP > 0 %}
; Always heat bed and wait if we're warming the frame.
; If we don't wait, the bed fans may not run at high speed
M190 S{BED_TEMP}
{% else %}
M140 S{BED_TEMP}
{% endif %}
{% endif %}
; Wait for chamber to reach temperatures
{% if CHAMBER_TEMP > 0 %}
ECHO WAIT_FOR_CHAMBER="{CHAMBER_TEMP}"
SET_TEMPERATURE_FAN_TARGET temperature_fan=Chamber target={CHAMBER_TEMP} min_speed=0 max_speed=1.0
TEMPERATURE_WAIT SENSOR="temperature_fan Chamber" MINIMUM={CHAMBER_TEMP}
{% endif %}
{% if FRAME_TEMP > 0 %}
ECHO WAIT_FOR_FRAME="{FRAME_TEMP}"
{% if BED_TEMP < 120 %}
M190 S120
{% endif %}
TEMPERATURE_WAIT SENSOR="temperature_sensor Frame" MINIMUM={FRAME_TEMP}
{% if BED_TEMP < 120 %}
M190 S{BED_TEMP}
TEMPERATURE_WAIT SENSOR="heater_bed" MAXIMUM={BED_TEMP}
{% endif %}
{% endif %}
; Wait for bed to finish warming up (or let it cool down)
{% if BED_TEMP > 0 %}
ECHO WAIT_FOR_BED="{BED_TEMP}"
M190 S{BED_TEMP}
{% endif %}
; Chamber, frame, and bed are now done, start heat soak
{% if SOAK_TIME > 0 %}
G4 P{(SOAK_TIME * 60 * 1000)|string}
{% endif %}
; Home and QGL
BED_MESH_CLEAR
status_homing
G28
; Move to back right to heat nozzle
status_heating
; DECONTAMINATE MOVE=1
{% if FILAMENT != "PC" %}
ECHO WAIT_FOR_EXTRUDER="{EXTRUDER_TEMP}"
M109 S{EXTRUDER_TEMP}
{% endif %}
status_cleaning
; DECONTAMINATE WIPE=5
{% if FILAMENT != "PC" %}
POOP_WIPE_AND_PRESS S={(EXTRUDER_TEMP - 50)} P={EXTRUDER_TEMP}
{% endif %}
status_leveling
; TODO: Stop part fan and allow extruder to drop below 50deg before QGL... :(
QUAD_GANTRY_LEVEL
status_homing
G28 ; This ends up staying here for heating...
BED_MESH_CALIBRATE PRINT_MIN={params.PRINT_MIN} PRINT_MAX={params.PRINT_MAX}
; Reset E for print
G92 E0
; Turn off part fan
M107
status_heating
M109 S{EXTRUDER_TEMP}
DECONTAMINATE WIPE=5
; Beep
M300
status_printing
[gcode_macro PRINT_END]
# Use PRINT_END for the slicer ending script - please customise for your slicer of choice
# This used to retract 30mm, but I got plastic buildup in the Rapido...
gcode:
M400 ; wait for buffer to clear
G92 E0 ; zero the extruder
G1 E-5.0 F3600 ; retract filament
M107 ; turn off fan
TURN_OFF_HEATERS
G91 ; relative positioning
G1 Z3 F3000 ; move nozzle up 3mm
G90 ; absolute positioning
G0 X0 Y357 F3600 ; park nozzle at rear
BED_MESH_CLEAR
status_ready
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
PRINT_END
CANCEL_PRINT_BASE
status_ready
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
# change this if you need more or less extrusion
variable_extrude: 1.0
gcode:
status_busy
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
{% set y_park = printer.toolhead.axis_minimum.y|float + 5.0 %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
PAUSE_BASE
SAVE_GCODE_STATE NAME=klipper_pause
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F6000
RESTORE_GCODE_STATE NAME=klipper_pause
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
SAVE_GCODE_STATE NAME=klipper_restore
G91
G1 E{E} F2100
RESTORE_GCODE_STATE NAME=klipper_restore
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESUME_BASE {get_params}
status_printing
[gcode_macro MISSED_STEPS]
description: Test for missed steps on the specified axis
gcode:
g28
g90
# Get AXIS parameter and move to start position
{% if params.AXIS|upper == "X" %}
{% set away = "g0 x10" %}
{% set toward = "g0 x" + (printer.configfile.settings.stepper_x.position_endstop - 10)|string %}
{% set fast = 'f' + (60 * printer.configfile.settings.printer.max_velocity)|string %}
{% set slow = 'f' + (6 * printer.configfile.settings.printer.max_velocity)|string %}
{% set endstop = 'g0 y' + (printer.configfile.settings.stepper_y.position_endstop / 2)|string + ' x' + (printer.configfile.settings.stepper_x.position_endstop)|string %}
{toward} y{(printer.configfile.settings.stepper_y.position_endstop / 2)|string} z50 {slow}
{% elif params.AXIS|upper == "Y" %}
{% set away = "g0 y10" %}
{% set toward = "g0 y" + (printer.configfile.settings.stepper_y.position_endstop - 10)|string %}
{% set fast = 'f' + (60 * printer.configfile.settings.printer.max_velocity)|string %}
{% set slow = 'f' + (6 * printer.configfile.settings.printer.max_velocity)|string %}
{% set endstop = 'g0 x' + (printer.configfile.settings.stepper_x.position_endstop / 2)|string + ' y' + (printer.configfile.settings.stepper_y.position_endstop)|string %}
{toward} x{(printer.configfile.settings.stepper_x.position_endstop / 2)|string} z50 {slow}
{% elif params.AXIS|upper == "Z" %}
{% set toward = "g0 z20" %}
{% set away = "g0 z" + (printer.configfile.settings.stepper_z.position_max - 10)|string %}
{% set fast = 'f' + (60 * printer.configfile.settings.printer.max_z_velocity)|string %}
{% set slow = 'f' + (6 * printer.configfile.settings.printer.max_z_velocity)|string %}
{% set endstop = 'g0 z' + (printer.configfile.settings.stepper_z.position_endstop)|string %}
{toward} x{printer.configfile.settings.safe_z_home.home_xy_position[0]|string} y{printer.configfile.settings.safe_z_home.home_xy_position[1]|string} {slow}
{% else %}
{ action_raise_error("Invalid AXIS") }
{% endif %}
# Set accel etc. to max
RESETSPEEDS
# Now, move to away slowly then toward fast 10 times
{% for i in range(10) %}
{away} {slow}
{toward} {fast}
{% endfor %}
# Finally, go to the endstop and display if it's triggered
{endstop}
query_endstops
[gcode_macro RESETALL]
description: Resets all values
gcode:
RESETSPEEDS
; Reset E
G92 E0.0
SET_GCODE_OFFSET Z=0.0 X=0 Y=0
; Relative E
M83
; Absolute coordinates
G90
SET_PRESSURE_ADVANCE ADVANCE=0
TURN_OFF_HEATERS
SET_DISPLAY_GROUP GROUP=_default_16x4
BED_MESH_CLEAR
SET_FILAMENT_SENSOR SENSOR=Filament ENABLE=1
;#SET_TEMPERATURE_FAN_TARGET temperature_fan=Chamber target={printer.configfile.settings["temperature_fan chamber"].target_temp}
[gcode_macro CENTRE]
description: Moves to center of bed
gcode:
SAVE_GCODE_STATE NAME=move_to_centre
G90
G0 X{((printer.configfile.settings.stepper_x.position_max - printer.configfile.settings.stepper_x.position_min) / 2)|string} Y{((printer.configfile.settings.stepper_y.position_max - printer.configfile.settings.stepper_y.position_min) / 2)|string} F3600
RESTORE_GCODE_STATE NAME=move_to_centre
[gcode_macro FRONT_TOP]
description: Moves to center of build area at top
gcode:
SAVE_GCODE_STATE NAME=move_to_front_top
G90
; Y = +10 to avoid suctioning the doors
; Z = -100 to allow working on the AfterBurner
G0 X{((printer.configfile.settings.stepper_x.position_max - printer.configfile.settings.stepper_x.position_min) / 2)|string} Y{(printer.configfile.settings.stepper_y.position_min + 10)|string} Z{(printer.configfile.settings.stepper_z.position_max-100)|string} F3600
RESTORE_GCODE_STATE NAME=move_to_front_top
[gcode_macro START_SOAK]
description: Starts headers for heatsoak
gcode:
; Home so we can move
status_homing
G28
status_busy
; Move to middle of print volume
G0 X{((printer.configfile.settings.stepper_x.position_max - printer.configfile.settings.stepper_x.position_min) / 2)|string} Y{((printer.configfile.settings.stepper_y.position_max - printer.configfile.settings.stepper_y.position_min) / 2)|string} Z{((printer.configfile.settings.stepper_z.position_max - printer.configfile.settings.stepper_z.position_min) / 2)|string} F3600
status_heating
; Turn on part fan at full for warmup
M106 S255
; Warm up nozzle, but not enough to ooze, and don't wait
M104 S150
; Warm up bed, don't wait
M140 S120
# From Ellis
[gcode_macro RESETSPEEDS]
gcode:
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} SQUARE_CORNER_VELOCITY={printer.configfile.settings.printer.square_corner_velocity}