Wanted to share again some of ‘tools’ I use when printing with K2 (this macro with other values I use also on other printers).
I had to change my nozzle because after 500+ hours of printing with it it was starting to clog every 2nd print, even with some PLA and always with PETG.
After replacing the nozzle and running all printer calibration I realized that I need to increase my Z-Offset by +0.02 mm now because even PLA was pushed too much into print plate.
On top of that I bought a 3rd party print plate (on AliExpress) which has one one side a golden textured PEI and on the other side a black flat carbon laser texture. For the flat side I user the ‘high temp plate’ settings in slice but it needs also some increased Z-offset of additional +0.06mm.
Most of my PETG needs also +0.025 Z-Offset so therefore to automatically set the right Z-Offset I use the the below macro:
#[gcode_macro MY_PRINT_START] sets Z-Offset based on print bed and filament type
[respond]
# the [respond] is needed to make m118 working and echo output! You need it only once in you macro file....
[gcode_macro MY_PRINT_START]
description: Add this to the "Machine start G-Code" section after the line "START_PRINT ..." in your special printer config file.
Usage: MY_PRINT_START FILAMENT_TYPE="{filament_type[initial_no_support_extruder]}" CURR_BED_TYPE="{curr_bed_type}" N_ZO=<your default offset>
gcode:
{% set CURR_BED_TYPE = params.CURR_BED_TYPE|default('none')|string %}
{% set FILAMENT_TYPE = params.FILAMENT_TYPE|default('none')|string %}
{% set N_ZO = params.N_ZO|default(0.0)|float %}
M118 My_PRINT_START with {FILAMENT_TYPE} and {CURR_BED_TYPE} @{N_ZO}
{% if FILAMENT_TYPE == 'PETG' %}
M118 PETG filament detected, increasing Z-Offset by 0.025!
{% set N_ZO = N_ZO + 0.025 %}
{% elif FILAMENT_TYPE == 'TPU' %}
{% set N_ZO = N_ZO + 0.025 %}
# {% else %}
# {% set N_ZO = N_ZO + 0.0 %}
{% endif %}
{% if CURR_BED_TYPE == 'High Temp Plate' %}
M118 High Temp Plate (flat) detected, increasing Z-Offset by 0.09!
{% set N_ZO = N_ZO + 0.06 %}
# {% elif CURR_BED_TYPE == ['Textured PEI Plate'] %}
# {% set N_ZO = N_ZO + 0.0 %}
# {% else %}
# {% set N_ZO = N_ZO + 0.09 %}
{% endif %}
M118 The new ZO is: {N_ZO}
SET_GCODE_OFFSET Z={N_ZO} MOVE=1
You can put the macro directly in the printer.cfg with fluidd but I have it in my ‘my_macros.cfg’ file which I include in ‘printer.cfg’ with
[include my_macros.cfg]
In this way I need to upload after firmware updates only my_macros.cfg and edit into printer.cfg only above line if firmware update changes printer.cfg.
Anyhow, to make the above macro working you need to run the macro also in your printer start code in slicer.
You need to enter in the ‘Machine start G-Code’ section after the ‘START_PRINT’ line
MY_PRINT_START FILAMENT_TYPE="{filament_type[initial_no_support_extruder]}" CURR_BED_TYPE="{curr_bed_type}" N_ZO=0.0
Where N_ZO will be the Z-Offset you would need with PLA on the textured print plate, before I changed my nozzle it was 0.0 but now it is 0.02!
In ‘Machine end G-Code’ you need to enter before the ‘END_PRINT’ line
SET_GCODE_OFFSET Z=0.0 MOVE=1
In this way the macro will be called just before loading filament and printing the purge line (which is important that purge line is also affected). At print end the Z-Offset is reset to 0 (or whatever you want or need).
The MY_PRINT_START macro itself is (in the listed version) only checking if filament = ‘PETG’ and if yes adding 0.025mm (you may change this for your filament needs) and then it’s checking if print plate = ‘High temp Plate’ and if yess adding my 0.06mm for this plate.
So in my case when I print PLA on textured plate the Z-Offset will be 0.02, for PETG it would be 0.045 and on High temp plate it would be 0.08 for PLA and 0.105 for PETG.
You may extend the macro for other filament or bed types as well, I use for TPU for example also the PETG settings.
All the best for your print optimization!