Macro, add test_speed
This commit is contained in:
parent
5957020fac
commit
ddb2c70a7c
|
@ -0,0 +1,186 @@
|
|||
# __ ______ ___ ____ _____
|
||||
# \ \ / / ___/ _ \| _ \| ____|
|
||||
# \ \ / / | | | | | |_) | _|
|
||||
# \ V /| |__| |_| | _ <| |___
|
||||
# \_/ \____\___/|_| \_\_____| 3.1
|
||||
# Standalone 300 Setup.
|
||||
#
|
||||
|
||||
|
||||
#####################################################################
|
||||
# TEST SPEED (AndrewEllis93)
|
||||
#####################################################################
|
||||
|
||||
# Src : https://github.com/AndrewEllis93/Print-Tuning-Guide/blob/main/articles/determining_max_speeds_accels.md#usage-of-the-test_speed-macro
|
||||
# Example: TEST_SPEED SPEED=300 ACCEL=5000 ITERATIONS=10
|
||||
# This macro do Home, get position, throw around toolhead, home again.
|
||||
#
|
||||
# Determining if Skipping Occured
|
||||
#
|
||||
# 1) Inspect the g-code terminal output :
|
||||
# > Compare the numbers for the X and Y steppers for the first and second homing. (mcu: stepper_x:111111 stepper_y:-22)
|
||||
# > These numbers represent the microstep position of the toolhead at X/Y max position.
|
||||
#
|
||||
# 2) Ensure that the difference between these numbers has not exceeded a full step.
|
||||
# > For example, I am running microsteps of 32 for my A and B motors. I would ensure that the values for each axis have not changed by more than 32.
|
||||
# > If the number has deviated more than this, that means that the corresponding axis has likely skipped.
|
||||
# > Measuring to a full step just accounts for a bit of endstop inaccuracy. It does not necessarily mean that any microsteps were lost.
|
||||
# > For hall effect endstops, you may need to measure to a few full steps. They can be bit less accurate, and they thermally drift.
|
||||
|
||||
[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
|
||||
|
||||
|
||||
#####################################################################
|
||||
# SPEED LOOP
|
||||
#####################################################################
|
||||
|
||||
[gcode_macro RESETSPEEDS]
|
||||
gcode:
|
||||
SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity}
|
||||
SET_VELOCITY_LIMIT ACCEL={printer.configfile.settings.printer.max_accel}
|
||||
SET_VELOCITY_LIMIT ACCEL_TO_DECEL={printer.configfile.settings.printer.max_accel_to_decel}
|
||||
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={printer.configfile.settings.printer.square_corner_velocity}
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
[gcode_macro SPEED_LOOP]
|
||||
gcode:
|
||||
MAYBE_HOME
|
||||
{% set vel = (300,400,500) %} # set velocity values to be tested (mm/s)
|
||||
{% set accel = (5000,9000,13000) %} # set accel values to be tested (mm/s^2)
|
||||
{% set min = 40 %} # set the square lower left point
|
||||
{% set max = 260 %} # set the square upper right corner
|
||||
G1 X{min} Y{min} F5000
|
||||
{% for V in vel %}
|
||||
{% set machineVel = V*60 %}
|
||||
{% for A in accel %}
|
||||
M118 velocity:{V}mm/s, accel:{A}mm/s^2
|
||||
SET_VELOCITY_LIMIT VELOCITY={V}
|
||||
SET_VELOCITY_LIMIT ACCEL={A}
|
||||
SET_VELOCITY_LIMIT ACCEL_TO_DECEL={A}
|
||||
G1 X{max} Y{min} F{machineVel}
|
||||
G1 X{max} Y{max}
|
||||
G1 X{min} Y{min}
|
||||
G1 X{min} Y{max}
|
||||
G1 X{max} Y{min}
|
||||
G1 X{max} Y{min}
|
||||
G1 X{max} Y{max}
|
||||
G1 X{min} Y{max}
|
||||
G1 X{min} Y{min}
|
||||
G4 P1000
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
RESETSPEEDS
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
[gcode_macro RESETSPEEDS]
|
||||
gcode:
|
||||
SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity}
|
||||
SET_VELOCITY_LIMIT ACCEL={printer.configfile.settings.printer.max_accel}
|
||||
SET_VELOCITY_LIMIT ACCEL_TO_DECEL={printer.configfile.settings.printer.max_accel_to_decel}
|
||||
SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY={printer.configfile.settings.printer.square_corner_velocity}
|
Loading…
Reference in New Issue