-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhoming_macros.cfg
90 lines (85 loc) · 3.79 KB
/
homing_macros.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#####################################################################
# Homing definition
#####################################################################
[gcode_macro _HOME_X]
gcode:
# Always use consistent run_current on A/B steppers during sensorless homing
{% set RUN_CURRENT_X = printer.configfile.settings['tmc2209 stepper_x'].run_current|float %}
{% set RUN_CURRENT_Y = printer.configfile.settings['tmc2209 stepper_y'].run_current|float %}
{% set HOME_CURRENT = 0.7 %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOME_CURRENT}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOME_CURRENT}
# Home
G28 X
# Move away
G91
G1 X-10 F1200
# Wait just a second… (give StallGuard registers time to clear)
G4 P1000
# Set current during print
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={RUN_CURRENT_X}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={RUN_CURRENT_Y}
LED_STANDBY
[gcode_macro _HOME_Y]
gcode:
# Set current for sensorless homing
{% set RUN_CURRENT_X = printer.configfile.settings['tmc2209 stepper_x'].run_current|float %}
{% set RUN_CURRENT_Y = printer.configfile.settings['tmc2209 stepper_y'].run_current|float %}
{% set HOME_CURRENT = 0.7 %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={HOME_CURRENT}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={HOME_CURRENT}
# Home
G28 Y
# Move away
G91
G1 Y-10 F1200
# Wait just a second… (give StallGuard registers time to clear)
G4 P1000
# Set current during print
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={RUN_CURRENT_X}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={RUN_CURRENT_Y}
#####################################################################
# Macros
#####################################################################
## conditional home
[gcode_macro _CG28]
description: Helper: Conditional homing
gcode:
{% if "xyz" not in printer.toolhead.homed_axes %}
G28 { rawparams }
{% endif %}
[gcode_macro _SET_Z_CURRENT]
description: Helper: Set Z-drive motor current
variable_last_val: 'CONFIG'
gcode:
{% set val = params.VAL|default('CONFIG') %}
{% set z_run = printer['gcode_macro _USER_VARIABLE'].homing.z_current if val == 'HOME'
else printer.configfile.settings['tmc2209 stepper_z'].run_current if 'tmc2209 stepper_z' in printer.configfile.settings
else printer.configfile.settings['tmc5160 stepper_z'].run_current if 'tmc5160 stepper_z' in printer.configfile.settings %}
{% if val != last_val %}
SET_GCODE_VARIABLE MACRO=_SET_Z_CURRENT VARIABLE=last_val VALUE='"{val}"'
{% if params.RESPOND|default(printer['gcode_macro _USER_VARIABLE'].respond.z_current)|int == 1 %}
{action_respond_info("Home&Probe: RunCur %.2fA rms" % z_run|float)}
{% endif %}
SET_TMC_CURRENT STEPPER=stepper_z CURRENT={z_run}
SET_TMC_CURRENT STEPPER=stepper_z1 CURRENT={z_run}
SET_TMC_CURRENT STEPPER=stepper_z2 CURRENT={z_run}
SET_TMC_CURRENT STEPPER=stepper_z3 CURRENT={z_run}
M400
{% endif %}
[gcode_macro _SET_ACC]
description: Helper: Set accel and accel_to_decel value
variable_last_val: 'CONFIG'
gcode:
{% set val = params.VAL|default('CONFIG') %}
{% set accel = printer['gcode_macro _USER_VARIABLE'].homing.accel if val == 'HOME'
else printer.configfile.settings.printer.max_accel %}
{% set accel_to_decel = printer['gcode_macro _USER_VARIABLE'].homing.accel|int / 2 if val == 'HOME'
else printer.configfile.settings.printer.max_accel_to_decel %}
{% if val != last_val %}
SET_GCODE_VARIABLE MACRO=_SET_ACC VARIABLE=last_val VALUE='"{val}"'
{% if params.RESPOND|default(printer['gcode_macro _USER_VARIABLE'].respond.acc)|int == 1 %}
{action_respond_info("Home&Probe: ACCEL: %d ACCEL_TO_DECEL: %d" % (accel|int, accel_to_decel|int))}
{% endif %}
SET_VELOCITY_LIMIT ACCEL={accel} ACCEL_TO_DECEL={accel_to_decel}
{% endif %}