diff --git a/TEST_SPEED.cfg b/TEST_SPEED.cfg new file mode 100644 index 0000000..25d8256 --- /dev/null +++ b/TEST_SPEED.cfg @@ -0,0 +1,110 @@ +# 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 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 + {% set smallpatternsize = SMALLPATTERNSIZE|default(20)|int %} + + # Large pattern + # Max positions, inset by BOUND + {% 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 %} + + # Small pattern at center + # Find X/Y center point + {% set x_center = (printer.toolhead.axis_minimum.x|float + printer.toolhead.axis_maximum.x|float ) / 2 %} + {% set y_center = (printer.toolhead.axis_minimum.y|float + printer.toolhead.axis_maximum.y|float ) / 2 %} + + # Set small pattern box around center point + {% set x_center_min = x_center - (smallpatternsize/2) %} + {% set x_center_max = x_center + (smallpatternsize/2) %} + {% set y_center_min = y_center - (smallpatternsize/2) %} + {% set y_center_max = y_center + (smallpatternsize/2) %} + + # Save current gcode state (absolute/relative, etc) + SAVE_GCODE_STATE NAME=TEST_SPEED + + # Output parameters to g-code terminal + { action_respond_info("TEST_SPEED: starting %d iterations at speed %d, accel %d" % (iterations, speed, accel)) } + + # 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 %} + # Move 50mm away from max position and home again (to help with hall effect endstop accuracy - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/24) + G90 + G1 X{printer.toolhead.axis_maximum.x-50} Y{printer.toolhead.axis_maximum.y-50} F{30*60} + G28 X Y + G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60} + G4 P1000 + GET_POSITION + + # Go to starting position + 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} + + {% for i in range(iterations) %} + # Large pattern + # 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} + + # Small pattern + # Small diagonals + G0 X{x_center_min} Y{y_center_min} F{speed*60} + G0 X{x_center_max} Y{y_center_max} F{speed*60} + G0 X{x_center_min} Y{y_center_min} F{speed*60} + G0 X{x_center_max} Y{y_center_min} 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} + + # Small box + 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_max} Y{y_center_max} F{speed*60} + G0 X{x_center_max} Y{y_center_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 and get position again for comparison: + G28 + # Go to XY home positions (in case your homing override leaves it elsewhere) + G90 + G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60} + G4 P1000 + GET_POSITION + + # Restore previous gcode state (absolute/relative, etc) + RESTORE_GCODE_STATE NAME=TEST_SPEED \ No newline at end of file diff --git a/klipper-printer-sovol-sv06.cfg b/klipper-printer-sovol-sv06.cfg index bd3beb1..5f5874c 100644 --- a/klipper-printer-sovol-sv06.cfg +++ b/klipper-printer-sovol-sv06.cfg @@ -11,6 +11,7 @@ # See docs/Config_Reference.md for a description of parameters. [include macros.cfg] +[include TEST_SPEED.cfg] [include mechanical_level_tmc2209.cfg] [mcu] diff --git a/macros.cfg b/macros.cfg index abc5f90..fc1b8ed 100644 --- a/macros.cfg +++ b/macros.cfg @@ -93,115 +93,6 @@ gcode: G90 ; absolute positioning G0 X60 Y{max_y} F3600 ; park nozzle at rear -[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: - # 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 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 - {% set smallpatternsize = SMALLPATTERNSIZE|default(20)|int %} - - # Large pattern - # Max positions, inset by BOUND - {% 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 %} - - # Small pattern at center - # Find X/Y center point - {% set x_center = (printer.toolhead.axis_minimum.x|float + printer.toolhead.axis_maximum.x|float ) / 2 %} - {% set y_center = (printer.toolhead.axis_minimum.y|float + printer.toolhead.axis_maximum.y|float ) / 2 %} - - # Set small pattern box around center point - {% set x_center_min = x_center - (smallpatternsize/2) %} - {% set x_center_max = x_center + (smallpatternsize/2) %} - {% set y_center_min = y_center - (smallpatternsize/2) %} - {% set y_center_max = y_center + (smallpatternsize/2) %} - - # Save current gcode state (absolute/relative, etc) - SAVE_GCODE_STATE NAME=TEST_SPEED - - # Output parameters to g-code terminal - { action_respond_info("TEST_SPEED: starting %d iterations at speed %d, accel %d" % (iterations, speed, accel)) } - - # 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) %} - # Large pattern - # 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} - - # Small pattern - # Small diagonals - G0 X{x_center_min} Y{y_center_min} F{speed*60} - G0 X{x_center_max} Y{y_center_max} F{speed*60} - G0 X{x_center_min} Y{y_center_min} F{speed*60} - G0 X{x_center_max} Y{y_center_min} 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} - - # Small box - 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_max} Y{y_center_max} F{speed*60} - G0 X{x_center_max} Y{y_center_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 and get position again for comparison: - G28 - # 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 - [gcode_macro LOAD_FILAMENT] gcode: M83 ; set extruder to relative