-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
print_extras.cfg
238 lines (212 loc) · 9.11 KB
/
print_extras.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
## Copyright (C) 2023 Chris Laprade (chris@rootiest.com)
##
## This file is part of printcfg.
##
## printcfg is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## printcfg is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with printcfg. If not, see <http://www.gnu.org/licenses/>.
#####################################
## Print Extras ##
## Version 4.1.0 2023-7-3 ##
#####################################
## This file contains optional config
## sections and optional macros that can
## be used to extend the functionality
## of your printer.
################################
####### OPTIONAL_CONFIGS #######
################################
## Support Arcs (G2/G3)
#[gcode_arcs]
#resolution: 0.10
## Support for forcing moves outside of homing
#[force_move]
#enable_force_move: True
## Enable support for looping prints
#[sdcard_loop]
## Enable support for skew correction
#[skew_correction]
################################
####### OPTIONAL_MACROS ########
################################
################################
####### MARLIN COMMANDS ########
################################
[gcode_macro M601]
description: Pause printer
gcode:
PAUSE ; Pause print
[gcode_macro M420]
description: Load bed mesh
gcode:
{% set s = params.S|default(0)|int %} ; S0 = clear, S1 = load
{% if s == 0 %} ; clear
BED_MESH_CLEAR ; Clear bed mesh
{% else %} ; load
{% set l = params.L|default('default') %} ; load profile
BED_MESH_PROFILE LOAD={l} ; Load bed mesh profile
{% endif %}
[gcode_macro M900]
description: Set Pressure Advance
gcode:
{% if 'K' in params %} ; K value is required
{% if 'E' in params %} ; E value is optional
SET_PRESSURE_ADVANCE EXTRUDER={params.E} ADVANCE={params.K} ; Set pressure advance
{% else %} ; E value is not present
SET_PRESSURE_ADVANCE ADVANCE={params.K} ; Set pressure advance
{% endif %}
{% endif %}
[gcode_macro G27]
description: Park the nozzle
gcode:
{% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables
{printcfg.park_base} ; Park the nozzle
[gcode_macro G29]
description: Mesh the bed
gcode:
{% set t = params.T|default(0)|float %} ; T value is optional
{% if printer.idle_timeout.state == "Printing" %}
{action_respond_info("This command cannot be used while printing")} ; Cannot run while printing
{% else %}
CG28 ; Home if needed
{% if t > 30.0 %} ; Set bed temp if needed
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={t} ; Set bed temp
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={t} MAXIMUM={t+1} ; Wait for bed temp (within 1 degree)
{% endif %}
BED_MESH_CALIBRATE ; Mesh the bed
{% endif %}
[gcode_macro M205]
description: Set square corner velocity
gcode:
{% if 'X' in params %} ; X value is optional
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.X} ; Set square corner velocity
{% elif 'Y' in params %} ; Y value is optional
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={params.Y} ; Set square corner velocity
{% endif %}
[gcode_macro M204]
description: Set acceleration
rename_existing: M204.1
gcode:
{% set f = params.F|default(0.5)|float %} ; F value is optional
{% if 'S' in params %} ; S value is required
{% set s = params.S|float %} ; S value is required
SET_VELOCITY_LIMIT ACCEL={s} ACCEL_TO_DECEL={ s * f } ; Set acceleration
{% else %} ; S value is not present
{% if 'P' in params %} ; P value is optional
{% set p = params.P|float %} ; P value is optional
{% if 'T' in params %} ; T value is optional
{% set t = params.T|float %} ; T value is optional
{% if p < t %} ; Use the smaller value
SET_VELOCITY_LIMIT ACCEL={p} ACCEL_TO_DECEL={ p * f } ; Set acceleration
{% else %} ; Use the smaller value
SET_VELOCITY_LIMIT ACCEL={t} ACCEL_TO_DECEL={ t * f } ; Set acceleration
{% endif %}
{% else %} ; T value is not present
SET_VELOCITY_LIMIT ACCEL={p} ACCEL_TO_DECEL={ p * f } ; Set acceleration
{% endif %}
{% elif 'T' in params %} ; T value is optional
{% set t = params.T|float %} ; T value is optional
SET_VELOCITY_LIMIT ACCEL={t} ACCEL_TO_DECEL={ t * f } ; Set acceleration
{% endif %}
{% endif %}
[gcode_macro m201]
description: Set acceleration
gcode:
{% if 'X' in params or 'Y' in params %}
{% set accel = (params.X|default(params.Y)|float,
params.Y|default(params.X)|float)|min %}
{% if accel < printer.toolhead.max_accel %}
SET_VELOCITY_LIMIT ACCEL="{accel}" ACCEL_TO_DECEL="{accel * 0.5}"
{% endif %}
{% else %}
SET_VELOCITY_LIMIT
{% endif %}
################################
####### HEATER_OVERIDES ########
################################
## Replaces M109/M190 with TEMPERATURE_WAIT commands
## This will result in less time spent stabilizing the temps
[gcode_macro M109]
rename_existing: M99109
gcode:
{% set s = params.S|float %}
M104 {rawparams} ; Set hotend temp
{% if s != 0 %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={s} MAXIMUM={s+1} ; Wait for hotend temp (within 1 degree)
{% endif %}
#[gcode_macro M190]
#rename_existing: M99190
#gcode:
# {% set s = params.S|float %}
# M140 {rawparams} ; Set bed temp
# {% if s != 0 %}
# TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={s} MAXIMUM={s+1} ; Wait for bed temp (within 1 degree)
# {% endif %}
################################
######### PID_EXTRUDER #########
################################
[gcode_macro PID_EXTRUDER]
description: PID Tune for the Extruder
gcode:
{% set e = printer.toolhead.extruder %} ; get current extruder
{% set T = params.TEMPERATURE|default(210)|float %} ; get target temperature
{% set S = params.FAN_IN_PERCENT|default(0)|float *2.55 %} ; get fan speed
{% set P = printer.configfile.config[e].pid_kp|float %} ; get PID parameters
{% set I = printer.configfile.config[e].pid_ki|float %} ; get PID parameters
{% set D = printer.configfile.config[e].pid_kd|float %} ; get PID parameters
M106 S{S} ; Turn on fan
M118 // PID parameters: pid_Kp={P} pid_Ki={I} pid_Kd={D} (old) ; Display old PID parameters
PID_CALIBRATE HEATER={e} TARGET={T} ; PID Tune the extruder
TURN_OFF_HEATERS ; Turn off heaters
SAVE_CONFIG ; Save the new PID parameters
[gcode_macro M301]
description: Hotend PID Tune
gcode:
{% set e = params.E|default(0)|int %} ; get extruder
{% set t = params.T|default(210)|float %} ; get target temperature
{% set S = params.FAN_IN_PERCENT|default(0)|float *2.55 %} ; get fan speed
{% set P = printer.configfile.config[e].pid_kp|float %} ; get PID parameters
{% set I = printer.configfile.config[e].pid_ki|float %} ; get PID parameters
{% set D = printer.configfile.config[e].pid_kd|float %} ; get PID parameters
M106 S{S} ; Turn on fan
M118 // PID parameters: pid_Kp={P} pid_Ki={I} pid_Kd={D} (old) ; Display old PID parameters
{% if e == 0 %}
{% set e = printer.toolhead.extruder %} ; get current extruder
{% else %}
{% set e = 'extruder' + e|string %} ; get extruder
{% endif %}
PID_CALIBRATE HEATER={e} TARGET={t} ; PID Tune the extruder
################################
############ PID_BED ###########
################################
[gcode_macro PID_BED]
description: PID Tune for the Bed
gcode:
{% set T = params.TEMPERATURE|default(60)|float %} ; get target temperature
{% set P = printer.configfile.config['heater_bed'].pid_kp|float %} ; get PID parameters
{% set I = printer.configfile.config['heater_bed'].pid_ki|float %} ; get PID parameters
{% set D = printer.configfile.config['heater_bed'].pid_kd|float %} ; get PID parameters
M118 // Previous PID parameters: pid_Kp={P} pid_Ki={I} pid_Kd={D} ; Display old PID parameters
PID_CALIBRATE HEATER=heater_bed TARGET={T} ; PID Tune the bed
TURN_OFF_HEATERS ; Turn off heaters
SAVE_CONFIG ; Save the new PID parameters
[gcode_macro M304]
description: Bed PID Tune
gcode:
{% set t = params.T|default(60)|float %} ; get target temperature
{% set P = printer.configfile.config['heater_bed'].pid_kp|float %} ; get PID parameters
{% set I = printer.configfile.config['heater_bed'].pid_ki|float %} ; get PID parameters
{% set D = printer.configfile.config['heater_bed'].pid_kd|float %} ; get PID parameters
M118 // Previous PID parameters: pid_Kp={P} pid_Ki={I} pid_Kd={D} ; Display old PID parameters
PID_CALIBRATE HEATER=heater_bed TARGET={t} ; PID Tune the bed
##TODO: Add M510: Lock Printer
##TODO: Add M511: Unlock Printer