Need a G30 / Probe then APPLY_PROBE_TO_Z_OFFSET in Start_Print Macro

Basic Information:

Printer Model: Custom Delta Printer
MCU / Printerboard: BTT SKR Pico
Host / SBC: Pi Zero 2 W
klippy.log: NA

Describe your issue:

I am looking for help or a macro to simulate the G30 command, or in Klipper, HOME then PROBE then APPLY_PROBE_TO_Z_OFFSET, then begin printing on my delta printer.

I would like to add this to my START_PRINT macro so that no matter what build plate I have, the printer will always probe the bed (Bl Touch) before starting a print job to set Z=0.

It seems my Z=0 drifts slightly (+/- 0.1 mm) due to ambient air temperature changes. This would help getting a good first layer. I use 3 different build plates and the meshes are almost identical, just at different heights due to the thickness differences.

I came across this post that seems like exactly what I am looking for, I just don’t know enough about macros to implement it properly.

I keep my macros in a separate folder and NOT in the printer.cfg folder. Any help on where to set the PROBE macro and the APPLY_PROBE_TO_Z_OFFSET macro would be much appreciated.

Thanks!!!

You didn’t provide the basic info requested in the template. “In all cases” does not mean “in all cases except for mine, because I’m special.”

1 Like

Hi,

I’m not sure what you mean. If your are referring to the Klippy Log, I didnt think that is relavant since my delta printer works fine, I get no errors. If I create3 a new bed mesh, it will print fine until the ambient air temps change; last two weeks were really hot in Southern California. This is when i started having the issue with nozzle too close to the bed.

Thanks.

With help from a great member, I got a macro that does what I was looking for:

I am sharing a macro developed by a very helpful member here ( gaolst):

gcode_macro MEASURE_AND_SET_Z_ZERO

What this macro does is probe the bed in the center only, with a BL Touch prior to each print job; it is embedded in my START_PRINT macro (it does not create a bed mesh) .

I have it set to probe the bed 10 times then average the results, once bed and nozzle are at temp, the print begins.

I have this running on a delta printer using a BL Touch probe. I wanted this macro to verify bed height before printing because I would get Z-height drift and have to baby-step at the start of each print. this macro eliminates that. This macro can be modified to use different probe type such as a micro switch.

Here is the macro:

[gcode_macro MEASURE_AND_SET_Z_ZERO]
gcode:
  G90
  #pre position toolhead for probing
  G0 X0 Y0 Z80 F2000
  PROBE
  QUERY_PROBE
  ALIGN_PROBE_TO_Z_OFFSET

[gcode_macro ALIGN_PROBE_TO_Z_OFFSET]
description: Query last probe result and align Z height to configured probe.z_offset
gcode:
    {% set z_probe = printer.probe.last_z_result|float %}
    {% set z_offset = printer.configfile.settings.bltouch.z_offset|float %}
    {% set z_delta = z_probe - z_offset %}
    {% set z_position = printer.toolhead.position.z|float %}
    {% set new_z_position = z_position - z_delta %}

    {action_respond_info(
        "Probe result: %.2f \n"
        "Configured Z_offset: %.2f \n"
        "Delta: %.2f \n"
        "Current Z:%.2f \n"
        "New Z:%.2f " % (
            z_probe,
            z_offset,
            z_delta,
            z_position,
            new_z_position))}

    G92 Z{new_z_position}
    #SET_GCODE_OFFSET Z={z_delta}

Here it is referenced in my START-PRINT macro:

[gcode_macro START_PRINT]
gcode:
    # For PLA
    {% set BED_TEMP = params.BED_TEMP|default(70)|float %}
    {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(205)|float %}
    M140 S{BED_TEMP}
    # Use absolute coordinates
    G90
    # Reset the G-Code Z offset (adjust Z offset if needed)
    SET_GCODE_OFFSET Z=0.0
    # Home the printer
    G28
    # default bed mesh is PEI_BuildTak plate
    BED_MESH_PROFILE LOAD=default
    MEASURE_AND_SET_Z_ZERO
    # Move the nozzle near the bed
    G1 Z20 F3000
    # Wait for bed to reach temperature
    M190 S{BED_TEMP}
    # Set and wait for nozzle to reach temperature
    M109 S{EXTRUDER_TEMP}

And here are my printer.cfg BL Touch settings (BTT Pico board):

[bltouch]
sensor_pin: ^gpio22
control_pin: gpio29
pin_move_time: 0.680
stow_on_each_sample: True
probe_with_touch_mode: False
x_offset: 0.0
y_offset: 30.0
#z_offset: 1.090
speed: 3.0
lift_speed: 3.0
samples: 10
sample_retract_dist: 4.0
samples_result: average
samples_tolerance: 0.100

If you need help setting this up, feel free to reach out to me.