Giter VIP home page Giter VIP logo

klipper.macro.g28_override's Introduction

Homing (G28) override for Klipper [v.3]

This macro overrides klipper ( https://github.com/KevinOConnor/klipper ) homing process to make a better customisation and

Dependencies

Requires having this somewhere in your printer configuration for SET_KINEMATIC_POSITION to work

[force_move]
enable_force_move: true

How to install

  1. download file through any method (file download, git clone, etc) to the computer running klipper
  2. add to configuration ( https://github.com/KevinOConnor/klipper/blob/master/docs/Config_Reference.md#include )
[include path/to/folder/macro_g28_override.cfg]
  1. also add to configuration if respond is not already configured ( https://github.com/KevinOConnor/klipper/blob/master/docs/Config_Reference.md#respond )
[respond]

and

[force_move]
enable_force_move: true
  1. configure homing as described below

Example File

[include macro_g28.cfg]

[gcode_macro HOMING_CONFIG]
variable_order: "x,y,z"
variable_dowith_z: "x,y"
variable_start_zhop: 20
gcode:
  RESPOND PREFIX="info" MSG="Homing config..."

[gcode_macro HOMING_OVERRIDE_BEFORE]
gcode:
    RESPOND PREFIX="info" MSG="Homing > Before homing: {params.X} - {params.Y} - {params.Z}"

[gcode_macro HOMING_OVERRIDE_X]
gcode:
    RESPOND PREFIX="info" MSG="Homing > X"
    G90
    G990028 X0
    G91
    G0 X-5 F2000
    G90

  
[gcode_macro HOMING_OVERRIDE_Y]
gcode:
    RESPOND PREFIX="info" MSG="Home > Y"
    G90
    G990028 Y0
    G91
    G0 Y-5 F2000
    G90

[gcode_macro HOMING_OVERRIDE_Z]
gcode:
    RESPOND PREFIX="info" MSG="Homing > Z"
    G90
    G0 X220 Y220
    G990028 Z0
    G91
    G0 Z30
    G90

[gcode_macro HOMING_OVERRIDE_AFTER]
gcode:
    RESPOND PREFIX="info" MSG="Homing > After homing: {params.X} - {params.Y} - {params.Z}"

Configuration

You need to add some configuration for these macros to be useful For example the configuration below has

  • order of homing: X then Y then Z
  • X and Y can be homed independently
  • Z requires both X and Y to be homed (and because of order settings, if you home only Z then X Y and Z will be homed in this specific order)
[gcode_macro HOMING_CONFIG]
variable_order: "y,x,z"
variable_dowith_z: "x,y"
variable_start_zhop: 20
gcode:
  RESPOND PREFIX="info" MSG="Homing config"

Read below for description of settings

Features

Keep track of actual homing status and can allow homing of each axis only when needed

When zero value is specified axis will not be homed if already "real" homed G28 X0 - will home only if needed G28 X - will always home X, regardless of status

Home Ordering

By editing adding the following configuration in your printer config file you can change the default homing order

[gcode_macro HOMING_OVERRIDE_CONFIG]
variable_order: "x,y,z"
gcode:
  RESPOND PREFIX="info" MSG="Homing config"

Just edit the "x,y,z" and put any order you want in it. Make sure all axis you want to home are set there, since if you skip one it will not be homed. Use lowercase letters for all axies.

Homing Dependencies

Sometimes homing an axis requires another one to be also homed, for example you want to home Y before X every time. In this case G28 X should home Y then X. This is resolved by setting homing order (see above) to "y,x,z" then set Y as a dependency of x by adding this to your config file

[gcode_macro HOMING_OVERRIDE_CONFIG]
variable_dowith_x: "y"
gcode:
  RESPOND PREFIX="info" MSG="Homing config"

If you don't want/need a dependency for an axis, just comment or remove that line

Homing Z-hop start

If you want to start homing by lifting the printhead (relative to bed), you can use this setting

[gcode_macro HOMING_OVERRIDE_CONFIG]
variable_start_zhop: 20
gcode:
  RESPOND PREFIX="info" MSG="Homing config"

Overriding individual axis homing

For each axis you can create a macro named "HOMING_OVERRIDE_<axis_name>" like below. Each gcode must contain G990028 X0 gcode command - replace X with the axis you're overriding

[gcode_macro HOMING_OVERRIDE_X]
gcode:
  RESPOND PREFIX="info" MSG="Homing > X"
  G90
  G990028 X0
  G91
  G0 X5 F2000
  G90
  
[gcode_macro HOMING_OVERRIDE_Y]
gcode:
  RESPOND PREFIX="info" MSG="Home > Y"
  G90
  G990028 Y0
  G91
  G0 Y-5 F2000
  G90
  
[gcode_macro HOMING_OVERRIDE_Z]
gcode:
  RESPOND PREFIX="info" MSG="Homing > Z"
  G90
  G0 X100 Y100
  G990028 Z0
  G91
  G0 Z20
  G90

You can override only the axis you need.

Overriding initial Z hop

[gcode_macro HOMING_OVERRIDE_ZHOP]
gcode:
  RESPOND PREFIX="info" MSG="Homing > Z Hop"
  SET_KINEMATIC_POSITION Z=0
  G91
  G0 Z{printer['gcode_macro HOMING_CONFIG'].start_zhop|int}
  G90

Run gcode before and after homing

These macros are called with paremeters X=1 Y=1 Z=1 where value is 1 for the axis that will be/were homed

[gcode_macro HOMING_OVERRIDE_BEFORE]
gcode:
  RESPOND PREFIX="info" MSG="Homing > Before G-code"
  

[gcode_macro HOMING_OVERRIDE_AFTER]
gcode:
  RESPOND PREFIX="info" MSG="Homing > After G-code"

klipper.macro.g28_override's People

Contributors

vladbabii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

klipper.macro.g28_override's Issues

Odd behavior when homing

I've set this up on one of my printers. I need customized homing because currently my Y endstop is in the middle of the X axis, not at any of the corners. So I need to home X, move to Xmax/2, home Y, move to the center of the bed, and probe Z.

Most of what I have in the various macros is taken directly from github -- either the readme, or the macro file. I did modify the homing overrides to reflect the logic above.

I fully expect that there is something I'm doing wrong. I just can't figure it out.
Here are my test cases:

  • Scenario 1

    1. FIRMWARE_RESTART
    2. Send G28, or use the home button in Mainsail or Fluidd: The printer homes perfectly.
    3. Print a file: The printer will home again, and the print will start successfully
    4. Reprint the same file: The printer will attempt to home again, but it will fail. Immediately after seeing Homing > X, I get the following error message: Must home axis first: 20.000 0.000 -0.037 [0.000]
  • Scenario 2

    1. FIRMWARE_RESTART
    2. Print a file: The printer will attempt to home, and it will fail. Immediately after seeing Homing > X, I get the following error message: Must home axis first: 20.000 0.000 -0.037 [0.000]
    3. Send G28, or use the home button in Mainsail or Fluid: Immediately after seeing Homing > X, I get the following error message: Must home axis first: 20.000 0.000 -0.037 [0.000]

Every time I get the error about homing the axis first, it always seems to be trying to move to X20, but I can't figure out why. The error message pops up after "Homing > X". However, I never get the "Homed > X. Moving to center" message that I added to the X override macro. Which makes me think that the issue is somewhere with G990028 X0. But I can't find any reason why it is trying to move to X20 or why it works is specific cases.

Currently my process to print is:

  1. FIRMWARE_RESTART
  2. G28
  3. Print file.

If I do anything else, it fails.

I use SuperSlicer as my slicer, and my start GCODE is simply: START_PRINT EXTRUDER_TEMP=[first_layer_temperature] BED_TEMP=[first_layer_bed_temperature]

Here are the sections of the config that I think are relevant to this.

#printer.cfg
[include macros/*.macro.cfg]

My start print macro:

#macros/start_print.macro.cfg
[gcode_macro START_PRINT]
gcode:
  {% set BED_TEMP = params.BED_TEMP|default(70)|float %}
  {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(210)|float %}
  # Load the bed mesh
  BED_MESH_PROFILE LOAD=default
  # Start bed heating
  M140 S{BED_TEMP}
  # Set nozzle heating
  M104 S160
  # Use absolute coordinates
  G90
  # Home the printer
  G28
  # Wait for bed temperature
  M190 S{BED_TEMP}
  # Move the nozzle to the spot for the prime line
  G1 Z2 F240
  G1 X2 Y10 F3000
  # Wait for extruder temperature
  M109 S{EXTRUDER_TEMP}
  PRIMING_LINE

and my macro g28 override file:

# macros/macro_g28_override.macro.cfg
[gcode_macro HOMING_CONFIG]
variable_order: "x,y,z"
variable_dowith_z: "x,y"
variable_dowith_y: "x"
variable_start_zhop: 20
gcode:
  RESPOND PREFIX="info" MSG="Homing config..."

[gcode_macro HOMING_STATUS]
variable_x: 0
variable_y: 0
variable_z: 0
gcode:
  RESPOND PREFIX="info" MSG="Homing status: 0=not homed, 1=real homed, 2=fake home"
  RESPOND PREFIX="info" MSG=" X: {printer['gcode_macro HOMING_STATUS'].x}"
  RESPOND PREFIX="info" MSG=" Y: {printer['gcode_macro HOMING_STATUS'].y}"
  RESPOND PREFIX="info" MSG=" Z: {printer['gcode_macro HOMING_STATUS'].z}"

[gcode_macro M84]
rename_existing: G990084
gcode:
  RESPOND PREFIX="info" MSG="Disable Steppers > Marking as not homed..."
  SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=x VALUE=0
  SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=y VALUE=0
  SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=z VALUE=0
  G990084
  RESPOND PREFIX="info" MSG="Disable Steppers > Steppers disabled"

[gcode_macro M18]
rename_existing: G990018
gcode:
  RESPOND PREFIX="info" MSG="Disable Steppers > ..."
  SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=x VALUE=0
  SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=y VALUE=0
  SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=z VALUE=0
  G990018

[gcode_macro SET_KINEMATIC_POSITION]
rename_existing: REAL_SET_KINEMATIC_POSITION
gcode:
  {% if params.X is defined %}
    RESPOND PREFIX="info" MSG="SET_KINEMATIC_POSITION > X={params.X}"
    REAL_SET_KINEMATIC_POSITION X={params.X}
    SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=x VALUE=2
  {% endif %}

  {% if params.Y is defined %}
    RESPOND PREFIX="info" MSG="SET_KINEMATIC_POSITION > Y={params.Y}"
    REAL_SET_KINEMATIC_POSITION Y={params.Y}
    SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=y VALUE=2
  {% endif %}

  {% if params.Z is defined %}
    RESPOND PREFIX="info" MSG="SET_KINEMATIC_POSITION > Z={params.Z}"
    REAL_SET_KINEMATIC_POSITION Z={params.Z}
    SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=z VALUE=2
  {% endif %}

[gcode_macro HOMING_NOW]
variable_do_x: 0
variable_do_y: 0
variable_do_z: 0
gcode:
  RESPOND PREFIX="info" MSG="Homing > Nothing to see here"

[gcode_macro G28]
rename_existing: G990028
gcode:
  SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_x VALUE=0
  SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_y VALUE=0
  SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_z VALUE=0

  {% set status_x = printer['gcode_macro HOMING_STATUS'].x|int %}
  {% set status_y = printer['gcode_macro HOMING_STATUS'].y|int %}
  {% set status_z = printer['gcode_macro HOMING_STATUS'].z|int %}

  {% set axis = printer['gcode_macro HOMING_CONFIG'].order.split(',') %}

  {% for i in axis %}
    {% set i = i|upper %}
    RESPOND PREFIX="info" MSG="Home > Checking {i}"

    {% if i=="X" %}
       {% if params.X is defined %}
        RESPOND PREFIX="info" MSG="Home > X is defined - {params.X}"
        {% if params.X|string=="0" and status_x==1 %}
          RESPOND PREFIX="info" MSG="Home > Skipping X (already homed)"
        {% else %}
          RESPOND PREFIX="info" MSG="Home > Homing X"
          SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_x VALUE=1
        {% endif %}
      {%else%}
        RESPOND PREFIX="info" MSG="Home > X is NOT defined"
      {% endif %}
    {% endif %}

    {% if i=="Y" %}
      {% if params.Y is defined %}
        RESPOND PREFIX="info" MSG="Home > Y is defined - {params.Y}"
        {% if params.Y|string=="0" and status_y==1 %}
          RESPOND PREFIX="info" MSG="Home > Skipping Y (already homed)"
        {% else %}
          RESPOND PREFIX="info" MSG="Home > Homing Y"
          SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_y VALUE=1
        {% endif %}
      {% else %}
        RESPOND PREFIX="info" MSG="Home > Y is NOT defined"
      {% endif %}
    {% endif %}

    {% if i=="Z" %}
      {% if params.Z is defined %}
        RESPOND PREFIX="info" MSG="Home > Z is defined - {params.Z}"
        {% if params.Z|string=="0" and status_z==1 %}
          RESPOND PREFIX="info" MSG="Home > Skipping Z (already homed)"
        {% else %}
          RESPOND PREFIX="info" MSG="Home > Homing Z"
          SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_z VALUE=1
        {% endif %}
      {% else %}  
        RESPOND PREFIX="info" MSG="Home > Z is NOT defined"
      {% endif %}
    {% endif %}

  {% endfor %}

  {% if ( params.X is not defined ) and ( params.Y is not defined ) and ( params.Z is not defined ) %}
    RESPOND PREFIX="info" MSG="Home > No parameters for home given, doing all configured axis {printer['gcode_macro HOMING_CONFIG'].order}"
    SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_x VALUE=1
    SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_y VALUE=1
    SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_z VALUE=1 
  {% endif %}

  G28002

[gcode_macro G28002]
gcode:
  {% set axis = printer['gcode_macro HOMING_CONFIG'].order.split(',') %}
  ## check do_width
  {% for i in axis %}
    {% set i = i|upper %}
    RESPOND PREFIX="info" MSG="Home > Checking dependency for {i} {do_x} {do_y} {do_z}"

    {% if i=="X" and printer['gcode_macro HOMING_NOW'].do_x|int==1 %}
      {% if printer['gcode_macro HOMING_CONFIG'].dowith_x is defined %}
        RESPOND PREFIX="info" MSG="Home > Checking dependency dowith X"
        {% set list = printer['gcode_macro HOMING_CONFIG'].dowith_x.split(',') %}
        {% for j in list %}
          RESPOND PREFIX="info" MSG="Home > Checking dependency > {j}" 
          {% if (j|upper=="Y" and printer['gcode_macro HOMING_NOW'].do_y|int==0) %}
            SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_y VALUE=1
            RESPOND PREFIX="info" MSG="Home > Also homing {j|upper} due to dependency from {i}"
          {%endif%}
          {% if (j|upper=="Z" and printer['gcode_macro HOMING_NOW'].do_z|int==0) %}
            SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_z VALUE=1
            RESPOND PREFIX="info" MSG="Home > Also homing {j|upper} due to dependency from {i}"
          {%endif%}
        {% endfor %}
      {%endif%}
    {%endif%}

    {% if i=="Y" and printer['gcode_macro HOMING_NOW'].do_y|int==1 %}
      {% if printer['gcode_macro HOMING_CONFIG'].dowith_y is defined %}
        RESPOND PREFIX="info" MSG="Home > Checking dependency dowith Y"
        {% set list = printer['gcode_macro HOMING_CONFIG'].dowith_y.split(',') %}
        {% for j in list %}
          RESPOND PREFIX="info" MSG="Home > Checking dependency > {j}" 
          {% if (j|upper=="X" and printer['gcode_macro HOMING_NOW'].do_x|int==0) %}
            SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_x VALUE=1
            RESPOND PREFIX="info" MSG="Home > Also homing {j|upper} due to dependency from {i}"
          {%endif%}
          {% if (j|upper=="Z" and printer['gcode_macro HOMING_NOW'].do_z|int==0) %}
            SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_z VALUE=1
            RESPOND PREFIX="info" MSG="Home > Also homing {j|upper} due to dependency from {i}"
          {%endif%}
        {% endfor %}
      {%endif%}
    {%endif%}

    {% if i=="Z" and printer['gcode_macro HOMING_NOW'].do_z|int==1 %}
      {% if printer['gcode_macro HOMING_CONFIG'].dowith_z is defined %}
        RESPOND PREFIX="info" MSG="Home > Checking dependency dowith Z"
        {% set list = printer['gcode_macro HOMING_CONFIG'].dowith_z.split(',') %}
        {% for j in list %}
          RESPOND PREFIX="info" MSG="Home > Checking dependency > {j}" 
          {% if (j|upper=="Y" and printer['gcode_macro HOMING_NOW'].do_y|int==0) %}
            SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_y VALUE=1
            RESPOND PREFIX="info" MSG="Home > Also homing {j|upper} due to dependency from {i}"
          {%endif%}
          {% if (j|upper=="X" and printer['gcode_macro HOMING_NOW'].do_x|int==0) %}
            SET_GCODE_VARIABLE MACRO=HOMING_NOW VARIABLE=do_x VALUE=1
            RESPOND PREFIX="info" MSG="Home > Also homing {j|upper} due to dependency from {i}"
          {%endif%}
        {% endfor %}
      {%endif%}
    {%endif%}

  {%endfor%}

  G28003

[gcode_macro G28003]
gcode:
  ## show in console what will be homed
  {% if printer['gcode_macro HOMING_NOW'].do_x|int==0 and printer['gcode_macro HOMING_NOW'].do_y|int==0 and printer['gcode_macro HOMING_NOW'].do_z|int==0 %}

     RESPOND PREFIX="info" MSG="Home > Nothing to home, all requested axis are already homed"

  {% else %}
    {% set axis = printer['gcode_macro HOMING_CONFIG'].order.split(',') %}

    {% for i in axis %}
      {% set i = i|upper %}
      {% if i=="X" and printer['gcode_macro HOMING_NOW'].do_x|int==1 %}
        RESPOND PREFIX="info" MSG="Home > Todo: {i}"
      {%endif%}
      {% if i=="Y" and printer['gcode_macro HOMING_NOW'].do_y|int==1 %}
        RESPOND PREFIX="info" MSG="Home > Todo: {i}"
      {%endif%}
      {% if i=="Z" and printer['gcode_macro HOMING_NOW'].do_z|int==1 %}
        RESPOND PREFIX="info" MSG="Home > Todo: {i}"
      {%endif%}
    {%endfor%}

    G28004

  {% endif %}

[gcode_macro G28004]
gcode:
  ## precheck if homing is defined - abort with m112 
   {% set axis = printer['gcode_macro HOMING_CONFIG'].order.split(',') %}

  {% for i in axis %}
    {% set i = i|upper %}

    {% if i=="X" and printer['gcode_macro HOMING_NOW'].do_x|int==1 %}
      {% if printer['gcode_macro HOMING_OVERRIDE_X'] is not defined and printer['gcode_macro HOMING_DEFAULT_X'] is not defined %}
        RESPOND PREFIX="error" MSG="Home > {i} > Uknown axis method"
        M112
      {%endif%}
    {%endif%}

    {% if i=="Y" and printer['gcode_macro HOMING_NOW'].do_y|int==1 %}
      {% if printer['gcode_macro HOMING_OVERRIDE_Y'] is not defined and printer['gcode_macro HOMING_DEFAULT_Y'] is not defined %}
        RESPOND PREFIX="error" MSG="Home > {i} > Uknown axis method"
        M112
      {%endif%}
    {%endif%}

    {% if i=="Z" and printer['gcode_macro HOMING_NOW'].do_z|int==1 %}
      {% if printer['gcode_macro HOMING_OVERRIDE_Z'] is not defined and printer['gcode_macro HOMING_DEFAULT_Z'] is defined %}
        RESPOND PREFIX="error" MSG="Home > {i} > Uknown axis method"
        M112
      {%endif%}
    {%endif%}
  {%endfor%}

  G28005

[gcode_macro G28005]
gcode:
  {% set axis = printer['gcode_macro HOMING_CONFIG'].order.split(',') %}

  {% if printer['gcode_macro HOMING_OVERRIDE_BEFORE'] is defined %}
    HOMING_OVERRIDE_BEFORE X={printer['gcode_macro HOMING_NOW'].do_x|int} Y={printer['gcode_macro HOMING_NOW'].do_y|int} Z={printer['gcode_macro HOMING_NOW'].do_z}
  {% else %}

    ## z hop first
    {% if printer['gcode_macro HOMING_NOW'].do_x|int==1 or printer['gcode_macro HOMING_NOW'].do_y|int==1 or printer['gcode_macro HOMING_NOW'].do_z|int==1 %}
      {% if printer['gcode_macro HOMING_OVERRIDE_ZHOP'] is defined %}
          HOMING_OVERRIDE_ZHOP
      {%endif%}
      {% if printer['gcode_macro HOMING_CONFIG'].start_zhop is defined and printer['gcode_macro HOMING_CONFIG'].start_zhop|int>0 %}
        {% if printer['gcode_macro HOMING_STATUS'].z|int != 1 %}
          RESPOND PREFIX="info" MSG="Home > Fake homing Z so it can move down prior to homing"
          REAL_SET_KINEMATIC_POSITION Z=0
        {% endif %}
        RESPOND PREFIX="info" MSG="Home > Moving up {printer['gcode_macro HOMING_CONFIG'].start_zhop} mm before homing"
        G91
        G0 Z{printer['gcode_macro HOMING_CONFIG'].start_zhop|int}
        G90
      {% endif %}
    {% endif %}

  {% endif %}

  ## actual homing
  {% for i in axis %}
    {% set i = i|upper %}

    {% if i=="X" and printer['gcode_macro HOMING_NOW'].do_x|int==1 %}
      {% if printer['gcode_macro HOMING_OVERRIDE_X'] is defined %}
        RESPOND PREFIX="info" MSG="Home > {i} > Homing Override"
        HOMING_OVERRIDE_X
        SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=x VALUE=1
      {% elif printer['gcode_macro HOMING_DEFAULT_X'] is defined %}
        RESPOND PREFIX="info" MSG="Home > {i} > Homing Default"
        HOMING_DEFAULT_X
        SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=x VALUE=1
      {%endif%}
    {%endif%}

    {% if i=="Y" and printer['gcode_macro HOMING_NOW'].do_y|int==1 %}
      {% if printer['gcode_macro HOMING_OVERRIDE_Y'] is defined %}
        RESPOND PREFIX="info" MSG="Home > {i} > Homing Override"
        HOMING_OVERRIDE_Y
        SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=y VALUE=1
      {% elif printer['gcode_macro HOMING_DEFAULT_Y'] is defined %}
        RESPOND PREFIX="info" MSG="Home > {i} > Homing Default"
        HOMING_DEFAULT_Y
        SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=y VALUE=1
      {%endif%}
    {%endif%}

    {% if i=="Z" and printer['gcode_macro HOMING_NOW'].do_z|int==1 %}
      {% if printer['gcode_macro HOMING_OVERRIDE_Z'] is defined %}
        RESPOND PREFIX="info" MSG="Home > {i} > Homing Override"
        HOMING_OVERRIDE_Z
        SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=z VALUE=1
      {% elif printer['gcode_macro HOMING_DEFAULT_Z'] is defined %}
        RESPOND PREFIX="info" MSG="Home > {i} > Homing Default"
        HOMING_DEFAULT_Z
        SET_GCODE_VARIABLE MACRO=HOMING_STATUS VARIABLE=z VALUE=1
      {%endif%}
    {%endif%}

  {%endfor%}

  {% if printer['gcode_macro HOMING_OVERRIDE_AFTER'] is defined %}
    HOMING_OVERRIDE_AFTER X={printer['gcode_macro HOMING_NOW'].do_x|int} Y={printer['gcode_macro HOMING_NOW'].do_y|int} Z={printer['gcode_macro HOMING_NOW'].do_z}
  {%endif%}

[gcode_macro HOMING_OVERRIDE_AFTER]
gcode:
    RESPOND PREFIX="info" MSG="Homing > After homing: {params.X} - {params.Y} - {params.Z}"

[gcode_macro HOMING_OVERRIDE_BEFORE]
gcode:
    RESPOND PREFIX="info" MSG="Homing > Before homing: {params.X} - {params.Y} - {params.Z}"

[gcode_macro HOMING_OVERRIDE_X]
gcode:
    RESPOND PREFIX="info" MSG="Homing > X"
    G90
    G990028 X0
    RESPOND PREFIX="info" MSG="Homed > X. Moving to center"
    G91
    G0 X115 F2000
    G90
    RESPOND PREFIX="info" MSG="Centered > X."  

[gcode_macro HOMING_OVERRIDE_Y]
gcode:
    RESPOND PREFIX="info" MSG="Home > Y"
    G0 X115
    G90
    G990028 Y
    G91
    G0 Y-50 F2000
    G90

[gcode_macro HOMING_OVERRIDE_Z]
gcode:
    RESPOND PREFIX="info" MSG="Homing > Z"
    G90
    G0 X115 Y125
    G990028 Z0
    G91
    G0 Z30
    G90

[gcode_macro HOMING_DEFAULT_X]
gcode:
  G990028 X

[gcode_macro HOMING_DEFAULT_Y]
gcode:
  G990028 Y

[gcode_macro HOMING_DEFAULT_Z]
gcode:
  G990028 Z

Homing override z hop

Not sure if this is an issue or an omission from the example config files. I have implemented these macros and they work well after some fiddling and getting to know them. The issue I have (but have resolved temporarily) is the use of the HOMING_OVERRIDE_ZHOP when I also have a HOMING_OVERRIDE_BEFORE defined. If both are true, the ZHOP doesn't get executed. I can see that from the [gcode_macro G28005] in that the ZHOP only gets executed if HOMING_OVERRIDE_BEFORE is not true.

As variable_start_zhop is included in the HOMING_CONFIG, shouldn't ZHOP ALWAYS get executed? It would seem like there is as chunk of code missing to do this when you have all the overrides configured.

For now, I've just put the macro HOMING_OVERRIDE_ZHOP in the gcode of the HOMING_OVERRIDE_BEFORE and that seems to work so far. I don't think it should have to be that way though.

Is this correct or am I missing something?

Great macros though so many thanks :)

My config file:

`###################################################################################################

Homing Macros

###################################################################################################

#------------------------------------------------------------------------------------ HOMING CONFIG
[gcode_macro HOMING_CONFIG]
variable_order: "x,y,z"
variable_dowith_z: "x,y"
variable_start_zhop: 20
gcode:
RESPOND PREFIX="info" MSG="Homing config..."

#---------------------------------------------------------------------------- HOMING OVERRIDE Z HOP
[gcode_macro HOMING_OVERRIDE_ZHOP]
gcode:
RESPOND PREFIX="info" MSG="Homing > Z Hop"
SET_KINEMATIC_POSITION Z=0
G91
G0 Z{printer['gcode_macro HOMING_CONFIG'].start_zhop|int}
G90

#--------------------------------------------------------------------------- HOMING OVERRIDE BEFORE
[gcode_macro HOMING_OVERRIDE_BEFORE]
gcode:
RESPOND PREFIX="info" MSG="Homing > Before homing: {params.X} - {params.Y} - {params.Z}"
BED_MESH_CLEAR
HOMING_OVERRIDE_ZHOP
LIGHTS_HOMING

#-------------------------------------------------------------------------------- HOMING OVERRIDE X
[gcode_macro HOMING_OVERRIDE_X]
gcode:
RESPOND PREFIX="info" MSG="Homing > X"
G90
G990028 X0
G91
G0 X-5 F2000
G90

#-------------------------------------------------------------------------------- HOMING OVERRIDE Y
[gcode_macro HOMING_OVERRIDE_Y]
gcode:
RESPOND PREFIX="info" MSG="Home > Y"
G90
G990028 Y0
G91
G0 Y-5 F2000
G90

#-------------------------------------------------------------------------------- HOMING OVERRIDE Z
[gcode_macro HOMING_OVERRIDE_Z]
gcode:
RESPOND PREFIX="info" MSG="Homing > Z"
G90
G0 X246.5 Y305 #Printer Z limit switch position
G990028 Z0
G91
G0 Z30
G90

#---------------------------------------------------------------------------- HOMING OVERRIDE AFTER
[gcode_macro HOMING_OVERRIDE_AFTER]
gcode:
RESPOND PREFIX="info" MSG="Homing > After homing: {params.X} - {params.Y} - {params.Z}"
LIGHTS_IDLE
BED_MESH_PROFILE LOAD=default`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.