Help for automatic Z offset with bltouch and Stallguard macro



  • Hi,
    I have seen the following posts :
    https://forum.duet3d.com/topic/4851/automatic-z-trigger-height-calibration/3
    https://forum.duet3d.com/topic/4772/motor-stall-detection-as-z-probe/33?_=1576161664265

    and I started to write a macro for automatic Z offset calibration with BLtouch and stallguard.
    This script have not been tested yet, because my printer is in maintenance.

    Bltouch probe offset is X0 Y80.

    Someone could tell me if it work :

    ; find_auto_Z_offset.g
    ; idea taken to https://forum.duet3d.com/topic/4851/automatic-z-trigger-height-calibration/3
    ; and https://forum.duet3d.com/topic/4772/motor-stall-detection-as-z-probe/33?_=1576161664265
    M291 P"Find Z offset for probe with StallGuard. Proceed ?" R"Yes or No?" S3
    G28                                 ; home axes
    G90                                 ; absolute positioning
    ; Use BLTOUCH to probe center of bed and set Z=0
    G31 X0 Y80 Z0                       ; Reset probe height
    G1 Z5 F1000                         ; Lower bed
    G1 X150 Y70 F6000                   ; Move probe to bed center position (nozzle+ probe offset)
    G30 F100                            ; raise bed, stop when probe triggered, set Z=0
    G1 Z5 F1000                         ; Lower bed
    ; Use stallguard to probe center of bed
    G1 X150 Y150 F6000                  ; Move nozzle to bed center position
    M558 P10 X0 Y0 Z0 H2 F600 T5000     ; Enable Stall Z probe
    M574 Z1 S3                          ; set Z-min to use motor StallGuard
    M913 Z20                            ; reduce Z motor current to 20%
    M201 Z30                            ; Reduce acceleration mm/s2
    M915 Z S3 F0 R0                     ; Set StallGuard sensitivity for endstop homing, 1 full step
    G30 S-3 F100                        ; Probe the bed and set the Z probe trigger height to the height it stopped at 
    M500 P30                            ; Store the Z height
    ; Revert back to bltouch probe
    M291 P"Z offset calibrated. Restoring settings." S3
    M913 Z100                           ; restore Z motor current to 100%
    M201 Z30                            ; Restore acceleration
    M915 Z S64 F1 R0	; Set StallGuard sensitivity for normal movement
    M558 P9 F120 H2.5 R0.5 T6000 A10 S0.005 B1  ; restore BLTOUCH Z probe type
    M574 Z1 S2                          ; set Z-min to use bltouch
    G30 S-1                             ; do a couple of repeteability tests, report the machine height at which the probe was triggered.
    G1 Z5
    G30 S-1
    G1 Z5
    G30 S-1
    G1 Z5
    G30 S-1
    ;M561                                ; clear any bed transform
    ;G29                                 ; Probe the bed, save the height map, and activate bed compensation
    

  • Moderator

    The only issue I see is that the stallguard Z probe would typically have a negative Z offset for the trigger height since it presses into the bed slightly before triggering. You could use the normal measuring procedure to find out what that offset is in your case and then set it in your macro.

    Have you tested and tuned stallguard Z probe on it's own already?



  • No the printer is in maintenance now.
    I know the manual process but I want an automatic process


  • Moderator

    @pipersw said in Help for automatic Z offset with bltouch and Stallguard macro:

    I know the manual process but I want an automatic process

    I understand, but what I mean is, the stallguard Z probe will need to be calibrated so that you know what trigger height it will have. Your macro assumes it will be 0, but that's not likely to actually be the case.



  • You are right. I will calibrate the z height.
    Thx


Log in to reply