Last active
December 29, 2023 19:11
-
-
Save NameOfTheDragon/5a920975975dd09bbe6d9a354d9e8669 to your computer and use it in GitHub Desktop.
Use Z-offset to detect the end of heat soak
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Macros for automating heat soak. | |
| # Will measure the Z-offset using the Auto-Z-Calibration plugin every few minutes. | |
| # Keeps track of how much the offset is changing between measurements. | |
| # When the delta falls below a threshold, stops measuring and starts the print queue. | |
| # | |
| # ASSUMPTIONS | |
| # 1. You are using Klicky Probe (this is a prerequisite for the Auto-Z-Calibration plugin) | |
| # 2. Auto-Z-Calibration plugin is installed and configured | |
| # | |
| # DEFAULTS | |
| # By experimentation, we have found that a measurement interval of 6 minutes (360 seconds) | |
| # and a delta-tolerance of 0.025mm brings the printer to thermal equilibrium in about 45 minutes. | |
| # This is for a Voron V2r1 350x350 and may be significantly different for other printers. | |
| # | |
| # Determining your own parameters | |
| # TOLERANCE | |
| # To determine the tolerance value, we heat-soaked our printer for more than an hour starting from cold, performing | |
| # A z-offset measurement and 10x10 bed mesh every few minutes. We plotted the change in Z offset (delta-Z) | |
| # along with cumulative Z offset against time on a graph in Excel. | |
| # You can then pick the maximum amount of Z-offset error you are prepared to tolerate on your first layer, | |
| # and look up the corresponding delta-Z value, which you can use as your Tolerance parameter in this GCode macro. | |
| # | |
| # The measurement interval is a bit more subjective. It needs to be long enough to allow a detectable change in delta-Z, | |
| # But short enough that thermal equilibrium is detected without wasting too much time. | |
| # We found that "about 6 minutes" was a good starting point and you may adjust this up or down depending on | |
| # how accurate you want to be (longer) vs. how impatient you are (shorter). | |
| # Whatever value you decide on, we recommend plotting your delte-Z graph using that time interval. | |
| [gcode_macro HEATSOAK] | |
| variable_tolerance: 0.0175 | |
| variable_previous_offset: 0 | |
| variable_delta: 0 | |
| variable_repeat_seconds: 180 | |
| gcode: | |
| {% set Threshold = params.TOLERANCE | default(0.025) | float %} | |
| {% set Repeat = params.INTERVAL | default(360) | int %} | |
| SET_GCODE_VARIABLE MACRO=HEATSOAK VARIABLE=tolerance VALUE={Threshold} | |
| SET_GCODE_VARIABLE MACRO=HEATSOAK VARIABLE=repeat_seconds VALUE={Repeat} | |
| M117 Heatsoak starting | |
| # PRINTER_STATE_PREHEAT - sets LED state | |
| UPDATE_DELAYED_GCODE ID=_HEATSOAK_CHECK_Z_OFFSET DURATION=5 | |
| [gcode_macro HEATSOAK_STOP] | |
| gcode: | |
| UPDATE_DELAYED_GCODE ID=_HEATSOAK_CHECK_Z_OFFSET DURATION=0 | |
| [delayed_gcode _HEATSOAK_CHECK_Z_OFFSET] | |
| initial_duration: 0 | |
| gcode: | |
| {action_respond_info("Measuring Z offset")} | |
| CALIBRATE_Z FORCE=1 | |
| _HEATSOAK_COMPUTE_DELTA | |
| _HEATSOAK_RESCHEDULE | |
| [gcode_macro _HEATSOAK_COMPUTE_DELTA] | |
| gcode: | |
| {% set previous = printer["gcode_macro HEATSOAK"].previous_offset %} | |
| {% set current = printer.gcode_move.homing_origin.z %} | |
| {% set delta = current - previous %} | |
| {% set tolerance = printer["gcode_macro HEATSOAK"].tolerance %} | |
| SET_GCODE_VARIABLE MACRO=HEATSOAK VARIABLE=previous_offset VALUE={current} | |
| SET_GCODE_VARIABLE MACRO=HEATSOAK VARIABLE=delta VALUE={delta} | |
| {action_respond_info("Previous: %.3f" % (previous))} | |
| {action_respond_info("Current: %.3f" % (current))} | |
| {action_respond_info("Delta: %.3f" % (delta))} | |
| {action_respond_info("Tolerance: %.3f" % (tolerance))} | |
| [gcode_macro _HEATSOAK_RESCHEDULE] | |
| gcode: | |
| {% set previous = printer["gcode_macro HEATSOAK"].previous_offset %} | |
| {% set current = printer.gcode_move.homing_origin.z %} | |
| {% set delta = printer["gcode_macro HEATSOAK"].delta %} | |
| {% set tolerance = printer["gcode_macro HEATSOAK"].tolerance %} | |
| {% set repeat = printer["gcode_macro HEATSOAK"].repeat_seconds %} | |
| {% if delta|abs <= tolerance %} | |
| # PRINTER_STATE_SUCCESS sets LED state | |
| M117 Heatsoak Complete | |
| BEEP DURATION=2000 | |
| HEATSOAK_STOP | |
| { action_call_remote_method("start_job_queue") } | |
| {% else %} | |
| M117 D{delta} T{tolerance} | |
| UPDATE_DELAYED_GCODE ID=_HEATSOAK_CHECK_Z_OFFSET DURATION={repeat} | |
| {% endif %} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment