diff --git a/macros/_init.cfg b/macros/_init.cfg index 6831d62..609e796 100644 --- a/macros/_init.cfg +++ b/macros/_init.cfg @@ -4,8 +4,5 @@ ##################################################################### [include debug.cfg] [include helpers.cfg] -[include override.cfg] [include print.cfg] -[include probe.cfg] -[include z_calibration.cfg] [include timelapse.cfg] diff --git a/macros/helpers.cfg b/macros/helpers.cfg index 254f610..b8e91c8 100644 --- a/macros/helpers.cfg +++ b/macros/helpers.cfg @@ -59,19 +59,3 @@ gcode: M117 HEATING EXTRUDER from {printer.extruder.temperature} to {EXTRUDER} M118 HEATING EXTRUDER from {printer.extruder.temperature} to {EXTRUDER} - -[gcode_macro ZC] -gcode: - G28 - CALIBRATE_Z - G0 X150 Y30 Z2 F10000 - G0 Z1 F300 - -[gcode_macro TZC] -gcode: - {% set N=params.N|default(1)|int %} - {% for i in range(N) %} - M118 move {(i+1)}/{N} - G28 - CALIBRATE_Z - {% endfor %} diff --git a/macros/override.cfg b/macros/override.cfg deleted file mode 100644 index b728df7..0000000 --- a/macros/override.cfg +++ /dev/null @@ -1,147 +0,0 @@ -##################################################################### -# 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 -# -# - BED_MESH_CALIBRATE -# - G0 -# - G1 -# - QUAD_GANTRY_LEVEL -##################################################################### - - -## BED_MESH_CALIBRATE -[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 - -## GO -# If your probe needs a Z move for attach/detach use either -# G0 .... 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(" ")} - -## TODO -## G1 -# If your probe needs a Z move for attach/detach use either -# G1 .... FORCE -# [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(" ")} - - -## QUAD_GANTRY_LEVEL -[gcode_macro QUAD_GANTRY_LEVEL] -description: Level a flying gantry to a stationary bed -rename_existing: _QUAD_GANTRY_LEVEL -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 - {% 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 - - diff --git a/macros/print.cfg b/macros/print.cfg index b5680de..9c8c373 100644 --- a/macros/print.cfg +++ b/macros/print.cfg @@ -22,9 +22,10 @@ gcode: {% set x0=250 %} {% set x1=200 %} - {% set y0=308 %} + {% set y0=printer.toolhead.axis_maximum.y %} {% set z0=1.0 %} - {% set z_hop = printer['gcode_macro _USER_VARIABLE'].z_hop|int %} + # {% set z_hop = printer['gcode_macro _USER_VARIABLE'].z_hop|int %} + {% set z_hop = 10 %} {% if "xyz" in printer.toolhead.homed_axes %} G0 Z{z_hop} F1000 # move Z to travel height G0 X{x0} Y{y0} F6000 # move to x0/y0 @@ -99,9 +100,9 @@ gcode: {% if z_safe > z_max %} {% set z_safe = z_max %} {% endif %} - G91 + G91 # use relative coordinates G0 Z{z_safe} F1200 - G90 + G90 # use absolute coordinates G0 X{x_park} Y{y_park} F6000 {% else %} M118 printer not homed @@ -126,12 +127,12 @@ gcode: {% if printer.extruder.can_extrude %} G1 E-1.0 F1500.0 {% endif %} - G90 + G90 # use absolute coordinates SAVE_GCODE_STATE NAME=PAUSE_state _PAUSE_BASE - G91 + G91 # use relative coordinates G1 Z{z_safe} F900 - G90 + G90 # use absolute coordinates G0 X{x_park} Y{y_park} F6000 {% else %} M117 already paused @@ -155,7 +156,7 @@ gcode: M118 CONFIGURING SET_GCODE_OFFSET Z=0.0 # reset z offset M140 S{BED} # start bed heating to bed - M104 S{EXTRUDER} # start extruder heating + # M104 S{EXTRUDER} # start extruder heating G92 E0 # reset extruder G21 # set units to millimeters G90 # use absolute coordinates @@ -180,14 +181,9 @@ gcode: M118 BED MESH LOAD {SHEET} BED_MESH_PROFILE LOAD={SHEET} {% endif %} - # CALIBRATE_Z - M117 CALIBRATE_Z - M118 CALIBRATE_Z - # G28 Z # irrelevant? - BRUSHIE - CALIBRATE_Z - G92 E0 # reset extruder + G92 E0 # reset extruder + G90 # use absolute coordinates NOTIFY_BED BED={BED} M190 S{BED} # set and wait for actual bed temperature M109 S{EXTRUDER} # set and wait for extruder temperature @@ -230,7 +226,8 @@ gcode: {% set x1=params.x1|default(200) %} {% set y0=params.y0|default(2) %} {% set y1=params.y1|default(3) %} - {% set z_hop = printer['gcode_macro _USER_VARIABLE'].z_hop|int %} + # {% set z_hop = printer['gcode_macro _USER_VARIABLE'].z_hop|int %} + {% set z_hop = 10 %} M118 purge nozzle G0 Z{z_hop} F300 # move Z to travel height G0 X{x0} Y{y0} F5000 # move to x0/y0 @@ -239,7 +236,7 @@ gcode: G0 Y{y1} # move to y1 G0 X{x0} E10 # draw fine line G0 X{x0-10} # move a little further - G0 E-5 # retract filament + # G0 E-5 # retract filament G0 Z{z_hop} F300 # move Z to travel height diff --git a/macros/probe.cfg b/macros/probe.cfg deleted file mode 100644 index 8fd6b41..0000000 --- a/macros/probe.cfg +++ /dev/null @@ -1,440 +0,0 @@ -##################################################################### -# Macros for mag probe -# - ATTACH_PROBE -# - DETACH_PROBE -# - GET_PROBE_STATUS -# - QUERY_PROBE -# - PROBE -# - PROBE_ABORT -# - PROBE_ACCURACY -# - PROBE_ACCEPT -# - PROBE_CALIBRATE -# - SET_PROBE_STATUS -# - _ATTACH_PROBE -# - _DOCK_PROBE -# - _MAG_PROBE -# - _PROBE_ACTION -# - _Z_MOVE_CHECK -##################################################################### - - -## ATTACH_PROBE -[gcode_macro ATTACH_PROBE] -description: Attaching the MagProbe if not already attached -gcode: - _MAG_PROBE ACTION=ATTACH - _MAG_PROBE ACTION=CHECK_ATTACH - - -## DETACH_PROBE -[gcode_macro DETACH_PROBE] -description: Dock the MagProbe if not already docked -gcode: - _MAG_PROBE ACTION=DOCK - _MAG_PROBE ACTION=CHECK_DOCK - - -## GET_PROBE_STATUS -[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 - - -## QUERY_PROBE -[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} - - -## PROBE -[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} - {% if printer.toolhead.position.y|float > 270 %} - G0 Y270 - {% endif %} - _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 %} - - -## PROBE_ABORT -[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 %} - - -## PROBE_ACCURACY -[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 %} - - -## PROBE_ACCEPT -[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 %} - - - - -## PROBE_CALIBRATE -[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(" ")} - - -## SET_PROBE_STATUS -[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 %} - - -## _ATTACH_PROBE -[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 %} - - ##### 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 - - -## _DOCK_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 - - -## MAG_PROBE -# 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 - - -## _PROBE_ACTION -[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 %} - - -## _Z_MOVE_CHECK -[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(" ")} diff --git a/macros/z_calibration.cfg b/macros/z_calibration.cfg deleted file mode 100644 index 874e732..0000000 --- a/macros/z_calibration.cfg +++ /dev/null @@ -1,121 +0,0 @@ -##################################################################### -# Macros for z-calibration -# - CALIBRATE_Z -# - _CG28 -# - _SET_CURRENT -# - _SET_ACC -##################################################################### - - -## CALIBRATE_Z -[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 %} - {% if printer.quad_gantry_level.applied|lower == 'false' %} - QUAD_GANTRY_LEVEL PARK=false - {% endif %} - #ATTACH_PROBE ; if not using start_gcode - _CALIBRATE_Z_BASE - #DETACH_PROBE ; if not using end_gcode - {% if params.RESET_SETTINGS|default('true') == 'true' %} - ## return to org current settings - _SET_CURRENT - _SET_ACC - {% endif %} - - -## _CG28 -[gcode_macro _CG28] -description: conditional home -gcode: - {% if "xyz" not in printer.toolhead.homed_axes %} - G28 RESET_SETTINGS={ params.RESET_SETTINGS|default('true') } - {% endif %} - -## _SET_ACC -[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 %} - - -## _SET_CURRENT -[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 %} - ## XY - {% if 'tmc2209 stepper_x' 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 %} - {% elif 'tmc5160 stepper_x' 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 %} - {% endif %} - ## Z - {% if 'tmc2209 stepper_z' in printer.configfile.settings %} - {% 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 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 %} diff --git a/printer.cfg b/printer.cfg index 2f2cfbe..2b75a52 100644 --- a/printer.cfg +++ b/printer.cfg @@ -63,7 +63,6 @@ path: /home/pi/gcode_files [include fans.cfg] [include input_shaper.cfg] # [include resonance_test.cfg] -[include z_calibration.cfg] [include ercf/hardware.cfg] [include ercf/software.cfg] @@ -108,8 +107,8 @@ microsteps: 32 full_steps_per_rotation: 400 # 200: 1.8 deg stepper, 400: 0.9 deg stepper endstop_pin: PG9 position_min: 0 -position_endstop: 306 -position_max: 308 +position_endstop: 303 +position_max: 305 homing_speed: 30 # Max 100 homing_retract_dist: 5 homing_positive_dir: true @@ -137,15 +136,13 @@ enable_pin: !PG5 rotation_distance: 40 gear_ratio: 80:16 microsteps: 32 -endstop_pin: PG10 -## actual_position = measured_position_endstop - position_endstop -position_endstop: 0 +endstop_pin: probe:z_virtual_endstop position_max: 290 -position_min: -1 -homing_speed: 8.0 # speed: mm/sec, feedrate: mm/min +position_min: -2 +homing_speed: 5.0 # speed: mm/sec, feedrate: mm/min homing_retract_speed: 10 second_homing_speed: 2 -homing_retract_dist: 3 +homing_retract_dist: 5 [tmc2209 stepper_z] uart_pin: PC6 @@ -312,13 +309,9 @@ max_temp: 100 [idle_timeout] timeout: 1800 -## replaced with homing_override in klicky-probe.cfg -# [safe_z_home] -# ## XY Location of the Z Endstop Switch -# home_xy_position: 94, 306 -# speed: 100 -# z_hop: 10 -# z_hop_speed: 25 +[safe_z_home] +home_xy_position: 150, 150 +z_hop: 10 ##################################################################### @@ -326,19 +319,36 @@ timeout: 1800 ##################################################################### [probe] -## Microswitch probe +## Voron-Tap pin: ^PG11 x_offset: 0 -y_offset: 30 -z_offset: 12 +y_offset: 0 +#z_offset: 0 speed: 5.0 -lift_speed: 20 +lift_speed: 10 samples: 3 samples_result: median -sample_retract_dist: 2 +sample_retract_dist: 3 samples_tolerance: 0.01 samples_tolerance_retries: 5 +activate_gcode: + {% set PROBE_TEMP = 150 %} + {% set MAX_TEMP = PROBE_TEMP + 5 %} + {% set ACTUAL_TEMP = printer.extruder.temperature %} + {% set TARGET_TEMP = printer.extruder.target %} + + {% if TARGET_TEMP > PROBE_TEMP %} + { action_respond_info('Extruder temperature target of %.1fC is too high, lowering to %.1fC' % (TARGET_TEMP, PROBE_TEMP)) } + M109 S{ PROBE_TEMP } + {% else %} + # Temperature target is already low enough, but nozzle may still be too hot. + {% if ACTUAL_TEMP > MAX_TEMP %} + { action_respond_info('Extruder temperature %.1fC is still too high, waiting until below %.1fC' % (ACTUAL_TEMP, MAX_TEMP)) } + TEMPERATURE_WAIT SENSOR=extruder MAXIMUM={ MAX_TEMP } + {% endif %} + {% endif %} + [bed_mesh] speed: 500 @@ -395,15 +405,15 @@ max_adjust: 10 #*# [bed_mesh default] #*# version = 1 #*# points = -#*# 0.063750, 0.050000, 0.041250, 0.030000, 0.022500, 0.021250, 0.011250, 0.011250, -0.003750 -#*# 0.060000, 0.036250, 0.038750, 0.022500, -0.002500, 0.005000, -0.012500, -0.006250, -0.026250 -#*# 0.052500, 0.027500, 0.028750, 0.023750, -0.001250, -0.010000, -0.022500, -0.028750, -0.045000 -#*# 0.031250, 0.007500, 0.001250, -0.006250, -0.003750, -0.002500, -0.028750, -0.041250, -0.061250 -#*# 0.033750, 0.015000, 0.001250, 0.023750, 0.000000, -0.005000, -0.038750, -0.041250, -0.071250 -#*# 0.030000, 0.020000, -0.000000, -0.011250, -0.020000, -0.016250, -0.028750, -0.040000, -0.071250 -#*# 0.012500, 0.003750, -0.011250, -0.017500, -0.023750, -0.032500, -0.045000, -0.052500, -0.086250 -#*# 0.030000, 0.022500, 0.001250, -0.006250, -0.012500, -0.015000, -0.023750, -0.035000, -0.056250 -#*# 0.053750, 0.038750, 0.057500, 0.008750, 0.002500, -0.002500, -0.007500, -0.012500, -0.033750 +#*# -0.010000, -0.012500, -0.016250, -0.006250, -0.013750, 0.018750, -0.003750, 0.008750, 0.005000 +#*# -0.010000, -0.016250, -0.012500, -0.010000, -0.028750, -0.013750, -0.017500, 0.000000, -0.007500 +#*# -0.026250, -0.031250, -0.018750, -0.013750, -0.001250, -0.005000, -0.008750, 0.008750, 0.005000 +#*# -0.007500, -0.025000, -0.013750, -0.008750, -0.002500, 0.000000, -0.010000, -0.002500, -0.006250 +#*# -0.010000, 0.000000, -0.005000, 0.002500, 0.000000, 0.028750, -0.001250, 0.010000, 0.020000 +#*# -0.027500, -0.026250, -0.032500, -0.022500, -0.028750, -0.016250, -0.015000, -0.018750, -0.028750 +#*# -0.021250, -0.011250, -0.011250, -0.015000, -0.016250, -0.006250, -0.012500, -0.008750, -0.002500 +#*# -0.005000, -0.002500, -0.007500, -0.007500, 0.006250, 0.007500, -0.003750, 0.010000, -0.008750 +#*# -0.002500, 0.027500, 0.053750, 0.021250, 0.016250, 0.038750, 0.021250, 0.012500, -0.011250 #*# tension = 0.2 #*# min_x = 40.0 #*# algo = bicubic @@ -414,3 +424,6 @@ max_adjust: 10 #*# max_y = 290.0 #*# mesh_x_pps = 2 #*# max_x = 260.0 +#*# +#*# [probe] +#*# z_offset = -0.710 diff --git a/z_calibration.cfg b/z_calibration.cfg deleted file mode 100644 index 39abef9..0000000 --- a/z_calibration.cfg +++ /dev/null @@ -1,164 +0,0 @@ -##################################################################### -# User Variables -##################################################################### -[gcode_macro _USER_VARIABLE] -description: Helper: Contains User defined printer variables -##### Homing and general movement ##### -variable_z_endstop_x: 94 ; z Endstop x position inside right profile -variable_z_endstop_y: 306 ; z Endstop y position -variable_z_hop: 12 ; z hop for moves e.g homing -variable_xy_home_current: 0.6 ; reduced homing current for x and y -variable_z_home_current: 0.5 ; reduced homing current for z -variable_home_accel: 1000 ; reduced ACCEL for homing -##### Mag Probe ##### -variable_probe_dock_x: 53 ; x toolhead position before docking probe -variable_probe_dock_y: 246 ; y toolhead position before docking probe -variable_probe_dock_z: 12 ; z toolhead position before docking probe (only for bed dock) -variable_probe_undock_x: 103 ; x toolhead position after docking probe -variable_probe_undock_y: 305 ; y toolhead position after docking probe -variable_probe_undock_z: 12 ; z toolhead position after docking probe (only for bed dock) -variable_probe_z_min: 12 ; z minimum height to avoid crash -variable_probe_travel_speed: 100 ; 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: [280,280,30] ; different park position -gcode: - - -##################################################################### -# Z Calibration -##################################################################### -[z_calibration] -# The X and Y coordinates (in mm) for clicking the nozzle on the -# Z endstop. -probe_nozzle_x: 94 -probe_nozzle_y: 307 -# The X and Y coordinates (in mm) for clicking the probe's switch -# on the Z endstop. -probe_switch_x: 90 -probe_switch_y: 283 -# 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. smaller switch_offset -> more distance to the build plate -switch_offset: 0.59 -# 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.0 -# 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. -#position_min: default from "stepper_z:position_min" section. -# Extra clearance when moving -clearance: 10 -# The moving speed in X and Y. The default is 50 mm/s. -speed: 100 -# 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 -# 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. -start_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. -before_switch_gcode: ATTACH_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. -end_gcode: DETACH_PROBE - - -##################################################################### -# 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 ; move z 10 up - 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} F6000 - G28 Z ; home Z - G0 Z3 F1500 ; move up - - ## return to org current settings - {% if params.RESET_SETTINGS|default('true') == 'true' %} - DETACH_PROBE - _SET_CURRENT - _SET_ACC - {% endif %} - - # Lift Z - # TODO check speed - # G0 Z{z_hop} F1800 - G0 Z{z_hop} F1300 - - RESTORE_GCODE_STATE NAME=HOMING_state