129 lines
5.2 KiB
INI
129 lines
5.2 KiB
INI
#####################################################################
|
|
# 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 %}
|