Skip to content

Conversation

@irrenhaus
Copy link

This PR adds a new config variable offset_macro.

When set to the name of a gcode_macro, instead of setting the calculated Z offset via SET_GCODE_OFFSET the configured macro is called with a parameter Z being set to the calculated offset value.

The reasoning behind this lies in toolchanging systems, in my case specifically Lineux: https://github.com/Bikin-Creative/Lineux-Toolchanger

For compensating any differences of the different tools in XYZ, all tools are measured against a common reference tool, most often T0.
Upon a toolchange to a different tool then SET_GCODE_OFFSET is used to adjust the motion system to the different nozzle position of the tool.
This in turn invalidates any changes made by klipper_z_calibration.

This PR now allows to:

  • Measure all tools of the toolchanger against T0
  • On each print, run CALIBRATE_Z for T0 calling a custom macro that lets the toolchanging code know about the new offset
  • Have the toolchanging code apply the measure offset additionally to the measured tool offsets at each toolchange

Example macro for Lineux:

[gcode_macro Z_CALIBRATION_SET_OFFSET_MACRO]
gcode:
  {% set z_offset = params.Z|default(0.0)|float %}
  RESPOND MSG="Forwarding Z offset adjustment of {z_offset} to Lineux"
  SET_GCODE_VARIABLE MACRO=_btc_Variables VARIABLE=gcode_offset_z_adjust VALUE={z_offset}
  SET_GCODE_OFFSET Z_ADJUST={z_offset}

Lineux then runs
SET_GCODE_OFFSET Z_ADJUST={printer["gcode_macro _btc_Variables"].gcode_offset_z_adjust} MOVE=1 on each toolchange.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant