This is a XY motion loop for testing several values of velocity and acceleration.
[gcode_macro LOOP_TEST]
gcode:
{% set vel = (300,400,500) %} # set velocity values to be tested (mm/s)
{% set accel = (10000,20000,30000) %} # set accel values to be tested (mm/s^2)
{% set min = 5 %} # set the square lower left point
{% set max = 195 %} # 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 %}
# restore original limits
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}
Not sure if this it the best way to write loops in jinja. It would be nice to be able to set low-value/high-value/step. Well, for the purpose of this experiment it’s not hard to define a handful of values in a couple of tuples.
Here it’s in action…