v2.4: use z_calibration plugin
This commit is contained in:
		
							parent
							
								
									97a84b3338
								
							
						
					
					
						commit
						fce3702a8a
					
				
					 9 changed files with 929 additions and 666 deletions
				
			
		
							
								
								
									
										662
									
								
								klicky-probe.cfg
									
										
									
									
									
								
							
							
						
						
									
										662
									
								
								klicky-probe.cfg
									
										
									
									
									
								
							|  | @ -1,662 +0,0 @@ | |||
| # This macro was provided by discord user Garrettwp to whom i give my thanks for sharing it with me. | ||||
| # I have tweaked it a lot. | ||||
| # | ||||
| # this macro is  based on the great Annex magprobe dockable probe macros "#Originally developed by Mental, modified for better use on K-series printers by RyanG and Trails" | ||||
| # that macro can be found here https://github.com/Annex-Engineering/Annex-Engineering_Other_Printer_Mods/blob/master/All_Printers/Microswitch_Probe/Klipper_Macros/dockable_probe_macros.cfg | ||||
| # | ||||
| # by standing on the shoulders of giants, lets see if we can see further | ||||
| # Klicky-probe.cfg version 11-10-2021 01 | ||||
| 
 | ||||
| [gcode_macro _User_Variables] | ||||
| variable_verbose:               True  # Enable verbose output | ||||
| variable_travel_speed:          200   # how fast all other travel moves will be performed when running these macros | ||||
| variable_dock_speed:            50    # how fast should the toolhead move when docking the probe for the final movement | ||||
| variable_release_speed:         100   # how fast should the toolhead move to release the hold of the magnets after docking | ||||
| variable_z_drop_speed:          20    # how fast the z will lower when moving to the z location to clear the probe | ||||
| variable_home_z_height:         20    # Z when homing | ||||
| variable_allow_g28xy_without_z:	0     # forces the initial G28 to calibrate X Y and Z, otherwise you could only do one axis and potentially hit the bed or gantry (by doing only a G28 Z) | ||||
| variable_max_bed_y:             250   #maximum Bed size avoids doing a probe_accuracy outside the bed | ||||
| 
 | ||||
| 
 | ||||
| # if a separate Z endstop switch is in | ||||
| # use, specify the coordinates of the switch here (Voron). | ||||
| # Set to 0 to have the probe move to center of bed | ||||
| variable_z_endstop_x:            208 | ||||
| variable_z_endstop_y:            305 | ||||
| 
 | ||||
| # location to park the toolhead | ||||
| variable_park_toolhead:         False  # Enable toolhead parking | ||||
| variable_parkposition_x:        125 | ||||
| variable_parkposition_y:        125 | ||||
| variable_parkposition_z:        30 | ||||
| 
 | ||||
| #dock location | ||||
| variable_docklocation_x:        148   # X Dock position | ||||
| variable_docklocation_y:        305   # Y Dock position | ||||
| variable_docklocation_z:        -128  # Z dock position (-128 for a gantry mount) | ||||
| variable_dockarmslenght:        30    # Dock arms lenght, toolhead movement necessary to clear the dock arms | ||||
| 
 | ||||
| #Umbilical to help untangle the umbilical in difficult situations | ||||
| variable_umbilical_x:           15    #X umbilical position | ||||
| variable_umbilical_y:           15    #Y umbilical position | ||||
| variable_umbilical:             False #should we untabgle the umbilical | ||||
| 
 | ||||
| # Do not modify below | ||||
| gcode: | ||||
|     {% set Mx = printer['configfile'].config["stepper_x"]["position_max"]|float %} | ||||
|     {% set My = printer['configfile'].config["stepper_y"]["position_max"]|float %} | ||||
|     {% set Ox = printer['configfile'].config["probe"]["x_offset"]|float %} | ||||
|     {% set Oy = printer['configfile'].config["probe"]["y_offset"]|float %} | ||||
|     {% set Oz = printer['configfile'].config["probe"]["z_offset"]|float %} | ||||
| 
 | ||||
|     # if docklocation_z is zero, use Home Z height for safety | ||||
|     {% if docklocation_z == 0 %} | ||||
|         SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=docklocation_z VALUE={ home_z_height } | ||||
|     {% endif %} | ||||
| 
 | ||||
|     # If x, y coordinates are set for z endstop, assign them | ||||
|     {% if z_endstop_x != 0 or z_endstop_y != 0 %} | ||||
|         SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=z_endstop_x VALUE={ z_endstop_x } | ||||
|         SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=z_endstop_y VALUE={ z_endstop_y } | ||||
| 
 | ||||
|     # if no x, y coordinates for z endstop, assume probe is endstop and move toolhead to center of bed | ||||
|     {% else %} | ||||
|         SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=z_endstop_x VALUE={ (Mx * 0.5) - Ox } | ||||
|         SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=z_endstop_y VALUE={ (My * 0.5) - Oy } | ||||
|     {% endif %} | ||||
| 
 | ||||
| 
 | ||||
| [gcode_macro _Probe_Variables] | ||||
| variable_probe_attached:            False | ||||
| variable_probe_state:               False | ||||
| variable_probe_lock:                False | ||||
| variable_z_endstop_x:               0 | ||||
| variable_z_endstop_y:               0 | ||||
| gcode: | ||||
| 
 | ||||
| 
 | ||||
| [gcode_macro _Homing_Variables] | ||||
| gcode: | ||||
|     {% set R  = params.RESET|default(0)  %} | ||||
| 
 | ||||
|     {% if R %} | ||||
|         SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_lock VALUE={ False } | ||||
|    {% endif %} | ||||
| 
 | ||||
| # Attach probe and lock it | ||||
| [gcode_macro Attach_Probe_Lock] | ||||
| description: Attaches Klicky Probe, can only be docked after unlocking | ||||
| gcode: | ||||
|     Attach_Probe | ||||
|     SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_lock VALUE={ True } | ||||
| 
 | ||||
| 
 | ||||
| # Dock probe and lock it | ||||
| [gcode_macro Dock_Probe_Unlock] | ||||
| description: Docks Klicky Probe even if it was locked | ||||
| gcode: | ||||
|     SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_lock VALUE={ False } | ||||
|     Dock_Probe | ||||
| 
 | ||||
| # Unlock Probe | ||||
| [gcode_macro Probe_Unlock] | ||||
| description: Unlocks Klicky Probe state | ||||
| gcode: | ||||
|     SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_lock VALUE={ False } | ||||
| 
 | ||||
| # Lock Probe | ||||
| [gcode_macro Probe_Lock] | ||||
| description: Locks Klicky Probe state | ||||
| gcode: | ||||
|     SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_lock VALUE={ True } | ||||
| 
 | ||||
| # Attach Probe Routine | ||||
| [gcode_macro Attach_Probe] | ||||
| description: Attaches Klicky Probe | ||||
| gcode: | ||||
|     # Get probe attach status | ||||
|     {% set P = printer["gcode_macro _Probe_Variables"].probe_attached %} | ||||
|     {% set L = printer["gcode_macro _Probe_Variables"].probe_lock %} | ||||
|     {% set V = printer["gcode_macro _User_Variables"].verbose %} | ||||
|     # Get Docking location | ||||
|     {% set Dx = printer["gcode_macro _User_Variables"].docklocation_x %} | ||||
|     {% set Dy = printer["gcode_macro _User_Variables"].docklocation_y %} | ||||
|     {% set Dz = printer["gcode_macro _User_Variables"].docklocation_z %} | ||||
|     {% set Da = printer["gcode_macro _User_Variables"].dockarmslenght %} | ||||
|     # Safe Z for travel | ||||
|     {% set Hzh = printer["gcode_macro _User_Variables"].home_z_height|float %} | ||||
|     #Set speed | ||||
|     {% set St = printer["gcode_macro _User_Variables"].travel_speed * 60    %} | ||||
| 
 | ||||
|     #prior to saving actual position, check if its necessary to move to a safe Z | ||||
|     #that has enought overhead for the attached probe | ||||
|     {% if (printer.toolhead.position.z < Hzh) %} | ||||
|         G1 Z{Hzh} F1200 | ||||
|     {% endif %} | ||||
|     M400 # mandatory to save the new safe position | ||||
|     #allows the docking position to be independent of the Z offset, necessary for bed mounted probes | ||||
|     SAVE_GCODE_STATE name=_attachProbe | ||||
|     SET_GCODE_OFFSET Z=0 | ||||
| 
 | ||||
|     # if x and y are not homed | ||||
|     {% if not 'xy' in printer.toolhead.homed_axes %} | ||||
|         { action_raise_error("Must Home X and Y Axis First!") } | ||||
| 
 | ||||
|     # If probe not attached and locked | ||||
|     {% elif not P and not L %} | ||||
|         {% if V %} | ||||
|             { action_respond_info("Attaching Probe") } | ||||
|         {% endif %} | ||||
|         G90 | ||||
| 
 | ||||
|         {% if (not 'z' in printer.toolhead.homed_axes) %} | ||||
|             {% if V %} | ||||
|                 { action_respond_info("Resetting Z position to zero") } | ||||
|             {% endif %} | ||||
|             SET_KINEMATIC_POSITION Z=0 | ||||
|         {% endif %} | ||||
| 
 | ||||
|         {% if (printer.toolhead.position.z < Hzh) %} | ||||
|             G1 Z{Hzh} F1200 | ||||
|         {% endif %} | ||||
| 
 | ||||
|         _Umbilical_Path | ||||
| 
 | ||||
|         # Probe entry location | ||||
|         G1 X{Dx} Y{Dy|int - Da|int} F{St} | ||||
|         {% if Dz != -128 %} | ||||
|           #lower to Z dock | ||||
|           G1 Z{Dz} F600 | ||||
|         {% endif %} | ||||
|         # pickup from Probe location | ||||
|         G1 X{Dx} Y{Dy} F1800 | ||||
|         # Probe entry location | ||||
|         G1 X{Dx} Y{Dy|int - Da|int} F6000 | ||||
|         #Go to Z safe distance | ||||
|         {% if (printer.toolhead.position.z < Hzh) %} | ||||
|           G1 Z{Hzh} F600 | ||||
|         {% endif %} | ||||
|         _Park_Toolhead | ||||
| 
 | ||||
|         _CheckProbe action=attach | ||||
| 
 | ||||
|     {% elif L %} | ||||
|         {% if V %} | ||||
|             { action_respond_info("Probe locked!") } | ||||
|         {% endif %} | ||||
| 
 | ||||
|         # Probe attached, do nothing | ||||
|         _CheckProbe action=query | ||||
| 
 | ||||
|     {% else %} | ||||
|         {% if V %} | ||||
|             { action_respond_info("Probe already attached!") } | ||||
|         {% endif %} | ||||
| 
 | ||||
|         # Probe attached, do nothing | ||||
|         _CheckProbe action=query | ||||
| 
 | ||||
|     {% endif %} | ||||
|     #reverts to the original Z offset | ||||
|     RESTORE_GCODE_STATE name=_attachProbe | ||||
| 
 | ||||
| 
 | ||||
| # Dock Probe Routine | ||||
| [gcode_macro Dock_Probe] | ||||
| description: Docks Klicky Probe | ||||
| gcode: | ||||
|     # Get probe attach status | ||||
|     {% set P = printer["gcode_macro _Probe_Variables"].probe_attached %} | ||||
|     {% set L = printer["gcode_macro _Probe_Variables"].probe_lock %} | ||||
|     {% set V = printer["gcode_macro _User_Variables"].verbose %} | ||||
|     # Get Docking location | ||||
|     {% set Dx = printer["gcode_macro _User_Variables"].docklocation_x %} | ||||
|     {% set Dy = printer["gcode_macro _User_Variables"].docklocation_y %} | ||||
|     {% set Dz = printer["gcode_macro _User_Variables"].docklocation_z %} | ||||
|     {% set Da = printer["gcode_macro _User_Variables"].dockarmslenght %} | ||||
|     # Safe Z for travel | ||||
|     {% set Hzh = printer["gcode_macro _User_Variables"].home_z_height|float %} | ||||
|     # Set speed | ||||
|     {% set St = printer["gcode_macro _User_Variables"].travel_speed * 60    %} | ||||
|     {% set Sd = printer["gcode_macro _User_Variables"].dock_speed * 60    %} | ||||
|     {% set Sr = printer["gcode_macro _User_Variables"].release_speed * 60    %} | ||||
|     {% set Sz = printer["gcode_macro _User_Variables"].z_drop_speed * 60    %} | ||||
| 
 | ||||
|     M400 # mandatory to save the new safe position | ||||
|     #allows the docking position to be independent of the Z offset, necessary for bed mounted probes | ||||
|     SAVE_GCODE_STATE name=_dockProbe | ||||
|     SET_GCODE_OFFSET Z=0 | ||||
| 
 | ||||
|     {% if not 'xyz' in printer.toolhead.homed_axes %} | ||||
|         { action_raise_error("Must Home X, Y and Z Axis First!") } | ||||
| 
 | ||||
|     # If probe not attached and not locked | ||||
|     {% elif P and not L %} | ||||
|         {% if V %} | ||||
|             { action_respond_info("Docking Probe") } | ||||
|         {% endif %} | ||||
|         G90 | ||||
| 
 | ||||
|         {% if (printer.toolhead.position.z < Hzh) %} | ||||
|             G1 Z{Hzh} F{Sz} | ||||
|         {% endif %} | ||||
| 
 | ||||
|         _Umbilical_Path | ||||
| 
 | ||||
|         # Probe entry location | ||||
|         G1 X{Dx} Y{Dy|int - Da|int} F{St} | ||||
|         {% if Dz != -128 %} | ||||
|           #lower to Z dock | ||||
|           G1 Z{Dz} F600 | ||||
|         {% endif %} | ||||
|         # Drop Probe to Probe location | ||||
|         G1 X{Dx} Y{Dy} F{Sd} | ||||
|         # Probe decoupling | ||||
|         G1 X{Dx|int + 40} Y{Dy} F{Sr} | ||||
|         #Go to Z safe distance | ||||
|         {% if (printer.toolhead.position.z < Hzh) %} | ||||
|           G1 Z{Hzh} F600 | ||||
|         {% endif %} | ||||
| 
 | ||||
|         _Park_Toolhead | ||||
| 
 | ||||
|         G4 P1000 | ||||
|         _CheckProbe action=dock | ||||
| 
 | ||||
|     {% elif L %} | ||||
|         {% if V %} | ||||
|             { action_respond_info("Probe locked!") } | ||||
|         {% endif %} | ||||
| 
 | ||||
|         # Probe docked, do nothing | ||||
|         _CheckProbe action=query | ||||
| 
 | ||||
|     {% else %} | ||||
|         {% if V %} | ||||
|             { action_respond_info("Probe already docked!") } | ||||
|         {% endif %} | ||||
| 
 | ||||
|         # Probe docked, do nothing | ||||
|         _CheckProbe action=query | ||||
| 
 | ||||
|     {% endif %} | ||||
|     #reverts to the original Z offset | ||||
|     RESTORE_GCODE_STATE name=_dockProbe | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| # Quad Gantry Level | ||||
| [gcode_macro QUAD_GANTRY_LEVEL] | ||||
| rename_existing:             _QUAD_GANTRY_LEVEL | ||||
| description: Conform a moving, twistable gantry to the shape of a stationary bed with klicky automount | ||||
| gcode: | ||||
|     {% set V = printer["gcode_macro _User_Variables"].verbose %} | ||||
|     {% if V %} | ||||
|         { action_respond_info("QG Level") } | ||||
|     {% endif %} | ||||
| 
 | ||||
|     _CheckProbe action=query | ||||
|     Attach_Probe | ||||
| 
 | ||||
|     _QUAD_GANTRY_LEVEL {% for p in params | ||||
|             %}{'%s=%s ' % (p, params[p])}{% | ||||
|             endfor %} | ||||
|     Dock_Probe | ||||
| 
 | ||||
| 
 | ||||
| # Z Tilt Adjust | ||||
| #[gcode_macro Z_TILT_ADJUST] | ||||
| #rename_existing:             _Z_TILT_ADJUST | ||||
| #description: | ||||
| #gcode: | ||||
| #    {% set V = printer["gcode_macro _User_Variables"].verbose %} | ||||
| #    {% if V %} | ||||
| #        { action_respond_info("Z Tilt Adjust") } | ||||
| #    {% endif %} | ||||
| # | ||||
| #    _CheckProbe action=query | ||||
| #    Attach_Probe | ||||
| # | ||||
| #    _Z_TILT_ADJUST {% for p in params | ||||
| #          %}{'%s=%s ' % (p, params[p])}{% | ||||
| #         endfor %} | ||||
| #    G28 Z0 | ||||
| #    Dock_Probe | ||||
| 
 | ||||
| 
 | ||||
| # Screws Tilt Adjust | ||||
| #gcode_macro SCREWS_TILT_CALCULATE] | ||||
| #rename_existing:             _SCREWS_TILT_CALCULATE | ||||
| #description:  | ||||
| #gcode: | ||||
| #    {% set V = printer["gcode_macro _User_Variables"].verbose %} | ||||
| #    {% if V %} | ||||
| #        { action_respond_info("Screws Tilt Adjust") } | ||||
| #    {% endif %} | ||||
| # | ||||
| #    _CheckProbe action=query | ||||
| #    Attach_Probe | ||||
| # | ||||
| #    _SCREWS_TILT_CALCULATE {% for p in params | ||||
| #          %}{'%s=%s ' % (p, params[p])}{% | ||||
| #         endfor %} | ||||
| # | ||||
| #    Dock_Probe | ||||
| 
 | ||||
| # Bed Mesh Calibrate | ||||
| [bed_mesh] | ||||
| 
 | ||||
| [gcode_macro BED_MESH_CALIBRATE] | ||||
| rename_existing:             _BED_MESH_CALIBRATE | ||||
| description: Perform Mesh Bed Leveling with klicky automount | ||||
| gcode: | ||||
| 
 | ||||
|     {% set V = printer["gcode_macro _User_Variables"].verbose %} | ||||
|     {% if V %} | ||||
|         { action_respond_info("Bed Mesh Calibrate") } | ||||
|     {% endif %} | ||||
| 
 | ||||
|     _CheckProbe action=query | ||||
|     Attach_Probe | ||||
| 
 | ||||
|     _BED_MESH_CALIBRATE {% for p in params | ||||
|            %}{'%s=%s ' % (p, params[p])}{% | ||||
|           endfor %} | ||||
| 
 | ||||
|     Dock_Probe | ||||
| 
 | ||||
| 
 | ||||
| # Probe Calibrate | ||||
| [gcode_macro PROBE_CALIBRATE] | ||||
| rename_existing:             _PROBE_CALIBRATE | ||||
| description:Calibrate the probe's z_offset with klicky automount | ||||
| gcode: | ||||
|     {% set Hzh = printer["gcode_macro _User_Variables"].home_z_height|float %} | ||||
|     {% set Sz = printer["gcode_macro _User_Variables"].z_drop_speed * 60 %} | ||||
|     {% set St = printer["gcode_macro _User_Variables"].travel_speed %} | ||||
|     {% set Mx = printer['configfile'].config["stepper_x"]["position_max"]|float %} | ||||
|     {% set My = printer['configfile'].config["stepper_y"]["position_max"]|float %} | ||||
|     {% set Ox = printer['configfile'].config["probe"]["x_offset"]|float %} | ||||
|     {% set Oy = printer['configfile'].config["probe"]["y_offset"]|float %} | ||||
| 
 | ||||
|     # Go to Z safe distance before saving location in order to | ||||
|     # avoid crashing the probe on the bed when coming back | ||||
|     G1 Z{Hzh} F{Sz} | ||||
|     #Protect against PROBE CALIBRATE performed from outside the bed | ||||
|     {% if (printer['gcode_move'].position.y > (My - Oy)) or (printer['gcode_move'].position.x > (Mx - Ox)) or (printer['gcode_move'].position.x < Ox) %} | ||||
|       { action_raise_error("Must perform PROBE_CALIBRATE with the probe above the BED!!!") } | ||||
|     {% endif%} | ||||
|     M400 # mandatory to save the new safe position | ||||
|     SAVE_GCODE_STATE NAME=_original_nozzle_location | ||||
|      | ||||
|     _CheckProbe action=query | ||||
|     Attach_Probe | ||||
| 
 | ||||
|     # Restore nozzle location to probe the right place | ||||
|     RESTORE_GCODE_STATE NAME=_original_nozzle_location MOVE=1 MOVE_SPEED={St} | ||||
| 
 | ||||
|     _PROBE_CALIBRATE {% for p in params | ||||
|             %}{'%s=%s ' % (p, params[p])}{% | ||||
|            endfor %} | ||||
| 
 | ||||
| 	#store current nozzle location | ||||
| 	SAVE_GCODE_STATE NAME=_original_nozzle_location   | ||||
|     Dock_Probe | ||||
| 	 | ||||
|     # Restore nozzle location again at the end | ||||
|     RESTORE_GCODE_STATE NAME=_original_nozzle_location MOVE=1 MOVE_SPEED={St} | ||||
| 
 | ||||
| 
 | ||||
| # Probe Accuracy | ||||
| [gcode_macro PROBE_ACCURACY] | ||||
| rename_existing:             _PROBE_ACCURACY | ||||
| description:Probe Z-height accuracy at current XY position with klicky automount | ||||
| gcode: | ||||
|     {% set Hzh = printer["gcode_macro _User_Variables"].home_z_height|float %} | ||||
|     {% set Sz = printer["gcode_macro _User_Variables"].z_drop_speed * 60 %} | ||||
|     {% set St = printer["gcode_macro _User_Variables"].travel_speed %} | ||||
|     {% set By = printer["gcode_macro _User_Variables"].max_bed_y %} | ||||
|     {% set Oy = printer['configfile'].config["probe"]["y_offset"]|float %} | ||||
| 
 | ||||
|     # Go to Z safe distance before saving location in order to | ||||
|     # avoid crashing the probe on the bed when coming back | ||||
|     G1 Z{Hzh} F{Sz} | ||||
|     #Protect against PROBE ACCURACY performed from outside the bed | ||||
|     {% if (printer.toolhead.position.y > (By - Oy)) %} | ||||
|       { action_raise_error("Must perform PROBE_ACCURACY with the probe above the BED!!!") } | ||||
|     {% endif%} | ||||
|     M400 # mandatory to save the new safe position | ||||
|     SAVE_GCODE_STATE NAME=_original_nozzle_location | ||||
| 
 | ||||
|     _CheckProbe action=query | ||||
|     Attach_Probe | ||||
| 
 | ||||
|     # Restore nozzle location to probe the right place | ||||
|     RESTORE_GCODE_STATE NAME=_original_nozzle_location MOVE=1 MOVE_SPEED={St} | ||||
| 
 | ||||
|     _PROBE_ACCURACY {% for p in params | ||||
|             %}{'%s=%s ' % (p, params[p])}{% | ||||
|            endfor %} | ||||
| 
 | ||||
| 	#store current nozzle location | ||||
| 	SAVE_GCODE_STATE NAME=_original_nozzle_location  | ||||
| 	 | ||||
| 	Dock_Probe | ||||
| 	 | ||||
|     # Restore nozzle location again at the end | ||||
|     RESTORE_GCODE_STATE NAME=_original_nozzle_location MOVE=1 MOVE_SPEED={St} | ||||
| 
 | ||||
| 
 | ||||
| # enable to SET_KINEMATIC_POSITION for Z hop | ||||
| [force_move] | ||||
| enable_force_move: True | ||||
| 
 | ||||
| # Homeing Override | ||||
| [homing_override] | ||||
| axes:                             xyz | ||||
| gcode: | ||||
|     # collect user state variables | ||||
|     _User_Variables | ||||
|     {% set V = printer["gcode_macro _User_Variables"].verbose %} | ||||
|     {% set XYwZ = printer["gcode_macro _User_Variables"].allow_g28xy_without_z %} | ||||
|     {% set Hzh = printer["gcode_macro _User_Variables"].home_z_height|float %} | ||||
| 
 | ||||
|     _CheckProbe action=query | ||||
| 
 | ||||
|     # reset parameters | ||||
|     {% set X, Y, Z = False, False, False %} | ||||
| 
 | ||||
|     # which axes have been requested for homing | ||||
|     {% if not 'X' in params | ||||
|         and not 'Y' in params | ||||
|         and not 'Z' in params %} | ||||
| 
 | ||||
|         {% set X, Y, Z = True, True, True %} | ||||
| 
 | ||||
|     {% else %} | ||||
|         {% if 'X' in params %} | ||||
|             {% set X = True %} | ||||
|         {% endif %} | ||||
| 
 | ||||
|         {% if 'Y' in params %} | ||||
|             {% set Y = True %} | ||||
|         {% endif %} | ||||
| 
 | ||||
|         {% if 'Z' in params %} | ||||
|             {% set Z = True %} | ||||
|         {% endif %} | ||||
| 
 | ||||
|         {% if 'X' in params | ||||
|           and 'Y' in params | ||||
|           and 'Z' in params %} | ||||
|             # reset homing state variables | ||||
|             # if homing all axes | ||||
|             _Homing_Variables reset=1 | ||||
|          {% endif %} | ||||
| 
 | ||||
|     {% endif %} | ||||
| 
 | ||||
|     {% if ('z' in printer.toolhead.homed_axes) %} | ||||
|         {% if (printer.toolhead.position.z < Hzh) %} | ||||
|             {% if V %} | ||||
|                 { action_respond_info("Z too low, performing ZHOP") } | ||||
|             {% endif %} | ||||
|             G1 Z{Hzh} F1200 | ||||
|         {% endif %} | ||||
|     {% else %} | ||||
|         #checks if it's allowed to do initially G28 X/Y without doing a G28 Z | ||||
|         {% if ( XYwZ == 0) %} | ||||
|             {% if V %} | ||||
|                 { action_respond_info("Z not homed, forcing full G28") } | ||||
|             {% endif %} | ||||
|             SET_KINEMATIC_POSITION X=0 Y=0 Z=0 | ||||
| 	          G1 Z{Hzh} F600 | ||||
| 	          {% set X, Y, Z = True, True, True %} | ||||
|         {% endif %} | ||||
|     {% endif %} | ||||
| 
 | ||||
|     # Home x | ||||
|     {% if X %} | ||||
|         {% if V %} | ||||
|             { action_respond_info("Homing X") } | ||||
|         {% endif %} | ||||
|         G28 X0 | ||||
|     {% endif %} | ||||
| 
 | ||||
|     # Home y | ||||
|     {% if Y %} | ||||
|         {% if V %} | ||||
|             { action_respond_info("Homing Y") } | ||||
|         {% endif %} | ||||
|         G28 Y0 | ||||
|     {% endif %} | ||||
| 
 | ||||
|     # Home z | ||||
|     {% if Z %} | ||||
|         {% if V %} | ||||
|             { action_respond_info("Homing Z") } | ||||
|         {% endif %} | ||||
| 
 | ||||
|         # if probe is configured as endstop, attach it, else dock the probe if attached | ||||
|         {% if printer['configfile'].config["stepper_z"]["endstop_pin"] == 'probe:z_virtual_endstop' %} | ||||
|             Attach_Probe | ||||
|         {% else %} | ||||
|             Dock_Probe | ||||
|         {% endif %} | ||||
| 
 | ||||
|         _Home_Z | ||||
| 
 | ||||
| 
 | ||||
|         # if probe is configured as endstop, dock it | ||||
|         {% if printer['configfile'].config["stepper_z"]["endstop_pin"] == 'probe:z_virtual_endstop' %} | ||||
|             Dock_Probe | ||||
|         {% endif %} | ||||
|     {% endif %} | ||||
|   _CheckProbe action=query | ||||
| 
 | ||||
|     # park the toolhead | ||||
|     _Park_Toolhead | ||||
| 
 | ||||
| # umbilical path setup | ||||
| [gcode_macro _Umbilical_Path] | ||||
| gcode: | ||||
|     {% set Ux = printer["gcode_macro _User_Variables"].umbilical_x %} | ||||
|     {% set Uy = printer["gcode_macro _User_Variables"].umbilical_y %} | ||||
|     {% set U = printer["gcode_macro _User_Variables"].umbilical    %} | ||||
|     {% set Hzh = printer["gcode_macro _User_Variables"].home_z_height|float %} | ||||
|     {% set St = printer["gcode_macro _User_Variables"].travel_speed * 60    %} | ||||
| 
 | ||||
|     {% if U %} | ||||
|         # Used to give the umbilical a better path to follow and coil properly if dock is tight in space | ||||
|         G1 X{Ux} Y{Uy} Z{Hzh} F{St} | ||||
|     {% endif %} | ||||
| 
 | ||||
| 
 | ||||
| # Home Z Routine | ||||
| [gcode_macro _Home_Z] | ||||
| gcode: | ||||
|     {% set Zx = printer["gcode_macro _Probe_Variables"].z_endstop_x         %} | ||||
|     {% set Zy = printer["gcode_macro _Probe_Variables"].z_endstop_y         %} | ||||
|     {% set Hzh = printer["gcode_macro _User_Variables"].home_z_height|float %} | ||||
|     {% set St = printer["gcode_macro _User_Variables"].travel_speed * 60    %} | ||||
|     {% set Sz = printer["gcode_macro _User_Variables"].z_drop_speed * 60    %} | ||||
| 
 | ||||
|     # if x and y are not homed yet, raise error | ||||
|     {% if not 'xy' in printer.toolhead.homed_axes %} | ||||
|         { action_raise_error("Must Home X and Y Axis First!") } | ||||
| 
 | ||||
|     {% else %} | ||||
|         {% if (not 'z' in printer.toolhead.homed_axes) %} | ||||
|             {% if V %} | ||||
|                 { action_respond_info("Resetting Z position to zero") } | ||||
|             {% endif %} | ||||
|             SET_KINEMATIC_POSITION Z=0 | ||||
|         {% endif %} | ||||
| 
 | ||||
|         # move tool to safe homing position and home Z axis | ||||
|         # location of z endstop | ||||
|         G1 X{Zx} Y{Zy} Z{Hzh} F{St} | ||||
|         G28 Z0 | ||||
|         G1 Z{Hzh} F{Sz} | ||||
| 
 | ||||
|     {% endif %} | ||||
| 
 | ||||
| 
 | ||||
| # check to see if probe is where it is supposed to be after | ||||
| # attaching/docking maneuver and set homing error or shutdown | ||||
| [gcode_macro _CheckProbe] | ||||
| variable_probe_state:           0 | ||||
| gcode: | ||||
|     Query_Probe | ||||
|     _SetProbeState action={ ACTION } | ||||
| 
 | ||||
| 
 | ||||
| # due to how templates are evaluated, we have query endstops in one | ||||
| # macro and call another macro to make decisions based on the result | ||||
| [gcode_macro _SetProbeState] | ||||
| gcode: | ||||
|     {% set P = printer.probe.last_query %} | ||||
|     {% set V = printer["gcode_macro _User_Variables"].verbose %} | ||||
| 
 | ||||
|     # If triggered (true), probe not attached | ||||
|     {% if P %} | ||||
|         SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_attached VALUE={ False } | ||||
| 
 | ||||
|     # If not triggered (false), probe attached | ||||
|     {% else %} | ||||
|         SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_attached VALUE={ True } | ||||
|     {% endif %} | ||||
| 
 | ||||
|     {% if params.ACTION == 'query' %} | ||||
|           SET_GCODE_VARIABLE MACRO=_Probe_Variables VARIABLE=probe_state VALUE={ P } | ||||
|     {% endif %} | ||||
| 
 | ||||
|     # if probe fails to attach/detach | ||||
|     # if not docked | ||||
|     {% if (not P and params.ACTION == 'dock') %} | ||||
|         { action_raise_error("Probe dock failed!") } | ||||
|     {% endif %} | ||||
| 
 | ||||
|     # if not attached | ||||
|     {% if P and params.ACTION == 'attach' %} | ||||
|         { action_raise_error("Probe attach failed!") } | ||||
|     {% endif %} | ||||
| 
 | ||||
| # Park Toolhead Routine | ||||
| [gcode_macro _Park_Toolhead] | ||||
| gcode: | ||||
|     {% set P = printer["gcode_macro _User_Variables"].park_toolhead %} | ||||
|     {% set Px = printer["gcode_macro _User_Variables"].parkposition_x %} | ||||
|     {% set Py = printer["gcode_macro _User_Variables"].parkposition_y %} | ||||
|     {% set Pz = printer["gcode_macro _User_Variables"].parkposition_z %} | ||||
|     {% set St = printer["gcode_macro _User_Variables"].travel_speed * 60 %} | ||||
|     {% set V = printer["gcode_macro _User_Variables"].verbose %} | ||||
| 
 | ||||
|     {% if (P and 'xyz' in printer.toolhead.homed_axes) %} | ||||
|         {% if V %} | ||||
|             { action_respond_info("Parking Toolhead") } | ||||
|         {% endif %} | ||||
|         G90 | ||||
|         G1 X{Px} Y{Py} Z{Pz} F{St} | ||||
|     {% endif %} | ||||
| 
 | ||||
|  | @ -49,6 +49,12 @@ env: ~/.KlipperScreen-env/bin/python | |||
| requirements: scripts/KlipperScreen-requirements.txt | ||||
| install_script: scripts/KlipperScreen-install.sh | ||||
| 
 | ||||
| [update_manager client z_calibration] | ||||
| type: git_repo | ||||
| path: /home/pi/klipper_z_calibration | ||||
| origin: https://github.com/protoloft/klipper_z_calibration.git | ||||
| install_script: install.sh | ||||
| 
 | ||||
| [power voron-v2.4] | ||||
| type: tplink_smartplug | ||||
| address: 192.168.11.91 | ||||
|  |  | |||
|  | @ -45,7 +45,6 @@ max_z_velocity: 30            # Max 15 for 12V TMC Drivers, can increase for 24V | |||
| max_z_accel: 500 | ||||
| square_corner_velocity: 5.0 | ||||
| 
 | ||||
| 
 | ||||
| ##################################################################### | ||||
| # includes | ||||
| ##################################################################### | ||||
|  | @ -56,7 +55,7 @@ square_corner_velocity: 5.0 | |||
| [include fans.cfg] | ||||
| [include input_shaper.cfg] | ||||
| # [include resonance_test.cfg] | ||||
| [include klicky-probe.cfg] | ||||
| [include z_calibration/printer.cfg] | ||||
| 
 | ||||
| 
 | ||||
| ##################################################################### | ||||
|  | @ -277,8 +276,9 @@ pin: ^PG11 | |||
| x_offset: 0 | ||||
| y_offset: 25.0 | ||||
| #z_offset: 0 | ||||
| speed: 10.0 | ||||
| samples: 3 | ||||
| speed: 6 | ||||
| lift_speed: 11 | ||||
| samples: 5 | ||||
| samples_result: median | ||||
| sample_retract_dist: 3.0 | ||||
| samples_tolerance: 0.01 | ||||
|  |  | |||
							
								
								
									
										11
									
								
								z_calibration/README.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								z_calibration/README.md
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,11 @@ | |||
| # Sample Configuration | ||||
| 
 | ||||
| This are some parts of my V2 300 configurations describing all the mag-probe, probing | ||||
| and QGL stuff. | ||||
| 
 | ||||
| These configurations are the essence of the overall configuration from | ||||
| [zellneralex](https://github.com/zellneralex/klipper_config/tree/master) | ||||
| which is really well done !! Have a look if you want to take all of it! | ||||
| 
 | ||||
| **CAUTION: Please, don't just copy it - understand and adapt for your needs instead! | ||||
| Use this on your own risk!** | ||||
							
								
								
									
										129
									
								
								z_calibration/homing.cfg
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										129
									
								
								z_calibration/homing.cfg
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,129 @@ | |||
| ##################################################################### | ||||
| #    Homing definition | ||||
| ##################################################################### | ||||
| [homing_override] | ||||
| axes: z | ||||
| set_position_z: 0 | ||||
| gcode: | ||||
|   ##### get user defines ##### | ||||
|   # use -10 as default to insure it error in case the variable is not existing | ||||
|   {% set z_endstop_x = printer['gcode_macro _USER_VARIABLE'].z_endstop_x|default(-10) %} | ||||
|   {% set z_endstop_y = printer['gcode_macro _USER_VARIABLE'].z_endstop_y|default(-10) %} | ||||
|   {% set z_hop = printer['gcode_macro _USER_VARIABLE'].z_hop %} | ||||
|   ##### end of definitions ##### | ||||
|   SAVE_GCODE_STATE NAME=HOMING_state | ||||
| 
 | ||||
|   ## reduce current of Z motors | ||||
|   _SET_ACC VAL=HOME | ||||
|   _SET_CURRENT VAL=HOME | ||||
|      | ||||
|   G91                            ; relative positioning | ||||
|   # G0 Z10 F1500 | ||||
|   G0 Z10 F1300 | ||||
|   G90                            ; absolute positioning | ||||
| 
 | ||||
|   # Home X and Y only for G28 or G28 XYZ | ||||
|   {% if 'Z' in params %} | ||||
|     {% if "x" not in printer.toolhead.homed_axes %} | ||||
|       G28 X | ||||
|     {% endif %} | ||||
|     {% if "y" not in printer.toolhead.homed_axes %} | ||||
|       G28 Y | ||||
|     {% endif %} | ||||
|   {% else %} | ||||
|     G28 X Y | ||||
|   {% endif %}  | ||||
| 
 | ||||
|   ##	XY Location of the Z Endstop Switch | ||||
|   G0 X{z_endstop_x} Y{z_endstop_y} F12000 | ||||
|   G28 Z                          ; home Z | ||||
|   # G0 Z2 F1500                   ; move up | ||||
|   G0 Z2 F1300                   ; move up | ||||
| 
 | ||||
|   ## return to org current settings | ||||
|   {% if params.RESET_SETTINGS|default('true') == 'true' %} | ||||
|     DETACH_PROBE | ||||
|     _SET_CURRENT | ||||
|     _SET_ACC | ||||
|   {% endif %} | ||||
| 
 | ||||
|   # Lift Z | ||||
|   # G0 Z{z_hop} F1800 | ||||
|   G0 Z{z_hop} F1300 | ||||
| 
 | ||||
|   RESTORE_GCODE_STATE NAME=HOMING_state | ||||
| 
 | ||||
| ##################################################################### | ||||
| #    Macros | ||||
| ##################################################################### | ||||
| ## conditional home | ||||
| [gcode_macro _CG28] | ||||
| gcode: | ||||
|   {% if "xyz" not in printer.toolhead.homed_axes %} | ||||
|     G28 RESET_SETTINGS={ params.RESET_SETTINGS|default('true') } | ||||
|   {% endif %} | ||||
| 
 | ||||
| [gcode_macro _SET_CURRENT] | ||||
| description: Helper: Set Z-drive motor current | ||||
| variable_last_val: 'CONFIG' | ||||
| gcode: | ||||
|   ###### set default values ##### | ||||
|   {% set default_respond = printer['gcode_macro _USER_VARIABLE'].respond_set_current|int %} | ||||
|   {% set val = params.VAL|default('CONFIG') %} | ||||
|   {% set respond = params.Z_RESPOND|default(default_respond)|int %} | ||||
|   {% if val == 'HOME' %} | ||||
|     {% set xy_run  = printer['gcode_macro _USER_VARIABLE'].xy_home_current %} | ||||
|     {% set xy_hold = printer['gcode_macro _USER_VARIABLE'].xy_home_current %} | ||||
|     {% set z_run  = printer['gcode_macro _USER_VARIABLE'].z_home_current %} | ||||
|     {% set z_hold = printer['gcode_macro _USER_VARIABLE'].z_home_current %} | ||||
|   {% else %} | ||||
|     {% if 'tmc2209 stepper_z' in printer.configfile.settings %} | ||||
|       {% set xy_run  = printer.configfile.settings['tmc2209 stepper_x'].run_current %} | ||||
|       {% set xy_hold = printer.configfile.settings['tmc2209 stepper_x'].hold_current %} | ||||
|       {% set z_run  = printer.configfile.settings['tmc2209 stepper_z'].run_current %} | ||||
|       {% set z_hold = printer.configfile.settings['tmc2209 stepper_z'].hold_current %} | ||||
|     {% elif 'tmc5160 stepper_z' in printer.configfile.settings %} | ||||
|       {% set xy_run  = printer.configfile.settings['tmc5160 stepper_x'].run_current %} | ||||
|       {% set xy_hold = printer.configfile.settings['tmc5160 stepper_x'].hold_current %} | ||||
|       {% set z_run  = printer.configfile.settings['tmc5160 stepper_z'].run_current %} | ||||
|       {% set z_hold = printer.configfile.settings['tmc5160 stepper_z'].hold_current %} | ||||
|     {% endif %} | ||||
|   {% endif %} | ||||
|   ##### end of definition ##### | ||||
|   {% if val != last_val %} | ||||
|     SET_GCODE_VARIABLE MACRO=_SET_CURRENT VARIABLE=last_val VALUE='"{val}"' | ||||
|     {% if respond == 1 %} | ||||
|       {action_respond_info("Home&Probe: RunCur %.2fA rms HoldCur %.2fA rms" % (z_run|float, z_hold|float))} | ||||
|     {% endif %} | ||||
|     SET_TMC_CURRENT STEPPER=stepper_x  CURRENT={xy_run} HOLDCURRENT={xy_hold} | ||||
|     SET_TMC_CURRENT STEPPER=stepper_y  CURRENT={xy_run} HOLDCURRENT={xy_hold} | ||||
|     SET_TMC_CURRENT STEPPER=stepper_z  CURRENT={z_run} HOLDCURRENT={z_hold} | ||||
|     SET_TMC_CURRENT STEPPER=stepper_z1 CURRENT={z_run} HOLDCURRENT={z_hold} | ||||
|     SET_TMC_CURRENT STEPPER=stepper_z2 CURRENT={z_run} HOLDCURRENT={z_hold} | ||||
|     SET_TMC_CURRENT STEPPER=stepper_z3 CURRENT={z_run} HOLDCURRENT={z_hold} | ||||
|     M400 | ||||
|   {% endif %} | ||||
| 
 | ||||
| [gcode_macro _SET_ACC] | ||||
| description: Helper: Set accel and accel_to_decel value | ||||
| variable_last_val: 'CONFIG' | ||||
| gcode: | ||||
|   ##### set default value ##### | ||||
|   {% set default_respond = printer['gcode_macro _USER_VARIABLE'].respond_set_acc|int %} | ||||
|   {% set val = params.VAL|default('CONFIG') %} | ||||
|   {% set respond = params.RESPOND|default(default_respond)|int %} | ||||
|   {% if val == 'HOME' %} | ||||
|     {% set accel = printer['gcode_macro _USER_VARIABLE'].home_accel %} | ||||
|     {% set accel_to_decel = printer['gcode_macro _USER_VARIABLE'].home_accel|int / 2 %} | ||||
|   {% else %} | ||||
|     {% set accel = printer.configfile.settings.printer.max_accel %} | ||||
|     {% set accel_to_decel = printer.configfile.settings.printer.max_accel_to_decel %} | ||||
|   {% endif %} | ||||
|   ##### end of definition ##### | ||||
|   {% if val != last_val %} | ||||
|     SET_GCODE_VARIABLE MACRO=_SET_ACC VARIABLE=last_val VALUE='"{val}"' | ||||
|     {% if respond == 1 %} | ||||
|       {action_respond_info("VELOCITY_LIMIT set ACCEL: %d ACCEL_TO_DECEL: %d" % (accel|int, accel_to_decel|int))} | ||||
|     {% endif %} | ||||
|     SET_VELOCITY_LIMIT ACCEL={accel} ACCEL_TO_DECEL={accel_to_decel} RESPOND=0 | ||||
|   {% endif %} | ||||
							
								
								
									
										48
									
								
								z_calibration/macros.cfg
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								z_calibration/macros.cfg
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,48 @@ | |||
| ##################################################################### | ||||
| #    Macros | ||||
| ##################################################################### | ||||
| [gcode_macro PRINT_START] | ||||
| gcode: | ||||
|     {% set bed_temp = params.BED_TEMP|default(100)|float %} | ||||
|     {% set extruder_temp = params.EXTRUDER_TEMP|default(220)|float %} | ||||
|     {% set z_adjust = params.Z_ADJUST|default(0.0)|float %} | ||||
|     {% set retract = 10 %} | ||||
|     BED_MESH_CLEAR                    ; clear mesh | ||||
|     _CG28                             ; Home the printer | ||||
|     G90                               ; Use absolute coordinates | ||||
|     PARKCENTER                        ; Move to center | ||||
|     M117 Heating.. | ||||
|     _HEATER_ON | ||||
|     M106 S255                         ; set print fan to full speed | ||||
|     M140 S{bed_temp}                  ; Start bed heating | ||||
|     M190 S{bed_temp}                  ; Wait for bed to reach temperature | ||||
|     M109 S{extruder_temp}             ; Set and wait for nozzle to reach temperature | ||||
|     M107                              ; turn print fan off | ||||
|     QUAD_GANTRY_LEVEL PARK=false | ||||
|     M109 S{extruder_temp}             ; Set and wait for nozzle to reach temperature | ||||
|     clean_nozzle                      ; clean nozzle | ||||
|     CALIBRATE_Z | ||||
|     #BED_MESH_PROFILE LOAD=default   ; load mesh if needed | ||||
|     # Adjust the G-Code Z offset with the Z_ADJUST parameter if needed | ||||
|     #SET_GCODE_OFFSET Z_ADJUST={z_adjust} MOVE=1 | ||||
|     M117 Intro Line.. | ||||
|     G90                               ; Use absolute coordinates | ||||
|     G1 Y0 X130 Z5 F12000              ; Move the nozzle to the front and near the bed | ||||
|     G1 Z0.7 F300                      ; Move the nozzle very close to the bed | ||||
|     G92 E0.0                          ; set extruder position to 0 | ||||
|     G1 E{retract} F3600               ; extrude retract | ||||
|     G92 E0.0                          ; set extruder option to 0 | ||||
|     G1 X180 E15.0 F500.0              ; intro line | ||||
|     G92 E0.0                          ; set extruder Poisson to 0 | ||||
|     G1 X174 F6000                     ; move away from intro line | ||||
|     M117 | ||||
| 
 | ||||
| [gcode_macro PARKCENTER] | ||||
| gcode: | ||||
|     {% set Z = params.Z|default(30)|float %} | ||||
|     SAVE_GCODE_STATE NAME=PARKCENTER_state | ||||
|     _CG28                          ; Home if not already homed | ||||
|     G90                            ; absolute positioning | ||||
|     G0 X150 Y150 Z{Z} F12000       ; move to center | ||||
|     RESTORE_GCODE_STATE NAME=PARKCENTER_state | ||||
| 
 | ||||
							
								
								
									
										37
									
								
								z_calibration/printer.cfg
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								z_calibration/printer.cfg
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,37 @@ | |||
| ##################################################################### | ||||
| #    User Variables | ||||
| ##################################################################### | ||||
| [gcode_macro _USER_VARIABLE] | ||||
| description: Helper: Contains User defined printer variables | ||||
| ##### Homing and general movement ##### | ||||
| variable_z_endstop_x: 208             ; z Endstop x position inside right profile | ||||
| variable_z_endstop_y: 305             ; z Endstop y position | ||||
| variable_z_hop: 10.0                  ; z hop for moves e.g homing | ||||
| variable_xy_home_current: 0.4         ; reduced homing current for x and y | ||||
| variable_z_home_current: 0.3          ; reduced homing current for z | ||||
| variable_home_accel: 1200             ; reduced ACCEL for homing | ||||
| ##### Mag Probe ##### | ||||
| variable_probe_dock_x: 148            ; x toolhead position before docking probe | ||||
| variable_probe_dock_y: 285            ; y toolhead position before docking probe | ||||
| variable_probe_dock_z: 10             ; z toolhead position before docking probe (only for bed dock) | ||||
| variable_probe_undock_x: 200          ; x toolhead position after docking probe | ||||
| variable_probe_undock_y: 305          ; y toolhead position after docking probe | ||||
| variable_probe_undock_z: 10           ; z toolhead position after docking probe (only for bed dock) | ||||
| variable_probe_z_min: 10              ; z minimum height to avoid crash | ||||
| variable_probe_travel_speed: 200      ; dock moves travel speed | ||||
| variable_probe_dock_speed: 100        ; dock speed for attach/dock | ||||
| ##### Respond defaults ##### | ||||
| variable_respond_set_current: 0       ; default of RESPOND if not set in the call | ||||
| variable_respond_set_acc: 0           ; default of RESPOND if not set in the call | ||||
| variable_respond_probe_action: 1      ; default of RESPOND if not set in the call | ||||
| ##### Park Position ##### | ||||
| variable_park_bed: [150,150,30]       ; different park position | ||||
| gcode: | ||||
| 
 | ||||
| ##################################################################### | ||||
| #    Includes | ||||
| ##################################################################### | ||||
| [include macros.cfg] | ||||
| [include homing.cfg] | ||||
| [include probing.cfg] | ||||
| [include z_calibration.cfg] | ||||
							
								
								
									
										567
									
								
								z_calibration/probing.cfg
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										567
									
								
								z_calibration/probing.cfg
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,567 @@ | |||
| ##################################################################### | ||||
| #    Mag Probe | ||||
| ##################################################################### | ||||
| # defined in printer.cfg | ||||
|    | ||||
| ##################################################################### | ||||
| #    Gantry Adjustment Routines | ||||
| ##################################################################### | ||||
| [quad_gantry_level] | ||||
| ##	Gantry Corners for 300mm Build | ||||
| gantry_corners: | ||||
| 	-60,-10 | ||||
| 	360,370 | ||||
| #	Probe points for 300m Build | ||||
| points: | ||||
| 	50,25 | ||||
| 	50,225 | ||||
| 	250,225 | ||||
| 	250,25 | ||||
| speed: 300 | ||||
| horizontal_move_z: 10 | ||||
| retries: 5 | ||||
| retry_tolerance: 0.007 | ||||
| max_adjust: 10 | ||||
| 
 | ||||
| ##################################################################### | ||||
| #    Macros | ||||
| ##################################################################### | ||||
| [gcode_macro QUAD_GANTRY_LEVEL] | ||||
| description: Level a flying gantry to a stationary bed | ||||
| rename_existing: QUAD_GANTRY_LEVEL_BASE | ||||
| gcode: | ||||
|   #####  get user defines  ##### | ||||
|   {% set park_pos = printer['gcode_macro _USER_VARIABLE'].park_bed %} | ||||
|   {% set z_hop = printer['gcode_macro _USER_VARIABLE'].z_hop|float %} | ||||
|   ##### get toolhead position ##### | ||||
|   {% set act_z = printer.toolhead.position.z|float %} | ||||
|   #####  set default  ##### | ||||
|   {% set park = params.PARK|default('true') %} | ||||
|   #####  end of definitions  ##### | ||||
|   # home all axes if not already | ||||
|   {% if "xyz" not in printer.toolhead.homed_axes %} | ||||
|     _CG28 | ||||
|   {% endif %} | ||||
|   SAVE_GCODE_STATE NAME=STATE_QUAD_GANTRY_LEVEL | ||||
|   _SET_ACC VAL=HOME | ||||
|   _SET_CURRENT VAL=HOME | ||||
|   _CG28 RESET_SETTINGS=false | ||||
|   {% if act_z < z_hop %} | ||||
|     G1 Z{z_hop} F900 ; move head up to insure Probe is not triggered in error case | ||||
|   {% endif %} | ||||
|   ATTACH_PROBE  | ||||
|   QUAD_GANTRY_LEVEL_BASE | ||||
|   {% if params.CALIBRATE|default('false') == 'true' %} | ||||
|     CALIBRATE_Z RESET_SETTINGS=false | ||||
|   {% else %} | ||||
|     DETACH_PROBE | ||||
|   {% endif %} | ||||
|   #G28 Z | ||||
|   {% if params.RESET_SETTINGS|default('true') == 'true' %} | ||||
|     _SET_CURRENT | ||||
|     _SET_ACC | ||||
|   {% endif %} | ||||
|   {% if park|lower == 'true' %} | ||||
|     G90 | ||||
|     G0 Z{park_pos[2]} F1800           ; move nozzle to z high first | ||||
|     G0 X{park_pos[0]} Y{park_pos[1]} F18000 ; home to get toolhead in the middle | ||||
|   {% endif %} | ||||
|   RESTORE_GCODE_STATE NAME=STATE_QUAD_GANTRY_LEVEL | ||||
| 
 | ||||
| [gcode_macro ATTACH_PROBE] | ||||
| description: Attaching the MagProbe if not already attached | ||||
| gcode: | ||||
|   _MAG_PROBE ACTION=ATTACH | ||||
|   _MAG_PROBE ACTION=CHECK_ATTACH | ||||
| 
 | ||||
| [gcode_macro DETACH_PROBE] | ||||
| description: Dock the MagProbe if not already docked | ||||
| gcode: | ||||
|   _MAG_PROBE ACTION=DOCK | ||||
|   _MAG_PROBE ACTION=CHECK_DOCK | ||||
|    | ||||
| [gcode_macro GET_PROBE_STATUS] | ||||
| description: Prints the current MagProbe state, valid probe states are UNKNOWN, ATTACHED and DOCKED | ||||
| gcode: | ||||
|   _MAG_PROBE ACTION=GET_STATUS RESPOND=1 | ||||
|    | ||||
| 
 | ||||
| [gcode_macro SET_PROBE_STATUS] | ||||
| description: Manually specify MagProbe status, valid probe states are UNKNOWN, ATTACHED and DOCKED | ||||
| variable_state: 'unknown' | ||||
| gcode: | ||||
|   {% if 'STATE' in params|upper and  | ||||
|         (params.STATE|lower == 'unknown' or params.STATE|lower == 'attached' or params.STATE|lower == 'docked') %} | ||||
|     SET_GCODE_VARIABLE MACRO=SET_PROBE_STATUS VARIABLE=state VALUE='"{params.STATE|lower}"' | ||||
|     SET_GCODE_VARIABLE MACRO=_MAG_PROBE VARIABLE=state VALUE='"{params.STATE|lower}"' | ||||
|   {% else %} | ||||
|     {% set state = params.STATE|default('none') %} | ||||
|     {action_raise_error("Invalid probe state: %s. Valid probe states are [UNKNOWN, ATTACHED, DOCKED]" % state|upper)} | ||||
|   {% endif %} | ||||
|      | ||||
| ##################################################################### | ||||
| #    Helper Macros | ||||
| ##################################################################### | ||||
| # QUERY_PROBE must run direct before _PROBE_ACTION | ||||
| # that relation is insured by the caller id | ||||
| [gcode_macro _MAG_PROBE] | ||||
| description: Helper: Query MagProbe state and request action | ||||
| variable_state: 'unknown' | ||||
| variable_id: 0 | ||||
| gcode: | ||||
|   ##### add RESPOND if specified ##### | ||||
|   {% if 'RESPOND' in params|upper %} | ||||
|     {% set respond = "RESPOND=" + params.RESPOND %} | ||||
|   {% else %} | ||||
|     {% set respond = "" %} | ||||
|   {% endif %} | ||||
|   ##### generate an id not equal to 0 ##### | ||||
|   {% if id == 0 %} | ||||
|     {% set id = 1 %} | ||||
|   {% else %} | ||||
|     {% set id = id + 1 %} | ||||
|   {% endif %} | ||||
|   ##### end of definition ##### | ||||
|   QUERY_PROBE ID={id} | ||||
|   _PROBE_ACTION ACTION={params.ACTION} ID={id} {respond} | ||||
|   SET_GCODE_VARIABLE MACRO=_MAG_PROBE VARIABLE=id VALUE={id} | ||||
|   M400 | ||||
| 
 | ||||
| [gcode_macro _PROBE_ACTION] | ||||
| description: Helper: Perform MagProbe action | ||||
| gcode: | ||||
|   ##### get params and defaults ##### | ||||
|   {% set default_respond = printer['gcode_macro _USER_VARIABLE'].respond_probe_action|default(1)|int %} | ||||
|   {% set respond = params.RESPOND|default(default_respond)|int %} | ||||
|   {% set action = params.ACTION|lower %} | ||||
|   {% set id = params.ID|default(0)|int %} ; call id 0 means invalid | ||||
|   ##### get probe variables ##### | ||||
|   {% set probe_id = printer['gcode_macro QUERY_PROBE'].id|default(0)|int %} | ||||
|   {% set man_state = printer['gcode_macro SET_PROBE_STATUS'].state|lower %} | ||||
|   ##### generate state ##### | ||||
|   {% if man_state != 'unknown' %} | ||||
|     SET_GCODE_VARIABLE MACRO=SET_PROBE_STATUS VARIABLE=state VALUE='"unknown"' | ||||
|     {% set state = man_state %} | ||||
|     {% if respond == 1 %} | ||||
|       {action_respond_info("MagProbe: State was set to %s by SET_PROBE_STATUS"% man_state|upper)} | ||||
|     {% endif %} | ||||
|   {% elif id == 0 or id != probe_id %} | ||||
|     {action_raise_error("MagProbe: Call ID invalid or does not match QUERY_PROBE call ID")} | ||||
|   {% elif printer.probe.last_query|lower == 'false' %} | ||||
|     {action_raise_error("MagProbe: Please execute QUERY_PROBE first")} | ||||
|   {% else %} | ||||
|     {% if printer.probe.last_query|int == 0 %} | ||||
|       {% set state = 'attached' %} | ||||
|     {% else %} | ||||
|       {% set state = 'docked' %} | ||||
|     {% endif %} | ||||
|   {% endif %} | ||||
|   ##### end of defines ##### | ||||
|   SET_GCODE_VARIABLE MACRO=_MAG_PROBE VARIABLE=state VALUE='"{state}"' | ||||
|   {% if action == 'attach' %} | ||||
|     {% if state == 'docked' %} | ||||
|       {% if respond == 1 %} | ||||
|         {action_respond_info("MagProbe: Attach Probe")} | ||||
|       {% endif %} | ||||
|       _ATTACH_PROBE | ||||
|     {% else %} | ||||
|       {% if respond == 1 %} | ||||
|         {action_respond_info("MagProbe: already attached")} | ||||
|       {% endif %} | ||||
|     {% endif %} | ||||
|   {% elif action == 'dock' %} | ||||
|     {% if state == 'attached' %} | ||||
|       {% if respond == 1 %} | ||||
|         {action_respond_info("MagProbe: Dock Probe")} | ||||
|       {% endif %} | ||||
|       _DOCK_PROBE | ||||
|     {% else %} | ||||
|       {% if respond == 1 %} | ||||
|         {action_respond_info("MagProbe: already docked")} | ||||
|       {% endif %} | ||||
|     {% endif %} | ||||
|   {% elif action == 'check_dock' %} | ||||
|     {% if state != 'docked' %} | ||||
|       {action_raise_error("MagProbe: dock failed!")} | ||||
|     {% endif %} | ||||
|   {% elif action == 'check_attach' %} | ||||
|     {% if state != 'attached' %} | ||||
|       {action_raise_error("MagProbe: attach failed!")} | ||||
|     {% endif %} | ||||
|   {% elif action == 'get_status' %} | ||||
|     {% if respond == 1 %} | ||||
|       {action_respond_info("MagProbe Status: %s" % state)} | ||||
|     {% endif %} | ||||
|   {% else %} | ||||
|     {action_raise_error("MagProbe: action not defined")} | ||||
|   {% endif %} | ||||
| 
 | ||||
| [gcode_macro _ATTACH_PROBE] | ||||
| description: Helper: Attach MagProbe | ||||
| gcode: | ||||
|   ##### Get user defines ##### | ||||
|   {% set dock_x = printer['gcode_macro _USER_VARIABLE'].probe_dock_x %} | ||||
|   {% set dock_y = printer['gcode_macro _USER_VARIABLE'].probe_dock_y %} | ||||
|   {% set dock_z = printer['gcode_macro _USER_VARIABLE'].probe_dock_z %} | ||||
|   {% set undock_x = printer['gcode_macro _USER_VARIABLE'].probe_undock_x %} | ||||
|   {% set undock_y = printer['gcode_macro _USER_VARIABLE'].probe_undock_y %} | ||||
|   {% set undock_z = printer['gcode_macro _USER_VARIABLE'].probe_undock_z %} | ||||
|   {% set z_min = printer['gcode_macro _USER_VARIABLE'].probe_z_min|float %} | ||||
|   {% set t_speed = printer['gcode_macro _USER_VARIABLE'].probe_travel_speed|float * 60 %} | ||||
|   {% set d_speed = printer['gcode_macro _USER_VARIABLE'].probe_dock_speed|float * 60 %} | ||||
|   ##### get toolhead position ##### | ||||
|   {% set act_z = printer.toolhead.position.z|float %} | ||||
|   ##### end of definitions ##### | ||||
|   SAVE_GCODE_STATE NAME=STATE_ATTACH_PROBE | ||||
|   SET_GCODE_OFFSET Z=0.0                ; reset offset - will be restored | ||||
|   G90                                   ; absolute positioning | ||||
|   {% if act_z < z_min %} | ||||
|     G0 Z{z_min} F1500                   ; move head up | ||||
|   {% endif %} | ||||
| 
 | ||||
|   ################################################################### | ||||
|   #        !!! Caution !!! | ||||
|   # | ||||
|   # Adapt for your needs if needed !! | ||||
|   ################################################################### | ||||
| 
 | ||||
|   ##### Example for a bed dock: | ||||
|   #G0 X{undock_x} Y{undock_y} F{t_speed} ; move to mag-probe | ||||
|   #G0 Z{dock_z} F1500 FORCE              ; move down to probe | ||||
|   #G0 Y{dock_y} F{d_speed}               ; move out of holder | ||||
|   #G0 Z{undock_z} F1500                  ; move head up | ||||
| 
 | ||||
|   ##### Example for a gantry dock: | ||||
|   G0 X{undock_x} Y{undock_y} F{t_speed} ; move next to mag-probe | ||||
|   G0 X{dock_x} F{d_speed}               ; move sideways to attach probe | ||||
|   G0 Y{dock_y} F{d_speed}               ; move out of holder | ||||
| 
 | ||||
|   RESTORE_GCODE_STATE NAME=STATE_ATTACH_PROBE | ||||
| 
 | ||||
| [gcode_macro _DOCK_PROBE] | ||||
| description: Helper: Dock MagProbe | ||||
| gcode: | ||||
|   ##### Get user defines ##### | ||||
|   {% set dock_x = printer['gcode_macro _USER_VARIABLE'].probe_dock_x %} | ||||
|   {% set dock_y = printer['gcode_macro _USER_VARIABLE'].probe_dock_y %} | ||||
|   {% set dock_z = printer['gcode_macro _USER_VARIABLE'].probe_dock_z %} | ||||
|   {% set undock_x = printer['gcode_macro _USER_VARIABLE'].probe_undock_x %} | ||||
|   {% set undock_y = printer['gcode_macro _USER_VARIABLE'].probe_undock_y %} | ||||
|   {% set undock_z = printer['gcode_macro _USER_VARIABLE'].probe_undock_z %} | ||||
|   {% set z_min = printer['gcode_macro _USER_VARIABLE'].probe_z_min|float %} | ||||
|   {% set t_speed = printer['gcode_macro _USER_VARIABLE'].probe_travel_speed|float * 60 %} | ||||
|   {% set d_speed = printer['gcode_macro _USER_VARIABLE'].probe_dock_speed|float * 60 %} | ||||
|   ##### get toolhead position ##### | ||||
|   {% set act_z = printer.toolhead.position.z|float %} | ||||
|   ##### end of definitions ##### | ||||
|   SAVE_GCODE_STATE NAME=STATE_DOCK_PROBE | ||||
|   SET_GCODE_OFFSET Z=0.0                ; reset offset - will be restored | ||||
|   G90                                   ; absolute positioning | ||||
|   {% if act_z < z_min %} | ||||
|     G0 Z{z_min} F900                    ; move head up | ||||
|   {% endif %} | ||||
| 
 | ||||
|   ################################################################### | ||||
|   #        !!! Caution !!! | ||||
|   # | ||||
|   # Adapt for your needs if needed !! | ||||
|   ################################################################### | ||||
| 
 | ||||
|   ##### Example for a bed dock: | ||||
|   #G0 X{dock_x} Y{dock_y} F{t_speed}     ; move to mag-probe | ||||
|   #G0 Z{dock_z} F1500 FORCE              ; move down to probe | ||||
|   #G0 Y{undock_y} F{d_speed}             ; move into the holder | ||||
|   #G0 Z{undock_z} F1500                  ; move upwards to remove probe | ||||
| 
 | ||||
|   ##### Example for a gantry dock: | ||||
|   G0 X{dock_x} Y{dock_y} F{t_speed}     ; move in front of mag-probe | ||||
|   G0 Y{undock_y} F{d_speed}             ; move into the holder | ||||
|   G0 X{undock_x} F{d_speed}             ; move sideways to remove probe   | ||||
|    | ||||
|   RESTORE_GCODE_STATE NAME=STATE_DOCK_PROBE | ||||
| 
 | ||||
| ##################################################################### | ||||
| #	Customized standard macros | ||||
| ##################################################################### | ||||
| # | ||||
| #        !!! Caution !!! | ||||
| # | ||||
| # PROBE_CALIBRATE can not dock the Magprobe automatically, as it  | ||||
| # start's a scripting process we need to stop at the execution  | ||||
| # of the base macro. Use  | ||||
| #  - PROBE_ABORT | ||||
| #  - PROBE_ACCEPT | ||||
| # instead of the original ABORT and ACCEPT to also dock the probe | ||||
| # | ||||
| ##################################################################### | ||||
| # | ||||
| # If your probe needs a Z move for attach/detach use either | ||||
| #   G0 .... FORCE | ||||
| #   G1 .... FORCE | ||||
| # | ||||
| ##################################################################### | ||||
| [gcode_macro G0] | ||||
| description: Move gcode that prevents moves lower than the limit when probe attached | ||||
| rename_existing: G0.1 | ||||
| gcode: | ||||
|   ##### set manual override ##### | ||||
|   {% if 'FORCE' in params|upper %} | ||||
|     {% set force = 1 %} | ||||
|   {% else %} | ||||
|     {% set force = 0 %} | ||||
|   {% endif %} | ||||
|   ##### get params ##### | ||||
|   {% set get_params = [] %} | ||||
|   {% for key in params %} | ||||
|     {% if key is not in ['G', 'FORCE'] %} ;G1/G0 is also seen as parameter | ||||
|       {% set get_params = get_params.append(key + "=" + params[key])  %} | ||||
|     {% endif %} | ||||
|   {% endfor %} | ||||
|   ##### add caller ##### | ||||
|   {% set tmp = get_params.append("CALLER=G0") %} ;hack to append list objects outside of a loop | ||||
|   ##### add force ##### | ||||
|   {% set tmp = get_params.append("FORCE=" + force|string) %} ;hack to append list objects outside of a loop | ||||
|   ##### end of definition ##### | ||||
|   {% if printer['gcode_macro _MAG_PROBE'].state|lower == 'unknown' and force == 0 %} | ||||
|     _MAG_PROBE ACTION=GET_STATUS RESPOND=0 | ||||
|   {% endif %} | ||||
|   _Z_MOVE_CHECK {get_params|join(" ")} | ||||
| 
 | ||||
| [gcode_macro G1] | ||||
| description: Move gcode that prevents moves lower than the limit when probe attached | ||||
| rename_existing: G1.1 | ||||
| gcode: | ||||
|   ##### set manual override ##### | ||||
|   {% if 'FORCE' in params|upper %} | ||||
|     {% set force = 1 %} | ||||
|   {% else %} | ||||
|     {% set force = 0 %} | ||||
|   {% endif %} | ||||
|   ##### get params ##### | ||||
|   {% set get_params = [] %} | ||||
|   {% for key in params %} | ||||
|     {% if key is not in ['G', 'FORCE'] %} ;G1/G0 is also seen as parameter | ||||
|       {% set get_params = get_params.append(key + "=" + params[key])  %} | ||||
|     {% endif %} | ||||
|   {% endfor %} | ||||
|   ##### add caller ##### | ||||
|   {% set tmp = get_params.append("CALLER=G1") %} ;hack to append list objects outside of a loop | ||||
|   ##### add force ##### | ||||
|   {% set tmp = get_params.append("FORCE=" + force|string) %} ;hack to append list objects outside of a loop | ||||
|   ##### end of definition ##### | ||||
|   {% if printer['gcode_macro _MAG_PROBE'].state|lower == 'unknown' and force == 0 %} | ||||
|     _MAG_PROBE ACTION=GET_STATUS RESPOND=0 | ||||
|   {% endif %} | ||||
|   _Z_MOVE_CHECK {get_params|join(" ")} | ||||
|    | ||||
| [gcode_macro _Z_MOVE_CHECK] | ||||
| description: Helper: Check limit and perform move | ||||
| gcode: | ||||
|   ##### define defaults ###### | ||||
|   {% set caller = params.CALLER|default('G0')|upper %} | ||||
|   {% set force = params.FORCE|default(0)|int %} | ||||
|   ##### z values ##### | ||||
|   {% set z_min = printer['gcode_macro _USER_VARIABLE'].probe_z_min|float %} | ||||
|   {% set z_act = printer.toolhead.position.z|float %} | ||||
|   ##### MagProbe state ##### | ||||
|   {% set probe_state = printer['gcode_macro _MAG_PROBE'].state|lower %} | ||||
|   ##### get params and prepare to send them to the base macro ##### | ||||
|   {% set get_params = [] %} | ||||
|   {% for key in params %} | ||||
|     {% if key is not in ['Z', 'CALLER', 'FORCE'] %} | ||||
|       {% set get_params = get_params.append(key + params[key]) %} | ||||
|     {% elif key is in ['Z'] %} | ||||
|       {% if force == 1 %} ;manual override of probe check | ||||
|         {% set get_params = get_params.append(key + params[key]) %} | ||||
|       {% elif probe_state ==  'unknown' %} | ||||
|         {action_raise_error("%s: MagProbe state %s run \"_MAG_PROBE ACTION=GET_STATUS\"" % (caller, probe_state|upper))} | ||||
|       {% elif probe_state ==  'docked' %} | ||||
|         {% set get_params = get_params.append(key + params[key]) %} | ||||
|       {% elif probe_state ==  'attached' %} | ||||
|         ##### define move target position depending on absolute_coordinates ##### | ||||
|         {% if printer.gcode_move.absolute_coordinates|lower == 'true' %} | ||||
|           {% set z_target = params.Z|float %} | ||||
|         {% else %} | ||||
|           {% set z_target = z_act + params.Z|float %} | ||||
|         {% endif %} | ||||
|         ##### decide if a Z move can be executed ##### | ||||
|         {% if z_target > z_min or z_act < z_target %} | ||||
|           {% set get_params = get_params.append(key + params[key]) %}               | ||||
|         {% else %} | ||||
|           {action_respond_info("%s: Z Moves lower than %.1fmm not allowed with installed probe" % (caller,z_min))}   | ||||
|         {% endif %} | ||||
|       {% else %} | ||||
|         {action_raise_error("%s: MagProbe state %s not valid" % (caller, probe_state|upper))} | ||||
|       {% endif %} | ||||
|     {% endif %} | ||||
|   {% endfor %} | ||||
|   ##### end of definitions ##### | ||||
|   {caller}.1 {get_params|join(" ")} | ||||
| 
 | ||||
| [gcode_macro QUERY_PROBE] | ||||
| description: Return the status of the z-probe and store ID | ||||
| rename_existing: QUERY_PROBE_BASE | ||||
| variable_id: 0 | ||||
| gcode: | ||||
|   {% set id = params.ID|default(0) %} ; call id 0 means invalid | ||||
|   QUERY_PROBE_BASE | ||||
|   SET_GCODE_VARIABLE MACRO=QUERY_PROBE VARIABLE=id VALUE={id} | ||||
| 
 | ||||
| [gcode_macro PROBE_ACCURACY] | ||||
| description: Probe Z-height accuracy at current XY position and dock/undock MagProbe | ||||
| rename_existing: PROBE_ACCURACY_BASE | ||||
| gcode: | ||||
|   #####  get new parameter. ##### | ||||
|   {% set dock = params.DOCK|default(1)|int %} ; use DOCK=0 to omit the probe docking | ||||
|   ##### get user defines  ##### | ||||
|   {% set z_min = printer['gcode_macro _USER_VARIABLE'].probe_z_min|float %} | ||||
|   {% set t_speed = printer['gcode_macro _USER_VARIABLE'].probe_travel_speed|float * 60 %} | ||||
|   ##### get toolhead parameters ##### | ||||
|   {% set act_z = printer.gcode_move.gcode_position.z|float %} | ||||
|   {% set absolute_coordinates = printer.gcode_move.absolute_coordinates|lower %} | ||||
|   ##### get params and prepare to send them to the base macro ##### | ||||
|   {% set get_params = [] %} | ||||
|   {% for key in params %} | ||||
|     {% set get_params = get_params.append(key + "=" + params[key])  %} | ||||
|   {% endfor %} | ||||
|   ##### end of definitions ##### | ||||
|   # as we need to return to the position with the probe we need to be at least at z_min | ||||
|   G90 ; absolute positioning | ||||
|   {% if act_z < z_min %} | ||||
|     {action_respond_info("PROBE_ACCURACY: High must be above %.2f" % z_min)} | ||||
|     G1 Z{z_min} F900 ; move head up | ||||
|   {% endif %} | ||||
|   M400 ; get the buffer cleared first | ||||
|   SAVE_GCODE_STATE NAME=STATE_PROBE_ACCURACY | ||||
|   ATTACH_PROBE | ||||
|   RESTORE_GCODE_STATE NAME=STATE_PROBE_ACCURACY MOVE=1 MOVE_SPEED={t_speed} | ||||
|   PROBE_ACCURACY_BASE {get_params|join(" ")} | ||||
|   {% if dock == 1 %} | ||||
|     DETACH_PROBE | ||||
|     RESTORE_GCODE_STATE NAME=STATE_PROBE_ACCURACY MOVE=1 MOVE_SPEED={t_speed} | ||||
|   {% endif %} | ||||
|   {% if absolute_coordinates == 'false' %} G91 {% endif %} | ||||
|    | ||||
| [gcode_macro PROBE] | ||||
| description: Probe Z-height at current XY position and dock/undock MagProbe | ||||
| rename_existing: PROBE_BASE | ||||
| gcode: | ||||
|   #####  get new parameter. ##### | ||||
|   {% set dock = params.DOCK|default(1)|int %} ; use DOCK=0 to omit the probe docking | ||||
|   ##### get user defines  ##### | ||||
|   {% set z_min = printer['gcode_macro _USER_VARIABLE'].probe_z_min|float %} | ||||
|   {% set t_speed = printer['gcode_macro _USER_VARIABLE'].probe_travel_speed|float * 60 %} | ||||
|   ##### get toolhead parameters ##### | ||||
|   {% set act_z = printer.gcode_move.gcode_position.z|float %} | ||||
|   {% set absolute_coordinates = printer.gcode_move.absolute_coordinates|lower %} | ||||
|   ##### get params and prepare to send them to the base macro ##### | ||||
|   {% set get_params = [] %} | ||||
|   {% for key in params %} | ||||
|     {% set get_params = get_params.append(key + "=" + params[key])  %} | ||||
|   {% endfor %} | ||||
|   ##### end of definitions ##### | ||||
|   # as we need to return to the position with the probe we need to be at least at z_min | ||||
|   G90 ; absolute positioning | ||||
|   {% if act_z < z_min %} | ||||
|     {action_respond_info("PROBE: High must be above %.2f" % z_min)} | ||||
|     G1 Z{z_min} F900 ; move head up | ||||
|   {% endif %} | ||||
|   M400 ; get the buffer cleared first | ||||
|   SAVE_GCODE_STATE NAME=STATE_PROBE | ||||
|   ATTACH_PROBE | ||||
|   RESTORE_GCODE_STATE NAME=STATE_PROBE MOVE=1 MOVE_SPEED={t_speed} | ||||
|   PROBE_BASE {get_params|join(" ")} | ||||
|   G1 Z{z_min} F900 ; move head up to remove trigger | ||||
|   {% if dock == 1 %} | ||||
|     DETACH_PROBE | ||||
|     RESTORE_GCODE_STATE NAME=STATE_PROBE MOVE=1 MOVE_SPEED={t_speed} | ||||
|   {% endif %} | ||||
|   {% if absolute_coordinates == 'false' %} G91 {% endif %} | ||||
|    | ||||
| [gcode_macro PROBE_CALIBRATE] | ||||
| description: Calibrate the probes z_offset and undock MagProbe | ||||
| rename_existing: PROBE_CALIBRATE_BASE | ||||
| gcode: | ||||
|   ##### get user defines  ##### | ||||
|   {% set z_min = printer['gcode_macro _USER_VARIABLE'].probe_z_min|float %} | ||||
|   {% set t_speed = printer['gcode_macro _USER_VARIABLE'].probe_travel_speed|float * 60 %} | ||||
|   ##### get toolhead parameters ##### | ||||
|   {% set act_z = printer.gcode_move.gcode_position.z|float %} | ||||
|   {% set absolute_coordinates = printer.gcode_move.absolute_coordinates|lower %} | ||||
|   ##### get params and prepare to send them to the base macro ##### | ||||
|   {% set get_params = [] %} | ||||
|   {% for key in params %} | ||||
|     {% set get_params = get_params.append(key + "=" + params[key])  %} | ||||
|   {% endfor %} | ||||
|   ##### end of definitions ##### | ||||
|   # as we need to return to the position with the probe we need to be at least at z_min | ||||
|   G90 ; absolute positioning | ||||
|   {% if act_z < z_min %} | ||||
|     {action_respond_info("PROBE_CALIBRATE: High must be above %.2f" % z_min)} | ||||
|     G1 Z{z_min} F900 ; move head up | ||||
|   {% endif %} | ||||
|   M400 ; get the buffer cleared first | ||||
|   SAVE_GCODE_STATE NAME=STATE_PROBE_CALIBRATE | ||||
|   ATTACH_PROBE | ||||
|   RESTORE_GCODE_STATE NAME=STATE_PROBE_CALIBRATE MOVE=1 MOVE_SPEED={t_speed} | ||||
|   SET_GCODE_VARIABLE MACRO=PROBE_ABORT VARIABLE=caller VALUE='"calib"' | ||||
|   SET_GCODE_VARIABLE MACRO=PROBE_ABORT VARIABLE=absolute_coordinates VALUE='"{absolute_coordinates}"' | ||||
|   PROBE_CALIBRATE_BASE {get_params|join(" ")} | ||||
|    | ||||
| [gcode_macro BED_MESH_CALIBRATE] | ||||
| description: Perform QGL and bed mesh leveling | ||||
| rename_existing: BED_MESH_CALIBRATE_BASE | ||||
| gcode: | ||||
|   ##### get params and prepare to send them to the base macro ##### | ||||
|   {% set get_params = [] %} | ||||
|   {% for key in params %} | ||||
|     {% set get_params = get_params.append(key + "=" + params[key])  %} | ||||
|   {% endfor %} | ||||
|   ##### end of definitions ##### | ||||
|   _CG28 | ||||
|   BED_MESH_CLEAR | ||||
|   ## check if QGL was already executed | ||||
|   {% if printer.quad_gantry_level.applied|lower == 'false' %} | ||||
|     QUAD_GANTRY_LEVEL PARK=false | ||||
|   {% endif %} | ||||
|   ATTACH_PROBE | ||||
|   BED_MESH_CALIBRATE_BASE {get_params|join(" ")} | ||||
|   DETACH_PROBE | ||||
| 
 | ||||
| [gcode_macro PROBE_ABORT] | ||||
| description: Abort manual Z probing tool for Probe and dock MagProbe | ||||
| variable_caller: 'unknown' | ||||
| variable_absolute_coordinates: False | ||||
| gcode: | ||||
|   ##### get user defines  ##### | ||||
|   {% set t_speed = printer['gcode_macro _USER_VARIABLE'].probe_travel_speed|float * 60 %} | ||||
|   ##### end of definitions ##### | ||||
|   {% if caller|lower|string == 'calib' %} | ||||
|     ABORT | ||||
|     DETACH_PROBE | ||||
|     RESTORE_GCODE_STATE NAME=STATE_PROBE_CALIBRATE MOVE=1 MOVE_SPEED={t_speed} | ||||
|     {% if absolute_coordinates == 'false' %} G91 {% endif %} | ||||
|       SET_GCODE_VARIABLE MACRO=PROBE_ABORT VARIABLE=caller VALUE='"unknown"' | ||||
|   {% else %} | ||||
|     {action_respond_info("PROBE_ABORT: Executed while PROBE_CALIBRATE is not running")} | ||||
|   {% endif %} | ||||
| 
 | ||||
| [gcode_macro PROBE_ACCEPT] | ||||
| description: Accept the current Z position for Probe and dock MagProbe | ||||
| gcode: | ||||
|   #####  get variables from ABORT  ##### | ||||
|   {% set caller = printer['gcode_macro PROBE_ABORT'].caller %} | ||||
|   {% set absolute_coordinates = printer['gcode_macro PROBE_ABORT'].absolute_coordinates %} | ||||
|   ##### get user defines  ##### | ||||
|   {% set t_speed = printer['gcode_macro _USER_VARIABLE'].probe_travel_speed|float * 60 %} | ||||
|   ##### end of definitions ##### | ||||
|   {% if caller|lower|string == 'calib' %} | ||||
|     ACCEPT | ||||
|     DETACH_PROBE | ||||
|     RESTORE_GCODE_STATE NAME=STATE_PROBE_CALIBRATE MOVE=1 MOVE_SPEED={t_speed} | ||||
|     {% if absolute_coordinates == 'false' %} G91 {% endif %} | ||||
|       SET_GCODE_VARIABLE MACRO=PROBE_ABORT VARIABLE=caller VALUE='"unknown"' | ||||
|   {% else %} | ||||
|     {action_respond_info("PROBE_ACCEPT: Executed while PROBE_CALIBRATE is not running")} | ||||
|   {% endif %} | ||||
| 
 | ||||
							
								
								
									
										127
									
								
								z_calibration/z_calibration.cfg
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								z_calibration/z_calibration.cfg
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,127 @@ | |||
| ##################################################################### | ||||
| #    Z Calibration | ||||
| ##################################################################### | ||||
| [z_calibration] | ||||
| #   The X and Y coordinates (in mm) for clicking the nozzle on the | ||||
| #   Z endstop. | ||||
| probe_nozzle_x: 208 | ||||
| probe_nozzle_y: 305 | ||||
| #   The X and Y coordinates (in mm) for clicking the probe's switch | ||||
| #   on the Z endstop. | ||||
| probe_switch_x: 201 | ||||
| probe_switch_y: 284 | ||||
| #   The X and Y coordinates (in mm) for probing on the print surface | ||||
| #   (e.g. the center point) These coordinates will be adapted by the | ||||
| #   probe's X and Y offsets. The default is the relative_reference_index | ||||
| #   of the configured bed_mesh. It will raise an error if there is no | ||||
| #   probe_bed site and no bed_mesh with a relative_reference_index | ||||
| #   configured. | ||||
| probe_bed_x: 150 | ||||
| probe_bed_y: 150 | ||||
| #   The trigger point offset of the used mag-probe switch. | ||||
| #   This needs to be fined out manually. More on this later | ||||
| #   in this section.. | ||||
| switch_offset: 0.42 | ||||
| #   The maximum allowed deviation of the calculated offset. | ||||
| #   If the offset exceeds this value, it will stop! | ||||
| #   The default is 1.0 mm. | ||||
| max_deviation: 1.5 | ||||
| #   The number of times to probe each point. The probed z-values | ||||
| #   will be averaged. The default is from the probe's configuration. | ||||
| #samples: default from "probe:samples" section | ||||
| #   The maximum Z distance (in mm) that a sample may differ from other | ||||
| #   samples. The default is from the probe's configuration. | ||||
| #samples_tolerance: default from "probe:samples_tolerance" section | ||||
| #   The number of times to retry if a sample is found that exceeds | ||||
| #   samples_tolerance. The default is from the probe's configuration. | ||||
| #samples_tolerance_retries: default from "probe:samples_tolerance_retries" section | ||||
| #   The calculation method when sampling more than once - either | ||||
| #   "median" or "average". The default is from the probe's configuration. | ||||
| #samples_result: default from "probe:samples_result" section | ||||
| #   The distance in mm to move up before moving to the next | ||||
| #   position. The default is two times the z_offset from the probe's | ||||
| #   configuration. | ||||
| clearance: 7.5 | ||||
| #position_min: default from "stepper_z:position_min" section. | ||||
| #   The moving speed in X and Y. The default is 50 mm/s. | ||||
| speed: 200 | ||||
| #   Speed (in mm/s) of the Z axis when lifting the probe between | ||||
| #   samples and clearance moves. The default is from the probe's | ||||
| #   configuration. | ||||
| #lift_speed: default from "probe:lift_speed" section | ||||
| #   The fast probing speed (in mm/s) used, when probing_first_fast | ||||
| #   is activated. The default is from the Z rail configuration. | ||||
| #probing_speed: default from "stepper_z:homing_speed" section. | ||||
| #   The slower speed (in mm/s) for probing the recorded samples. | ||||
| #   The default is second_homing_speed of the Z rail configuration. | ||||
| #probing_second_speed: default from "stepper_z:second_homing_speed" section. | ||||
| #   Distance to back off (in mm) before probing the next sample. | ||||
| #   The default is homing_retract_dist from the Z rail configuration. | ||||
| #probing_retract_dist: default from "stepper_z:homing_retract_dist" section. | ||||
| #   If true, the first probing is done faster by the probing speed. | ||||
| #   This is to get faster down and the result is not recorded as a | ||||
| #   probing sample. The default is false. | ||||
| probing_first_fast: true | ||||
| #   If true, the first probing is done faster by the probing speed. | ||||
| #   This is to get faster down and the result is not recorded as a | ||||
| #   probing sample. The default is false. | ||||
| start_gcode: DETACH_PROBE | ||||
| #   A list of G-Code commands to execute prior to each calibration command. | ||||
| #   See docs/Command_Templates.md for G-Code format. This can be used to | ||||
| #   attach the probe. | ||||
| before_switch_gcode: ATTACH_PROBE | ||||
| #   A list of G-Code commands to execute prior to each probing on the | ||||
| #   mag-probe. See docs/Command_Templates.md for G-Code format. This can be | ||||
| #   used to attach the probe after probing on the nozzle and before probing | ||||
| #   on the mag-probe. | ||||
| end_gcode: DETACH_PROBE | ||||
| #   A list of G-Code commands to execute after each calibration command. | ||||
| #   See docs/Command_Templates.md for G-Code format. This can be used to | ||||
| #   detach the probe afterwards. | ||||
| 
 | ||||
| ##################################################################### | ||||
| ## With these settings, the probe is attached after probing the nozzle | ||||
| ## and before probing the switch !! | ||||
| ##################################################################### | ||||
| ## Otherwise, starting with the probe attached would be like this: | ||||
| start_gcode: ATTACH_PROBE | ||||
| #before_switch_gcode: ATTACH_PROBE | ||||
| end_gcode: DETACH_PROBE | ||||
| ##################################################################### | ||||
| 
 | ||||
| ##################################################################### | ||||
| #    Macros | ||||
| ##################################################################### | ||||
| 
 | ||||
| ################################################################### | ||||
| #        !!! Caution !!! | ||||
| # | ||||
| # This Macro is only needed if not using the start/end_gcode | ||||
| # properties to attach/detach the probe | ||||
| ################################################################### | ||||
| [gcode_macro CALIBRATE_Z] | ||||
| description: Automatically calibrates the nozzles offset to the print surface and dock/undock MagProbe  | ||||
| rename_existing: CALIBRATE_Z_BASE | ||||
| gcode: | ||||
|   ##### get user defines  ##### | ||||
|   {% set z_hop = printer['gcode_macro _USER_VARIABLE'].probe_z_min|float %} | ||||
|   ##### get toolhead parameters ##### | ||||
|   {% set act_z = printer.gcode_move.gcode_position.z|float %} | ||||
|   #### end of definitions ##### | ||||
|   ## reduce current of motors | ||||
|   _SET_ACC VAL=HOME | ||||
|   _SET_CURRENT VAL=HOME | ||||
|   _CG28 RESET_SETTINGS=false | ||||
|   {% if act_z < z_hop %} | ||||
|     G90 ; absolute positioning | ||||
|     {action_respond_info("CALIBRATE_Z: High must be above %.2f" % z_hop)} | ||||
|     G1 Z{z_hop} F900 ; move head up | ||||
|   {% endif %} | ||||
|   #ATTACH_PROBE | ||||
|   CALIBRATE_Z_BASE | ||||
|   #DETACH_PROBE  | ||||
|   {% if params.RESET_SETTINGS|default('true') == 'true' %} | ||||
|     ## return to org current settings | ||||
|     _SET_CURRENT | ||||
|     _SET_ACC | ||||
|   {% endif %} | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue