Skip to content

Commit

Permalink
Update TEST_SPEED.cfg (#120)
Browse files Browse the repository at this point in the history
* Update TEST_SPEED.cfg

Klipper no longer has a MAX_ACCEL_TO_DECEL paramter in the firmware, it has been changed to MINIMUM CRUISE RATIO.

This is a patch that works for now.

* Update TEST_SPEED.cfg

Tested config, I don't know what the klipper internal parameter for minimum cruise ratio name is. Need to figure that out, this is working at he moment.

* Update TEST_SPEED.cfg

Fixes proposed by jomik. This is working with settings being restored after testing.
  • Loading branch information
SuhbatDaRobot authored Jul 5, 2024
1 parent 21d36ff commit 3b198ca
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions macros/TEST_SPEED.cfg
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
[gcode_macro TEST_SPEED]
# 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]
description: Test for max speed and acceleration parameters for the printer. Procedure: Home -> ReadPositionFromMCU -> MovesToolhead@Vel&Accel -> Home -> ReadPositionfromMCU

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 %}
# Minimum Cruise Ratio
{% set min_cruise_ratio = params.MIN_CRUISE_RATIO|default(0)|float %} # Possible location in printer object stack: printer.configfile.settings.printer.minimum_cruise_ratio
# 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 %}
# Size for small pattern box
Expand Down Expand Up @@ -63,7 +67,8 @@ gcode:
G0 X{x_min} Y{y_min} Z{bound + 10} F{speed*60}

# Set new limits
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2}
# SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2} # DEPRECATED | Due to deprecation of accel_to_decel parameter in Klipper
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} MIN_CRUISE_RATIO={minCruiseRatio}

{% for i in range(iterations) %}
# Large pattern diagonals
Expand Down Expand Up @@ -96,7 +101,8 @@ gcode:
{% 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}
#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} # DEPRECATED | Depercating of accel_to_decel param in klipper
SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} MIN_CRUISE_RATIO={printer.configfile.settings.printer.minimum_cruise_ratio}

# Re-home and get position again for comparison:
M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66
Expand All @@ -108,4 +114,5 @@ gcode:
GET_POSITION

# Restore previous gcode state (absolute/relative, etc)
RESTORE_GCODE_STATE NAME=TEST_SPEED
RESTORE_GCODE_STATE NAME=TEST_SPEED

0 comments on commit 3b198ca

Please sign in to comment.