forked from AndrewEllis93/Print-Tuning-Guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEST_SPEED.cfg
74 lines (63 loc) · 2.79 KB
/
TEST_SPEED.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
# Home, get position, throw around toolhead, home again.
# If MCU stepper positions (first line in GET_POSITION) are greater than a full step different (your number of microsteps), then skipping occured.
# We only measure to a full step to accomodate for endstop variance.
# Example: TEST_SPEED SPEED=300 ACCEL=5000 ITERATIONS=10
[gcode_macro TEST_SPEED]
gcode:
# Speed
{% set speed = params.SPEED|default(printer.configfile.settings.printer.max_velocity)|int %}
# Iterations
{% set iterations = params.ITERATIONS|default(5)|int %}
# Acceleration
{% set accel = params.ACCEL|default(printer.configfile.settings.printer.max_accel)|int %}
# Bounding box (in case the machine min/maxes are not perfect)
{% set bound = params.BOUND|default(20)|int %}
# Set speed test bounds (machine minimum/maximum positions, inset by the bounding box)
{% set x_min = printer.toolhead.axis_minimum.x + bound %}
{% set x_max = printer.toolhead.axis_maximum.x - bound %}
{% set y_min = printer.toolhead.axis_minimum.y + bound %}
{% set y_max = printer.toolhead.axis_maximum.y - bound %}
# Save current gcode state (absolute/relative, etc)
SAVE_GCODE_STATE NAME=TEST_SPEED
# Absolute positioning
G90
# Set new limits
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2}
# Home and get position for comparison later:
G28
# QGL if not already QGLd (only if QGL section exists in config)
{% if printer.configfile.settings.quad_gantry_level %}
{% if printer.quad_gantry_level.applied == False %}
QUAD_GANTRY_LEVEL
G28 Z
{% endif %}
{% endif %}
G0 X{printer.toolhead.axis_maximum.x} Y{printer.toolhead.axis_maximum.y} F{30 * 60}
G4 P1000
GET_POSITION
# Go to starting position
G0 X{x_min} Y{y_min} Z{bound + 10} F{speed * 60}
{% for i in range(iterations) %}
# Diagonals
G0 X{x_min} Y{y_min} F{speed * 60}
G0 X{x_max} Y{y_max} F{speed * 60}
G0 X{x_min} Y{y_min} F{speed * 60}
G0 X{x_max} Y{y_min} F{speed * 60}
G0 X{x_min} Y{y_max} F{speed * 60}
G0 X{x_max} Y{y_min} F{speed * 60}
# Box
G0 X{x_min} Y{y_min} F{speed * 60}
G0 X{x_min} Y{y_max} F{speed * 60}
G0 X{x_max} Y{y_max} F{speed * 60}
G0 X{x_max} Y{y_min} F{speed * 60}
{% endfor %}
# Restore max speed/accel/accel_to_decel to their configured values
SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} ACCEL_TO_DECEL={printer.configfile.settings.printer.max_accel_to_decel}
# Re-home XY and get position again for comparison:
G28 X Y
# Go to XY home positions (in case your homing override leaves it elsewhere)
G0 X{printer.toolhead.axis_maximum.x} Y{printer.toolhead.axis_maximum.y} F{30 * 60}
G4 P1000
GET_POSITION
# Restore previous gcode state (absolute/relative, etc)
RESTORE_GCODE_STATE NAME=TEST_SPEED