klipper_switchwire/calibration_macros.cfg
2021-11-28 13:43:47 -08:00

160 lines
5.5 KiB
INI

[gcode_macro MEASURE_RESONNANCES_X]
gcode:
RESPOND PREFIX= MSG="Homing"
G28
Dock_probe
RESPOND PREFIX= MSG="Measuring resonnances on X Axis"
SHAPER_CALIBRATE AXIS=X
#Park_toolhead
[gcode_macro MEASURE_RESONNANCES_Y]
gcode:
RESPOND PREFIX= MSG="Homing"
G28
Dock_probe
RESPOND PREFIX= MSG="Measuring resonnances on Y Axis"
SHAPER_CALIBRATE AXIS=Y
#Park_toolhead
[gcode_macro Screws_tilt]
gcode:
{% set travel_speed = printer["gcode_macro GlobalVariables"].travel_speed %}
{% set home_x = printer["gcode_macro GlobalVariables"].home_x %}
{% set probe_x_offset = printer["gcode_macro GlobalVariables"].probe_x_offset %}
{% set BED_TEMP = params.BED_TEMP|default(100)|float %}
# Start bed heating and wait
RESPOND PREFIX= MSG="Waiting for bed temperature..."
M140 S{BED_TEMP}
{% if printer.toolhead.homed_axes != 'xyz' %}
G28 #Home All Axes
{% endif %}
G4 P15000
M190 S{BED_TEMP}
Attach_probe
SCREWS_TILT_CALCULATE samples=3
G1 X{ home_x - probe_x_offset } Y230 Z200 F{ travel_speed }
[gcode_macro M900]
gcode:
# Parameters
{% set pa = params.K|float %}
SET_PRESSURE_ADVANCE ADVANCE={pa}
[gcode_macro FLOW_CALIBRATION]
gcode:
M221 S{params.FLOW}
SET_PRESSURE_ADVANCE ADVANCE={params.PRESSURE_ADVANCE}
[gcode_macro SEARCH_VARS]
gcode:
{% set search = params.S|lower %}
{% set ns = namespace() %}
{% for item in printer %}
{% if ' ' in item %}
{% set ns.path = ['printer', "['%s']" % (item), ''] %}
{% else %}
{% set ns.path = ['printer.', item, ''] %}
{% endif %}
{% if search in ns.path|lower %}
{ action_respond_info(ns.path|join) }
{% endif %}
{% if printer[item].items() %}
{% for childkey, child in printer[item].items() recursive %}
{% set ns.path = ns.path[:loop.depth|int + 1] %}
{% if ' ' in childkey %}
{% set null = ns.path.append("['%s']" % (childkey)) %}
{% else %}
{% set null = ns.path.append(".%s" % (childkey)) %}
{% endif %}
{% if child is mapping %}
{ loop(child.items()) }
{% else %}
{% if search in ns.path|lower %}
{ action_respond_info("%s : %s" % (ns.path|join, child)) }
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
# 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 box (in case the machine min/maxes are not perfect)
{% set bound = params.BOUND|default(20)|int %}
# Set speed test bounds (machine minimum/maximum positions, inset by the bounding box)
{% 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 %}
# Save current gcode state (absolute/relative, etc)
SAVE_GCODE_STATE NAME=TEST_SPEED
# 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) %}
# 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}
{% 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 XY and get position again for comparison:
G28 X Y
# 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