diff --git a/printer_data/config/printer.cfg b/printer_data/config/printer.cfg index d1ae7c7..6c42971 100644 --- a/printer_data/config/printer.cfg +++ b/printer_data/config/printer.cfg @@ -626,18 +626,27 @@ gcode: [gcode_macro PRINT_START] description: Heat, home, level, touch-calibrate, scan adaptively, and purge +# Touch runs at 150 C, but the hotend grows as it heats further, which lowers +# the nozzle at print temperature (most visible with ABS at 250-260 C). +# Compensation = (EXTRUDER - touch_temp) * thermal_z_per_c, applied as a Z +# gcode offset. Tune the base height only with TOUCH_SAVE_Z_OFFSET. +variable_touch_temp: 150 +variable_thermal_z_per_c: 0.0004 +variable_thermal_z_comp: 0.0 gcode: {% set bedtemp = params.BED|int %} {% set hotendtemp = params.EXTRUDER|int %} + {% set thermal_z_comp = ([hotendtemp - touch_temp, 0]|max * thermal_z_per_c)|round(3) %} SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout|int} G90 SET_GCODE_OFFSET Z=0 + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=thermal_z_comp VALUE=0.0 SET_FAN_SPEED FAN=front SPEED=0.55 STATUS_HOMING G28 # Soften residue while the bed heats; Cartographer Touch uses at most 150 C. - M104 S150 + M104 S{touch_temp} STATUS_HEATING M190 S{bedtemp} {% if bedtemp > 95 %} @@ -647,7 +656,8 @@ gcode: {% endif %} STATUS_LEVELING QUAD_GANTRY_LEVEL - M109 S150 + # The nozzle has been at touch_temp since homing, so tip residue is soft for the wipe. + M109 S{touch_temp} STATUS_CLEANING CLEAN_NOZZLE STATUS_CALIBRATING_Z @@ -658,10 +668,23 @@ gcode: M107 STATUS_HEATING M109 S{hotendtemp} + SET_GCODE_OFFSET Z={thermal_z_comp} MOVE=0 + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=thermal_z_comp VALUE={thermal_z_comp} + { action_respond_info("PRINT_START: hot-nozzle Z compensation +%.3f mm for %d C" % (thermal_z_comp, hotendtemp)) } STATUS_CLEANING LINE_PURGE STATUS_PRINTING +[gcode_macro TOUCH_SAVE_Z_OFFSET] +description: Store baby-stepping into the Touch model without the hot-nozzle compensation; then run SAVE_CONFIG +gcode: + {% set comp = printer["gcode_macro PRINT_START"].thermal_z_comp|float %} + {% set total = printer.gcode_move.homing_origin.z|float %} + { action_respond_info("TOUCH_SAVE_Z_OFFSET: gcode offset %.3f, of which hot-nozzle compensation %.3f; saving %.3f" % (total, comp, total - comp)) } + SET_GCODE_OFFSET Z_ADJUST={-comp} MOVE=0 + Z_OFFSET_APPLY_PROBE + SET_GCODE_OFFSET Z_ADJUST={comp} MOVE=0 + [gcode_macro CARTOGRAPHER_MESH] description: Adaptive scan with a safe full-mesh fallback for unreachable edge-only objects gcode: