From 150807803e3b8f3b2b150b09edc3d980e3732922 Mon Sep 17 00:00:00 2001 From: Kyle Brown Date: Sat, 11 Jun 2022 12:24:15 -0700 Subject: [PATCH] timelapse --- calibration_macros.cfg | 375 +++++++++++++++++++++-------------------- macros.cfg | 4 +- moonraker.conf | 14 +- print_start.cfg | 2 +- printer.cfg | 19 ++- timelapse.cfg | 1 + 6 files changed, 224 insertions(+), 191 deletions(-) create mode 120000 timelapse.cfg diff --git a/calibration_macros.cfg b/calibration_macros.cfg index 150abb8..0e3e842 100644 --- a/calibration_macros.cfg +++ b/calibration_macros.cfg @@ -1,180 +1,195 @@ -[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 %} - - G28 - DOCK_PROBE - # 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 X Y - # 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 - -[gcode_macro TEST_Z_DOWN] -gcode: - {% set amount = params.amount|default(1)|int %} - TESTZ Z=-{amount} - -[gcode_macro TEST_Z_UP] -gcode: - {% set amount = params.amount|default(1)|int %} - TESTZ Z=+{amount} - -[gcode_macro TEST_Z_UP_MIDDLE] -gcode: - TESTZ Z=+ - -[gcode_macro TEST_Z_DOWN_MIDDLE] -gcode: - TESTZ Z=- +[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 %} + +[gcode_macro TEST_Z_DOWN] +gcode: + {% set amount = params.amount|default(1)|int %} + TESTZ Z=-{amount} + +[gcode_macro TEST_Z_UP] +gcode: + {% set amount = params.amount|default(1)|int %} + TESTZ Z=+{amount} + +[gcode_macro TEST_Z_UP_MIDDLE] +gcode: + TESTZ Z=+ + +[gcode_macro TEST_Z_DOWN_MIDDLE] +gcode: + TESTZ Z=- + +# 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)) } + + # Absolute positioning + G90 + + # Set new limits + SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel} + + # Home and get position for comparison later: + G28 + + # 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} + + # Restore previous gcode state (absolute/relative, etc) + RESTORE_GCODE_STATE NAME=TEST_SPEED diff --git a/macros.cfg b/macros.cfg index bfa7488..26d89f7 100644 --- a/macros.cfg +++ b/macros.cfg @@ -84,8 +84,8 @@ rename_existing: BASE_PAUSE gcode: #Edit this# {% set X = 230 %} - {% set Y = 230 %} - {% set Z = 10 %} + {% set Y = 200 %} + {% set Z = 30 %} ########### SAVE_GCODE_STATE NAME=PAUSE_state BASE_PAUSE diff --git a/moonraker.conf b/moonraker.conf index af64db4..e42be3a 100644 --- a/moonraker.conf +++ b/moonraker.conf @@ -5,18 +5,23 @@ enable_debug_logging: False config_path: ~/klipper_config log_path: ~/klipper_logs +[timelapse] + [authorization] cors_domains: https://my.mainsail.xyz http://my.mainsail.xyz http://*.local http://*.lan + http://*.home + http://*.far trusted_clients: 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 192.168.0.0/16 + 192.168.25.0/24 FE80::/10 ::1/128 @@ -32,4 +37,11 @@ trusted_clients: [update_manager mainsail] type: web repo: meteyou/mainsail -path: ~/mainsail \ No newline at end of file +path: ~/mainsail + +[update_manager timelapse] +type: git_repo +primary_branch: main +path: ~/moonraker-timelapse +origin: https://github.com/mainsail-crew/moonraker-timelapse.git + diff --git a/print_start.cfg b/print_start.cfg index e5fb778..06825ec 100644 --- a/print_start.cfg +++ b/print_start.cfg @@ -14,7 +14,6 @@ gcode: #LIGHTS_ON M190 S{bedTemp} # Wait for bed to come to temperature RESPOND PREFIX= MSG="Waiting for thermal expansion..." - M117 Waiting for thermal expansion... HEATSOAK DWELL={DWELL} # Dwelling # Homing and creating a mesh @@ -35,6 +34,7 @@ gcode: [gcode_macro HEATSOAK] gcode: + M117 Waiting for thermal expansion... G4 P{params.DWELL|int*1000} [gcode_macro LIGHT_DISPLAY] diff --git a/printer.cfg b/printer.cfg index f71c532..8c44804 100644 --- a/printer.cfg +++ b/printer.cfg @@ -5,6 +5,7 @@ [include calibration_macros.cfg] [include klipper-mini12864.cfg] [include dock_macros.cfg] +[include timelapse.cfg] [pause_resume] [respond] @@ -93,7 +94,7 @@ fade_target: 0 pin: PC15 x_offset: 0.0 y_offset: 34.5 -z_offset = 6.300 +z_offset = 6.275 speed: 25 samples_result: median samples_tolerance: 0.05 @@ -151,17 +152,16 @@ pid_kd = 1260.320 min_temp: 0 max_temp: 120 -[thermistor chamber_temp] -temperature1: 10 +[thermistor custom_chamber] +temperature1: 8 resistance1: 100000 -temperature2: 150 +temperature2: 144 resistance2: 1074 -temperature3: 300 +temperature3: 284 resistance3: 82.78 [temperature_sensor chamber] -#sensor_type: chamber_temp -sensor_type: ATC Semitec 104NT-4-R025H42G +sensor_type: custom_chamber sensor_pin: PA6 min_temp: 0 max_temp: 200 @@ -246,6 +246,11 @@ accel_chip: adxl345 probe_points: 125,119,20 +[firmware_retraction] +retract_length: 0.2 +retract_speed: 80 +unretract_speed: 80 + [input_shaper] shaper_type_x = mzv shaper_freq_x = 51.0 diff --git a/timelapse.cfg b/timelapse.cfg new file mode 120000 index 0000000..982e949 --- /dev/null +++ b/timelapse.cfg @@ -0,0 +1 @@ +/home/pi/moonraker-timelapse/klipper_macro/timelapse.cfg \ No newline at end of file