Creality K2: Pause & Resume Print without loosing set hotend temperature
When trying to pause and resume a print, I experienced the issue that my Creality K2 only re-heated the hotend once on resume, but then “lost” the set hotend temperature and failed to print due to the too low temperature.
I fixed this by modifying the pause and resume macros in the gcode_macro.cfg:
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
variable_extrude: 2.0
variable_last_temp: 0
gcode:
{% if printer.pause_resume.is_paused|lower == 'false' %}
{% if printer.extruder.target > 0 %}
SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=last_temp VALUE={printer.extruder.target|int}
{% endif %}
SET_IDLE_TIMEOUT TIMEOUT=43200
PAUSE_BASE
PAUSE_EXTERNAL
{% endif %}
[...]
[gcode_macro RESUME_EXTERNAL]
gcode:
{% set resume_temp = printer['gcode_macro PRINTER_PARAM'].hotend_temp|int or printer['gcode_macro PAUSE'].last_temp|int %}
{% if printer.pause_resume.resume_err is none or printer.pause_resume.resume_err|lower == 'false' %}
{% if resume_temp != 0 %}
{% if resume_temp > printer.extruder.temperature %}
M109 S{resume_temp}
{% else %}
M104 S{resume_temp}
{% endif %}
{% endif %}
{% if printer['gcode_macro PRINTER_PARAM'].fan2_speed > 0 %}
SET_PIN PIN=fan2 VALUE={(printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 + 0.5)|int}
{% set s_value = (printer['gcode_macro PRINTER_PARAM'].fan2_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan2_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan2_min)|float %}
# M106 P2 S{s_value}
{% endif %}
{% if printer['gcode_macro PRINTER_PARAM'].fan0_speed > 0 %}
SET_PIN PIN=fan0 VALUE={(printer['gcode_macro PRINTER_PARAM'].fan0_speed * 255 + 0.5)|int}
{% set s_value_0 = (printer['gcode_macro PRINTER_PARAM'].fan0_speed * 255 - printer['gcode_macro PRINTER_PARAM'].fan0_min) * 255 / (255 - printer['gcode_macro PRINTER_PARAM'].fan0_min)|float %}
# M106 P2 S{s_value}
{% endif %}
BOX_GO_TO_EXTRUDE_POS
{% set z_resume_move = printer['gcode_macro PRINTER_PARAM'].z_safe_pause|int %}
{% if z_resume_move > 2 %}
{% set z_resume_move = z_resume_move - 2 %}
G91
#G1 Z-{z_resume_move} F600
M400
{% endif %}
{action_respond_info("z_resume_move = %s"% (z_resume_move))}
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float + 80.0 %}
{% set E_VELOCITY = printer['filament_rack'].remain_material_velocity * 0.8 %}
{action_respond_info("velocity: %s" % (E_VELOCITY))}
#### 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 == 'false' %}
{action_respond_info("Extruder not hot enough, SET M109 S%s" % resume_temp)}
M109 S{resume_temp}
{% else %}
M104 S{resume_temp}
{% endif %}
G91
M106 S0 F1
G1 E{E} F{E_VELOCITY}
G90
M106 S127 F1
G4 P3000
BOX_NOZZLE_CLEAN
M106 P2 S{s_value} F1
M106 P0 S{s_value_0} F1
SET_LIMITS
M400
SET_PIN PIN=extruder_fan VALUE=1
{% if resume_temp > 0 %}
M104 S{resume_temp} ; Temperatur nach den BOX-Makros wiederherstellen
SET_GCODE_VARIABLE MACRO=PRINTER_PARAM VARIABLE=hotend_temp VALUE=0
{% endif %}
{% endif %}
Now the set temperature is saved and re-applied, but also the idle timeout is extended from 5 minutes to 12 hours.