Files
voron2.4-config/printer_data/config/printer.cfg
T

1052 lines
37 KiB
INI

# Active mainboard: BigTreeTech Octopus family with STM32F407xx (PCB revision not confirmed).
# Firmware profile: 32KiB factory SD bootloader, 8MHz crystal, USB on PA11/PA12.
# Do not substitute the STM32F446/12MHz profile; runtime hardware was verified on 2026-09-06.
# after running "make", copy the generated "klipper/out/klipper.bin" file to a
# file named "firmware.bin" on an SD card and then restart the Octopus with that SD card.
# See docs/Config_Reference.md for a description of parameters.
## Voron Design VORON2 250mm; BigTreeTech Octopus-family STM32F407; TMC2209 UART.
[include stealthburner_leds.cfg]
[include motorsCalibrate.cfg]
[include cartographer.cfg]
[include ebb36.cfg]
[include homing.cfg]
[exclude_object]
[force_move]
enable_force_move: true
[mcu]
## Obtain definition by "ls -l /dev/serial/by-id/" then unplug to verify
##--------------------------------------------------------------------
serial: /dev/serial/by-id/usb-Klipper_stm32f407xx_2B0024001150304235343520-if00
restart_method: command
##--------------------------------------------------------------------
[printer]
kinematics: corexy
max_velocity: 750
max_accel: 12000
max_z_velocity: 30
max_z_accel: 350
square_corner_velocity: 5.0
[input_shaper]
# Active values are maintained by SAVE_CONFIG at the end of this file.
#####################################################################
# X/Y Stepper Settings
#####################################################################
## B Stepper - Left
## Connected to MOTOR_0
## Endstop connected to DIAG_0
[stepper_x]
step_pin: PF13
dir_pin: PF12
enable_pin: !PF14
rotation_distance: 40
microsteps: 32
full_steps_per_rotation:200 #set to 400 for 0.9 degree stepper
endstop_pin: tmc2209_stepper_x:virtual_endstop
position_min: 0
##--------------------------------------------------------------------
##Uncomment below for 250mm build
position_endstop: 0
position_max: 254
## Uncomment for 300mm build
#position_endstop: 300
#position_max: 300
## Uncomment for 350mm build
#position_endstop: 350
#position_max: 350
##--------------------------------------------------------------------
homing_speed: 80 #Max 100
homing_retract_dist: 0
homing_positive_dir: false
## Make sure to update below for your relevant driver (2208 or 2209)
[tmc2209 stepper_x]
diag_pin: ^PG6
uart_pin: PC4
interpolate: true
run_current: 1.4
sense_resistor: 0.110
driver_SGTHRS: 150
## A Stepper - Right
## Connected to MOTOR_1
## Endstop connected to DIAG_1
[stepper_y]
step_pin: PG0
dir_pin: PG1
enable_pin: !PF15
rotation_distance: 40
microsteps: 32
full_steps_per_rotation:200 #set to 400 for 0.9 degree stepper
endstop_pin: PG9
position_min: 0
##--------------------------------------------------------------------
## Uncomment for 250mm build
position_endstop: 253
position_max: 253
## Uncomment for 300mm build
#position_endstop: 300
#position_max: 300
## Uncomment for 350mm build
#position_endstop: 350
#position_max: 350
##--------------------------------------------------------------------
homing_speed: 100 #Max 100
homing_retract_dist: 0
homing_positive_dir: true
## Make sure to update below for your relevant driver (2208 or 2209)
[tmc2209 stepper_y]
uart_pin: PD11
interpolate: true
run_current: 1.4
sense_resistor: 0.110
stealthchop_threshold: 0
#####################################################################
# Z Stepper Settings
#####################################################################
## Z0 Stepper - Front Left
## Connected to MOTOR_2
## Endstop connected to DIAG_2
[stepper_z]
step_pin: PF11
dir_pin: PG3
enable_pin: !PG5
rotation_distance: 40
gear_ratio: 80:16
microsteps: 32
endstop_pin: probe:z_virtual_endstop
## Z-position of nozzle (in mm) to z-endstop trigger point relative to print surface (Z0)
## (+) value = endstop above Z0, (-) value = endstop below
## Increasing position_endstop brings nozzle closer to the bed
## After you run Z_ENDSTOP_CALIBRATE, position_endstop will be stored at the very end of your config
# position_endstop: -0.5
##--------------------------------------------------------------------
## Uncomment below for 250mm build
position_max: 230
## Uncomment below for 300mm build
#position_max: 260
## Uncomment below for 350mm build
#position_max: 310
##--------------------------------------------------------------------
position_min: -1
homing_speed: 100
second_homing_speed: 2
homing_retract_dist: 0
## Make sure to update below for your relevant driver (2208 or 2209)
[tmc2209 stepper_z]
uart_pin: PC6
interpolate: true
run_current: 1.4
sense_resistor: 0.110
## Z1 Stepper - Rear Left
## Connected to MOTOR_3
[stepper_z1]
step_pin: PG4
dir_pin: !PC1
## Octopus 1.0 & 1.1. Octopus PRO 1.0
enable_pin: !PA0
## Octopus PRO 1.1
#enable_pin: !PA2
rotation_distance: 40
gear_ratio: 80:16
microsteps: 32
## Make sure to update below for your relevant driver (2208 or 2209)
[tmc2209 stepper_z1]
uart_pin: PC7
interpolate: true
run_current: 1.4
sense_resistor: 0.110
## Z2 Stepper - Rear Right
## Connected to MOTOR_4
[stepper_z2]
step_pin: PF9
dir_pin: PF10
enable_pin: !PG2
rotation_distance: 40
gear_ratio: 80:16
microsteps: 32
## Make sure to update below for your relevant driver (2208 or 2209)
[tmc2209 stepper_z2]
uart_pin: PF2
interpolate: true
run_current: 1.4
sense_resistor: 0.110
## Z3 Stepper - Front Right
## Connected to MOTOR_5
[stepper_z3]
step_pin: PC13
dir_pin: !PF0
enable_pin: !PF1
rotation_distance: 40
gear_ratio: 80:16
microsteps: 32
## Make sure to update below for your relevant driver (2208 or 2209)
[tmc2209 stepper_z3]
uart_pin: PE4
interpolate: true
run_current:1.4
sense_resistor: 0.110
[filament_switch_sensor switch_sensor]
switch_pin: ^PG12
pause_on_runout: True
runout_gcode:
M117 Filament switch runout
insert_gcode:
M117 Filament switch inserted
[filament_motion_sensor encoder_sensor]
switch_pin: ^PG13
detection_length: 4.5 # Calibrated filament travel required to detect motion.
extruder: extruder
pause_on_runout: True
runout_gcode:
M117 Filament encoder runout
insert_gcode:
M117 Filament encoder inserted
#####################################################################
# Bed Heater
#####################################################################
## SSR Pin - HE1
## Thermistor - TB
[heater_bed]
## Uncomment the following line if using the default SSR wiring from the docs site
heater_pin: PA3
## Other wiring guides may use BED_OUT to control the SSR. Uncomment the following line for those cases
#heater_pin: PA1
## Check what thermistor type you have. See https://www.klipper3d.org/Config_Reference.html#common-thermistors for common thermistor types.
## Use "Generic 3950" for Keenovo heaters
sensor_type: Generic 3950
sensor_pin: PF3
## Adjust max_power so it doesn't exceed the SSR rating. The Omron G3NA-210B-DC5 SSR is rated at 4 amps without a heatsink.
## The formula is "4 / (Wattage_of_bed_heater / Mains_voltage) = max_power"
## If max_power is greater than 1.0, use 1.0
max_power: 0.8
min_temp: 0
max_temp: 120
control: pid
pid_kp: 58.437
pid_ki: 2.347
pid_kd: 363.769
[bed_mesh]
zero_reference_position: 125, 125 # center of your bed
speed: 400
horizontal_move_z: 5
# These are physical Cartographer probe coordinates. With y_offset: 25 the
# nozzle travels through Y=5..220 while the probe covers Y=30..245. X=5..245
# keeps both nozzle and probe inside the plate. The rear brush is at nozzle
# Y=250.5, well outside the scan path.
mesh_min: 5, 30
mesh_max: 245, 245
probe_count: 30,30
algorithm: bicubic
adaptive_margin: 5
#####################################################################
# Fan Control
#####################################################################
## Controller fan - FAN2
[controller_fan controller_fan_1]
pin: PD12
kick_start_time: 0.5
idle_speed: 0.6
max_power: 1
heater: heater_bed
[fan_generic front]
pin: PE5
[temperature_fan ebb36_fan]
# Despite the historical name, this is a chamber circulation fan. The EBB MCU
# has no dedicated active cooling; its temperature is only a chamber proxy used
# to switch this fan automatically.
pin: PD14
sensor_type: temperature_mcu
sensor_mcu: EBBCan
control: pid
pid_Kp: 2.0
pid_Ki: 5.0
pid_Kd: 0.5
pid_deriv_time: 2.0
target_temp: 40.0
min_temp: 0.0
max_temp: 90.0
min_speed: 0.0
max_speed: 1.0
kick_start_time: 0.1
cycle_time: 0.001
shutdown_speed: 0.0
gcode_id: C
[temperature_sensor raspberry_pi]
sensor_type: temperature_host
max_temp: 100
[temperature_sensor mcu_temp]
sensor_type: temperature_mcu
max_temp: 100
[fan_generic nevermore]
## Nevermore - FAN5 on Octopus
## Adjust if you use a different board or a different terminal.
pin: PD13
#####################################################################
# Homing and Gantry Adjustment Routines
#####################################################################
[idle_timeout]
timeout: 1800
gcode:
TURN_OFF_HEATERS
SET_FAN_SPEED FAN=nevermore SPEED=0
SET_FAN_SPEED FAN=front SPEED=0
M107
STATUS_READY
M84
# [safe_z_home]
# ## XY Location of the Z Endstop Switch
# ## Update -10,-10 to the XY coordinates of your endstop pin
# ## (such as 157,305) after going through Z Endstop Pin
# ## Location Definition step.
# home_xy_position: 125, 125
# speed:100
# z_hop:10
# Use QUAD_GANTRY_LEVEL to level a gantry.
# Min & Max gantry corners - measure from nozzle at MIN (0,0) and
# MAX (250, 250), (300,300), or (350,350) depending on your printer size
# to respective belt positions
[quad_gantry_level]
#--------------------------------------------------------------------
## Gantry Corners for 250mm Build
## Uncomment for 250mm build
gantry_corners:
-60,-10
310, 320
## Probe points
points:
50,25
50,210
220,210
220,25
## Gantry Corners for 300mm Build
## Uncomment for 300mm build
#gantry_corners:
# -60,-10
# 360,370
## Probe points
#points:
# 50,25
# 50,225
# 250,225
# 250,25
## Gantry Corners for 350mm Build
## Uncomment for 350mm build
#gantry_corners:
# -60,-10
# 410,420
## Probe points
#points:
# 50,25
# 50,275
# 300,275
# 300,25
#--------------------------------------------------------------------
speed: 300
horizontal_move_z: 10
retries: 5
retry_tolerance: 0.0075
max_adjust: 10
########################################
# EXP1 / EXP2 (display) pins
########################################
[board_pins]
aliases:
# EXP1 header
EXP1_1=PE8, EXP1_2=PE7,
EXP1_3=PE9, EXP1_4=PE10,
EXP1_5=PE12, EXP1_6=PE13, # Slot in the socket on this side
EXP1_7=PE14, EXP1_8=PE15,
EXP1_9=<GND>, EXP1_10=<5V>,
# EXP2 header
EXP2_1=PA6, EXP2_2=PA5,
EXP2_3=PB1, EXP2_4=PA4,
EXP2_5=PB2, EXP2_6=PA7, # Slot in the socket on this side
EXP2_7=PC15, EXP2_8=<RST>,
EXP2_9=<GND>, EXP2_10=<5V>
#####################################################################
# Displays
#####################################################################
## Uncomment the display that you have
#--------------------------------------------------------------------
## RepRapDiscount 128x64 Full Graphic Smart Controller
#[display]
#lcd_type: st7920
#cs_pin: EXP1_4
#sclk_pin: EXP1_5
#sid_pin: EXP1_3
#menu_timeout: 40
#encoder_pins: ^EXP2_5, ^EXP2_3
#click_pin: ^!EXP1_2
#[output_pin beeper]
#pin: EXP1_1
#--------------------------------------------------------------------
## mini12864 LCD Display
#[display]
#lcd_type: uc1701
#cs_pin: EXP1_3
#a0_pin: EXP1_4
#rst_pin: EXP1_5
#encoder_pins: ^EXP2_5, ^EXP2_3
#click_pin: ^!EXP1_2
#contrast: 63
#spi_software_miso_pin: EXP2_1
#spi_software_mosi_pin: EXP2_6
#spi_software_sclk_pin: EXP2_2
## To control Neopixel RGB in mini12864 display
#[neopixel btt_mini12864]
#pin: EXP1_6
#chain_count: 3
#initial_RED: 0.1
#initial_GREEN: 0.5
#initial_BLUE: 0.0
#color_order: RGB
## Set RGB values on boot up for each Neopixel.
## Index 1 = display, Index 2 and 3 = Knob
#[delayed_gcode setdisplayneopixel]
#initial_duration: 1
#gcode:
# SET_LED LED=btt_mini12864 RED=1 GREEN=1 BLUE=1 INDEX=1 TRANSMIT=0
# SET_LED LED=btt_mini12864 RED=1 GREEN=0 BLUE=0 INDEX=2 TRANSMIT=0
# SET_LED LED=btt_mini12864 RED=1 GREEN=0 BLUE=0 INDEX=3
#--------------------------------------------------------------------
[virtual_sdcard]
path: ~/printer_data/gcodes
[display_status]
[pause_resume]
#####################################################################
# Macros
#####################################################################
[gcode_macro LOAD_FILAMENT]
variable_load_distance: 50
variable_purge_distance: 25
gcode:
{% set speed = params.SPEED|default(300) %}
{% set max_velocity = printer.configfile.settings['extruder'].max_extrude_only_velocity * 60 %}
{% if not printer.extruder.can_extrude %}
{ action_raise_error("LOAD_FILAMENT requires a hot extruder") }
{% else %}
SAVE_GCODE_STATE NAME=load_state
G91
G92 E0
G1 E{load_distance} F{max_velocity} # fast-load
G1 E{purge_distance} F{speed} # purge
RESTORE_GCODE_STATE NAME=load_state MOVE=0
{% endif %}
[gcode_macro UNLOAD_FILAMENT]
variable_unload_distance: 50
variable_purge_distance: 25
gcode:
{% set speed = params.SPEED|default(300) %}
{% set max_velocity = printer.configfile.settings['extruder'].max_extrude_only_velocity * 60 %}
{% if not printer.extruder.can_extrude %}
{ action_raise_error("UNLOAD_FILAMENT requires a hot extruder") }
{% else %}
SAVE_GCODE_STATE NAME=unload_state
G91
G92 E0
G1 E{purge_distance} F{speed} # purge
G1 E-{unload_distance} F{max_velocity} # fast-unload
RESTORE_GCODE_STATE NAME=unload_state MOVE=0
{% endif %}
[gcode_macro start_heating]
description: Home, lift, and preheat the chamber manually; use STOP_HEATING to finish
gcode:
{% set bed = params.BED|default(115)|float %}
{% set hotend = params.HOTEND|default(50)|float %}
{% set lift = params.LIFT|default(50)|float %}
{% set front = params.FRONT|default(0.55)|float %}
{% set filter = params.FILTER|default(1.0)|float %}
{% set part = params.PART|default(0.31)|float %}
{% set timeout = params.TIMEOUT|default(printer.configfile.settings.idle_timeout.timeout)|int %}
{% set bed_max = printer.configfile.settings.heater_bed.max_temp|float %}
{% set hotend_max = printer.configfile.settings.extruder.max_temp|float %}
{% set print_state = printer.print_stats.state|string|lower %}
{% if print_state in ["printing", "paused"] %}
{ action_raise_error("START_HEATING is only for manual preheat while no print is active") }
{% elif bed < 0 or bed >= bed_max %}
{ action_raise_error("BED must be at least 0 and below %.0f C" % (bed_max)) }
{% elif hotend < 0 or hotend >= hotend_max %}
{ action_raise_error("HOTEND must be at least 0 and below %.0f C" % (hotend_max)) }
{% elif lift < printer.toolhead.axis_minimum.z|float or lift > printer.toolhead.axis_maximum.z|float %}
{ action_raise_error("LIFT is outside the configured Z travel") }
{% elif front < 0 or front > 1 or filter < 0 or filter > 1 or part < 0 or part > 1 %}
{ action_raise_error("FRONT, FILTER and PART must be between 0.0 and 1.0") }
{% elif timeout < 300 or timeout > 7200 %}
{ action_raise_error("TIMEOUT must be between 300 and 7200 seconds") }
{% else %}
SAVE_GCODE_STATE NAME=START_HEATING_STATE
STATUS_HOMING
{% if "xyz" not in printer.toolhead.homed_axes %}
G28
{% endif %}
G90
G0 Z{lift} F900
STATUS_HEATING
SET_IDLE_TIMEOUT TIMEOUT={timeout}
SET_HEATER_TEMPERATURE HEATER=heater_bed TARGET={bed}
SET_HEATER_TEMPERATURE HEATER=extruder TARGET={hotend}
SET_FAN_SPEED FAN=nevermore SPEED={filter}
SET_FAN_SPEED FAN=front SPEED={front}
M106 S{(part * 255)|int}
RESTORE_GCODE_STATE NAME=START_HEATING_STATE MOVE=0
{ action_respond_info("Manual preheat: Z %.1f mm, bed %.0f C, hotend %.0f C, timeout %d min. HOTEND=50 intentionally starts the hotend fan for chamber circulation; EBB temperature is only a proxy." % (lift, bed, hotend, timeout // 60)) }
{% endif %}
[gcode_macro STOP_HEATING]
description: Stop manual preheat and restore the configured idle timeout
gcode:
{% set print_state = printer.print_stats.state|string|lower %}
{% if print_state in ["printing", "paused"] %}
{ action_raise_error("STOP_HEATING is only for manual preheat; use print controls during a print") }
{% else %}
TURN_OFF_HEATERS
SET_FAN_SPEED FAN=nevermore SPEED=0
SET_FAN_SPEED FAN=front SPEED=0
M107
SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout|int}
STATUS_READY
{ action_respond_info("Manual preheat stopped; heaters and preheat fans are off") }
{% endif %}
[gcode_macro nvmOn]
gcode:
SET_FAN_SPEED FAN=nevermore SPEED=1
[gcode_macro nvmOff]
gcode:
SET_FAN_SPEED FAN=nevermore SPEED=0
[gcode_macro PARK]
description: Park safely at the center without lowering Z
gcode:
{% set th = printer.toolhead %}
{% if "xyz" not in th.homed_axes %}
{ action_raise_error("PARK requires homed X, Y and Z") }
{% else %}
{% set park_z = [th.position.z|float + 5.0, th.axis_maximum.z|float]|min %}
SAVE_GCODE_STATE NAME=PARK_STATE
G90
G0 Z{park_z} F900
G0 X{th.axis_maximum.x/2} Y{th.axis_maximum.y/2} F12000
RESTORE_GCODE_STATE NAME=PARK_STATE MOVE=0
{% endif %}
[gcode_macro G32]
gcode:
SAVE_GCODE_STATE NAME=STATE_G32
G90
G28
QUAD_GANTRY_LEVEL
G28
PARK
RESTORE_GCODE_STATE NAME=STATE_G32
[gcode_macro PRINT_START]
description: Heat, home, level, touch-calibrate, scan adaptively, and purge
gcode:
{% set bedtemp = params.BED|int %}
{% set hotendtemp = params.EXTRUDER|int %}
SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout|int}
G90
SET_GCODE_OFFSET Z=0
SET_FAN_SPEED FAN=front SPEED=0.55
STATUS_HOMING
G28
# Soften residue while the bed heats; Cartographer Touch uses at most 150 C.
M104 S150
STATUS_HEATING
M190 S{bedtemp}
{% if bedtemp > 95 %}
nvmOn
{% else %}
nvmOff
{% endif %}
STATUS_LEVELING
QUAD_GANTRY_LEVEL
M109 S150
STATUS_CLEANING
CLEAN_NOZZLE
STATUS_CALIBRATING_Z
CARTOGRAPHER_TOUCH_HOME
STATUS_MESHING
CARTOGRAPHER_MESH
# START_HEATING may leave part cooling on for circulation; printing starts clean.
M107
STATUS_HEATING
M109 S{hotendtemp}
STATUS_CLEANING
LINE_PURGE
STATUS_PRINTING
[gcode_macro CARTOGRAPHER_MESH]
description: Adaptive scan with a safe full-mesh fallback for unreachable edge-only objects
gcode:
{% set points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %}
{% set mesh_min = printer.configfile.settings.bed_mesh.mesh_min %}
{% set mesh_max = printer.configfile.settings.bed_mesh.mesh_max %}
{% set margin = printer.configfile.settings.bed_mesh.adaptive_margin|float %}
{% if points|length == 0 %}
{ action_respond_info("CARTOGRAPHER_MESH: no object polygons; scanning the configured safe area") }
BED_MESH_CALIBRATE
{% else %}
{% set object_x_min = points | map(attribute=0) | min | float %}
{% set object_x_max = points | map(attribute=0) | max | float %}
{% set object_y_min = points | map(attribute=1) | min | float %}
{% set object_y_max = points | map(attribute=1) | max | float %}
{% set outside = object_x_max + margin <= mesh_min[0]
or object_x_min - margin >= mesh_max[0]
or object_y_max + margin <= mesh_min[1]
or object_y_min - margin >= mesh_max[1] %}
{% if outside %}
{ action_respond_info("CARTOGRAPHER_MESH: object lies outside the probe-reachable area; using the full safe mesh") }
BED_MESH_CALIBRATE
{% else %}
BED_MESH_CALIBRATE ADAPTIVE=1
{% endif %}
{% endif %}
[gcode_macro LINE_PURGE]
description: Adaptive purge outside the print; safely skips when no free edge exists
gcode:
{% set objects = printer.exclude_object.objects %}
{% set points = objects | map(attribute='polygon') | sum(start=[]) %}
{% set line_length = 100.0 %}
{% set wipe_length = 5.0 %}
{% set clearance = 8.0 %}
{% set x_offset = printer.configfile.settings.cartographer.x_offset|float %}
{% set y_offset = printer.configfile.settings.cartographer.y_offset|float %}
# Both nozzle and protruding Cartographer must remain at least 5 mm inside
# the 250 mm plate. The rear limit also avoids the brush at nozzle Y=250.5.
{% set safe_x_min = [printer.toolhead.axis_minimum.x|float + 5.0, 5.0 - x_offset]|max %}
{% set safe_x_max = [printer.toolhead.axis_maximum.x|float - 5.0, 245.0 - x_offset]|min %}
{% set safe_y_min = [printer.toolhead.axis_minimum.y|float + 5.0, 5.0 - y_offset]|max %}
{% set safe_y_max = [printer.toolhead.axis_maximum.y|float - 5.0, 245.0 - y_offset]|min %}
{% if "xyz" not in printer.toolhead.homed_axes %}
{ action_raise_error("LINE_PURGE requires homed X, Y and Z") }
{% elif not printer.extruder.can_extrude %}
{ action_raise_error("LINE_PURGE requires a hot extruder") }
{% elif points|length == 0 %}
{ action_respond_info("LINE_PURGE skipped: slicer supplied no object polygons") }
{% elif safe_x_max - safe_x_min < line_length + wipe_length or safe_y_max - safe_y_min < line_length + wipe_length %}
{ action_respond_info("LINE_PURGE skipped: configured safe area is too small") }
{% else %}
{% set object_x_min = points | map(attribute=0) | min | float %}
{% set object_x_max = points | map(attribute=0) | max | float %}
{% set object_y_min = points | map(attribute=1) | min | float %}
{% set object_y_max = points | map(attribute=1) | max | float %}
{% set front_gap = object_y_min - safe_y_min %}
{% set left_gap = object_x_min - safe_x_min %}
{% set right_gap = safe_x_max - object_x_max %}
{% set rear_gap = safe_y_max - object_y_max %}
{% set largest_gap = [front_gap, left_gap, right_gap, rear_gap]|max %}
{% set x_center = (object_x_min + object_x_max) / 2.0 %}
{% set y_center = (object_y_min + object_y_max) / 2.0 %}
{% set purge_x = [[x_center - line_length / 2.0, safe_x_min]|max, safe_x_max - line_length - wipe_length]|min %}
{% set purge_y = [[y_center - line_length / 2.0, safe_y_min]|max, safe_y_max - line_length - wipe_length]|min %}
{% if largest_gap < clearance %}
{ action_respond_info("LINE_PURGE skipped: print occupies every safe bed edge") }
{% else %}
# 12 mm of 1.75 mm filament over 100 mm = about 0.289 mm2,
# safely below max_extrude_cross_section=0.64 mm2 for the 0.4 mm nozzle.
SAVE_GCODE_STATE NAME=LINE_PURGE_STATE
G90
M83
{% if largest_gap == front_gap %}
{% set edge = "front" %}
G0 X{purge_x} Y{object_y_min - clearance} Z2 F12000
G0 Z0.4 F600
G1 X{purge_x + line_length} E12 F600
G1 X{purge_x + line_length + wipe_length} F1800
{% elif largest_gap == left_gap %}
{% set edge = "left" %}
G0 X{object_x_min - clearance} Y{purge_y} Z2 F12000
G0 Z0.4 F600
G1 Y{purge_y + line_length} E12 F600
G1 Y{purge_y + line_length + wipe_length} F1800
{% elif largest_gap == right_gap %}
{% set edge = "right" %}
G0 X{object_x_max + clearance} Y{purge_y} Z2 F12000
G0 Z0.4 F600
G1 Y{purge_y + line_length} E12 F600
G1 Y{purge_y + line_length + wipe_length} F1800
{% else %}
{% set edge = "rear" %}
G0 X{purge_x} Y{object_y_max + clearance} Z2 F12000
G0 Z0.4 F600
G1 X{purge_x + line_length} E12 F600
G1 X{purge_x + line_length + wipe_length} F1800
{% endif %}
G0 Z2 F600
RESTORE_GCODE_STATE NAME=LINE_PURGE_STATE MOVE=0
{ action_respond_info("LINE_PURGE used the %s free edge with 8 mm object clearance" % edge) }
{% endif %}
{% endif %}
[gcode_macro _PRINT_CLEANUP]
description: Shared non-motion cleanup for completed and cancelled prints
gcode:
TURN_OFF_HEATERS
SET_FAN_SPEED FAN=nevermore SPEED=0
SET_FAN_SPEED FAN=front SPEED=0
M107
BED_MESH_CLEAR
SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=1
SET_FILAMENT_SENSOR SENSOR=switch_sensor ENABLE=1
SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout|int}
STATUS_READY
[gcode_macro CANCEL_PRINT]
description: Cancel the job and leave heaters, print fans, sensors, and timeout safe
rename_existing: BASE_CANCEL_PRINT
gcode:
_PRINT_CLEANUP
BASE_CANCEL_PRINT
[gcode_macro PRINT_END]
description: Retract, park, and return the printer to a safe idle state
gcode:
# safe anti-stringing move coords
{% set th = printer.toolhead %}
{% set x_safe = th.position.x + 20 * (1 if th.axis_maximum.x - th.position.x > 20 else -1) %}
{% set y_safe = th.position.y + 20 * (1 if th.axis_maximum.y - th.position.y > 20 else -1) %}
{% set z_safe = [th.position.z + 2, th.axis_maximum.z]|min %}
SAVE_GCODE_STATE NAME=STATE_PRINT_END
M400 ; wait for buffer to clear
G92 E0 ; zero the extruder
G1 E-1.0 F1800 ; small anti-stringing retract
TURN_OFF_HEATERS
G90 ; absolute positioning
G0 X{x_safe} Y{y_safe} Z{z_safe} F20000 ; move nozzle to remove stringing
G0 X{th.axis_maximum.x//2} Y{th.axis_maximum.y - 2} F3600 ; park nozzle at rear
RESTORE_GCODE_STATE NAME=STATE_PRINT_END MOVE=0
_PRINT_CLEANUP
# Home, get position, throw around toolhead, home again.
# If MCU stepper positions (first line in GET_POSITION) are greater than a full step different (your number of microsteps), then skipping occured.
# We only measure to a full step to accomodate for endstop variance.
# Example: TEST_SPEED SPEED=300 ACCEL=5000 ITERATIONS=10
[gcode_macro TEST_SPEED]
description: Motion test with conservative defaults; override SPEED and ACCEL explicitly if needed
gcode:
# Speed
{% set speed = params.SPEED|default(300)|int %}
# Iterations
{% set iterations = params.ITERATIONS|default(5)|int %}
# Acceleration
{% set accel = params.ACCEL|default(5000)|int %}
# Bounding inset for large pattern (helps prevent slamming the toolhead into the sides after small skips, and helps to account for machines with imperfectly set dimensions)
{% set bound = params.BOUND|default(20)|int %}
# Size for small pattern box
{% set smallpatternsize = params.SMALLPATTERNSIZE|default(20)|int %}
{% if speed <= 0 or speed > printer.configfile.settings.printer.max_velocity|int %}
{ action_raise_error("SPEED must be between 1 and the configured max_velocity") }
{% elif accel <= 0 or accel > printer.configfile.settings.printer.max_accel|int %}
{ action_raise_error("ACCEL must be between 1 and the configured max_accel") }
{% elif iterations < 1 or iterations > 50 %}
{ action_raise_error("ITERATIONS must be between 1 and 50") }
{% elif bound < 1 or bound * 2 >= printer.toolhead.axis_maximum.x|int or bound * 2 >= printer.toolhead.axis_maximum.y|int %}
{ action_raise_error("BOUND leaves no valid motion area") }
{% elif smallpatternsize < 1 or smallpatternsize >= printer.toolhead.axis_maximum.x|int or smallpatternsize >= printer.toolhead.axis_maximum.y|int %}
{ action_raise_error("SMALLPATTERNSIZE is outside the motion area") }
{% endif %}
# Large pattern
# Max positions, inset by BOUND
{% set x_min = printer.toolhead.axis_minimum.x + bound %}
{% set x_max = printer.toolhead.axis_maximum.x - bound %}
{% set y_min = printer.toolhead.axis_minimum.y + bound %}
{% set y_max = printer.toolhead.axis_maximum.y - bound %}
# Small pattern at center
# Find X/Y center point
{% set x_center = (printer.toolhead.axis_minimum.x|float + printer.toolhead.axis_maximum.x|float ) / 2 %}
{% set y_center = (printer.toolhead.axis_minimum.y|float + printer.toolhead.axis_maximum.y|float ) / 2 %}
# Set small pattern box around center point
{% set x_center_min = x_center - (smallpatternsize/2) %}
{% set x_center_max = x_center + (smallpatternsize/2) %}
{% set y_center_min = y_center - (smallpatternsize/2) %}
{% set y_center_max = y_center + (smallpatternsize/2) %}
# Save current gcode state (absolute/relative, etc)
SAVE_GCODE_STATE NAME=TEST_SPEED
# Output parameters to g-code terminal
{ action_respond_info("TEST_SPEED: starting %d iterations at speed %d, accel %d" % (iterations, speed, accel)) }
# Home and get position for comparison later:
M400 # Finish moves - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/66
G28
# QGL if not already QGLd (only if QGL section exists in config)
{% if printer.configfile.settings.quad_gantry_level %}
{% if printer.quad_gantry_level.applied == False %}
QUAD_GANTRY_LEVEL
G28 Z
{% endif %}
{% endif %}
# 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{30*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{30*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
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} MINIMUM_CRUISE_RATIO=0.5
{% 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 patternbox
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/minimum_cruise_ratio to their configured values
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}
# 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)
G90
G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
G4 P1000
GET_POSITION
# Restore previous gcode state (absolute/relative, etc)
RESTORE_GCODE_STATE NAME=TEST_SPEED
[gcode_macro CLEAN_NOZZLE]
variable_start_x: 110
variable_start_y: 250.5
variable_start_z: 0.3
variable_wipe_dist: -45
variable_wipe_qty: 10
variable_wipe_spd: 400
variable_raise_distance: 15
gcode:
SAVE_GCODE_STATE NAME=CLEAN_NOZZLE_STATE
{% if "xyz" not in printer.toolhead.homed_axes %}
G28
{% endif %}
G90 ; absolute positioning
## Move nozzle to start position
G1 X{start_x} Y{start_y} F6000
G1 Z{start_z} F1500
## Wipe nozzle
{% for wipes in range(1, (wipe_qty + 1)) %}
G1 X{start_x + wipe_dist} F{wipe_spd * 60}
G1 X{start_x} F{wipe_spd * 60}
{% endfor %}
## Raise nozzle
G1 Z{raise_distance}
RESTORE_GCODE_STATE NAME=CLEAN_NOZZLE_STATE MOVE=0
[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=encoder_sensor ENABLE=0 ; avoid a second runout while paused
SET_FILAMENT_SENSOR SENSOR=switch_sensor ENABLE=0
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_minimum.y+5} F6000 ; park toolhead at front 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)|float %} ; hotend prime amount (in mm)
{% if printer['pause_resume'].is_paused|int == 1 %}
SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=1 ; enable filament sensor
SET_FILAMENT_SENSOR SENSOR=switch_sensor ENABLE=1
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 %}
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 26.908
#*# pid_ki = 2.360
#*# pid_kd = 76.690
#*#
#*# [input_shaper]
#*# shaper_type_x = mzv
#*# shaper_freq_x = 60.8
#*# shaper_type_y = mzv
#*# shaper_freq_y = 43.4
#*#
#*# [cartographer scan_model default]
#*# coefficients = 1.5077021654307656,1.982925374522947,0.8069624702177761,0.44075023484388876,0.5125827502492211,0.2069086470851544,-0.3443498114430992,-0.00819725951495316,0.31856943991554365,0.08027243835900834
#*# domain = 3.238062151773355e-07,3.3502316466550964e-07
#*# z_offset = 0
#*# reference_temperature = 29.33
#*# software_version = 1.9.0
#*# mcu_version = CARTOGRAPHER V3 6.1.0
#*#
#*# [cartographer touch_model default]
#*# threshold = 1139
#*# speed = 2
#*# z_offset = -0.05
#*# software_version = 1.9.0
#*# mcu_version = CARTOGRAPHER V3 6.1.0