Creando nuestro fichero de configuración para ajustes
Aprovechando la potencia de Klipper y su configuración modular crearemos un fichero de configuración donde, en la medida de lo posible, colocaremos aquellos ajustes que nos permitan personalizar y ajustar a nuestro gusto el funcionamiento de nuestra K2
Crearemos una carpeta 3dwork y dentro un fichero de configuración 3dwork_macro.cfg
Añadiremos el include en printer.cfg, importante que este se encuentre justo antes de la sección SAVE_CONFIG
Os vamos a sugerir algunos cambios que añadiremos en nuestro 3dwork_macro.cfg
Habilitaremos las funciones respond para disponer de más notificaciones añadiendo esta sección
### GENERAL OVERRIDES
[respond]
Mejoras nivelado
El proceso de nivelado de la K2 es bastante lento y teniendo en cuenta cambios en el proceso de inicio de impresión para ser más "inteligente" vamos a eliminar el requerimiento que se haga de forma obligatoria
Añadiremos la siguiente sección para desactivar la obligación de mallado:
[virtual_sdcard]
forced_leveling: false
Mejoraremos también el número de puntos de mallado para mallado de toda la plataforma:
Aumentar el número de puntos de sondeo va a mejorar nuestra malla, pero por otro lado va a aumentar el tiempo en realizar esta.
Por otro lado, y en firmware actual este cambio puede afectar a la conexión de la pantalla local de la impresora reseteando la comunicación al trabajar con mallas, esperemos que Creality de la libertad y corrija esto en el futuro cercano.
START_PRINT
El inicio de impresión no está muy optimizado en estas impresoras, por lo que os sugerimos una serie de cambios/ajustes para optimizar este proceso.
Seguiremos realizando los siguientes cambios en nuestro 3dwork_macro.cfg donde vamos a mejorar el proceso de inicio de impresión.
Para empezar con los cambios nuestra nueva macro START_PRINT vamos a disponer de una serie de variables para controlar sus diferentes funciones:
Z-Offset para diferentes tipos de filamentos, suele ser común que dependiendo del filamento que utilicemos el ajuste del Z-Offset pueda requerir ajuste fino. Aunque esto lo ideal es implementarlo en el script gcode del perfil de filamento de nuestro laminador no todos los incluyen por lo que se ha dejado esta función.
Disponemos de variables para PLA, PETG, ABS, ASA y DEFAULT. Aunque ya lo veremos más adelante básicamente el propio laminador nos va a proporcionar esta información de estar soportada.
Precalentamiento, es algo importante antes de ciertos procesos asegurarnos que esperamos X minutos antes de realizar un mallado por ejemplo... para ello tenemos la variable heat_soak en la que indicaremos el número de minutos que queremos esperar. Esta variable os la aconsejamos poner al tiempo para filamentos técnicos, normalmente entre 5-10m, y en el caso de que usemos PLA la macro automáticamente va a reducir a la mitad este tiempo porque no requiere de tanto precalentamiento
Mallado adaptativo, EN PROCESO
EN TESTING!!! en proceso... malla adaptativa
Purga adaptativa, la purga de la K2 bajo nuestro punto de vista no esta muy optimizada además de en ocasiones ser complicada de eliminar. En nuestro caso incluimos opciones para activar una purga mejor y que dispondremos de diferentes opciones:
0 la línea de purga original de K2
1-4 línea de purga adaptativa en diferentes posiciones
5 un pequeño triángulo
En resumen esta sería nuestra sección/macro de variables, en la que también añadimos una para retornar por consola nuestra configuración:
Esta macro _START_PRINT_VARS podemos también ubicarla en nuestro printer.cfg, después del include a nuestro 3dwork/3dwork_macro.cfg, para un acceso más rápido al ajuste de las variables.
Recuerda que en caso de que no se obtengan en este escenario el funcionamiento correcto puedes utilizar la macro ECHO_START_PRINT_VARS para poder ver que parámetros estamos usando o el log de Klipper.
Dentro de nuestro proceso de inicio de impresión y para reducir el tiempo de este en procesos que no siempre son necesarios o redundantes se ha mejorado la función de generación y carga de mallado.
Para ello hemos creado/personalizado dos nuevas macros:
La primera, MESH_IF_NEEDED, que básicamente verifica si tenemos guardada una malla ya hecha para la combinación temperatura cama y cerramiento... si existe la carga y no realiza malla y si no pues lanza la siguiente macro para realizar un sondeo y crear la malla.
Como ya os adelantamos en el punto anterior disponemos de la macro _CREATE_MESH la cual básicamente hace un sondeo y guarda la malla con el nombre temperatura de cama/cerramiento
Es importante que después de finalizar una impresión donde se haya creado una nueva malla guardes los cambios de tu configuración desde el interfaz web... por desgracia son limitaciones dentro de Klipper
### BED MESH OVERRIDES
[gcode_macro _CREATE_MESH]
gcode:
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set CHAMBER_TEMP = params.CHAMBER_TEMP|default(0)|float %}
{% set PROFILE_NAME = BED_TEMP|string + 'c_' + CHAMBER_TEMP|string + 'c' %}
## make these configurable
{% set SOAK_TIME = params.SOAK_TIME|default(5)|float %}
{% set EXTRUDER_WAITTEMP = (140.0|float)|int %}
{% if not 'xyz' in printer.toolhead.homed_axes %}
M117 Homing ...
RESPOND MSG="Homing ..."
G28
{% endif %}
# heating nozzle mesh temperature
M104 S{EXTRUDER_WAITTEMP}
# heating bed
M117 Heating Bed {BED_TEMP} ...
RESPOND MSG="Heating Bed {BED_TEMP} ..."
M190 S{BED_TEMP}
# heating nozzle mesh temperature
M117 Heating Nozzle {EXTRUDER_WAITTEMP} ...
RESPOND MSG="Heating Nozzle {EXTRUDER_WAITTEMP} ..."
M109 S{EXTRUDER_WAITTEMP}
{% if CHAMBER_TEMP > 0 %}
M117 Heating Chamber {CHAMBER_TEMP} ...
RESPOND MSG="Heating Chamber {CHAMBER_TEMP} ..."
M191 S{CHAMBER_TEMP}
{% endif %}
M117 Heat soaking for {SOAK_TIME} minutes ...
RESPOND MSG="Heat soaking for {SOAK_TIME} minutes ..."
G4 P{60000 * SOAK_TIME} # x minute heat soak
# ensure bed is level
# some users have reported that the bed does not raise uniformly from the bottom
M117 Adjusting Z TILT ...
RESPOND MSG="Adjusting Z TILT ..."
Z_TILT_ADJUST
# rehome Z after tilt adjust
M117 re-Homing Z ...
RESPOND MSG="re-Homing Z ..."
G28 Z
BOX_NOZZLE_CLEAN
M117 Creating Mesh {PROFILE_NAME} ...
RESPOND MSG="Creating Mesh {PROFILE_NAME} ..."
BED_MESH_CALIBRATE PROFILE={PROFILE_NAME}
M117 Saving Config ...
RESPOND MSG="Saving Config ..."
CXSAVE_CONFIG
[gcode_macro MESH_IF_NEEDED]
gcode:
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set CHAMBER_TEMP = params.CHAMBER_TEMP|default(0)|float %}
{% set PROFILE_NAME = BED_TEMP|string + 'c_' + CHAMBER_TEMP|string + 'c' %}
## make these configurable
{% set SOAK_TIME = params.SOAK_TIME|default(5)|float %}
{% if printer.scanner %} # cartographer
_CREATE_MESH BED_TEMP={BED_TEMP} CHAMBER_TEMP={CHAMBER_TEMP} SOAK_TIME={SOAK_TIME}
{% else %}
RESPOND MSG="Looking for {PROFILE_NAME} ..."
{% if PROFILE_NAME in printer.bed_mesh.profiles %}
RESPOND MSG="{PROFILE_NAME} exists ..."
{% else %}
M117 Mesh {PROFILE_NAME} missing
RESPOND MSG="{PROFILE_NAME} does not exist, creating ..."
_CREATE_MESH BED_TEMP={BED_TEMP} CHAMBER_TEMP={CHAMBER_TEMP} SOAK_TIME={SOAK_TIME}
{% endif %}
{% endif %}
```
A continuación, tenemos la macro START_PRINT la cual se encarga de todo el proceso anterior enviando mensajes durante todo el proceso y con la información de uso para identificar puntos de fallo:
[gcode_macro START_PRINT]
# be sure to update your slicer to pass in both chamber temp and material type and print area, for Creality Prin/OrcaSlicer:
# START_PRINT EXTRUDER_TEMP=[nozzle_temperature_initial_layer] BED_TEMP=[bed_temperature_initial_layer_single] CHAMBER_TEMP=[overall_chamber_temperature] MATERIAL={filament_type[initial_tool]} START_TOOL=[initial_no_support_extruder]
variable_prepare: 0
gcode:
M117 START_PRINT
BOX_START_PRINT # what exactly does this do?
G90
# TEMPERATURE VARS
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set CHAMBER_TEMP = params.CHAMBER_TEMP|default(0)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(220)|float %}
{% set EXTRUDER_WAITTEMP = (140.0|float)|int %}
{% set SOAK_TIME = printer['gcode_macro _START_PRINT_VARS'].heat_soak|float %}
{% set MATERIAL = params.MATERIAL|default('')|string %}
# MESH VARS
{% set mesh_min = params.BED_MESH_MIN %}
{% set mesh_max = params.BED_MESH_MAX %}
{% set probe_count = params.BED_MESH_PROBE_COUNT %}
{% set algorithm = params.BED_MESH_ALGORITHM %}
# TOOL VARS
{% set START_TOOL = params.START_TOOL %}
# ECHO VARS
ECHO_START_PRINT_VARS
M117 BED_TEMP - {BED_TEMP} ...
M117 CHAMBER_TEMP - {CHAMBER_TEMP} ...
M117 EXTRUDER_TEMP - {EXTRUDER_TEMP} ...
M117 EXTRUDER_WAITTEMP - {EXTRUDER_WAITTEMP} ...
M117 SOAK_TIME - {SOAK_TIME} ...
M117 MATERIAL - {MATERIAL} ...
M117 mesh_min - {mesh_min} ...
M117 mesh_max - {mesh_max} ...
M117 probe_count - {probe_count} ...
M117 algorithm - {algorithm} ...
{% if MATERIAL == 'PLA' %}
{% set SOAK_TIME = SOAK_TIME / 2 %}
{% set OFFSET = printer['gcode_macro _START_PRINT_VARS'].offset_pla %}
{% elif MATERIAL == 'PETG' %}
{% set OFFSET = printer['gcode_macro _START_PRINT_VARS'].offset_petg %}
{% elif MATERIAL == 'ASA' %}
{% set HEAT_BUMP = 1 %}
{% set OFFSET = printer['gcode_macro _START_PRINT_VARS'].offset_asa %}
{% elif MATERIAL == 'ABS' %}
{% set HEAT_BUMP = 1 %}
{% set OFFSET = printer['gcode_macro _START_PRINT_VARS'].offset_abs %}
{% else %}
# default value
{% set OFFSET = printer['gcode_macro _START_PRINT_VARS'].offset_default %}
{% endif %}
M117 Setting Z offset for {MATERIAL} of {OFFSET} ...
RESPOND MSG="Setting Z offset for {MATERIAL} of {OFFSET} ..."
SET_GCODE_OFFSET Z={OFFSET}
# better safe than sorry, re-homing is a small price to pay
M117 Homing ...
RESPOND MSG="Homing ..."
G28
# ensure bed is level
# some users have reported that the bed does not raise uniformly from the bottom
M117 Adjusting Z TILT ...
RESPOND MSG="Adjusting Z TILT ..."
Z_TILT_ADJUST
# rehome Z after tilt adjust
M117 re-Homing Z ...
RESPOND MSG="re-Homing Z ..."
G28 Z
{% if CHAMBER_TEMP > 0 %}
M117 pre-Heating Chamber {CHAMBER_TEMP} ...
RESPOND MSG="pre-Heating Chamber {CHAMBER_TEMP} ..."
M141 S{CHAMBER_TEMP}
{% endif %}
# when is a print prepared?
{% if printer['gcode_macro START_PRINT'].prepare|int == 0 %}
{action_respond_info("print prepared 111")}
M106 S0 # No need to turn off the model fan
M140 S{BED_TEMP}
M104 S{EXTRUDER_WAITTEMP}
SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=5000
NOZZLE_CLEAR
M104 S{EXTRUDER_WAITTEMP}
M117 Heating bed ...
M190 S{BED_TEMP}
M109 S{EXTRUDER_WAITTEMP}
BOX_NOZZLE_CLEAN#M1501
# Return to zero
NEXT_HOMEZ_NACCU
G28 Z
# BED_MESH_CALIBRATE
# CXSAVE_CONFIG
{% else %}
PRINT_PREPARE_CLEAR
{% endif %}
# don't want to accidently turn off chamber heating if a temp wasn't passed in
{% if CHAMBER_TEMP > 0 %}
M117 Heating Chamber {CHAMBER_TEMP} ...
RESPOND MSG="Heating Chamber {CHAMBER_TEMP} ..."
M191 S{CHAMBER_TEMP}
{% endif %}
M117 pre-Heating Nozzle {EXTRUDER_WAITTEMP} ...
RESPOND MSG="pre-Heating Nozzle {EXTRUDER_WAITTEMP} ..."
M109 S{EXTRUDER_WAITTEMP}
# Ensure bed is at the desired temp
# works around some firmware bugs that sometimes turn off the bed
M117 Heating Bed {BED_TEMP} ...
RESPOND MSG="Heating Bed {BED_TEMP} ..."
M190 S{BED_TEMP}
{% if SOAK_TIME > 0 %}
M117 Heat soaking for {SOAK_TIME} minutes ...
RESPOND MSG="Heat soaking for {SOAK_TIME} minutes ..."
G4 P{60000 * SOAK_TIME}
{% endif %}
# ensure a nozzle wipe happens before touching the bed
M117 Wiping Nozzle ...
RESPOND MSG="Wiping Nozzle ..."
BOX_NOZZLE_CLEAN
M117 Homing ...
RESPOND MSG="Homing ..."
{% if printer.scanner %} # cartographer
M117 Cartographer Adaptarive Mesh
RESPOND MSG="Cartographer Adaptarive Mesh"
CARTOGRAPHER_TOUCH
BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1
{% else %} # everyone else
{% if printer['gcode_macro _START_PRINT_VARS'].mesh_adaptative == 0 %}
# !!! this MUST come after all G28s as they reset the mesh to "default"
# load the mesh for the current bed and chamber temp
MESH_IF_NEEDED BED_TEMP={BED_TEMP} CHAMBER_TEMP={CHAMBER_TEMP}
M117 Loading bed mesh: {BED_TEMP}c_{CHAMBER_TEMP}c ...
RESPOND MSG="Loading bed mesh: {BED_TEMP}c_{CHAMBER_TEMP}c ..."
BED_MESH_PROFILE LOAD={BED_TEMP}c_{CHAMBER_TEMP}c
{% else %}
M117 Adaptative bed mesh: {mesh_min}-{mesh_max} coordinates, {algorithm} algorithm, {probe_count} probe count...
RESPOND MSG="Adaptative bed mesh: {mesh_min}-{mesh_max} coordinates, {algorithm} algorithm, {probe_count} probe count..."
BED_MESH_CLEAR
#BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1 ADAPTIVE_MARGIN=5
BED_MESH_CALIBRATE PROFILE=adaptative mesh_min={mesh_min} mesh_max={mesh_max} ALGORITHM={algorithm} PROBE_COUNT={probe_count} ADAPTIVE=0 ADAPTIVE_MARGIN=0
{% endif %}
{% endif %}
BOX_GO_TO_EXTRUDE_POS#M1500
M117 Heating Nozzle {EXTRUDER_TEMP} ...
RESPOND MSG="Heating Nozzle {EXTRUDER_TEMP} ..."
M109 S{EXTRUDER_TEMP} ;wait nozzle heating
# the stock chamber heater configuration is watermark
# which means at best it will reach the target temp, but rarely exceed it
# for materials like ASA the chamber temp should be a _minimum_
{% if HEAT_BUMP == 1%}
{% if CHAMBER_TEMP > 0 %}
{% if CHAMBER_TEMP + 5 <= 60 %}
M141 S{CHAMBER_TEMP + 5}
{% else %}
M141 S60
{% endif %}
{% endif %}
{% endif %}
M220 S100 ;Reset Feedrate
# M221 S100 ;Reset Flowrate
G21
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=10
M204 S5000
SET_VELOCITY_LIMIT ACCEL_TO_DECEL=5000
G92 E0 ; Reset Extruder
SET_PIN PIN=extruder_fan VALUE=1
# set the initial tool
M117 Loading Tool {START_TOOL} ...
RESPOND MSG="Loading Tool {START_TOOL} ..."
T{START_TOOL}
# print purge line
PURGE_LINE PRINT_MIN={mesh_min} PRINT_MAX={mesh_max}
M117 Starting printing ...
RESPOND MSG="Starting printing ..."
Ajustes en nuestro laminador
En nuestro caso utilizamos OrcaSlicer, el de Creality se basa en este también, en el cual deberemos realizar cambios en nuestro perfil de impresora en el gcode de inicio de impresión:
Los principales cambios son ajustar la llamada a nuestra macro START_PRINT para facilitarle todas las configuraciones de laminador y, por ahora ya que más tarde se integrará dentro de START_PRINT, la llamada a la linea de purgado por lo que eliminaremos la original.
El proceso de caltentado de cámara puede ser algo engorroso y tardar bastante tiempo. Para mejorar el proceso se va ha hacer un proceso más inteligente en el que utilizaremos la propia capa para ayudir en el proceso
### M191 OVERRIDES
[gcode_macro M191]
#TODO: should this leverage the existing M141?
description: Set and wait for chamber temperature, with intelligent bed assist
gcode:
SAVE_GCODE_STATE NAME=M191
# Parameters
{% set S = params.S|default(0)|float %}
{% if S == 0 %}
TURN_OFF_HEATERS
M107
{% else %}
M117 Heating chamber
{% if S > 35.0 %}
RESPOND MSG="The chamber heater alone can not reach {S}c, using bed assist ..."
# bed needs to raise to near the nozzle
{% if "xyz" not in printer.toolhead.homed_axes %}
G28
{% endif %}
G1 Z5 F600
{% if printer.heater_bed.target > 99.0 %}
RESPOND MSG="Bed target temp already high enough, not changing ..."
{% else %}
RESPOND MSG="Bed target temp not high enough, setting to 105c ..."
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET=105
{% endif %}
SET_PIN PIN=fan2 VALUE=153
{% endif %}
# turn on the fan to help
SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET={S}
# Set chamber temperature
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={S}
# Wait indefinitely for temperature
TEMPERATURE_WAIT SENSOR="temperature_sensor chamber_temp" MINIMUM={S} MAXIMUM={S+5}
RESPOND MSG="Chamber temperature {S}c reached ..."
{% endif %}
RESTORE_GCODE_STATE NAME=M191
Resumen de nuestros cambios
A modo de resumen, en el siguiente código tenéis todo el conjunto de modificaciones hechas:
/3dwork/3dwork_macro.cfg
### GENERAL OVERRIDES
[respond]
[virtual_sdcard]
forced_leveling: false
[bed_mesh]
probe_count:15,15
move_check_distance: 3
### LIST OVERRIDES
# START PRINT OVERRIDES
# BED MESH OVERRIDES
# M191 OVERRIDES
### START PRINT OVERRIDES
[gcode_macro _START_PRINT_VARS]
variable_offset_PLA: 0
variable_offset_PETG: 0
variable_offset_ABS: 0
variable_offset_ASA: 0
variable_offset_DEFAULT: 0
variable_heat_soak: 5 # minutes
variable_mesh_adaptative: 0 # 1 - enable adaptative mesh , 0 - adaptative mesh disabled
variable_purge_adaptative: 2 # 1 - line vertical right, 2 - Horizontal Lower Left, 3 - Vertical Lower Left, 4 - Horizontal Upper Right, 5 - Triangle Lower Left , 0 - k2 default
gcode:
ECHO_START_PRINT_VARS
[gcode_macro ECHO_START_PRINT_VARS]
description: Echo START_PRINT_VARS variables to the console.
gcode:
{action_respond_info("Listing START_PRINT_VARS...")}
{% for var, value in printer["gcode_macro _START_PRINT_VARS"].items() %}
{action_respond_info(var ~ ": " ~ value)}
{% endfor %}
[gcode_macro START_PRINT]
# be sure to update your slicer to pass in both chamber temp and material type and print area, for Creality Prin/OrcaSlicer:
# START_PRINT EXTRUDER_TEMP=[nozzle_temperature_initial_layer] BED_TEMP=[bed_temperature_initial_layer_single] CHAMBER_TEMP=[overall_chamber_temperature] MATERIAL={filament_type[initial_tool]} START_TOOL=[initial_no_support_extruder]
variable_prepare: 0
gcode:
M117 START_PRINT
BOX_START_PRINT # what exactly does this do?
G90
# TEMPERATURE VARS
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set CHAMBER_TEMP = params.CHAMBER_TEMP|default(0)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(220)|float %}
{% set EXTRUDER_WAITTEMP = (140.0|float)|int %}
{% set SOAK_TIME = printer['gcode_macro _START_PRINT_VARS'].heat_soak|float %}
{% set MATERIAL = params.MATERIAL|default('')|string %}
# MESH VARS
{% set mesh_min = params.BED_MESH_MIN %}
{% set mesh_max = params.BED_MESH_MAX %}
{% set probe_count = params.BED_MESH_PROBE_COUNT %}
{% set algorithm = params.BED_MESH_ALGORITHM %}
# TOOL VARS
{% set START_TOOL = params.START_TOOL %}
# ECHO VARS
ECHO_START_PRINT_VARS
M117 BED_TEMP - {BED_TEMP} ...
M117 CHAMBER_TEMP - {CHAMBER_TEMP} ...
M117 EXTRUDER_TEMP - {EXTRUDER_TEMP} ...
M117 EXTRUDER_WAITTEMP - {EXTRUDER_WAITTEMP} ...
M117 SOAK_TIME - {SOAK_TIME} ...
M117 MATERIAL - {MATERIAL} ...
M117 mesh_min - {mesh_min} ...
M117 mesh_max - {mesh_max} ...
M117 probe_count - {probe_count} ...
M117 algorithm - {algorithm} ...
{% if MATERIAL == 'PLA' %}
{% set SOAK_TIME = SOAK_TIME / 2 %}
{% set OFFSET = printer['gcode_macro _START_PRINT_VARS'].offset_pla %}
{% elif MATERIAL == 'PETG' %}
{% set OFFSET = printer['gcode_macro _START_PRINT_VARS'].offset_petg %}
{% elif MATERIAL == 'ASA' %}
{% set HEAT_BUMP = 1 %}
{% set OFFSET = printer['gcode_macro _START_PRINT_VARS'].offset_asa %}
{% elif MATERIAL == 'ABS' %}
{% set HEAT_BUMP = 1 %}
{% set OFFSET = printer['gcode_macro _START_PRINT_VARS'].offset_abs %}
{% else %}
# default value
{% set OFFSET = printer['gcode_macro _START_PRINT_VARS'].offset_default %}
{% endif %}
M117 Setting Z offset for {MATERIAL} of {OFFSET} ...
RESPOND MSG="Setting Z offset for {MATERIAL} of {OFFSET} ..."
SET_GCODE_OFFSET Z={OFFSET}
# better safe than sorry, re-homing is a small price to pay
M117 Homing ...
RESPOND MSG="Homing ..."
G28
# ensure bed is level
# some users have reported that the bed does not raise uniformly from the bottom
M117 Adjusting Z TILT ...
RESPOND MSG="Adjusting Z TILT ..."
Z_TILT_ADJUST
# rehome Z after tilt adjust
M117 re-Homing Z ...
RESPOND MSG="re-Homing Z ..."
G28 Z
{% if CHAMBER_TEMP > 0 %}
M117 pre-Heating Chamber {CHAMBER_TEMP} ...
RESPOND MSG="pre-Heating Chamber {CHAMBER_TEMP} ..."
M141 S{CHAMBER_TEMP}
{% endif %}
# when is a print prepared?
{% if printer['gcode_macro START_PRINT'].prepare|int == 0 %}
{action_respond_info("print prepared 111")}
M106 S0 # No need to turn off the model fan
M140 S{BED_TEMP}
M104 S{EXTRUDER_WAITTEMP}
SET_VELOCITY_LIMIT ACCEL=5000 ACCEL_TO_DECEL=5000
NOZZLE_CLEAR
M104 S{EXTRUDER_WAITTEMP}
M117 Heating bed ...
M190 S{BED_TEMP}
M109 S{EXTRUDER_WAITTEMP}
BOX_NOZZLE_CLEAN#M1501
# Return to zero
NEXT_HOMEZ_NACCU
G28 Z
# BED_MESH_CALIBRATE
# CXSAVE_CONFIG
{% else %}
PRINT_PREPARE_CLEAR
{% endif %}
# don't want to accidently turn off chamber heating if a temp wasn't passed in
{% if CHAMBER_TEMP > 0 %}
M117 Heating Chamber {CHAMBER_TEMP} ...
RESPOND MSG="Heating Chamber {CHAMBER_TEMP} ..."
M191 S{CHAMBER_TEMP}
{% endif %}
M117 pre-Heating Nozzle {EXTRUDER_WAITTEMP} ...
RESPOND MSG="pre-Heating Nozzle {EXTRUDER_WAITTEMP} ..."
M109 S{EXTRUDER_WAITTEMP}
# Ensure bed is at the desired temp
# works around some firmware bugs that sometimes turn off the bed
M117 Heating Bed {BED_TEMP} ...
RESPOND MSG="Heating Bed {BED_TEMP} ..."
M190 S{BED_TEMP}
{% if SOAK_TIME > 0 %}
M117 Heat soaking for {SOAK_TIME} minutes ...
RESPOND MSG="Heat soaking for {SOAK_TIME} minutes ..."
G4 P{60000 * SOAK_TIME}
{% endif %}
# ensure a nozzle wipe happens before touching the bed
M117 Wiping Nozzle ...
RESPOND MSG="Wiping Nozzle ..."
BOX_NOZZLE_CLEAN
M117 Homing ...
RESPOND MSG="Homing ..."
{% if printer.scanner %} # cartographer
M117 Cartographer Adaptarive Mesh
RESPOND MSG="Cartographer Adaptarive Mesh"
CARTOGRAPHER_TOUCH
BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1
{% else %} # everyone else
{% if printer['gcode_macro _START_PRINT_VARS'].mesh_adaptative == 0 %}
# !!! this MUST come after all G28s as they reset the mesh to "default"
# load the mesh for the current bed and chamber temp
MESH_IF_NEEDED BED_TEMP={BED_TEMP} CHAMBER_TEMP={CHAMBER_TEMP}
M117 Loading bed mesh: {BED_TEMP}c_{CHAMBER_TEMP}c ...
RESPOND MSG="Loading bed mesh: {BED_TEMP}c_{CHAMBER_TEMP}c ..."
BED_MESH_PROFILE LOAD={BED_TEMP}c_{CHAMBER_TEMP}c
{% else %}
M117 Adaptative bed mesh: {mesh_min}-{mesh_max} coordinates, {algorithm} algorithm, {probe_count} probe count...
RESPOND MSG="Adaptative bed mesh: {mesh_min}-{mesh_max} coordinates, {algorithm} algorithm, {probe_count} probe count..."
BED_MESH_CLEAR
#BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1 ADAPTIVE_MARGIN=5
BED_MESH_CALIBRATE PROFILE=adaptative mesh_min={mesh_min} mesh_max={mesh_max} ALGORITHM={algorithm} PROBE_COUNT={probe_count} ADAPTIVE=0 ADAPTIVE_MARGIN=0
{% endif %}
{% endif %}
BOX_GO_TO_EXTRUDE_POS#M1500
M117 Heating Nozzle {EXTRUDER_TEMP} ...
RESPOND MSG="Heating Nozzle {EXTRUDER_TEMP} ..."
M109 S{EXTRUDER_TEMP} ;wait nozzle heating
# the stock chamber heater configuration is watermark
# which means at best it will reach the target temp, but rarely exceed it
# for materials like ASA the chamber temp should be a _minimum_
{% if HEAT_BUMP == 1%}
{% if CHAMBER_TEMP > 0 %}
{% if CHAMBER_TEMP + 5 <= 60 %}
M141 S{CHAMBER_TEMP + 5}
{% else %}
M141 S60
{% endif %}
{% endif %}
{% endif %}
M220 S100 ;Reset Feedrate
# M221 S100 ;Reset Flowrate
G21
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=10
M204 S5000
SET_VELOCITY_LIMIT ACCEL_TO_DECEL=5000
G92 E0 ; Reset Extruder
SET_PIN PIN=extruder_fan VALUE=1
# set the initial tool
M117 Loading Tool {START_TOOL} ...
RESPOND MSG="Loading Tool {START_TOOL} ..."
T{START_TOOL}
# print purge line
PURGE_LINE PRINT_MIN={mesh_min} PRINT_MAX={mesh_max}
M117 Starting printing ...
RESPOND MSG="Starting printing ..."
### BED MESH OVERRIDES
[gcode_macro _CREATE_MESH]
gcode:
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set CHAMBER_TEMP = params.CHAMBER_TEMP|default(0)|float %}
{% set PROFILE_NAME = BED_TEMP|string + 'c_' + CHAMBER_TEMP|string + 'c' %}
## make these configurable
{% set SOAK_TIME = params.SOAK_TIME|default(5)|float %}
{% set EXTRUDER_WAITTEMP = (140.0|float)|int %}
{% if not 'xyz' in printer.toolhead.homed_axes %}
M117 Homing ...
RESPOND MSG="Homing ..."
G28
{% endif %}
# heating nozzle mesh temperature
M104 S{EXTRUDER_WAITTEMP}
# heating bed
M117 Heating Bed {BED_TEMP} ...
RESPOND MSG="Heating Bed {BED_TEMP} ..."
M190 S{BED_TEMP}
# heating nozzle mesh temperature
M117 Heating Nozzle {EXTRUDER_WAITTEMP} ...
RESPOND MSG="Heating Nozzle {EXTRUDER_WAITTEMP} ..."
M109 S{EXTRUDER_WAITTEMP}
{% if CHAMBER_TEMP > 0 %}
M117 Heating Chamber {CHAMBER_TEMP} ...
RESPOND MSG="Heating Chamber {CHAMBER_TEMP} ..."
M191 S{CHAMBER_TEMP}
{% endif %}
M117 Heat soaking for {SOAK_TIME} minutes ...
RESPOND MSG="Heat soaking for {SOAK_TIME} minutes ..."
G4 P{60000 * SOAK_TIME} # x minute heat soak
# ensure bed is level
# some users have reported that the bed does not raise uniformly from the bottom
M117 Adjusting Z TILT ...
RESPOND MSG="Adjusting Z TILT ..."
Z_TILT_ADJUST
# rehome Z after tilt adjust
M117 re-Homing Z ...
RESPOND MSG="re-Homing Z ..."
G28 Z
BOX_NOZZLE_CLEAN
M117 Creating Mesh {PROFILE_NAME} ...
RESPOND MSG="Creating Mesh {PROFILE_NAME} ..."
BED_MESH_CALIBRATE PROFILE={PROFILE_NAME}
M117 Saving Config ...
RESPOND MSG="Saving Config ..."
CXSAVE_CONFIG
[gcode_macro MESH_IF_NEEDED]
gcode:
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set CHAMBER_TEMP = params.CHAMBER_TEMP|default(0)|float %}
{% set PROFILE_NAME = BED_TEMP|string + 'c_' + CHAMBER_TEMP|string + 'c' %}
## make these configurable
{% set SOAK_TIME = params.SOAK_TIME|default(5)|float %}
{% if printer.scanner %} # cartographer
_CREATE_MESH BED_TEMP={BED_TEMP} CHAMBER_TEMP={CHAMBER_TEMP} SOAK_TIME={SOAK_TIME}
{% else %}
RESPOND MSG="Looking for {PROFILE_NAME} ..."
{% if PROFILE_NAME in printer.bed_mesh.profiles %}
RESPOND MSG="{PROFILE_NAME} exists ..."
{% else %}
M117 Mesh {PROFILE_NAME} missing
RESPOND MSG="{PROFILE_NAME} does not exist, creating ..."
_CREATE_MESH BED_TEMP={BED_TEMP} CHAMBER_TEMP={CHAMBER_TEMP} SOAK_TIME={SOAK_TIME}
{% endif %}
{% endif %}
### ADAPTATIVE PURGE compatible with PrusaSlicer, Orca Slicer, Super Slicer and Bambu Studio
# more information https://www.printables.com/model/1035759-adaptive-purge-for-any-3d-printer-using-slicer-var/files
[gcode_macro PURGE_LINE]
gcode:
# coordinates from the slicer start gcode
{% set x0 = params.PRINT_MIN.split(",")[0]|default(-1)|float %}
{% set y0 = params.PRINT_MIN.split(",")[1]|default(-1)|float %}
{% set x1 = params.PRINT_MAX.split(",")[0]|default(-1)|float %}
{% set y1 = params.PRINT_MAX.split(",")[1]|default(-1)|float %}
RESPOND MSG="ADAPTATIVE PURGE LINE: Recieved coordinates X0={x0} Y0={y0} X1={x1} Y1={y1}"
M204 S2000
G1 Z3 F600
M83
{% if printer['gcode_macro _START_PRINT_VARS'].purge_adaptative == 0 %}
M117 K2 Purge Line
RESPOND MSG="K2 Purge Line"
G1 Y150 F12000
G1 X0 F12000
G1 Z0.2 F600
G1 X0 Y150 F6000
G1 X0 Y0 E15 F6000
G1 X150 Y0 E15 F6000
{% endif %}
{% if printer['gcode_macro _START_PRINT_VARS'].purge_adaptative == 1 %}
M117 Adaptative Purge Line 1 - Vertical Lower Right
RESPOND MSG="Adaptative Purge Line 1 - Vertical Lower Right"
G92 E0.0 ; reset extruder
G1 X{x1+10} Y{y1} Z0.8 F6000.0 ; position 10mm right of the lower right of the first layer
G1 X{x1+10} Y{y1+30} E30 F360.0 ; extrude 30mm of filament in the y direction
G92 E0.0 ; reset extruder
G1 E-0.5 F2100 ; small retraction
G1 Y{y1+40} F6000.0 ; move an additional 10mm without extruding
{% endif %}
{% if printer['gcode_macro _START_PRINT_VARS'].purge_adaptative == 2 %}
M117 Adaptative Purge Line 2 - Horizontal Lower Left
RESPOND MSG="Adaptative Purge Line 2 - Horizontal Lower Left"
G92 E0.0 ; reset extruder
G1 X{x0} Y{y0-10} Z0.8 F6000.0 ; position 10mm down from the lower left of the first layer
G1 X{x0+30} Y{y0-10} E30 F360.0 ; extrude 30mm of filament in the x direction
G92 E0.0 ; reset extruder
G1 E-0.5 F2100 ; small retraction
G1 X{x0+40} F6000.0 ; move an additional 10mm without extruding
{% endif %}
{% if printer['gcode_macro _START_PRINT_VARS'].purge_adaptative == 3 %}
M117 Adaptative Purge Line 3 - Vertical Lower Left
RESPOND MSG="Adaptative Purge Line 3 - Vertical Lower Left"
G92 E0.0 ; reset extruder
G1 X{x0-10} Y{y0} Z0.8 F6000.0 ; position 10mm left from the lower left of the first layer
G1 X{x0-10} Y{y0+30} E30 F360.0 ; extrude 30mm of filament in the y direction
G92 E0.0 ; reset extruder
G1 E-0.5 F2100 ; small retraction
G1 Y{y0+40} F6000.0 ; move an additional 10mm without extruding
{% endif %}
{% if printer['gcode_macro _START_PRINT_VARS'].purge_adaptative == 4 %}
M117 Adaptative Purge Line 4 - Horizontal Upper Right
RESPOND MSG="Adaptative Purge Line 4 - Horizontal Upper Right"
G92 E0.0 ; reset extruder
G1 X{x1} Y{y1+10} Z0.8 F6000.0 ; position 10mm up from the upper right of the first layer
G1 X{x1-30} Y{y1+10} E30 F360.0 ; extrude 30mm of filament in the x direction
G92 E0.0 ; reset extruder
G1 E-0.5 F2100 ; small retraction
G1 X{x1-40} F6000.0 ; move an additional 10mm without extruding
{% endif %}
{% if printer['gcode_macro _START_PRINT_VARS'].purge_adaptative == 5 %}
M117 Adaptative Purge Line 5 - Triangle Lower Left
RESPOND MSG="Adaptative Purge Line 5 - Triangle Lower Left"
G92 E0.0 ; reset extruder
G1 X{x0-10} Y{y0} Z0.8 F6000.0 ; position 10mm left from the lower left of the first layer
G1 X{x0-10} Y{y0+30} E30 F360.0 ; extrude 30mm of filament in the y direction
G92 E0.0 ; reset extruder
G1 X{x0-30} Y{y0+15} E30 F360.0 ; extrude 30mm of filament in both the x and y direction
G92 E0.0 ; reset extruder
G1 X{x0-10} Y{y0} E30 F360.0 ; extrude 30mm of filament returning back to the start
G92 E0.0 ; reset extruder
G1 E-0.5 F2100 ; small retraction
G1 X{x0-10} Y{y0-10} F6000.0 ; move an additional 10mm without extruding
{% endif %}
G92 E0.0 ; reset extruder
G1 Z3 F600
M117 Finished purge line ...
RESPOND MSG="Finished purge line ..."
### M191 OVERRIDES
[gcode_macro M191]
#TODO: should this leverage the existing M141?
description: Set and wait for chamber temperature, with intelligent bed assist
gcode:
SAVE_GCODE_STATE NAME=M191
# Parameters
{% set S = params.S|default(0)|float %}
{% if S == 0 %}
TURN_OFF_HEATERS
M107
{% else %}
M117 Heating chamber
{% if S > 35.0 %}
RESPOND MSG="The chamber heater alone can not reach {S}c, using bed assist ..."
# bed needs to raise to near the nozzle
{% if "xyz" not in printer.toolhead.homed_axes %}
G28
{% endif %}
G1 Z5 F600
{% if printer.heater_bed.target > 99.0 %}
RESPOND MSG="Bed target temp already high enough, not changing ..."
{% else %}
RESPOND MSG="Bed target temp not high enough, setting to 105c ..."
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET=105
{% endif %}
SET_PIN PIN=fan2 VALUE=153
{% endif %}
# turn on the fan to help
SET_TEMPERATURE_FAN_TARGET TEMPERATURE_FAN=chamber_fan TARGET={S}
# Set chamber temperature
SET_HEATER_TEMPERATURE HEATER=chamber_heater TARGET={S}
# Wait indefinitely for temperature
TEMPERATURE_WAIT SENSOR="temperature_sensor chamber_temp" MINIMUM={S} MAXIMUM={S+5}
RESPOND MSG="Chamber temperature {S}c reached ..."
{% endif %}
RESTORE_GCODE_STATE NAME=M191