Fix test_speed macro.

This commit is contained in:
Bassam Husain
2024-08-28 23:07:44 -04:00
parent 387c8b080a
commit 7a50d722d6

View File

@@ -1,10 +1,12 @@
# NOTE Find how to use instructions here: https://ellis3dp.com/Print-Tuning-Guide/articles/determining_max_speeds_accels.html # NOTE Find how to use instructions here: https://ellis3dp.com/Print-Tuning-Guide/articles/determining_max_speeds_accels.html
[gcode_macro TEST_SPEED]
# Home, get position, throw around toolhead, home again. # 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. # 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. # We only measure to a full step to accomodate for endstop variance.
# Example: TEST_SPEED SPEED=300 ACCEL=5000 ITERATIONS=10 # Example: TEST_SPEED SPEED=300 ACCEL=5000 ITERATIONS=10
[gcode_macro TEST_SPEED] description: Test for max speed and acceleration parameters for the printer. Procedure: Home -> ReadPositionFromMCU -> MovesToolhead@Vel&Accel -> Home -> ReadPositionfromMCU
gcode: gcode:
# Speed # Speed
{% set speed = params.SPEED|default(printer.configfile.settings.printer.max_velocity)|int %} {% set speed = params.SPEED|default(printer.configfile.settings.printer.max_velocity)|int %}
@@ -12,6 +14,8 @@ gcode:
{% set iterations = params.ITERATIONS|default(5)|int %} {% set iterations = params.ITERATIONS|default(5)|int %}
# Acceleration # Acceleration
{% set accel = params.ACCEL|default(printer.configfile.settings.printer.max_accel)|int %} {% set accel = params.ACCEL|default(printer.configfile.settings.printer.max_accel)|int %}
# Minimum Cruise Ratio
{% set min_cruise_ratio = params.MIN_CRUISE_RATIO|default(0.5)|float %}
# Bounding inset for large pattern (helps prevent slamming the toolhead into the sides after small skips, and helps to account for machines with imperfectly set dimensions) # Bounding inset for large pattern (helps prevent slamming the toolhead into the sides after small skips, and helps to account for machines with imperfectly set dimensions)
{% set bound = params.BOUND|default(20)|int %} {% set bound = params.BOUND|default(20)|int %}
# Size for small pattern box # Size for small pattern box
@@ -64,7 +68,11 @@ gcode:
G0 X{x_min} Y{y_min} Z{bound + 10} F{speed*60} G0 X{x_min} Y{y_min} Z{bound + 10} F{speed*60}
# Set new limits # Set new limits
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2} {% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %}
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} MINIMUM_CRUISE_RATIO={min_cruise_ratio}
{% else %}
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2}
{% endif %}
{% for i in range(iterations) %} {% for i in range(iterations) %}
# Large pattern diagonals # Large pattern diagonals
@@ -89,7 +97,7 @@ gcode:
G0 X{x_center_min} Y{y_center_max} F{speed*60} G0 X{x_center_min} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60} G0 X{x_center_max} Y{y_center_min} F{speed*60}
# Small patternbox # Small pattern box
G0 X{x_center_min} Y{y_center_min} F{speed*60} G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_min} Y{y_center_max} F{speed*60} G0 X{x_center_min} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_max} F{speed*60} G0 X{x_center_max} Y{y_center_max} F{speed*60}
@@ -97,7 +105,11 @@ gcode:
{% endfor %} {% endfor %}
# Restore max speed/accel/accel_to_decel to their configured values # 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} {% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %}
SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} MINIMUM_CRUISE_RATIO={printer.configfile.settings.printer.minimum_cruise_ratio}
{% else %}
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}
{% endif %}
# Re-home and get position again for comparison: # Re-home and get position again for comparison:
M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66 M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66
@@ -110,3 +122,4 @@ gcode:
# Restore previous gcode state (absolute/relative, etc) # Restore previous gcode state (absolute/relative, etc)
RESTORE_GCODE_STATE NAME=TEST_SPEED RESTORE_GCODE_STATE NAME=TEST_SPEED