Have to "bite the bullet"a little bit here and admit defeat when it comes to calculating the offset for both probes.
And since i'm moving over to direct nozzle probing and ditching that second probe static to the bed i'm not inclined to try fixing it either š¤£
So i've opted to turn off the Z-pin offset calculation in the newest version of this script.
And with that i've also moved over to doing all Z homing with the klicky probe rather than on the Z-pin. This removes one "fudge" factor by only using the Z-pin to calculate the Klicky-probe offsett AND it makes transitioning to direct nozzle probing a little bit easier since down the road when it comes to homing macros etc.
Version 2.3 of the macro:
; /sys/lib/z_cal.g (v2.3)
; Called when "M98 P"/sys/lib/z_cal.g" is sent
; Used to calibrate the Z offsett between the Nozzle and buildplate.
; - -
; ====================---------------------------------------------------------
; - -
; IMPORTANT!! Do you wish to calibrate K1 / Z-pin as well? (Not working like intended as of v2.3 so I would advice to not use it!)
var calibrate_Z_Pin = false
; - -
; ====================---------------------------------------------------------
; - -
; ====================---------------------------------------------------------
; Preparation before probing
; ====================
; Report whats going on
M291 R"Z Offset Calibration" P"Please wait..." T0 ; Leveling bed message
; The distance from the body of the klicky probe to it's own trigger point
var base_Hot_offset = global.klicky_offset
var add_Cold_offset = 0.06
; Remember the old offsets
var old_k0_offset = sensors.probes[0].triggerHeight ; Old klicky offset
var old_k1_offset = sensors.probes[1].triggerHeight ; Old z-pin offset
; Reset existing calibration
G31 K0 Z7.50 ; Reset klicky
G31 K1 Z0.00 ; Reset z-pin
; Variables for klicky calculation
var temp0 = 0 ; Placeholder value
var temp1 = 5 ; Placeholder value
var temp2 = 10 ; Set value above target value
; Variables for z-pin calculation
var temp3 = 0 ; Placeholder value
var temp4 = 2.5 ; Placeholder value
var temp5 = 5 ; Set value above target value
; Message placeholder
var consoleMessage1 = "N/A"
M290 R0 S0 ; Clear babystepping
; LED status
set global.sb_leds = "homing"
; ====================---------------------------------------------------------
; Home all axes and lower the bed
; ====================
; Make sure all axes are homed, and home Z again anyways
if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed ; If axes aren't homed
; Home all axis
G91 ; Relative positioning
; Lower currents, speed & accel
M98 P"/sys/lib/current/xy_current_low.g" ; Set low XY currents
M98 P"/sys/lib/current/z_current_low.g" ; Set low Z currents
M98 P"/sys/lib/speed/speed_probing.g" ; Set low speed & accel
; Lower Z relative to current position if needed
if !move.axes[2].homed ; If Z ain't homed
G1 Z20 F9000 H1 ; Lower Z(bed) relative to current position
elif move.axes[2].userPosition < 10 ; If Z is homed and less than 10
G1 Z20 F9000 ; Move to Z 10
; Coarse home X or Y
G1 X600 Y600 F2400 H1 ; Move quickly to X or Y endstop(first pass)
; Coarse home X
G1 X600 H1 ; Move quickly to X endstop(first pass)
; Coarse home Y
G1 Y600 H1 ; Move quickly to Y endstop(first pass)
; Move away from the endstops
G1 X-5 Y-5 F9000 ; Go back a few mm
; Fine home X
G1 X600 F360 H1 ; Move slowly to X axis endstop(second pass)
; Fine home Y
G1 Y600 H1 ; move slowly to Y axis endstop(second pass)
; Absolute positioning
G90 ; Absolute positioning
; Home Z
; Load the probe
M400 ; Wait for moves to finish
M98 P"/sys/lib/klicky/klicky_status.g" ; Refresh klicky status
M401 P0 ; Load the klicky probe
M400 ; Wait for moves to finish
M98 P"/sys/lib/klicky/klicky_status.g" ; Refresh klicky status
; Last check to ensure klicky is attached
if global.klicky_status = "attached"
echo "Probe ATTACHED"
else
echo "Error probe not attached - aborting"
M291 T5 R"Z Homing Aborted!" P"Z haven't been homed - check probe"
abort
; Move to bed center and home Z
M98 P"/sys/lib/goto/bed_center.g" ; Move to bed center
M98 P"/sys/lib/speed/speed_probing.g" ; Set low speed & accel
G30 K0 Z-99999 ; Probe the center of the bed
else
; Home Z axis-
; Do nothing if XY is not homed yet
if move.axes[0].homed && move.axes[1].homed
M98 P"/sys/lib/current/z_current_low.g" ; Set low Z currents
if !move.axes[2].homed ; If Z ain't homed
G1 Z20 F9000 H1 ; Lower Z(bed) relative to current position
elif move.axes[2].userPosition < 10 ; If Z is homed and less than 10
G1 Z20 F9000 ; Move to Z 10
; Lower currents, speed & accel
M98 P"/sys/lib/current/xy_current_low.g" ; Set low XY currents
M98 P"/sys/lib/current/z_current_low.g" ; Set low Z currents
M98 P"/sys/lib/speed/speed_probing.g" ; Set low speed & accel
; Load the probe
M400 ; Wait for moves to finish
M98 P"/sys/lib/klicky/klicky_status.g" ; Refresh klicky status
M401 P0 ; Load the klicky probe
M400 ; Wait for moves to finish
M98 P"/sys/lib/klicky/klicky_status.g" ; Refresh klicky status
; Last check to ensure klicky is attached
if global.klicky_status = "attached"
echo "Probe ATTACHED"
else
echo "Error probe not attached - aborting"
M291 T5 R"Z Homing Aborted!" P"Z haven't been homed - check probe"
abort
; Move to bed center and home Z
M98 P"/sys/lib/goto/bed_center.g" ; Move to bed center
M98 P"/sys/lib/speed/speed_probing.g" ; Set low speed & accel
G30 K0 Z-99999 ; Probe the center of the bed
if move.axes[2].userPosition < 20
G1 Z20 F2400 ; Lower Z
; ====================---------------------------------------------------------
; Calibrate klicky
; ====================
; Position for probing
G1 X{global.z_pin_x - 4} Y{global.z_pin_y - 23.5} F18000 ; Move the klicky body over the Z-pin
G1 Z10 F2400 ; Move probe closer to z-pin
; Lower probing speed for accuracy
M558 K1 F100:50 ; Lower probing speed
; Probe klicky body on Z-pin, minimum 0.004mm accuracy
while var.temp2 >= 0.004
G30 K1 S-1 ; Probe the klicky body with the Z-pin and report value
M400 ; Wait for moves to finish
; Lift from z-pin
G91 ; Relative positioning
G1 Z2 F500 ; Quickly move up 2mm
G90 ; Absolute positioning
M400 ; Wait for moves to finish
; Save first probe result
set var.temp0 = sensors.probes[1].lastStopHeight
; Probe klicky body on Z-pin again
G30 K1 S-1 ; Probe the klicky body with the Z-pin and report value
M400 ; Wait for moves to finish
; Lift from z-pin
G91 ; Relative positioning
G1 Z2 F500 ; Quickly move up 2mm
G90 ; Absolute positioning
M400 ; Wait for moves to finish
; Save second probe result
set var.temp1 = sensors.probes[1].lastStopHeight
;Calculate deviation
set var.temp2 = (var.temp0-var.temp1)
; Calculate the new klicky offset
var new_k0_offset = {((var.temp0 + var.temp1) / 2) + var.base_Hot_offset}
; Compensate for cold extruder
if heat.heaters[1].current < 150
set var.new_k0_offset = {var.new_k0_offset + var.add_Cold_offset}
; Enable the new klicky offset
G31 K0 Z{var.new_k0_offset} ; Apply the new Z offsett value
; Return standard probing speed
M558 K1 F600:180 ; Reset probing speed to normal values
; Make a report message
set var.consoleMessage1 = "Old Klicky offset " ^ var.old_k0_offset ^ " New Klicky offset " ^ var.new_k0_offset
; ====================---------------------------------------------------------
; Calibrate Z-pin
; ====================
; Check if Z-Pin calibration is enabled or not
if var.calibrate_Z_Pin
; Message placeholder
var consoleMessage2 = "N/A"
; Move bed away from nozzle
G1 Z10 F2400 ; Lower the bed
; Position for probing
M98 P"/sys/lib/goto/bed_center.g" ; Move to the center of the bed
M400 ; Wait for moves to finish
; Lower probing speed for accuracy
M558 K0 F100:50 ; Lower probing speed
; Probe the bed, minimum 0.004mm accuracy
while var.temp5 >= 0.004
G30 K0 S-1 ; Probe the klicky body with the Z-pin and report value
M400 ; Wait for moves to finish
; Lift from z-pin
G91 ; Relative positioning
G1 Z2 F500 ; Quickly move up 2mm
G90 ; Absolute positioning
M400 ; Wait for moves to finish
; Save first probe result
set var.temp3 = sensors.probes[0].lastStopHeight
; Probe klicky body on Z-pin again
G30 K0 S-1 ; Probe the klicky body with the Z-pin and report value
M400 ; Wait for moves to finish
; Lift from z-pin
G91 ; Relative positioning
G1 Z2 F500 ; Quickly move up 2mm
G90 ; Absolute positioning
M400 ; Wait for moves to finish
; Save second probe result
set var.temp4 = sensors.probes[0].lastStopHeight
;Calculate deviation
set var.temp5 = (var.temp3-var.temp4)
; Calculate the new z-pin offset
var new_k1_offset = {var.new_k0_offset - ((var.temp3 + var.temp4) / 2)}
; Enable the new z-pin offset
G31 K1 Z{var.new_k1_offset} ; Apply the new Z offsett value
; Return standard probing speed
M558 K0 F600:180 ; Reset probing speed to normal values
; Move bed away from nozzle
G1 Z{global.klicky_clearance} F2400 ; Lower the bed
; Make a report message
set var.consoleMessage2 = "Old Z-pin offset " ^ var.old_k1_offset ^ " New Z-pin offset " ^ var.new_k1_offset
; ====================---------------------------------------------------------
; Finish up
; ====================
; Save the new offsets
M500 P10:31 ; Store the new Z offsett values to config-override.g
G4 P250 ; Wait 250 milliseconds
; Lower bed to reduce pucker factor
G1 Z20 F9000 ; Move to Z 20
; Home z with the new offsets
M98 P"/sys/lib/goto/bed_center.g" ; Move to bed center
M98 P"/sys/lib/speed/speed_probing.g" ; Set low speed & accel
G30 K0 Z-99999 ; Probe the center of the bed
M400 ; Wait for moves to finish
; Report the new offsets
;K0 / klicky probe
M118 P2 S{var.consoleMessage1} ; send used probe grid to paneldue
M118 P3 S{var.consoleMessage1} ; send used probe grid to DWC console
if var.calibrate_Z_Pin
;K1 / Z-pin
M118 P2 S{var.consoleMessage2} ; send used probe grid to paneldue
M118 P3 S{var.consoleMessage2} ; send used probe grid to DWC console
set global.Z_cal = true
; Dock the probe
M402 P0 ; Dock the klicky probe
M400 ; Wait for moves to finish
M98 P"/sys/lib/klicky/klicky_status.g" ; Refresh klicky status
; Full currents, speed & accel
M98 P"/sys/lib/current/z_current_high.g" ; Restore normal Z currents
M98 P"/sys/lib/current/xy_current_high.g" ; Set high XY currents
M98 P"/sys/lib/speed/speed_printing.g" ; Restore normal speed & accels
; Lower Z(bed) after probing
G90 ; Absolute positioning
G1 Z5 F2400 ; Move to Z 5
; Report whats going on
M291 R"Z Offset Calibration" P"Done" T5 ; Bed leveling done message
;LED status
set global.sb_leds = "ready"
I've also moved all the homing portion fully into the macro itself rather than calling for G28 or G28 Z that makes it "deploy" and "retract" the probe way to many times.
@mher