diff --git a/config/00_macros.cfg b/config/00_macros.cfg new file mode 100644 index 0000000..c2deac1 --- /dev/null +++ b/config/00_macros.cfg @@ -0,0 +1,487 @@ +# gcode to run on printer start +[delayed_gcode STARTUP] +gcode: + # grab saved variables + {% set svv = printer.save_variables.variables %} + {% set bed_leeway_temp = 5 %} + {% set extruder_leeway_temp = 20 %} + {% set hotend_filament = svv.hotend_filament %} + + # check if stored variables make sense, and set them to default values if not + {% if not(svv.heater_mode == "auto" or svv.heater_mode == "manual" or svv.heater_mode == "slicer")%} + { action_respond_info("setting heater_mode to AUTO, before: %s" % (svv.heater_mode)) } + SAVE_VARIABLE VARIABLE=heater_mode VALUE='"auto"' + {% endif %} + + # set temp variables - call variables macro + VARIABLES + + # kickstart fan control macro + # UPDATE_DELAYED_GCODE ID=FAN_CONTROL_LOOP DURATION=2 + + + # check the current heater states and re enable heaters if able + {% if svv.extruder_state == 'hot' %} + {% if svv.extruder_temperature - extruder_leeway_temp <= printer.extruder.temperature %} + { action_respond_info("re-enabling extruder after printer shutoff") } + SET_HEATER_TEMPERATURE HEATER=extruder TARGET={svv.extruder_temperature} + {% else %} + { action_respond_info("extruder was enabled before last shutoff. State updated to cold.") } + SAVE_VARIABLE VARIABLE=extruder_state VALUE='"cold"' + {% endif %} + {% endif %} + + {% if svv.bed_state == 'hot' %} + {action_respond_info(printer.heater_bed.temperature|string)} + {action_respond_info(bed_leeway_temp|string)} + {action_respond_info(svv.bed_temperature|string)} + + {% if svv.bed_temperature - bed_leeway_temp <= printer.heater_bed.temperature %} + { action_respond_info("re-enabling bed after printer shutoff") } + SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={svv.bed_temperature} + {% else %} + { action_respond_info("bed was enabled before last shutoff. State updated to cold.") } + SAVE_VARIABLE VARIABLE=bed_state VALUE='"cold"' + {% endif %} + {% endif %} + + # check the filament load state: + # exit-entry-bowden + # 000 unloaded + # 001 unloaded + # 010 invalid + # 011 unloaded + # 100 runout + # 101 invalid + # 110 near_runout + # 111 loaded + + # store button vals + {% set exit_sense = (printer["gcode_button extruder_exit"].state == "PRESSED") %} + {% set entry_sense = (printer["gcode_button extruder_entry"].state == "PRESSED") %} + {% set bowden_sense = (printer["gcode_button bowden_sensor"].state == "PRESSED") %} + + # detect unloaded + {% if not(entry_sense and exit_sense) or (not(entry_sense) and bowden_sense) %} + {% if svv.filament_load_state != "unloaded" %} + { action_respond_info("Current filament state does not match filament state on last boot. Was " ~ (svv.filament_load_state|string) ~ ", currently unloaded.") } + {% endif %} + SET_FILAMENT_LOAD_STATE STATE="unloaded" + SET_FILAMENT_SENSOR SENSOR=bowden_encoder_sensor ENABLE=0 + + # loaded + {% elif entry_sense and exit_sense and bowden_sense %} + {% if svv.filament_load_state not in ["loaded", "primed"] %} + { action_respond_info("Current filament state does not match filament state on last boot. Was " ~ (svv.filament_load_state|string) ~ "") } + {% endif %} + SET_FILAMENT_LOAD_STATE STATE="loaded" + SET_FILAMENT_SENSOR SENSOR=bowden_encoder_sensor ENABLE=1 + + # runout + {% elif entry_sense and not(exit_sense) and not(bowden_sense) %} + { action_respond_info("Current filament state is runout. Unable to print.") } + SET_FILAMENT_SENSOR SENSOR=bowden_encoder_sensor ENABLE=0 + + # near_runout + {% elif entry_sense and exit_sense and not(bowden_sense) %} + { action_respond_info("Current filament state is runout. Unable to print.") } + SET_FILAMENT_SENSOR SENSOR=bowden_encoder_sensor ENABLE=0 + {% endif %} + +initial_duration: 4 + +[gcode_macro TEST] +gcode: + {% set svv = printer.save_variables.variables %} + {break} + {action_respond_info(svv.filaments|selectattr("name", "in", [svv.filament_hotend, + svv.filament_extruder])|map(attribute="extruder",default='None')|max|string)} + +####### Calibration +[gcode_macro calibrate_full] +gcode: + G28 + QUAD_GANTRY_LEVEL + BED_MESH_CALIBRATE METHOD=rapid_scan + SET_GCODE_VARIABLE MACRO=VARIABLES VARIABLE=mesh_bed_temp VALUE={printer['heater_bed'].temperature} + + MOVE_TO_PURGE_BUCKET + +[gcode_macro calibrate] +gcode: + {% set mesh_temp_leeway = printer["gcode_macro VARIABLES"].mesh_bed_temp_leeway %} + {% set mesh_temp = printer["gcode_macro VARIABLES"].mesh_bed_temp %} + {% set skip_mesh = params.SKIP_MESH|default(False)%} + + {% if "xyz" not in printer['toolhead'].homed_axes %} + G28 + {% endif %} + + {% if not printer['quad_gantry_level'].applied %} + QUAD_GANTRY_LEVEL + {% endif %} + + {action_respond_info((not printer['bed_mesh'].profile_name)|string)} + + {% if skip_mesh %} + G0 X239 Y210 F{700*60} + # if a bed mesh has not been performed, or the temperature hasn't changed by more than 15 degrees. + {% elif ((not printer['bed_mesh'].profile_name) or + (printer['heater_bed'].temperature <= mesh_temp - mesh_temp_leeway) or + (printer['heater_bed'].temperature >= mesh_temp + mesh_temp_leeway)) %} + + G0 X15 Y22 F{700*60} + BED_MESH_CALIBRATE METHOD=rapid_scan + SET_GCODE_VARIABLE MACRO=VARIABLES VARIABLE=mesh_bed_temp VALUE={printer['heater_bed'].temperature} + + G0 X239 Y210 F{700*60} + {% endif %} + + MOVE_TO_PURGE_BUCKET + +####### PRINT START AND STOP ETC +[gcode_macro START_PRINT] +description: Runs before the start of a print. Checks print readyness, corrects if nessesary, and primes the nozzle. +gcode: + {% set svv = printer.save_variables.variables %} + # check the state of the loaded filament + {% if svv.filament_load_state in ["loaded", "primed"] and svv.filament_runout_state != "runout" %} + # if in auto, set bed and extruder to loaded filament parameters. + {% if svv.heater_mode == "auto" %} + SET_BED_TO_FILAMENT + SET_HOTEND_TO_FILAMENT POSITION=both + + # if in slicer or manual mode, quickly sanity check the set temperatures: + {% else %} + {% if printer['extruder'].target <= 0 %} + {action_raise_error("Extruder temperature is set to at or below zero")} + {% endif %} + {% endif %} + + # check calibration + # CALIBRATE SKIP_MESH=True + + # {% if svv.filament_extruder != svv.filament_hotend %} + # PURGE_FILAMENT + # {% endif %} + + # final enable of heaters and wait for temperature to be reached + SET_HEATERS_TO_FILAMENT_AND_WAIT + + # CLEAN_NOZZLE + + # CALIBRATE + + # PRIME_FILAMENT + + _CLIENT_LINEAR_MOVE E=2 F=600 + # enable the encoder filament sensor + SET_FILAMENT_SENSOR SENSOR=bowden_encoder_sensor ENABLE=1 + + {% elif svv.filament_runout_state == "runout" %} + {action_raise_error("Error, filament in runout state")} + + {% else %} + {action_raise_error("Error, filament not loaded. Filament is %s" % (svv.filament_state))} + {% endif %} + + +[gcode_macro stop_print] +gcode: + {% set z = params.Z|default(50)|int %} ; z hop amount + + SET_FILAMENT_SENSOR SENSOR=bowden_encoder_sensor ENABLE=0 + + # reduce temperature of extruder by 10c to reduce oozing + SET_HEATER_TEMPERATURE HEATER=extruder TARGET={printer['extruder'].target - 10} MODE=auto + + {% if (printer.gcode_move.position.z + z) < printer.toolhead.axis_maximum.z %} ; check that zhop doesn't exceed z max + G91 ; relative positioning + G1 Z{z} F900 ; raise Z up by z hop amount + {% else %} + G0 Z{printer.toolhead.axis_maximum.z} + { action_respond_info("Pause zhop exceeds maximum Z height.") } + {% endif %} + G90 ; absolute positioning + G1 Y{258} F6000 ; park toolhead + + +[gcode_macro PAUSE] +description: Pause the actual running print +rename_existing: PAUSE_MAINSAIL +gcode: +# Parameters + {% set svv = printer.save_variables.variables %} + + {% set z = params.Z|default(10)|int %} ; z hop amount + #{% set idle_timeout = client.idle_timeout|default({60*5}) %} + {% set idle_timeout = 60*5 %} + + # if printer is not already paused... + {% if printer['pause_resume'].is_paused|int == 0 %} + # set variables for reference in resume macro + SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=posx VALUE={printer['gcode_move'].gcode_position.x} + SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=posy VALUE={printer['gcode_move'].gcode_position.y} + SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=posz VALUE={printer['gcode_move'].gcode_position.z} + + SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=etemp VALUE={printer['extruder'].target} + SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=btemp VALUE={printer['heater_bed'].target} + SAVE_GCODE_STATE NAME=PAUSE + PAUSE_MAINSAIL + # set a new idle_timeout value + SET_IDLE_TIMEOUT TIMEOUT={idle_timeout} + + # {client.user_pause_macro|default("")} + + # reduce temperature of extruder by 10c to reduce oozing if extruder is enabled + {% if svv.extruder_state == 'hot' %} + SET_HEATER_TEMPERATURE HEATER=extruder TARGET={printer['extruder'].target - 10} MODE=auto + {% endif %} + + {% if (printer.gcode_move.position.z + z) < printer.toolhead.axis_maximum.z %} ; check that zhop doesn't exceed z max + G91 ; relative positioning + G1 Z{z} F900 ; raise Z up by z hop amount + {% else %} + G0 Z{printer.toolhead.axis_maximum.z} + { action_respond_info("Pause zhop exceeds maximum Z height.") } + {% endif %} + G90 ; absolute positioning + G1 Y{258} F6000 ; park toolhead + SAVE_GCODE_STATE NAME=PAUSEPARK ; save parked position in case toolhead is moved during the pause (otherwise the return zhop can error) + {% endif %} + +[gcode_macro RESUME] +description: Resume the actual running print +rename_existing: RESUME_MAINSAIL +variable_posx: 0 +variable_posy: 0 +variable_posz: 0 +variable_zhop: 0 +variable_etemp: 0 +variable_btemp: 0 +gcode: + # Parameters + {% set e = params.E|default(2.5)|int %} ; hotend prime amount (in mm) + {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} + {% set velocity = printer.configfile.settings.pause_resume.recover_velocity %} + {% set sp_move = client.speed_move|default(velocity) %} + {% set runout_resume = True if client.runout_sensor|default("") == "" # no runout + else True if not printer[client.runout_sensor].enabled # sensor is disabled + else printer[client.runout_sensor].filament_detected %} # sensor status + {% set can_extrude = True if printer.toolhead.extruder == '' # no extruder defined in config + else printer[printer.toolhead.extruder].can_extrude %} # status of active extruder + {% set do_resume = False %} + {% set prompt_txt = [] %} + + # if printer is paused... + {% if printer['pause_resume'].is_paused|int == 1 %} + SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value + + RESTORE_GCODE_STATE NAME=PAUSEPARK MOVE=1 MOVE_SPEED=200 ; go back to parked position in case toolhead was moved during pause (otherwise the return zhop can error) + + # reset temperatures + {% if etemp > 0 %} + SET_HEATER_TEMPERATURE HEATER=extruder TARGET={etemp} MODE=auto + {% endif %} + {% if btemp > 0 %} + SET_HEATER_TEMPERATURE_AND_WAIT HEATER=heater_bed TARGET={btemp} MODE=auto + {% endif %} + {% if etemp > 0 %} + SET_HEATER_TEMPERATURE_AND_WAIT HEATER=extruder TARGET={etemp} MODE=auto ; Wait for hotend temp + {% endif %} + + G91 ; relative positioning + M83 ; relative extruder positioning + {% if printer[printer.toolhead.extruder].temperature >= printer.configfile.settings.extruder.min_extrude_temp %} + G1 Z{zhop * -1} E{e} F900 ; prime nozzle by E, lower Z back down + {% else %} + G1 Z{zhop * -1} F900 ; lower Z back down without priming (just in case we are testing the macro with cold hotend) + {% endif %} + RESTORE_GCODE_STATE NAME=PAUSE MOVE=1 MOVE_SPEED=60 ; restore position + RESUME_MAINSAIL + {% endif %} + +[gcode_macro CANCEL_PRINT] +rename_existing: CANCEL_PRINT_MAINSAIL +gcode: + {% set z = params.Z|default(10)|int %} ; z hop amount + + SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value + CLEAR_PAUSE + CANCEL_PRINT_MAINSAIL + + # reduce temperature of extruder by 10c to reduce oozing + SET_HEATER_TEMPERATURE HEATER=extruder TARGET={printer['extruder'].target - 10} MODE=auto + + {% if (printer.gcode_move.position.z + z) < printer.toolhead.axis_maximum.z %} ; check that zhop doesn't exceed z max + G91 ; relative positioning + G1 Z{z} F900 ; raise Z up by z hop amount + {% else %} + G0 Z{printer.toolhead.axis_maximum.z} + { action_respond_info("Pause zhop exceeds maximum Z height.") } + {% endif %} + + G90 ; absolute positioning + G1 Y{258} F6000 ; park toolhead + # clear pause_next_layer and pause_at_layer as preparation for next print + SET_PAUSE_NEXT_LAYER ENABLE=0 + SET_PAUSE_AT_LAYER ENABLE=0 LAYER=0 + + +## MISC MACROS + +[gcode_macro DUMP_VARIABLES] +gcode: + {% set filter_name = params.NAME|default('')|string|lower %} + {% set filter_value = params.VALUE|default('')|string|lower %} + {% set show_cfg = params.SHOW_CFG|default(0)|int %} + + {% set out = [] %} + + {% for key1 in printer %} + {% for key2 in printer[key1] %} + {% if (show_cfg or not (key1|lower == 'configfile' and key2|lower in ['config', 'settings'])) and (filter_name in key1|lower or filter_name in key2|lower) and filter_value in printer[key1][key2]|string|lower %} + {% set dummy = out.append("printer['%s'].%s = %s" % (key1, key2, printer[key1][key2])) %} + {% endif %} + {% else %} + {% if filter_name in key1|lower and filter_value in printer[key1]|string|lower %} + {% set dummy = out.append("printer['%s'] = %s" % (key1, printer[key1])) %} + {% endif %} + {% endfor %} + {% endfor %} + + {action_respond_info(out|join("\n"))} + +[gcode_macro TEST_SPEED] +# 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 + +description: Test for max speed and acceleration parameters for the printer. Procedure: Home -> ReadPositionFromMCU -> MovesToolhead@Vel&Accel -> Home -> ReadPositionfromMCU + +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 %} + # Minimum Cruise Ratio + {% set min_cruise_ratio = params.MIN_CRUISE_RATIO|default(0.5)|float %} + # 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 %} + {% if x_min < 0 %} + {% set x_min = 0 %} + {% endif %} + + {% set y_min = printer.toolhead.axis_minimum.y %} + {% if y_min < 0 %} + {% set y_min = 0 %} + {% endif %} + + {% set x_min = x_min + bound %} + {% set x_max = printer.toolhead.axis_maximum.x - bound %} + {% set y_min = y_min + 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: + M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66 + # 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 %} + G28 + 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{100*60} + M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66 + G28 X Y + G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{100*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 + {% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %} + SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} MINIMUM_CRUISE_RATIO={min_cruise_ratio} + {% else %} + SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2} + {% endif %} + + {% 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} + + # Large pattern 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 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 pattern 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 + {% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %} + SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} MINIMUM_CRUISE_RATIO={printer.configfile.settings.printer.minimum_cruise_ratio} + {% else %} + 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} + {% endif %} + + # Re-home and get position again for comparison: + M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66 + # G28 # This is a full G28 to fix an issue with CoreXZ - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/12 + # Go to XY home positions (in case your homing override leaves it elsewhere) + G90motors + G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{100*60} + G4 P1000 + GET_POSITION + + # Restore previous gcode state (absolute/relative, etc) + RESTORE_GCODE_STATE NAME=TEST_SPEED \ No newline at end of file diff --git a/config/01_filament_management.cfg b/config/01_filament_management.cfg new file mode 100644 index 0000000..a93aeba --- /dev/null +++ b/config/01_filament_management.cfg @@ -0,0 +1,385 @@ +# filament states: +# is_ready_to_print - +# load_state +# hotend_filament - the filament currently in the hotend. Set to the current loaded filament +# loaded_filament - the filament spool which is currently connected to the extruder. Modifiable when filament is +# heater_state - cold, heating, heated +# if the heater state is 'heated' on printer boot, +# and the current hotend and bed temperature is within 15c of the set temperature, then turn the heaters back on. + +[filaments] +on_set_filament_gcode: +# A list of G-Code commands to execute after the SET_FILAMENT macro runs. See +# docs/Command_Templates.md for G-Code format. These parameters are passed +# to the gcode: +# * 'EXTRUDER' - the name of the extruder. 'extruder', 'extruder1' etc. +# * 'T' - the integer index of the extruder +# * 'PRESET' - the filament preset that was just assigned to th extruder +# * 'LAST_PRESET' - the filament preset that was previously assigned to the extruder, if any +on_clear_filament_gcode: +# A list of G-Code commands to execute after the CLEAR_FILAMENT macro runs. See +# docs/Command_Templates.md for G-Code format. These parameters are pass to the gcode: +# * 'EXTRUDER' - the name of the extruder. 'extruder', 'extruder1' etc. +# * 'T' - the integer index of the extruder +# * 'LAST_PRESET' - the filament preset that was previously assigned to the extruder, if any + +[gcode_macro QUERY_FILAMENT] +description: Prompts the user to select a filament, and sets the value of filament_extruder to that filament +gcode: + {% set response = params.RESPONSE|default(False) %} + {% set name = params.NAME|default(False) %} + {% set return_macro = params.RETURN_MACRO|default(False) %} + + {% if not response %} + RESPOND TYPE=command MSG="action:prompt_begin Select Filament" + {% for filament_name in printer.filaments.presets|map(attribute='name',default='None') %} + RESPOND TYPE=command MSG="action:prompt_button {filament_name}|QUERY_FILAMENT {rawparams} NAME={filament_name} RESPONSE=True|primary" + {% endfor %} + RESPOND TYPE=command MSG="action:prompt_show" + {% else %} + # close the dialog + RESPOND TYPE=command MSG="action:prompt_end" + SET_EXTRUDER_FILAMENT NAME={name} + # if we've specified a return macro, run this next. + {% if return_macro %} + {return_macro} + {% endif %} + {% endif %} + + +[gcode_macro UNPRIME_FILAMENT] +description: Unprimes the filament, leaving it in a state where it can be unloaded without changing temperatures +gcode: + {% set svv = printer.save_variables.variables %} + {% set unload = params.UNLOAD|default(False) %} + + {% if svv.filament_load_state == "primed" %} + # check if there is a valid value for the currently loaded filament. if not, prompt the user for it. + {% if svv.filament_extruder == 'None' %} + # if there isn't a set loaded filament, run QUERY_FILAMENT + QUERY_FILAMENT RETURN_MACRO=UNPRIME_FILAMENT + {% else %} + SET_FILAMENT_LOAD_STATE STATE="processing" + + # tell the end macro wether to call the unload macro after this + SET_GCODE_VARIABLE MACRO=END_UNPRIME_FILAMENT VARIABLE=unload VALUE={unload} + # If the extruder was cold, keep it cold after finishing. + SET_GCODE_VARIABLE MACRO=END_UNPRIME_FILAMENT VARIABLE=etemp VALUE={printer['extruder'].target} + + # set temperature of extruder + # if in auto mode, set temperature and wait. Otherwise wait for the set temperature if it it's above 25c. + {% if svv.heater_mode == "auto" %} + SET_TEMPERATURE_AND_WAIT HEATER=extruder TARGET={printer['extruder'].filament.extruder} MODE=auto + {% elif printer['extruder'].target > 25 %} + TEMPERATURE_WAIT SENSOR=extruder MINIMUM={printer['extruder'].target|float - 1} MAXIMUM={printer['extruder'].target|float + 2} + {% endif %} + + # run the loop to retract until the switch is no longer pressed + CLEAN_NOZZLE + # mini purge to ensure filament remains connected + _CLIENT_LINEAR_MOVE E=10 F={60*20} + _CLIENT_LINEAR_MOVE E=-30 F={60*30} + + UPDATE_DELAYED_GCODE ID=LOOP_UNPRIME_FILAMENT DURATION=0.15 + # retract filament until the button is no longer pressed + {% endif %} + {% else %} + {action_respond_info("unable to unprime filament. Current filament state: %s " %(svv.filament_load_state))} + {% endif %} + +[delayed_gcode LOOP_UNPRIME_FILAMENT] +# Retracts filament until the extruder_exit button is no longer pressed +gcode: + {% if printer["gcode_button extruder_exit"].state == "PRESSED" %} + G0 E-2 F{20*60} + # retract by -2mm at 20mm/s (0.1s) + UPDATE_DELAYED_GCODE ID=LOOP_UNPRIME_FILAMENT DURATION=0.15 + # really long wait here. Otherwise klipper gets angry and queues up moves or something. + {% else %} + END_UNPRIME_FILAMENT + {% endif %} + +[gcode_macro END_UNPRIME_FILAMENT] +description: Called by LOOP_UNPRIME_FILAMENT, finishes up unpriming the filament. +variable_etemp = 0 +variable_unload = False +gcode: + # set temperature to what it was before + SET_HEATER_TEMPERATURE HEATER='extruder' TARGET={etemp} MODE=auto + + # set filament state + SET_FILAMENT_LOAD_STATE STATE="loaded" + + # if we want to unload after this, do so + {% if unload %} + UNLOAD_FILAMENT + {% else %} + # reload filament by an extra 10mm to press the button again + _CLIENT_LINEAR_MOVE E=10 F={60*60} + {% endif %} + +[gcode_macro UNLOAD_FILAMENT] +description: Unloads the current filament +gcode: + {% set svv = printer.save_variables.variables %} + # check against current filament state + {% if svv.filament_load_state == "loaded" %} + _CLIENT_LINEAR_MOVE E=-40 F={60*10} + {action_respond_info('fuck')} + SET_STEPPER_ENABLE STEPPER=extruder ENABLE=0 + SET_FILAMENT_LOAD_STATE STATE="unloaded_waiting" + SET_EXTRUDER_FILAMENT NAME="None" + + {% elif svv.filament_load_state == "primed" %} + {action_respond_info('shit')} + UNPRIME_FILAMENT UNLOAD=True + {% else %} + {action_respond_info("unable to unload filament. Current filament state: %s " %(svv.filament_load_state))} + {% endif %} + +[gcode_macro LOAD_FILAMENT] +# loads filament after it has been detected in the entry sensor or manually triggered +gcode: + {% set svv = printer.save_variables.variables %} + {% set prompt = params.PROMPT|default(False) %}M84 E + {% set prime = params.PRIME|default(False) %} + + # tell the end macro wether to call the prime macro after this + SET_GCODE_VARIABLE MACRO=END_LOAD_FILAMENT VARIABLE=prime VALUE={prime} + + {% if not filament_state in ['unloaded'] %} + # forward the filament name to the next macro + SET_GCODE_VARIABLE MACRO=END_LOAD_FILAMENT VARIABLE=name VALUE="'{params.NAME}'" + # we could set it here, but it avoids weird states if the macro fails for some reason. + + SET_FILAMENT_LOAD_STATE STATE="processing" + M83 # relative extruder moves + # load filament into extruder gear + UPDATE_DELAYED_GCODE ID=LOOP_LOAD_FILAMENT DURATION=0.15 + {% else %} + {action_respond_info("unable to load filament. Current filament state: %s " %(svv.filament_load_state))} + {% endif %} + +[delayed_gcode LOOP_LOAD_FILAMENT] +gcode: + {% if printer["gcode_button extruder_exit"].state == "RELEASED" %} + G0 E2 F{20*60} + # Extrude by 2mm at 20mm/s (0.1s) + UPDATE_DELAYED_GCODE ID=LOOP_LOAD_FILAMENT DURATION=0.15 + # really long wait here. Otherwise klipper gets angry and queues up moves or something. + {% else %} + END_LOAD_FILAMENT + {% endif %} + + +[gcode_macro END_LOAD_FILAMENT] +variable_prime = False +variable_name = None +gcode: + {% set svv = printer.save_variables.variables %} + M82 # absolute extruder moves + # set loaded filament + SET_FILAMENT_LOAD_STATE STATE="loaded" + + # check if there is a valid value for the currently loaded filament. if not, prompt the user for it. + {% if not svv.filament_extruder in printer.filaments.presets|map(attribute='name',default='yeet') %} + # if there isn't a set loaded filament, extrude a bit then run QUERY_FILAMENT + G0 E4 F{20*60} + QUERY_FILAMENT RETURN_MACRO=LOAD_FILAMENT + {% endif %} + + {% if prime %} + PRIME_FILAMENT + {% endif %} + + +[gcode_macro PRIME_FILAMENT] +gcode: + {% set svv = printer.save_variables.variables %} + + {% if svv.filament_load_state in ['unloaded', 'loaded', 'primed'] %} + # check if there is a valid value for the currently loaded filament. if not, prompt the user for it. + {% if not svv.filament_extruder in printer.filaments.presets|map(attribute='name',default='yeet') %} + # if there isn't a set loaded filament, run QUERY_FILAMENT + QUERY_FILAMENT RETURN_MACRO=PRIME_FILAMENT + + {% elif svv.filament_load_state in ['unloaded'] %} + LOAD_FILAMENT PRIME=True + {% elif svv.filament_load_state in ['loaded', 'primed'] %} + # ensure that the filament in the hotend is the same as the filament in the extruder + {% if svv.filament_extruder == svv.filament_hotend %} + SET_HOTEND_TO_FILAMENT + + MOVE_TO_PURGE_BUCKET + + SET_HOTEND_TO_FILAMENT WAIT=True + + # if the filament is only loaded, then extrude a bit to get it to the end of the extruder + {% if svv.filament_load_state in ['loaded'] %} + _CLIENT_LINEAR_MOVE E=25 F={60*20} + {% endif %} + _CLIENT_LINEAR_MOVE E=10 F={60*10} + _CLIENT_LINEAR_MOVE E={-printer['gcode_macro VARIABLES'].retraction_length} F={60*20} + + CLEAN_NOZZLE + + SET_FILAMENT_LOAD_STATE STATE=primed + {% else %} + {action_respond_info("unable to prime filament. Filament in hotend doesn't match current filament")} + {% endif %} + {% endif %} + {% else %} + {action_respond_info("unable to prime filament. Current filament state: %s " % (svv.filament_load_state))} + {% endif %} + +[gcode_macro PURGE_FILAMENT] +gcode: + {% set svv = printer.save_variables.variables %} + + {% if not svv.filament_extruder in printer.filaments.presets|map(attribute='name',default='yeet') %} + # if there isn't a set loaded filament, run QUERY_FILAMENT + QUERY_FILAMENT RETURN_MACRO=PURGE_FILAMENT + + {% elif svv.filament_load_state in ["loaded", "primed"] %} + # if the filament is loaded or primed, then continue + SET_HOTEND_TO_FILAMENT POSITION=both + # move to purge bucket + MOVE_TO_PURGE_BUCKET + + SET_HOTEND_TO_FILAMENT Wait=True POSITION=both + {% if svv.filament_load_state in ['loaded'] %} + _CLIENT_LINEAR_MOVE E=25 F={60*20} + {% endif %} + _CLIENT_LINEAR_MOVE E={printer['gcode_macro VARIABLES'].purge_line_length} F={60*10} + _CLIENT_LINEAR_MOVE E={-printer['gcode_macro VARIABLES'].retraction_length} F={60*20} + + CLEAN_NOZZLE + + SET_HOTEND_FILAMENT NAME={svv.filament_extruder} + SET_FILAMENT_LOAD_STATE STATE=primed + + {% else %} + {action_respond_info("unable to purge filament. Current filament state: %s " %(svv.filament_load_state))} + {% endif %} + +[gcode_macro MOVE_TO_PURGE_BUCKET] +gcode: + # move z to minimum of 6 + {% if printer['gcode_move'].position.z < 6 %} + _CLIENT_LINEAR_MOVE Z=6 F={60*60} ABSOLUTE=1 + {% endif %} + + # move y out if necessary + {% if printer['gcode_move'].position.y > 254 %} + _CLIENT_LINEAR_MOVE Y=254 F={60*700} ABSOLUTE=1 + {% endif %} + + # move xy to purge bucket + _CLIENT_LINEAR_MOVE Y=254 X=25 F={60*700} ABSOLUTE=1 + _CLIENT_LINEAR_MOVE Y=259 F={60*60} ABSOLUTE=1 + +[gcode_macro CLEAN_NOZZLE] +description: wipes filament off the nozzle +gcode: + MOVE_TO_PURGE_BUCKET + + # wipe a few times + {% for x in range(2) %} + _CLIENT_LINEAR_MOVE X=55 F={60*700} + _CLIENT_LINEAR_MOVE X=-55 F={60*700} + {% endfor %} + +[gcode_macro STABILIZE_NOZZLE] +description: tries to prevent the nozzle from leaking filament too much +gcode: + + +[gcode_button bowden_sensor] +pin: PF2 +press_gcode: + {% set svv = printer.save_variables.variables %} + { action_respond_info("bowden_load") } #DEBUG + + # TODO - USER LOAD FILAMENT. Setup some sort of response? Maybe wake printer from sleep mode and turn on lights? + # can't switch back frgom near runout as the extruder can't grab further filament + +release_gcode: + {% set svv = printer.save_variables.variables %} + {% if svv.filament_load_state in ['primed', 'loaded'] %} + {action_raise_error("Warning: bowden sensor released, nearing filament runout")} + # disable the encoder sensor + + # TODO IMPLEMENT MORE WARNINGS. + {% elif svv.filament_load_state != 'unloaded' %} + {action_raise_error("Warning: bowden sensor released during nonsensical filament state.")} + {% endif %} + +[filament_motion_sensor bowden_encoder_sensor] +detection_length: 10 +extruder: extruder +switch_pin: ^PF3 +pause_on_runout: False +insert_gcode: +runout_gcode: + # if the printer is both printing, and the bowden sensor is pressed, then pause print. + {% if (printer["gcode_button bowden_sensor"].state == "PRESSED") and + printer['print_stats'].state == "printing" %} + PAUSE + {% endif %} + # check if the bowden sensor is pressed + + +[gcode_button extruder_entry] +pin: printHead:PB7 +press_gcode: + {% set svv = printer.save_variables.variables %} + + { action_respond_info("extruder_entry_insert") } + + {% if svv.filament_load_state == 'unloaded' %} + LOAD_FILAMENT + {% endif %} + +release_gcode: + { action_respond_info("extruder_entry_release") } + {% set svv = printer.save_variables.variables %} + + # if filament is loaded, check if it's running out or being unloaded + {% if svv.filament_load_state == 'loaded' %} + # runout + {% if printer['gcode_button extruder_exit'].state == PRESSED %} + {action_raise_error("Warning: extruder entry sensor released, filament runout")} + SET_FILAMENT_LOAD_STATE STATE="runout" + + # pause printer on runout + {% if svv.printer_state == 'printing'%} + # PAUSE + {% endif %} + # being unloaded + {% else %} + SET_FILAMENT_LOAD_STATE STATE="unloaded" + {% endif %} + {% elif svv.filament_load_state == 'unloaded_waiting' %} + SET_FILAMENT_LOAD_STATE STATE="unloaded" + {% elif svv.filament_load_state != 'unloaded' %} + {action_raise_error("Warning: bowden sensor released during nonsensical filament state.")} + {% endif %} + +[gcode_button extruder_exit] +pin: printHead:PB5 + +press_gcode: + { action_respond_info("extruder_exit_insert") } + {% set svv = printer.save_variables.variables %} + + # auto state update if the user is manually doing things + {% if svv.filament_load_state not in ['loaded', 'primed'] %} + SET_FILAMENT_LOAD_STATE STATE="loaded" + {% endif %} + + +release_gcode: + { action_respond_info("extruder_exit_runout") } + {% set svv = printer.save_variables.variables %} + + diff --git a/config/01_heater_management.cfg b/config/01_heater_management.cfg new file mode 100644 index 0000000..f6c644a --- /dev/null +++ b/config/01_heater_management.cfg @@ -0,0 +1,48 @@ +###### HEATER AUTO HANDLING +[gcode_macro SET_HEATERS_TO_FILAMENT_AND_WAIT] +description: +gcode: + {% set svv = printer.save_variables.variables %} + + SET_HEATER_TEMPERATURE HEATER=extruder TARGET={svv.filaments|selectattr("name", "equalto", svv.filament_hotend)|map(attribute="extruder",default='None')|first|string} MODE=auto + SET_HEATER_TEMPERATURE_AND_WAIT HEATER=heater_bed TARGET={svv.filaments|selectattr("name", "equalto", svv.filament_hotend)|map(attribute="bed",default='None')|first|string} MODE=auto + SET_HEATER_TEMPERATURE_AND_WAIT HEATER=extruder TARGET={svv.filaments|selectattr("name", "equalto", svv.filament_hotend)|map(attribute="extruder",default='None')|first|string} MODE=auto + +[gcode_macro SET_HOTEND_TO_FILAMENT] +description: sets the temperature of the hotend to the temperature required by the stored filament +gcode: + {% set wait = params.WAIT|default(False) %} ; z hop amount + {% set svv = printer.save_variables.variables %} + + {% set position = params.POSITION|default('extruder')|string|lower %} + {% if wait %} + {% if position == 'extruder' %} + SET_HEATER_TEMPERATURE_AND_WAIT HEATER=extruder TARGET={svv.filaments|selectattr("name", "in", [svv.filament_extruder])|map(attribute="extruder",default='None')|max|string} MODE=auto + {% elif position == 'hotend' %} + SET_HEATER_TEMPERATURE_AND_WAIT HEATER=extruder TARGET={svv.filaments|selectattr("name", "in", [svv.filament_hotend])|map(attribute="extruder",default='None')|max|string} MODE=auto + {% elif position == 'both' %} + SET_HEATER_TEMPERATURE_AND_WAIT HEATER=extruder TARGET={svv.filaments|selectattr("name", "in", [svv.filament_hotend, svv.filament_extruder])|map(attribute="extruder",default='None')|max|string} MODE=auto + {% endif %} + {% else %} + {% if position == 'extruder' %} + SET_HEATER_TEMPERATURE HEATER=extruder TARGET={svv.filaments|selectattr("name", "in", [svv.filament_extruder])|map(attribute="extruder",default='None')|max|string} MODE=auto + {% elif position == 'hotend' %} + SET_HEATER_TEMPERATURE HEATER=extruder TARGET={svv.filaments|selectattr("name", "in", [svv.filament_hotend])|map(attribute="extruder",default='None')|max|string} MODE=auto + {% elif position == 'both' %} + SET_HEATER_TEMPERATURE HEATER=extruder TARGET={svv.filaments|selectattr("name", "in", [svv.filament_hotend, svv.filament_extruder])|map(attribute="extruder",default='None')|max|string} MODE=auto + {% endif %} + {% endif %} + +[gcode_macro SET_BED_TO_FILAMENT] +description: sets the temperature of the bed to the temperature required by the stored filament +gcode: + {% set svv = printer.save_variables.variables %} + + {% set position = params.POSITION|default('extruder')|string|lower %} + {% if position == 'extruder' %} + SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={svv.filaments|selectattr("name", "in", [svv.filament_extruder])|map(attribute="bed",default='None')|max|string} MODE=auto + {% elif position == 'hotend' %} + SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={svv.filaments|selectattr("name", "in", [svv.filament_hotend])|map(attribute="bed",default='None')|max|string} MODE=auto + {% elif position == 'both' %} + SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={svv.filaments|selectattr("name", "in", [svv.filament_hotend, svv.filament_extruder])|map(attribute="bed",default='None')|max|string} MODE=auto + {% endif %} \ No newline at end of file diff --git a/config/calibration.cfg b/config/calibration.cfg new file mode 100644 index 0000000..577d920 --- /dev/null +++ b/config/calibration.cfg @@ -0,0 +1,112 @@ +## <---------------------- Input shaper ----------------------> + +[resonance_tester] +probe_points: 125, 125, 20 +# A list of X, Y, Z coordinates of points (one point per line) to test +# resonances at. + +accel_chip:adxl345 +#max_smoothing: +# Maximum input shaper smoothing to allow for each axis during shaper +# auto-calibration (with 'SHAPER_CALIBRATE' command). By default no +# maximum smoothing is specified. Refer to Measuring_Resonances guide +# for more details on using this feature. +move_speed: 50 +min_freq: 5 #5Hz +max_freq: 200 #133.33 Hz. +accel_per_hz: 300 +# This parameter is used to determine which acceleration to use to +# test a specific frequency: accel = accel_per_hz * freq. Higher the +# value, the higher is the energy of the oscillations. Can be set to +# a lower than the default value if the resonances get too strong on +# the printer. However, lower values make measurements of +# high-frequency resonances less precise. The default value is 75 +# (mm/sec). +hz_per_sec: 1 +# Determines the speed of the test. When testing all frequencies in +# range [min_freq, max_freq], each second the frequency increases by +# hz_per_sec. Small values make the test slow, and the large values +# will decrease the precision of the test. The default value is 1.0 +# (Hz/sec == sec^-2). +#sweeping_accel: 400 +# An acceleration of slow sweeping moves. The default is 400 mm/sec^2. +sweeping_period: 1.2 +# A period of slow sweeping moves. Setting this parameter to 0 +# disables slow sweeping moves. Avoid setting it to a too small +# non-zero value in order to not poison the measurements. +# The default is 1.2 sec which is a good all-round choice. + +[input_shaper] +shaper_freq_x: 62.4 +# A frequency (in Hz) of the input shaper for X axis. This is +# usually a resonance frequency of X axis that the input shaper +# should suppress. For more complex shapers, like 2- and 3-hump EI +# input shapers, this parameter can be set from different +# considerations. The default value is 0, which disables input +# shaping for X axis. +shaper_freq_y: 49 +# A frequency (in Hz) of the input shaper for Y axis. This is +# usually a resonance frequency of Y axis that the input shaper +# should suppress. For more complex shapers, like 2- and 3-hump EI +# input shapers, this parameter can be set from different +# considerations. The default value is 0, which disables input +# shaping for Y axis. +shaper_type: mzv +#damping_ratio_x: 0.1 +#damping_ratio_y: 0.1 +# Damping ratios of vibrations of X and Y axes used by input shapers +# to improve vibration suppression. Default value is 0.1 which is a +# good all-round value for most printers. In most circumstances this +# parameter requires no tuning and should not be changed. + + +## <---------------------- Homing ----------------------> + + +[quad_gantry_level] +# Use QUAD_GANTRY_LEVEL to level a gantry. +gantry_corners: + -57, 0 + 312, 320 +# Min & Max gantry corners - measure from nozzle at MIN (0,0) and MAX (250,250) to respective belt positions +points: + # 239, 210 + # 15, 210 + # 15, 0 + # 239, 0 + 16, 1 + 16, 208 + 238, 208 + 238, 1 + +# Probe points +speed: 600 +horizontal_move_z: 6 +max_adjust: 10 + +[bed_mesh] +horizontal_move_z: 3 +speed: 300 +# For the mesh dimensions below, the coordinates need to be reachable by the center of the probe. To calculate coordinates that will work, use the formula below: +# mesh x min = position_min_x + greater_of (15mm or x_offset) <--- in this term, only consider the x offset if it is positive, ignore if negative. +# mesh y min = position_min_y + greater_of (15mm or y_offset) <--- in this term, only consider the y offset if it is positive, ignore if negative. +# mesh x max = position_max_x - greater_of (15mm or |x_offset|) <--- in this term, only consider the x offset if it is negative, ignore if positive. +# mesh y max = position_max_y - greater_of (15mm or |y_offset|) <--- in this term, only consider the y offset if it is negative, ignore if positive. +# Example: Consider that you have a 300 x 300 bed with the max x and y positions being 300 and the min being 0. Your probe offsets are -20 for X and 10 for Y +# For mesh x min we ignore the x offset term because it is negative. Therefore mesh x min = 15 +# For mesh y min we do not ignore the y offset term because it is positive but it is less than 15 so we use 15. Therefore mesh y min = 15 +# For mesh x max we do not ignore the x offset term because it is negative. It is also greater than 15. Therefore mesh x max = 280 +# For mesh y max we ignore the y offset term because it is positive but it is less than 15 so we use 15. Therefore mesh y max = 285 +# The final result would be mesh_min: 15, 15 mesh_max: 280, 285 +mesh_min: 17, 22 # modify these according to the above guide. If the probe cannot reach then you will get a klipper error when trying to scan a bed mesh. +mesh_max: 237, 237 # modify these according to the above guide. If the probe cannot reach then you will get a klipper error when trying to scan a bed mesh. +probe_count: 40, 12 +algorithm: bicubic +scan_overshoot: 5 #uncomment this section if you still have room left over on the X axis for some scan overshoot to product smoother movements and more accurate scanning. Uncommenting this should be fine if you are using a standard voron mount. + +# Uncomment this if you are using Eddy as the probe AND the homing endstop +[safe_z_home] +home_xy_position: 239, 210 # Choose an X,Y position that is in the center of your bed. For a 300x300 machine that will be 150, 150. Use the same principle to calculate your bed center. +z_hop: 10 +z_hop_speed: 25 +speed: 600 diff --git a/config/eddy.cfg b/config/eddy.cfg index 1d8cab5..8554484 100644 --- a/config/eddy.cfg +++ b/config/eddy.cfg @@ -1,80 +1,3 @@ -# The MCU section only applies to the Eddy USB. For Eddy Coil you will use the MCU name of the toolboard that you connected the Eddy Coil to. -[mcu eddy] -canbus_uuid: c544ec61c167 -#Did you read all of the comments before the macros? Make sure that you do and then uncomment the ones that you need. Remove this line when you are done. - -[temperature_sensor btt_eddy_mcu] -sensor_type: temperature_mcu # Sets the type of sensor for Klipper to read -sensor_mcu: eddy # Sets the MCU of the eddy probe tempereature sensor -min_temp: 10 # Sets the minimum tempereature for eddys tempereature sensor to operate -max_temp: 120 # Sets the maximum tempereature for eddys tempereature sensor to operate - -[probe_eddy_current btt_eddy] -sensor_type: ldc1612 -#z_offset: 2.5 -#i2c_address: -i2c_mcu: eddy # This value is good for the Eddy USB but would need to be adjusted for the Eddy Coil according to the MCU you have used. -i2c_bus: i2c0f # This value is good for the Eddy USB but would need to be adjusted for the Eddy Coil according to the I2C bus you have used. -# Measure the offsets below using the method described here: https://www.klipper3d.org/Probe_Calibrate.html#calibrating-probe-x-and-y-offsets -# For a standard Voron stealthburner X carriage mount there should be no need to change the defaults below. -x_offset: 0 -y_offset: 21.42 -sensor_type: ldc1612 - -# This section is only relevant for Eddy USB. Comment it out for Eddy Coil. -[temperature_probe btt_eddy] -sensor_type: Generic 3950 -sensor_pin: eddy:gpio26 -horizontal_move_z: 2 - -[quad_gantry_level] -# Use QUAD_GANTRY_LEVEL to level a gantry. -gantry_corners: - -57, 0 - 312, 320 -# Min & Max gantry corners - measure from nozzle at MIN (0,0) and MAX (250,250) to respective belt positions -points: - # 239, 210 - # 15, 210 - # 15, 0 - # 239, 0 - 16, 1 - 16, 208 - 238, 208 - 238, 1 - -# Probe points -speed: 600 -horizontal_move_z: 6 -max_adjust: 10 - -[bed_mesh] -horizontal_move_z: 3 -speed: 300 -# For the mesh dimensions below, the coordinates need to be reachable by the center of the probe. To calculate coordinates that will work, use the formula below: -# mesh x min = position_min_x + greater_of (15mm or x_offset) <--- in this term, only consider the x offset if it is positive, ignore if negative. -# mesh y min = position_min_y + greater_of (15mm or y_offset) <--- in this term, only consider the y offset if it is positive, ignore if negative. -# mesh x max = position_max_x - greater_of (15mm or |x_offset|) <--- in this term, only consider the x offset if it is negative, ignore if positive. -# mesh y max = position_max_y - greater_of (15mm or |y_offset|) <--- in this term, only consider the y offset if it is negative, ignore if positive. -# Example: Consider that you have a 300 x 300 bed with the max x and y positions being 300 and the min being 0. Your probe offsets are -20 for X and 10 for Y -# For mesh x min we ignore the x offset term because it is negative. Therefore mesh x min = 15 -# For mesh y min we do not ignore the y offset term because it is positive but it is less than 15 so we use 15. Therefore mesh y min = 15 -# For mesh x max we do not ignore the x offset term because it is negative. It is also greater than 15. Therefore mesh x max = 280 -# For mesh y max we ignore the y offset term because it is positive but it is less than 15 so we use 15. Therefore mesh y max = 285 -# The final result would be mesh_min: 15, 15 mesh_max: 280, 285 -mesh_min: 17, 22 # modify these according to the above guide. If the probe cannot reach then you will get a klipper error when trying to scan a bed mesh. -mesh_max: 237, 237 # modify these according to the above guide. If the probe cannot reach then you will get a klipper error when trying to scan a bed mesh. -probe_count: 40, 12 -algorithm: bicubic -scan_overshoot: 5 #uncomment this section if you still have room left over on the X axis for some scan overshoot to product smoother movements and more accurate scanning. Uncommenting this should be fine if you are using a standard voron mount. - -# Uncomment this if you are using Eddy as the probe AND the homing endstop -[safe_z_home] -home_xy_position: 239, 210 # Choose an X,Y position that is in the center of your bed. For a 300x300 machine that will be 150, 150. Use the same principle to calculate your bed center. -z_hop: 10 -z_hop_speed: 25 -speed: 600 - ###############################Macros and related################################ #This secton contains macros and related config sections. Some should be used, others are optional. Read the comment above each one to find out whether or not to uncomment it for your installation. @@ -144,11 +67,4 @@ PROBE_EDDY_CURRENT_CALIBRATE {rawparams} - #This macro is optional but useful if you want to run a rapid scan before each print. Simply uncomment it and add BED_MESH_SCAN to your print start code. -#[gcode_macro BED_MESH_CALIBRATE] -#rename_existing: BTT_BED_MESH_CALIBRATE -#gcode: -# SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=probing VALUE=True #Only uncomment this line if using a KNOMI and then remove the BED_MESH_CALIBRATE macro from KNOMI.cfg -# BTT_BED_MESH_CALIBRATE METHOD=rapid_scan -# SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=probing VALUE=False #Only uncomment this line if using a KNOMI and then remove the BED_MESH_CALIBRATE macro from KNOMI.cfg \ No newline at end of file diff --git a/config/filament_sensors.cfg b/config/filament_sensors.cfg deleted file mode 100644 index ebd7076..0000000 --- a/config/filament_sensors.cfg +++ /dev/null @@ -1,385 +0,0 @@ -# filament states: -# is_ready_to_print - -# load_state -# hotend_filament - the filament currently in the hotend. Set to the current loaded filament -# loaded_filament - the filament spool which is currently connected to the extruder. Modifiable when filament is -# heater_state - cold, heating, heated -# if the heater state is 'heated' on printer boot, -# and the current hotend and bed temperature is within 15c of the set temperature, then turn the heaters back on. - -[filaments] -on_set_filament_gcode: -# A list of G-Code commands to execute after the SET_FILAMENT macro runs. See -# docs/Command_Templates.md for G-Code format. These parameters are passed -# to the gcode: -# * 'EXTRUDER' - the name of the extruder. 'extruder', 'extruder1' etc. -# * 'T' - the integer index of the extruder -# * 'PRESET' - the filament preset that was just assigned to th extruder -# * 'LAST_PRESET' - the filament preset that was previously assigned to the extruder, if any -on_clear_filament_gcode: -# A list of G-Code commands to execute after the CLEAR_FILAMENT macro runs. See -# docs/Command_Templates.md for G-Code format. These parameters are pass to the gcode: -# * 'EXTRUDER' - the name of the extruder. 'extruder', 'extruder1' etc. -# * 'T' - the integer index of the extruder -# * 'LAST_PRESET' - the filament preset that was previously assigned to the extruder, if any - -[gcode_macro QUERY_FILAMENT] -description: Prompts the user to select a filament, and sets the value of filament_extruder to that filament -gcode: - {% set response = params.RESPONSE|default(False) %} - {% set name = params.NAME|default(False) %} - {% set return_macro = params.RETURN_MACRO|default(False) %} - - {% if not response %} - RESPOND TYPE=command MSG="action:prompt_begin Select Filament" - {% for filament_name in printer.filaments.presets|map(attribute='name',default='None') %} - RESPOND TYPE=command MSG="action:prompt_button {filament_name}|QUERY_FILAMENT {rawparams} NAME={filament_name} RESPONSE=True|primary" - {% endfor %} - RESPOND TYPE=command MSG="action:prompt_show" - {% else %} - # close the dialog - RESPOND TYPE=command MSG="action:prompt_end" - SET_EXTRUDER_FILAMENT NAME={name} - # if we've specified a return macro, run this next. - {% if return_macro %} - {return_macro} - {% endif %} - {% endif %} - - -[gcode_macro UNPRIME_FILAMENT] -description: Unprimes the filament, leaving it in a state where it can be unloaded without changing temperatures -gcode: - {% set svv = printer.save_variables.variables %} - {% set unload = params.UNLOAD|default(False) %} - - {% if svv.filament_load_state == "primed" %} - # check if there is a valid value for the currently loaded filament. if not, prompt the user for it. - {% if svv.filament_extruder == 'None' %} - # if there isn't a set loaded filament, run QUERY_FILAMENT - QUERY_FILAMENT RETURN_MACRO=UNPRIME_FILAMENT - {% else %} - SET_FILAMENT_LOAD_STATE STATE="processing" - - # tell the end macro wether to call the unload macro after this - SET_GCODE_VARIABLE MACRO=END_UNPRIME_FILAMENT VARIABLE=unload VALUE={unload} - # If the extruder was cold, keep it cold after finishing. - SET_GCODE_VARIABLE MACRO=END_UNPRIME_FILAMENT VARIABLE=etemp VALUE={printer['extruder'].target} - - # set temperature of extruder - # if in auto mode, set temperature and wait. Otherwise wait for the set temperature if it it's above 25c. - {% if svv.heater_mode == "auto" %} - SET_TEMPERATURE_AND_WAIT HEATER=extruder TARGET={printer['extruder'].filament.extruder} MODE=auto - {% elif printer['extruder'].target > 25 %} - TEMPERATURE_WAIT SENSOR=extruder MINIMUM={printer['extruder'].target|float - 1} MAXIMUM={printer['extruder'].target|float + 2} - {% endif %} - - # run the loop to retract until the switch is no longer pressed - CLEAN_NOZZLE - # mini purge to ensure filament remains connected - _CLIENT_LINEAR_MOVE E=10 F={60*20} - _CLIENT_LINEAR_MOVE E=-30 F={60*30} - - UPDATE_DELAYED_GCODE ID=LOOP_UNPRIME_FILAMENT DURATION=0.15 - # retract filament until the button is no longer pressed - {% endif %} - {% else %} - {action_respond_info("unable to unprime filament. Current filament state: %s " %(svv.filament_load_state))} - {% endif %} - -[delayed_gcode LOOP_UNPRIME_FILAMENT] -# Retracts filament until the extruder_exit button is no longer pressed -gcode: - {% if printer["gcode_button extruder_exit"].state == "PRESSED" %} - G0 E-2 F{20*60} - # retract by -2mm at 20mm/s (0.1s) - UPDATE_DELAYED_GCODE ID=LOOP_UNPRIME_FILAMENT DURATION=0.15 - # really long wait here. Otherwise klipper gets angry and queues up moves or something. - {% else %} - END_UNPRIME_FILAMENT - {% endif %} - -[gcode_macro END_UNPRIME_FILAMENT] -description: Called by LOOP_UNPRIME_FILAMENT, finishes up unpriming the filament. -variable_etemp = 0 -variable_unload = False -gcode: - # set temperature to what it was before - SET_HEATER_TEMPERATURE HEATER='extruder' TARGET={etemp} MODE=auto - - # set filament state - SET_FILAMENT_LOAD_STATE STATE="loaded" - - # if we want to unload after this, do so - {% if unload %} - UNLOAD_FILAMENT - {% else %} - # reload filament by an extra 10mm to press the button again - _CLIENT_LINEAR_MOVE E=10 F={60*60} - {% endif %} - -[gcode_macro UNLOAD_FILAMENT] -description: Unloads the current filament -gcode: - {% set svv = printer.save_variables.variables %} - # check against current filament state - {% if svv.filament_load_state == "loaded" %} - _CLIENT_LINEAR_MOVE E=-40 F={60*10} - {action_respond_info('fuck')} - SET_STEPPER_ENABLE STEPPER=extruder ENABLE=0 - SET_FILAMENT_LOAD_STATE STATE="unloaded_waiting" - SET_EXTRUDER_FILAMENT NAME="None" - - {% elif svv.filament_load_state == "primed" %} - {action_respond_info('shit')} - UNPRIME_FILAMENT UNLOAD=True - {% else %} - {action_respond_info("unable to unload filament. Current filament state: %s " %(svv.filament_load_state))} - {% endif %} - -[gcode_macro LOAD_FILAMENT] -# loads filament after it has been detected in the entry sensor or manually triggered -gcode: - {% set svv = printer.save_variables.variables %} - {% set prompt = params.PROMPT|default(False) %}M84 E - {% set prime = params.PRIME|default(False) %} - - # tell the end macro wether to call the prime macro after this - SET_GCODE_VARIABLE MACRO=END_LOAD_FILAMENT VARIABLE=prime VALUE={prime} - - {% if not filament_state in ['unloaded'] %} - # forward the filament name to the next macro - SET_GCODE_VARIABLE MACRO=END_LOAD_FILAMENT VARIABLE=name VALUE="'{params.NAME}'" - # we could set it here, but it avoids weird states if the macro fails for some reason. - - SET_FILAMENT_LOAD_STATE STATE="processing" - M83 # relative extruder moves - # load filament into extruder gear - UPDATE_DELAYED_GCODE ID=LOOP_LOAD_FILAMENT DURATION=0.15 - {% else %} - {action_respond_info("unable to load filament. Current filament state: %s " %(svv.filament_load_state))} - {% endif %} - -[delayed_gcode LOOP_LOAD_FILAMENT] -gcode: - {% if printer["gcode_button extruder_exit"].state == "RELEASED" %} - G0 E2 F{20*60} - # Extrude by 2mm at 20mm/s (0.1s) - UPDATE_DELAYED_GCODE ID=LOOP_LOAD_FILAMENT DURATION=0.15 - # really long wait here. Otherwise klipper gets angry and queues up moves or something. - {% else %} - END_LOAD_FILAMENT - {% endif %} - - -[gcode_macro END_LOAD_FILAMENT] -variable_prime = False -variable_name = None -gcode: - {% set svv = printer.save_variables.variables %} - M82 # absolute extruder moves - # set loaded filament - SET_FILAMENT_LOAD_STATE STATE="loaded" - - # check if there is a valid value for the currently loaded filament. if not, prompt the user for it. - {% if not svv.filament_extruder in printer.filaments.presets|map(attribute='name',default='yeet') %} - # if there isn't a set loaded filament, extrude a bit then run QUERY_FILAMENT - G0 E4 F{20*60} - QUERY_FILAMENT RETURN_MACRO=LOAD_FILAMENT - {% endif %} - - {% if prime %} - PRIME_FILAMENT - {% endif %} - - -[gcode_macro PRIME_FILAMENT] -gcode: - {% set svv = printer.save_variables.variables %} - - {% if svv.filament_load_state in ['unloaded', 'loaded', 'primed'] %} - # check if there is a valid value for the currently loaded filament. if not, prompt the user for it. - {% if not svv.filament_extruder in printer.filaments.presets|map(attribute='name',default='yeet') %} - # if there isn't a set loaded filament, run QUERY_FILAMENT - QUERY_FILAMENT RETURN_MACRO=PRIME_FILAMENT - - {% elif svv.filament_load_state in ['unloaded'] %} - LOAD_FILAMENT PRIME=True - {% elif svv.filament_load_state in ['loaded', 'primed'] %} - # ensure that the filament in the hotend is the same as the filament in the extruder - {% if svv.filament_extruder == svv.filament_hotend %} - SET_HOTEND_TO_FILAMENT - - MOVE_TO_PURGE_BUCKET - - SET_HOTEND_TO_FILAMENT WAIT=True - - # if the filament is only loaded, then extrude a bit to get it to the end of the extruder - {% if svv.filament_load_state in ['loaded'] %} - _CLIENT_LINEAR_MOVE E=25 F={60*20} - {% endif %} - _CLIENT_LINEAR_MOVE E=10 F={60*10} - _CLIENT_LINEAR_MOVE E={-printer['gcode_macro VARIABLES'].retraction_length} F={60*20} - - CLEAN_NOZZLE - - SET_FILAMENT_LOAD_STATE STATE=primed - {% else %} - {action_respond_info("unable to prime filament. Filament in hotend doesn't match current filament")} - {% endif %} - {% endif %} - {% else %} - {action_respond_info("unable to prime filament. Current filament state: %s " % (svv.filament_load_state))} - {% endif %} - -[gcode_macro PURGE_FILAMENT] -gcode: - {% set svv = printer.save_variables.variables %} - - {% if not svv.filament_extruder in printer.filaments.presets|map(attribute='name',default='yeet') %} - # if there isn't a set loaded filament, run QUERY_FILAMENT - QUERY_FILAMENT RETURN_MACRO=PURGE_FILAMENT - - {% elif svv.filament_load_state in ["loaded", "primed"] %} - # if the filament is loaded or primed, then continue - SET_HOTEND_TO_FILAMENT POSITION=both - # move to purge bucket - MOVE_TO_PURGE_BUCKET - - SET_HOTEND_TO_FILAMENT Wait=True POSITION=both - {% if svv.filament_load_state in ['loaded'] %} - _CLIENT_LINEAR_MOVE E=25 F={60*20} - {% endif %} - _CLIENT_LINEAR_MOVE E={printer['gcode_macro VARIABLES'].purge_line_length} F={60*10} - _CLIENT_LINEAR_MOVE E={-printer['gcode_macro VARIABLES'].retraction_length} F={60*20} - - CLEAN_NOZZLE - - SET_HOTEND_FILAMENT NAME={svv.filament_extruder} - SET_FILAMENT_LOAD_STATE STATE=primed - - {% else %} - {action_respond_info("unable to purge filament. Current filament state: %s " %(svv.filament_load_state))} - {% endif %} - -[gcode_macro MOVE_TO_PURGE_BUCKET] -gcode: - # move z to minimum of 2 - {% if printer['gcode_move'].position.z < 6 %} - _CLIENT_LINEAR_MOVE Z=6 F={60*60} ABSOLUTE=1 - {% endif %} - - # move y out if necessary - {% if printer['gcode_move'].position.y > 254 %} - _CLIENT_LINEAR_MOVE Y=254 F={60*700} ABSOLUTE=1 - {% endif %} - - # move xy to purge bucket - _CLIENT_LINEAR_MOVE Y=254 X=25 F={60*700} ABSOLUTE=1 - _CLIENT_LINEAR_MOVE Y=258 F={60*60} ABSOLUTE=1 - -[gcode_macro CLEAN_NOZZLE] -description: wipes filament off the nozzle -gcode: - MOVE_TO_PURGE_BUCKET - - # wipe a few times - {% for x in range(2) %} - _CLIENT_LINEAR_MOVE X=55 F={60*700} - _CLIENT_LINEAR_MOVE X=-55 F={60*700} - {% endfor %} - -[gcode_macro STABILIZE_NOZZLE] -description: tries to prevent the nozzle from leaking filament too much -gcode: - - -[gcode_button bowden_sensor] -pin: PF2 -press_gcode: - {% set svv = printer.save_variables.variables %} - { action_respond_info("bowden_load") } #DEBUG - - # TODO - USER LOAD FILAMENT. Setup some sort of response? Maybe wake printer from sleep mode and turn on lights? - # can't switch back frgom near runout as the extruder can't grab further filament - -release_gcode: - {% set svv = printer.save_variables.variables %} - {% if svv.filament_load_state in ['primed', 'loaded'] %} - {action_raise_error("Warning: bowden sensor released, nearing filament runout")} - # disable the encoder sensor - - # TODO IMPLEMENT MORE WARNINGS. - {% elif svv.filament_load_state != 'unloaded' %} - {action_raise_error("Warning: bowden sensor released during nonsensical filament state.")} - {% endif %} - -[filament_motion_sensor bowden_encoder_sensor] -detection_length: 10 -extruder: extruder -switch_pin: ^PF3 -pause_on_runout: False -insert_gcode: -runout_gcode: - # if the printer is both printing, and the bowden sensor is pressed, then pause print. - {% if (printer["gcode_button bowden_sensor"].state == "PRESSED") and - printer['print_stats'].state == "printing" %} - PAUSE - {% endif %} - # check if the bowden sensor is pressed - - -[gcode_button extruder_entry] -pin: printHead:PB7 -press_gcode: - {% set svv = printer.save_variables.variables %} - - { action_respond_info("extruder_entry_insert") } - - {% if svv.filament_load_state == 'unloaded' %} - LOAD_FILAMENT - {% endif %} - -release_gcode: - { action_respond_info("extruder_entry_release") } - {% set svv = printer.save_variables.variables %} - - # if filament is loaded, check if it's running out or being unloaded - {% if svv.filament_load_state == 'loaded' %} - # runout - {% if printer['gcode_button extruder_exit'].state == PRESSED %} - {action_raise_error("Warning: extruder entry sensor released, filament runout")} - SET_FILAMENT_LOAD_STATE STATE="runout" - - # pause printer on runout - {% if svv.printer_state == 'printing'%} - # PAUSE - {% endif %} - # being unloaded - {% else %} - SET_FILAMENT_LOAD_STATE STATE="unloaded" - {% endif %} - {% elif svv.filament_load_state == 'unloaded_waiting' %} - SET_FILAMENT_LOAD_STATE STATE="unloaded" - {% elif svv.filament_load_state != 'unloaded' %} - {action_raise_error("Warning: bowden sensor released during nonsensical filament state.")} - {% endif %} - -[gcode_button extruder_exit] -pin: printHead:PB5 - -press_gcode: - { action_respond_info("extruder_exit_insert") } - {% set svv = printer.save_variables.variables %} - - # auto state update if the user is manually doing things - {% if svv.filament_load_state not in ['loaded', 'primed'] %} - SET_FILAMENT_LOAD_STATE STATE="loaded" - {% endif %} - - -release_gcode: - { action_respond_info("extruder_exit_runout") } - {% set svv = printer.save_variables.variables %} - - diff --git a/config/macros.cfg b/config/macros.cfg deleted file mode 100644 index 3c56734..0000000 --- a/config/macros.cfg +++ /dev/null @@ -1,535 +0,0 @@ -# gcode to run on printer start -[delayed_gcode STARTUP] -gcode: - # grab saved variables - {% set svv = printer.save_variables.variables %} - {% set bed_leeway_temp = 5 %} - {% set extruder_leeway_temp = 20 %} - {% set hotend_filament = svv.hotend_filament %} - - # check if stored variables make sense, and set them to default values if not - {% if not(svv.heater_mode == "auto" or svv.heater_mode == "manual" or svv.heater_mode == "slicer")%} - { action_respond_info("setting heater_mode to AUTO, before: %s" % (svv.heater_mode)) } - SAVE_VARIABLE VARIABLE=heater_mode VALUE='"auto"' - {% endif %} - - # set temp variables - call variables macro - VARIABLES - - # kickstart fan control macro - # UPDATE_DELAYED_GCODE ID=FAN_CONTROL_LOOP DURATION=2 - - - # check the current heater states and re enable heaters if able - {% if svv.extruder_state == 'hot' %} - {% if svv.extruder_temperature - extruder_leeway_temp <= printer.extruder.temperature %} - { action_respond_info("re-enabling extruder after printer shutoff") } - SET_HEATER_TEMPERATURE HEATER=extruder TARGET={svv.extruder_temperature} - {% else %} - { action_respond_info("extruder was enabled before last shutoff. State updated to cold.") } - SAVE_VARIABLE VARIABLE=extruder_state VALUE='"cold"' - {% endif %} - {% endif %} - - {% if svv.bed_state == 'hot' %} - {action_respond_info(printer.heater_bed.temperature|string)} - {action_respond_info(bed_leeway_temp|string)} - {action_respond_info(svv.bed_temperature|string)} - - {% if svv.bed_temperature - bed_leeway_temp <= printer.heater_bed.temperature %} - { action_respond_info("re-enabling bed after printer shutoff") } - SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={svv.bed_temperature} - {% else %} - { action_respond_info("bed was enabled before last shutoff. State updated to cold.") } - SAVE_VARIABLE VARIABLE=bed_state VALUE='"cold"' - {% endif %} - {% endif %} - - # check the filament load state: - # exit-entry-bowden - # 000 unloaded - # 001 unloaded - # 010 invalid - # 011 unloaded - # 100 runout - # 101 invalid - # 110 near_runout - # 111 loaded - - # store button vals - {% set exit_sense = (printer["gcode_button extruder_exit"].state == "PRESSED") %} - {% set entry_sense = (printer["gcode_button extruder_entry"].state == "PRESSED") %} - {% set bowden_sense = (printer["gcode_button bowden_sensor"].state == "PRESSED") %} - - # detect unloaded - {% if not(entry_sense and exit_sense) or (not(entry_sense) and bowden_sense) %} - {% if svv.filament_load_state != "unloaded" %} - { action_respond_info("Current filament state does not match filament state on last boot. Was " ~ (svv.filament_load_state|string) ~ ", currently unloaded.") } - {% endif %} - SET_FILAMENT_LOAD_STATE STATE="unloaded" - SET_FILAMENT_SENSOR SENSOR=bowden_encoder_sensor ENABLE=0 - - # loaded - {% elif entry_sense and exit_sense and bowden_sense %} - {% if svv.filament_load_state not in ["loaded", "primed"] %} - { action_respond_info("Current filament state does not match filament state on last boot. Was " ~ (svv.filament_load_state|string) ~ "") } - {% endif %} - SET_FILAMENT_LOAD_STATE STATE="loaded" - SET_FILAMENT_SENSOR SENSOR=bowden_encoder_sensor ENABLE=1 - - # runout - {% elif entry_sense and not(exit_sense) and not(bowden_sense) %} - { action_respond_info("Current filament state is runout. Unable to print.") } - SET_FILAMENT_SENSOR SENSOR=bowden_encoder_sensor ENABLE=0 - - # near_runout - {% elif entry_sense and exit_sense and not(bowden_sense) %} - { action_respond_info("Current filament state is runout. Unable to print.") } - SET_FILAMENT_SENSOR SENSOR=bowden_encoder_sensor ENABLE=0 - {% endif %} - -initial_duration: 4 - -[gcode_macro TEST] -gcode: - {% set svv = printer.save_variables.variables %} - {break} - {action_respond_info(svv.filaments|selectattr("name", "in", [svv.filament_hotend, - svv.filament_extruder])|map(attribute="extruder",default='None')|max|string)} - -####### Calibration -[gcode_macro calibrate_full] -gcode: - G28 - QUAD_GANTRY_LEVEL - BED_MESH_CALIBRATE METHOD=rapid_scan - SET_GCODE_VARIABLE MACRO=VARIABLES VARIABLE=mesh_bed_temp VALUE={printer['heater_bed'].temperature} - - MOVE_TO_PURGE_BUCKET - -[gcode_macro calibrate] -gcode: - {% set mesh_temp_leeway = printer["gcode_macro VARIABLES"].mesh_bed_temp_leeway %} - {% set mesh_temp = printer["gcode_macro VARIABLES"].mesh_bed_temp %} - {% set skip_mesh = params.SKIP_MESH|default(False)%} - - {% if "xyz" not in printer['toolhead'].homed_axes %} - G28 - {% endif %} - - {% if not printer['quad_gantry_level'].applied %} - QUAD_GANTRY_LEVEL - {% endif %} - - {action_respond_info((not printer['bed_mesh'].profile_name)|string)} - - {% if skip_mesh %} - G0 X239 Y210 F{700*60} - # if a bed mesh has not been performed, or the temperature hasn't changed by more than 15 degrees. - {% elif ((not printer['bed_mesh'].profile_name) or - (printer['heater_bed'].temperature <= mesh_temp - mesh_temp_leeway) or - (printer['heater_bed'].temperature >= mesh_temp + mesh_temp_leeway)) %} - - G0 X15 Y22 F{700*60} - BED_MESH_CALIBRATE METHOD=rapid_scan - SET_GCODE_VARIABLE MACRO=VARIABLES VARIABLE=mesh_bed_temp VALUE={printer['heater_bed'].temperature} - - G0 X239 Y210 F{700*60} - {% endif %} - - MOVE_TO_PURGE_BUCKET - -####### PRINT START AND STOP ETC -[gcode_macro START_PRINT] -description: Runs before the start of a print. Checks print readyness, corrects if nessesary, and primes the nozzle. -gcode: - {% set svv = printer.save_variables.variables %} - # check the state of the loaded filament - {% if svv.filament_load_state in ["loaded", "primed"] and svv.filament_runout_state != "runout" %} - # if in auto, set bed and extruder to loaded filament parameters. - {% if svv.heater_mode == "auto" %} - SET_BED_TO_FILAMENT - SET_HOTEND_TO_FILAMENT POSITION=both - - # if in slicer or manual mode, quickly sanity check the set temperatures: - {% else %} - {% if printer['extruder'].target <= 0 %} - {action_raise_error("Extruder temperature is set to at or below zero")} - {% endif %} - {% endif %} - - # check calibration - # CALIBRATE SKIP_MESH=True - - # {% if svv.filament_extruder != svv.filament_hotend %} - # PURGE_FILAMENT - # {% endif %} - - # final enable of heaters and wait for temperature to be reached - SET_HEATERS_TO_FILAMENT_AND_WAIT - - # CLEAN_NOZZLE - - # CALIBRATE - - # PRIME_FILAMENT - - _CLIENT_LINEAR_MOVE E=2 F=600 - # enable the encoder filament sensor - SET_FILAMENT_SENSOR SENSOR=bowden_encoder_sensor ENABLE=1 - - {% elif svv.filament_runout_state == "runout" %} - {action_raise_error("Error, filament in runout state")} - - {% else %} - {action_raise_error("Error, filament not loaded. Filament is %s" % (svv.filament_state))} - {% endif %} - - -[gcode_macro stop_print] -gcode: - {% set z = params.Z|default(50)|int %} ; z hop amount - - SET_FILAMENT_SENSOR SENSOR=bowden_encoder_sensor ENABLE=0 - - # reduce temperature of extruder by 10c to reduce oozing - SET_HEATER_TEMPERATURE HEATER=extruder TARGET={printer['extruder'].target - 10} MODE=auto - - {% if (printer.gcode_move.position.z + z) < printer.toolhead.axis_maximum.z %} ; check that zhop doesn't exceed z max - G91 ; relative positioning - G1 Z{z} F900 ; raise Z up by z hop amount - {% else %} - G0 Z{printer.toolhead.axis_maximum.z} - { action_respond_info("Pause zhop exceeds maximum Z height.") } - {% endif %} - G90 ; absolute positioning - G1 Y{258} F6000 ; park toolhead - - -[gcode_macro PAUSE] -description: Pause the actual running print -rename_existing: PAUSE_MAINSAIL -gcode: -# Parameters - {% set svv = printer.save_variables.variables %} - - {% set z = params.Z|default(10)|int %} ; z hop amount - #{% set idle_timeout = client.idle_timeout|default({60*5}) %} - {% set idle_timeout = 60*5 %} - - # if printer is not already paused... - {% if printer['pause_resume'].is_paused|int == 0 %} - # set variables for reference in resume macro - SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=posx VALUE={printer['gcode_move'].gcode_position.x} - SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=posy VALUE={printer['gcode_move'].gcode_position.y} - SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=posz VALUE={printer['gcode_move'].gcode_position.z} - - SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=etemp VALUE={printer['extruder'].target} - SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=btemp VALUE={printer['heater_bed'].target} - SAVE_GCODE_STATE NAME=PAUSE - PAUSE_MAINSAIL - # set a new idle_timeout value - SET_IDLE_TIMEOUT TIMEOUT={idle_timeout} - - # {client.user_pause_macro|default("")} - - # reduce temperature of extruder by 10c to reduce oozing if extruder is enabled - {% if svv.extruder_state == 'hot' %} - SET_HEATER_TEMPERATURE HEATER=extruder TARGET={printer['extruder'].target - 10} MODE=auto - {% endif %} - - {% if (printer.gcode_move.position.z + z) < printer.toolhead.axis_maximum.z %} ; check that zhop doesn't exceed z max - G91 ; relative positioning - G1 Z{z} F900 ; raise Z up by z hop amount - {% else %} - G0 Z{printer.toolhead.axis_maximum.z} - { action_respond_info("Pause zhop exceeds maximum Z height.") } - {% endif %} - G90 ; absolute positioning - G1 Y{258} F6000 ; park toolhead - SAVE_GCODE_STATE NAME=PAUSEPARK ; save parked position in case toolhead is moved during the pause (otherwise the return zhop can error) - {% endif %} - -[gcode_macro RESUME] -description: Resume the actual running print -rename_existing: RESUME_MAINSAIL -variable_posx: 0 -variable_posy: 0 -variable_posz: 0 -variable_zhop: 0 -variable_etemp: 0 -variable_btemp: 0 -gcode: - # Parameters - {% set e = params.E|default(2.5)|int %} ; hotend prime amount (in mm) - {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} - {% set velocity = printer.configfile.settings.pause_resume.recover_velocity %} - {% set sp_move = client.speed_move|default(velocity) %} - {% set runout_resume = True if client.runout_sensor|default("") == "" # no runout - else True if not printer[client.runout_sensor].enabled # sensor is disabled - else printer[client.runout_sensor].filament_detected %} # sensor status - {% set can_extrude = True if printer.toolhead.extruder == '' # no extruder defined in config - else printer[printer.toolhead.extruder].can_extrude %} # status of active extruder - {% set do_resume = False %} - {% set prompt_txt = [] %} - - # if printer is paused... - {% if printer['pause_resume'].is_paused|int == 1 %} - SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value - - RESTORE_GCODE_STATE NAME=PAUSEPARK MOVE=1 MOVE_SPEED=200 ; go back to parked position in case toolhead was moved during pause (otherwise the return zhop can error) - - # reset temperatures - {% if etemp > 0 %} - SET_HEATER_TEMPERATURE HEATER=extruder TARGET={etemp} MODE=auto - {% endif %} - {% if btemp > 0 %} - SET_HEATER_TEMPERATURE_AND_WAIT HEATER=heater_bed TARGET={btemp} MODE=auto - {% endif %} - {% if etemp > 0 %} - SET_HEATER_TEMPERATURE_AND_WAIT HEATER=extruder TARGET={etemp} MODE=auto ; Wait for hotend temp - {% endif %} - - G91 ; relative positioning - M83 ; relative extruder positioning - {% if printer[printer.toolhead.extruder].temperature >= printer.configfile.settings.extruder.min_extrude_temp %} - G1 Z{zhop * -1} E{e} F900 ; prime nozzle by E, lower Z back down - {% else %} - G1 Z{zhop * -1} F900 ; lower Z back down without priming (just in case we are testing the macro with cold hotend) - {% endif %} - RESTORE_GCODE_STATE NAME=PAUSE MOVE=1 MOVE_SPEED=60 ; restore position - RESUME_MAINSAIL - {% endif %} - -[gcode_macro CANCEL_PRINT] -rename_existing: CANCEL_PRINT_MAINSAIL -gcode: - {% set z = params.Z|default(10)|int %} ; z hop amount - - SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value - CLEAR_PAUSE - CANCEL_PRINT_MAINSAIL - - # reduce temperature of extruder by 10c to reduce oozing - SET_HEATER_TEMPERATURE HEATER=extruder TARGET={printer['extruder'].target - 10} MODE=auto - - {% if (printer.gcode_move.position.z + z) < printer.toolhead.axis_maximum.z %} ; check that zhop doesn't exceed z max - G91 ; relative positioning - G1 Z{z} F900 ; raise Z up by z hop amount - {% else %} - G0 Z{printer.toolhead.axis_maximum.z} - { action_respond_info("Pause zhop exceeds maximum Z height.") } - {% endif %} - - G90 ; absolute positioning - G1 Y{258} F6000 ; park toolhead - # clear pause_next_layer and pause_at_layer as preparation for next print - SET_PAUSE_NEXT_LAYER ENABLE=0 - SET_PAUSE_AT_LAYER ENABLE=0 LAYER=0 - -###### HEATER AUTO HANDLING -[gcode_macro SET_HEATERS_TO_FILAMENT_AND_WAIT] -description: -gcode: - {% set svv = printer.save_variables.variables %} - - SET_HEATER_TEMPERATURE HEATER=extruder TARGET={svv.filaments|selectattr("name", "equalto", svv.filament_hotend)|map(attribute="extruder",default='None')|first|string} MODE=auto - SET_HEATER_TEMPERATURE_AND_WAIT HEATER=heater_bed TARGET={svv.filaments|selectattr("name", "equalto", svv.filament_hotend)|map(attribute="bed",default='None')|first|string} MODE=auto - SET_HEATER_TEMPERATURE_AND_WAIT HEATER=extruder TARGET={svv.filaments|selectattr("name", "equalto", svv.filament_hotend)|map(attribute="extruder",default='None')|first|string} MODE=auto - -[gcode_macro SET_HOTEND_TO_FILAMENT] -description: sets the temperature of the hotend to the temperature required by the stored filament -gcode: - {% set wait = params.WAIT|default(False) %} ; z hop amount - {% set svv = printer.save_variables.variables %} - - {% set position = params.POSITION|default('extruder')|string|lower %} - {% if wait %} - {% if position == 'extruder' %} - SET_HEATER_TEMPERATURE_AND_WAIT HEATER=extruder TARGET={svv.filaments|selectattr("name", "in", [svv.filament_extruder])|map(attribute="extruder",default='None')|max|string} MODE=auto - {% elif position == 'hotend' %} - SET_HEATER_TEMPERATURE_AND_WAIT HEATER=extruder TARGET={svv.filaments|selectattr("name", "in", [svv.filament_hotend])|map(attribute="extruder",default='None')|max|string} MODE=auto - {% elif position == 'both' %} - SET_HEATER_TEMPERATURE_AND_WAIT HEATER=extruder TARGET={svv.filaments|selectattr("name", "in", [svv.filament_hotend, svv.filament_extruder])|map(attribute="extruder",default='None')|max|string} MODE=auto - {% endif %} - {% else %} - {% if position == 'extruder' %} - SET_HEATER_TEMPERATURE HEATER=extruder TARGET={svv.filaments|selectattr("name", "in", [svv.filament_extruder])|map(attribute="extruder",default='None')|max|string} MODE=auto - {% elif position == 'hotend' %} - SET_HEATER_TEMPERATURE HEATER=extruder TARGET={svv.filaments|selectattr("name", "in", [svv.filament_hotend])|map(attribute="extruder",default='None')|max|string} MODE=auto - {% elif position == 'both' %} - SET_HEATER_TEMPERATURE HEATER=extruder TARGET={svv.filaments|selectattr("name", "in", [svv.filament_hotend, svv.filament_extruder])|map(attribute="extruder",default='None')|max|string} MODE=auto - {% endif %} - {% endif %} - -[gcode_macro SET_BED_TO_FILAMENT] -description: sets the temperature of the bed to the temperature required by the stored filament -gcode: - {% set svv = printer.save_variables.variables %} - - {% set position = params.POSITION|default('extruder')|string|lower %} - {% if position == 'extruder' %} - SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={svv.filaments|selectattr("name", "in", [svv.filament_extruder])|map(attribute="bed",default='None')|max|string} MODE=auto - {% elif position == 'hotend' %} - SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={svv.filaments|selectattr("name", "in", [svv.filament_hotend])|map(attribute="bed",default='None')|max|string} MODE=auto - {% elif position == 'both' %} - SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={svv.filaments|selectattr("name", "in", [svv.filament_hotend, svv.filament_extruder])|map(attribute="bed",default='None')|max|string} MODE=auto - {% endif %} - -## MISC MACROS - -[gcode_macro DUMP_VARIABLES] -gcode: - {% set filter_name = params.NAME|default('')|string|lower %} - {% set filter_value = params.VALUE|default('')|string|lower %} - {% set show_cfg = params.SHOW_CFG|default(0)|int %} - - {% set out = [] %} - - {% for key1 in printer %} - {% for key2 in printer[key1] %} - {% if (show_cfg or not (key1|lower == 'configfile' and key2|lower in ['config', 'settings'])) and (filter_name in key1|lower or filter_name in key2|lower) and filter_value in printer[key1][key2]|string|lower %} - {% set dummy = out.append("printer['%s'].%s = %s" % (key1, key2, printer[key1][key2])) %} - {% endif %} - {% else %} - {% if filter_name in key1|lower and filter_value in printer[key1]|string|lower %} - {% set dummy = out.append("printer['%s'] = %s" % (key1, printer[key1])) %} - {% endif %} - {% endfor %} - {% endfor %} - - {action_respond_info(out|join("\n"))} - -[gcode_macro TEST_SPEED] -# 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 - -description: Test for max speed and acceleration parameters for the printer. Procedure: Home -> ReadPositionFromMCU -> MovesToolhead@Vel&Accel -> Home -> ReadPositionfromMCU - -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 %} - # Minimum Cruise Ratio - {% set min_cruise_ratio = params.MIN_CRUISE_RATIO|default(0.5)|float %} - # 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 %} - {% if x_min < 0 %} - {% set x_min = 0 %} - {% endif %} - - {% set y_min = printer.toolhead.axis_minimum.y %} - {% if y_min < 0 %} - {% set y_min = 0 %} - {% endif %} - - {% set x_min = x_min + bound %} - {% set x_max = printer.toolhead.axis_maximum.x - bound %} - {% set y_min = y_min + 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: - M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66 - # 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 %} - G28 - 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{100*60} - M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66 - G28 X Y - G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{100*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 - {% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %} - SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} MINIMUM_CRUISE_RATIO={min_cruise_ratio} - {% else %} - SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2} - {% endif %} - - {% 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} - - # Large pattern 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 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 pattern 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 - {% if printer.configfile.settings.printer.minimum_cruise_ratio is defined %} - SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} MINIMUM_CRUISE_RATIO={printer.configfile.settings.printer.minimum_cruise_ratio} - {% else %} - 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} - {% endif %} - - # Re-home and get position again for comparison: - M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66 - # G28 # This is a full G28 to fix an issue with CoreXZ - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/12 - # Go to XY home positions (in case your homing override leaves it elsewhere) - G90motors - G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{100*60} - G4 P1000 - GET_POSITION - - # Restore previous gcode state (absolute/relative, etc) - RESTORE_GCODE_STATE NAME=TEST_SPEED \ No newline at end of file diff --git a/config/overrides.cfg b/config/overrides.cfg index f77e936..d885993 100644 --- a/config/overrides.cfg +++ b/config/overrides.cfg @@ -50,7 +50,6 @@ [gcode_macro G28] rename_existing: G9928 gcode: - G9928 {rawparams} {% if not rawparams or (rawparams and 'Z' in rawparams) %} PROBE @@ -79,11 +78,20 @@ # BED_MESH_CALIBRATE1 {rawparams} +[gcode_macro BED_MESH_CALIBRATE] +rename_existing: BTT_BED_MESH_CALIBRATE +gcode: + SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=probing VALUE=True #Only uncomment this line if using a KNOMI and then remove the BED_MESH_CALIBRATE macro from KNOMI.cfg + BTT_BED_MESH_CALIBRATE METHOD=rapid_scan + SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=probing VALUE=False #Only uncomment this line if using a KNOMI and then remove the BED_MESH_CALIBRATE macro from KNOMI.cfg + # replace pause [gcode_macro M600] gcode: PAUSE +## <---------------------- TEMPERATURES ----------------------> + # replace extruder with temperature wait [gcode_macro M109] rename_existing: M99109 diff --git a/config/unused b/config/unused deleted file mode 100644 index 666f966..0000000 --- a/config/unused +++ /dev/null @@ -1,88 +0,0 @@ -[gcode_macro start_print] -gcode: - # todo check if printer is able to print - {% set calibrate = printer["gcode_macro VARIABLES"].caliabrate %} - - CALIBRATE - - SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1 - G90 # absolute positioningofnon - G92 E0 # reset extruder origin - G1 Z5 F5000 #lift nozzle - G1 y240 X240 F5000 #move to edge - - M104 S{params.EXTRUDER_TEMP}; set extruder temp - M140 S{params.BED_TEMP} ; set bed temp - M109 S{params.EXTRUDER_TEMP}; Wait for extruder temp - M190S{params.BED_TEMP}; Wait for bed temp - -[gcode_macro stop_print] -gcode: - SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0 - G1 Z80 - # M84 ; disable motors - #M104 S0 ; turn off temperature - - -[gcode_macro PAUSE] -rename_existing: BASE_PAUSE -gcode: - # Parameters - {% set z = params.Z|default(10)|int %} ; z hop amount - - {% if printer['pause_resume'].is_paused|int == 0 %} - SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=zhop VALUE={z} ; set z hop variable for reference in resume macro - SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=etemp VALUE={printer['extruder'].target} ; set hotend temp variable for reference in resume macro - - SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=0 ; disable filament sensor - SAVE_GCODE_STATE NAME=PAUSE ; save current print position for resume - BASE_PAUSE ; pause print - {% if (printer.gcode_move.position.z + z) < printer.toolhead.axis_maximum.z %} ; check that zhop doesn't exceed z max - G91 ; relative positioning - G1 Z{z} F900 ; raise Z up by z hop amount - {% else %} - { action_respond_info("Pause zhop exceeds maximum Z height.") } ; if z max is exceeded, show message and set zhop value for resume to 0 - SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=zhop VALUE=0 - {% endif %} - G90 ; absolute positioning - G1 X{printer.toolhead.axis_maximum.x/2} Y{printer.toolhead.axis_maximum.y-5} F6000 ; park toolhead at rear center - SAVE_GCODE_STATE NAME=PAUSEPARK ; save parked position in case toolhead is moved during the pause (otherwise the return zhop can error) - # M104 S0 ; turn off hotend - SET_IDLE_TIMEOUT TIMEOUT=43200 ; set timeout to 12 hours - {% endif %} - -[gcode_macro RESUME] -rename_existing: BASE_RESUME -variable_zhop: 0 -variable_etemp: 0 -gcode: - # Parameters - {% set e = params.E|default(2.5)|int %} ; hotend prime amount (in mm) - - {% if printer['pause_resume'].is_paused|int == 1 %} - SET_FILAMENT_SENSOR SENSOR=filament_sensor ENABLE=1 ; enable filament sensor - #INITIAL_RGB ; reset LCD color - SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value - {% if etemp > 0 %} - M109 S{etemp|int} ; wait for hotend to heat back up - {% endif %} - RESTORE_GCODE_STATE NAME=PAUSEPARK MOVE=1 MOVE_SPEED=100 ; go back to parked position in case toolhead was moved during pause (otherwise the return zhop can error) - G91 ; relative positioning - M83 ; relative extruder positioning - {% if printer[printer.toolhead.extruder].temperature >= printer.configfile.settings.extruder.min_extrude_temp %} - G1 Z{zhop * -1} E{e} F900 ; prime nozzle by E, lower Z back down - {% else %} - G1 Z{zhop * -1} F900 ; lower Z back down without priming (just in case we are testing the macro with cold hotend) - {% endif %} - RESTORE_GCODE_STATE NAME=PAUSE MOVE=1 MOVE_SPEED=60 ; restore position - BASE_RESUME ; resume print - {% endif %} - -[gcode_macro CANCEL_PRINT] -rename_existing: BASE_CANCEL_PRINT -gcode: - SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value - CLEAR_PAUSE - SDCARD_RESET_FILE - PRINT_END - BASE_CANCEL_PRINT \ No newline at end of file diff --git a/printer.cfg b/printer.cfg index 1f91a55..8daab3c 100644 --- a/printer.cfg +++ b/printer.cfg @@ -1,33 +1,38 @@ -[include shell_command.cfg] -# VORON2 250mm config -# For other build sizes, controllers, or non-standard pin connections, please see -# https://github.com/mzbotreprap/VORON/tree/master/Firmware/Klipper/Voron_2.1/Klipper/Configurations -# for other example Klipper configs created by the VORON community. -## <---------------------- Main ----------------------> +# vaguely in order of importance [include mainsail.cfg] -[include config/variable_macros.cfg] -[include config/macros.cfg] + [include config/overrides.cfg] + +[include config/calibration.cfg] + +[include config/macros.cfg] +[include config/filament_management.cfg] +[include config/heater_management.cfg] + [include config/cooling.cfg] [include config/leds.cfg] + [include config/eddy.cfg] -[include config/filament_sensors.cfg] -[include config/bash.cfg] + +[include config/variable_macros.cfg] [include config/interface_macros.cfg] +[include config/bash.cfg] [virtual_sdcard] path: /home/cory/printer_data/gcodes on_error_gcode: CANCEL_PRINT [mcu] -##serial: /dev/serial/by-id/usb-Klipper_stm32h723xx_1E003E000D51313339373836-if00 canbus_uuid: 21641089de00 [mcu printHead] canbus_uuid: b8ebea905eb6 +[mcu eddy] +canbus_uuid: c544ec61c167 + [printer] kinematics: corexy max_velocity: 720 @@ -38,34 +43,19 @@ ## <---------------------- Motors ----------------------> - -# [manual_stepper test_explode] -# step_pin: PC7 -# dir_pin: PC8 -# enable_pin: !PD2 -# rotation_distance: 40 -# velocity: 5 -# microsteps: 16 -# [tmc2209 manual_stepper test_explode] -# uart_pin: PC6 -# run_current: 2 - -# Motor6 +# Motor8 # A motor [tmc2209 stepper_y] -uart_pin: PC6 #PG10 -#diag_pin: PC15 +uart_pin: PC6 run_current: 2 -driver_SGTHRS: 255 [stepper_y] # A Stepper -step_pin: PC7 #PG9 -dir_pin: PC8 #PD7 -enable_pin: !PD2 #!PG11 +step_pin: PC7 +dir_pin: PC8 +enable_pin: !PD2 microsteps: 16 rotation_distance: 40 -# 80 steps per mm - 1.8 deg - 1/16 microstepping endstop_pin: ^PF4 position_min: -0.15 position_endstop: 257 @@ -73,13 +63,11 @@ homing_speed: 100 homing_retract_dist: 5 -# Motor5 +# Motor6 # B motor [tmc2209 stepper_x] uart_pin: PG10 -diag_pin: PC15 run_current: 2 -driver_SGTHRS: 255 [stepper_x] step_pin: PG9 @@ -87,7 +75,6 @@ enable_pin: !PG11 microsteps: 16 rotation_distance: 40 -# 80 steps per mm - 1.8 deg - 1/16 microstepping endstop_pin: printHead:PB6 position_min: -.3 position_endstop: 254 @@ -95,81 +82,33 @@ homing_speed: 100 homing_retract_dist: 5 -# [gcode_button stepper_x] -# pin: tmc2209_stepper_x:virtual_endstop -# press_gcode: -# {action_respond_info ("stepper_x reports steps lost")} ## <---------------------- Z STEPPERS ----------------------> -[gcode_macro SET_Z_PARAMS] -gcode: -variable_run_current: 0.8 -variable_microsteps: 16 -variable_rotation_distance: 8 - # Motor 1 # Z0 Stepper - Front Left [tmc2209 stepper_z] uart_pin: PC13 -#diag_pin: PF3 run_current: 0.4 -#stealthchop_threshold: 999999 + [stepper_z] step_pin: PE6 dir_pin: PE5 enable_pin: !PC14 microsteps: 16 rotation_distance: 8 -# 400 steps per mm - 1.8 deg - 1/16 microstepping endstop_pin: probe:z_virtual_endstop -# Offset (in mm) for nozzle to bed off z switch position_max: 200 position_min: -2 -# Set to -2 to allow room for squaring gantry with quad_gantry_level homing_speed: 50.0 second_homing_speed: 3.0 homing_retract_dist: 3.0 -# Motor 3 -# Z1 Stepper - Rear Left -[tmc2209 stepper_z1] -uart_pin: PB9 -#diag_pin: PF5 -run_current: 0.4 -#run_current: {printer.SET_Z_PARAMS.variable_run_current} -#stealthchop_threshold: 999999 -[stepper_z1] -step_pin: PB8 -dir_pin: !PB7 -enable_pin: !PE0 -microsteps: 16 -rotation_distance: 8 -# 400 steps per mm - 1.8 deg - 1/16 microstepping - -# Motor 4 -# Z2 Stepper - Rear Right -[tmc2209 stepper_z2] -uart_pin: PB5 -#diag_pin: PC0 -run_current: 0.4 -#stealthchop_threshold: 999999 -[stepper_z2] -step_pin: PB4 -dir_pin: PB3 -enable_pin: !PB6 - -microsteps: 16 -rotation_distance: 8 -# 400 steps per mm - 1.8 deg - 1/16 microstepping - # Motor 2 # Z3 Stepper - Front Right [tmc2209 stepper_z3] uart_pin: PE3 -#diag_pin: PF4 run_current: 0.4 -#stealthchop_threshold: 999999 [stepper_z3] step_pin: PE2 @@ -178,16 +117,40 @@ microsteps: 16 rotation_distance: 8 -# 400 steps per mm - 1.8 deg - 1/16 microstepping + +# Motor 3 +# Z1 Stepper - Rear Left +[tmc2209 stepper_z1] +uart_pin: PB9 +run_current: 0.4 + +[stepper_z1] +step_pin: PB8 +dir_pin: !PB7 +enable_pin: !PE0 +microsteps: 16 +rotation_distance: 8 + +# Motor 4 +# Z2 Stepper - Rear Right +[tmc2209 stepper_z2] +uart_pin: PB5 +run_current: 0.4 + +[stepper_z2] +step_pin: PB4 +dir_pin: PB3 +enable_pin: !PB6 + +microsteps: 16 +rotation_distance: 8 ## <---------------------- HEATERS ----------------------> [tmc2209 extruder] uart_pin: printHead:PA15 -#diag_pin: PF4 run_current: .8 -#stealthchop_threshold: 999999 [extruder] step_pin: printHead:PD0 dir_pin: printHead:PD1 @@ -199,9 +162,7 @@ filament_diameter: 1.750 max_extrude_cross_section: 99 max_extrude_only_distance: 780.0 -# This is set high to allow the load/unload filament macros to run heater_pin: printHead:PB13 -# D10 on mcu_xye max_power: 1.0 sensor_type: ATC Semitec 104NT-4-R025H42G sensor_pin: printHead:PA3 @@ -214,14 +175,11 @@ min_extrude_temp: 10 min_temp: 10 max_temp: 350 -pressure_advance: 0.03 - -[endstop_phase] +pressure_advance: 0.04 [heater_bed] heater_pin: PA1 -# D11 (servo) on mcu_z sensor_type: Generic 3950 sensor_pin: PB1 @@ -234,6 +192,8 @@ min_temp: 10 max_temp: 150 +## <---------------------- Resonance ----------------------> + [adxl345] cs_pin: printHead:PB12 spi_software_sclk_pin: printHead:PB10 @@ -241,64 +201,30 @@ spi_software_miso_pin: printHead:PB2 axes_map: z,-y,x -[resonance_tester] -probe_points: 125, 125, 20 -# A list of X, Y, Z coordinates of points (one point per line) to test -# resonances at. +## <---------------------- Eddy ----------------------> +[temperature_sensor btt_eddy_mcu] +sensor_type: temperature_mcu # Sets the type of sensor for Klipper to read +sensor_mcu: eddy # Sets the MCU of the eddy probe tempereature sensor +min_temp: 10 # Sets the minimum tempereature for eddys tempereature sensor to operate +max_temp: 120 # Sets the maximum tempereature for eddys tempereature sensor to operate -accel_chip:adxl345 -#max_smoothing: -# Maximum input shaper smoothing to allow for each axis during shaper -# auto-calibration (with 'SHAPER_CALIBRATE' command). By default no -# maximum smoothing is specified. Refer to Measuring_Resonances guide -# for more details on using this feature. -move_speed: 50 -min_freq: 5 #5Hz -max_freq: 200 #133.33 Hz. -accel_per_hz: 300 -# This parameter is used to determine which acceleration to use to -# test a specific frequency: accel = accel_per_hz * freq. Higher the -# value, the higher is the energy of the oscillations. Can be set to -# a lower than the default value if the resonances get too strong on -# the printer. However, lower values make measurements of -# high-frequency resonances less precise. The default value is 75 -# (mm/sec). -hz_per_sec: 1 -# Determines the speed of the test. When testing all frequencies in -# range [min_freq, max_freq], each second the frequency increases by -# hz_per_sec. Small values make the test slow, and the large values -# will decrease the precision of the test. The default value is 1.0 -# (Hz/sec == sec^-2). -#sweeping_accel: 400 -# An acceleration of slow sweeping moves. The default is 400 mm/sec^2. -sweeping_period: 1.2 -# A period of slow sweeping moves. Setting this parameter to 0 -# disables slow sweeping moves. Avoid setting it to a too small -# non-zero value in order to not poison the measurements. -# The default is 1.2 sec which is a good all-round choice. +[probe_eddy_current btt_eddy] +sensor_type: ldc1612 +#z_offset: 2.5 +#i2c_address: +i2c_mcu: eddy # This value is good for the Eddy USB but would need to be adjusted for the Eddy Coil according to the MCU you have used. +i2c_bus: i2c0f # This value is good for the Eddy USB but would need to be adjusted for the Eddy Coil according to the I2C bus you have used. +# Measure the offsets below using the method described here: https://www.klipper3d.org/Probe_Calibrate.html#calibrating-probe-x-and-y-offsets +# For a standard Voron stealthburner X carriage mount there should be no need to change the defaults below. +x_offset: 0 +y_offset: 21.42 +sensor_type: ldc1612 -[input_shaper] -shaper_freq_x: 62.4 -# A frequency (in Hz) of the input shaper for X axis. This is -# usually a resonance frequency of X axis that the input shaper -# should suppress. For more complex shapers, like 2- and 3-hump EI -# input shapers, this parameter can be set from different -# considerations. The default value is 0, which disables input -# shaping for X axis. -shaper_freq_y: 49 -# A frequency (in Hz) of the input shaper for Y axis. This is -# usually a resonance frequency of Y axis that the input shaper -# should suppress. For more complex shapers, like 2- and 3-hump EI -# input shapers, this parameter can be set from different -# considerations. The default value is 0, which disables input -# shaping for Y axis. -shaper_type: mzv -#damping_ratio_x: 0.1 -#damping_ratio_y: 0.1 -# Damping ratios of vibrations of X and Y axes used by input shapers -# to improve vibration suppression. Default value is 0.1 which is a -# good all-round value for most printers. In most circumstances this -# parameter requires no tuning and should not be changed. +# This section is only relevant for Eddy USB. Comment it out for Eddy Coil. +[temperature_probe btt_eddy] +sensor_type: Generic 3950 +sensor_pin: eddy:gpio26 +horizontal_move_z: 2 #*# <---------------------- SAVE_CONFIG ----------------------> #*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.