Skip to content

Instantly share code, notes, and snippets.

@cscashby
Last active July 8, 2022 15:05
Show Gist options
  • Save cscashby/41a60b4efabd5b10c842e2cee54141f8 to your computer and use it in GitHub Desktop.
Save cscashby/41a60b4efabd5b10c842e2cee54141f8 to your computer and use it in GitHub Desktop.
Updates for LEDs and position_endstop
# This file contains common pin mappings for the Fysetc Spider board.
# To use this config, the firmware should be compiled for the STM32F446.
# When calling "menuconfig", enable "extra low-level configuration setup"
# and select the "12MHz crystal" as clock reference
# For flashing, write the compiled klipper.bin to memory location 0x08000000
# See docs/Config_Reference.md for a description of parameters.
## Voron Design VORON2 250/300/350mm Spider TMC2209 UART config
## *** THINGS TO CHANGE/CHECK: ***
## Spider version Please search this file for "SpiderVersion" and uncomment the appropriate line for each
## MCU paths [mcu] section
## Thermistor types [extruder] and [heater_bed] sections - See 'sensor types' list at end of file
## Z Endstop Switch location [safe_z_home] section
## Homing end position [gcode_macro G32] section
## Z Endstop Switch offset for Z0 [stepper_z] section
## Probe points [quad_gantry_level] section
## Min & Max gantry corner postions [quad_gantry_level] section
## PID tune [extruder] and [heater_bed] sections
## Fine tune E steps [extruder] section
[mcu]
serial: /dev/serial/by-id/usb-Klipper_stm32f446xx_29004C001350325635393320-if00
[printer]
kinematics: corexy
max_velocity: 300
max_accel: 3000 #Max 4000
max_z_velocity: 15 #Max 15 for 12V TMC Drivers, can increase for 24V
max_z_accel: 350
square_corner_velocity: 5.0
#####################################################################
# X/Y Stepper Settings
#####################################################################
[stepper_x]
## Connected to X-MOT (B Motor)
step_pin: PE11
dir_pin: !PE10
enable_pin: !PE9
rotation_distance: 40
microsteps: 16
full_steps_per_rotation:200 #set to 400 for 0.9 degree stepper
endstop_pin: ^PB14
position_min: 0
##--------------------------------------------------------------------
## Uncomment below for 250mm build
#position_endstop: 250
#position_max: 250
## Uncomment for 300mm build
position_endstop: 292.8
position_max: 292.8
## Uncomment for 350mm build
#position_endstop: 350
#position_max: 350
##--------------------------------------------------------------------
homing_speed: 100 #Max 100
homing_retract_dist: 5
homing_positive_dir: true
## Make sure to update below for your relevant driver (2208 or 2209)
[tmc2209 stepper_x]
uart_pin: PE7
interpolate: True
run_current: 0.7
hold_current: 0.4
sense_resistor: 0.110
stealthchop_threshold: 0
## Make sure to update below for your relevant driver (5160)
#[tmc5160 stepper_x]
#spi_bus: spi4
#cs_pin: PE7
#interpolate: True
#diag1_pin: PB14
#run_current: 0.800
#hold_current: 0.500
##stealthchop_threshold: 0
[stepper_y]
## Connected to Y-MOT (A Motor)
step_pin: PD8
dir_pin: !PB12
enable_pin: !PD9
rotation_distance: 40
microsteps: 16
full_steps_per_rotation:200 #set to 400 for 0.9 degree stepper
endstop_pin: ^PB13
position_min: 0
##--------------------------------------------------------------------
## Uncomment for 250mm build
#position_endstop: 250
#position_max: 250
## Uncomment for 300mm build
position_endstop: 300
position_max: 301
## Uncomment for 350mm build
#position_endstop: 358
#position_max: 358
##--------------------------------------------------------------------
homing_speed: 100 #Max 100
homing_retract_dist: 5
homing_positive_dir: true
## Make sure to update below for your relevant driver (2208 or 2209)
[tmc2209 stepper_y]
uart_pin: PE15
interpolate: True
run_current: 0.7
hold_current: 0.4
sense_resistor: 0.110
stealthchop_threshold: 0
## Make sure to update below for your relevant driver (5160)
#[tmc5160 stepper_y]
#spi_bus: spi4
#cs_pin: PE15
##diag1_pin: PB13
#interpolate: True
#run_current: 0.8
#hold_current: 0.7
##stealthchop_threshold: 0
#####################################################################
# Z Stepper Settings
#####################################################################
## In Z-MOT Position
## Z0 Stepper - Front Left
[stepper_z]
step_pin: PD14
dir_pin: PD13
enable_pin: !PD15
rotation_distance: 40
gear_ratio: 80:16
microsteps: 16
## In Z- Position
endstop_pin: ^PA0
## 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.530
#position_endstop: -5
##--------------------------------------------------------------------
## Uncomment below for 250mm build
#position_max: 240
## Uncomment below for 300mm build
position_max: 290
## Uncomment below for 350mm build
#position_max: 345
##--------------------------------------------------------------------
position_min: -10
homing_speed: 8
second_homing_speed: 3
homing_retract_dist: 3
## Make sure to update below for your relevant driver (2208 or 2209)
[tmc2209 stepper_z]
uart_pin: PD10
uart_address: 0
interpolate: True
run_current: 0.7
hold_current: 0.4
sense_resistor: 0.110
stealthchop_threshold: 0
## In E1-MOT Position
## Z1 Stepper - Rear Left
[stepper_z1]
step_pin: PE6
dir_pin: !PC13
enable_pin: !PE5
rotation_distance: 40
gear_ratio: 80:16
microsteps: 16
## Make sure to update below for your relevant driver (2208 or 2209)
[tmc2209 stepper_z1]
uart_pin: PC14
interpolate: True
run_current: 0.7
hold_current: 0.4
sense_resistor: 0.110
stealthchop_threshold: 0
## In E2-MOT Position
## Z2 Stepper - Rear Right
[stepper_z2]
step_pin: PE2
dir_pin: PE4
enable_pin: !PE3
rotation_distance: 40
gear_ratio: 80:16
microsteps: 16
## Make sure to update below for your relevant driver (2208 or 2209)
[tmc2209 stepper_z2]
uart_pin: PC15
interpolate: true
run_current: 0.7
hold_current: 0.4
sense_resistor: 0.110
stealthchop_threshold: 0
## In E3-MOT Position
## Z3 Stepper - Front Right
[stepper_z3]
step_pin: PD12
dir_pin: !PC4
enable_pin: !PE8
rotation_distance: 40
gear_ratio: 80:16
microsteps: 16
[tmc2209 stepper_z3]
uart_pin: PA15
interpolate: true
run_current: 0.7
hold_current: 0.4
sense_resistor: 0.110
stealthchop_threshold: 0
#####################################################################
# Extruder
#####################################################################
## In E0-MOT Position
[extruder]
step_pin: PD5
dir_pin: PD6
enable_pin: !PD4
## Update value below when you perform extruder calibration
## If you ask for 100mm of filament, but in reality it is 98mm:
## rotation_distance = <previous_rotation_distance> * <actual_extrude_distance> / 100
## 22.6789511 is a good starting point
rotation_distance: 23.41107
## Update Gear Ratio depending on your Extruder Type
## Use 50:17 for Afterburner/Clockwork (BMG Gear Ratio)
## Use 80:20 for M4, M3.1
gear_ratio: 50:17 #BMG Gear Ratio
microsteps: 16
full_steps_per_rotation: 200 #200 for 1.8 degree, 400 for 0.9 degree
nozzle_diameter: 0.400
filament_diameter: 1.75
## In E0 OUT Position
heater_pin: PB15
## Validate the following thermistor type to make sure it is correct
sensor_type: NTC 100K beta 3950 #ATC Semitec 104GT-2
sensor_pin: PC0 # TE0 Position
min_temp: 10
max_temp: 300
max_power: 1.0
min_extrude_temp: 170
control = pid
pid_kp = 26.213
pid_ki = 1.304
pid_kd = 131.721
## Try to keep pressure_advance below 1.0
pressure_advance: 0.02
## Default is 0.040, leave stock
pressure_advance_smooth_time: 0.040
## In E0-MOT Position
## Make sure to update below for your relevant driver (2208 or 2209)
[tmc2209 extruder]
uart_pin: PD7
interpolate: false
run_current: 0.5
hold_current: 0.2
sense_resistor: 0.110
stealthchop_threshold: 0
#####################################################################
# Bed Heater
#####################################################################
[heater_bed]
## SSR Pin - In BED OUT position
heater_pin: PB4
sensor_type: NTC 100K MGB18-104F39050L32
## Uncomment below for SpiderVersion 1.x
#sensor_pin: PC3 # TB Position
## Uncomment below for SpiderVersion 2.2
sensor_pin: PB0 # TB Position
## Adjust Max Power so your heater doesn't warp your bed
max_power: 0.6
min_temp: 0
max_temp: 120
control: pid
pid_kp: 58.437
pid_ki: 2.347
pid_kd: 363.769
#####################################################################
# Probe
#####################################################################
[probe]
## Inductive Probe - If you use this section , please comment the [bltouch] section
## This probe is not used for Z height, only Quad Gantry Leveling
## In Z+ position
## If your probe is NC instead of NO, add change pin to ^PA3
pin: ^!PA3
x_offset: 0
y_offset: 25.0
z_offset: 0
speed: 10.0
samples: 3
samples_result: median
sample_retract_dist: 3.0
samples_tolerance: 0.006
samples_tolerance_retries: 3
#####################################################################
# Bltouch
#####################################################################
#[bltouch]
## Bltouch - If you use this section , please comment the [probe] section
## More infomation at : https://www.klipper3d.org/BLTouch.html
## This bltouch is not used for Z height, only Quad Gantry Leveling
## In Z+ Position
#sensor_pin: PA0
## In Y+ Position
#control_pin: PA2
#x_offset: 0
#y_offset: 25.0
#z_offset: 0
#speed: 10.0
#samples: 3
#samples_result: median
#sample_retract_dist: 3.0
#samples_tolerance: 0.006
#samples_tolerance_retries: 3
#####################################################################
# Fan Control
#####################################################################
[heater_fan hotend_fan]
## Hotend Fan - E2 OUT Connector
pin: PB3
max_power: 1.0
kick_start_time: 0.5
heater: extruder
heater_temp: 50.0
## If you are experiencing back flow, you can reduce fan_speed
fan_speed: 1
[fan]
## Print Cooling Fan - FAN1 Connector
pin: PA14
max_power: 1.0
shutdown_speed: 0.0
kick_start_time: 0.1
## Depending on your fan, you may need to increase this value
## if your fan will not start. Can change cycle_time (increase)
## if your fan is not able to slow down effectively
off_below: 0.1
[heater_fan controller_fan]
## Controller fan - FAN2 Connector
pin: PB2
kick_start_time: 0.1
heater: heater_bed
heater_temp: 45.0
fan_speed: 0.75
[fan_generic chamber]
# Exhaust fan - LED R Connector
pin: PA13
max_power: 1.0
shutdown_speed: 0.0
kick_start_time: 0.1
[fan_generic bed]
# Bed fan - E1 OUT Connector
pin: PC8
max_power: 0.9
shutdown_speed: 0.0
kick_start_time: 0.1
#heater: heater_bed
#heater_temp: 60
#fan_speed: 1.0
#[temperature_sensor chamber]
#sensor_type: NTC 100K beta 3950
#sensor_pin: PC1
#min_temp: 0
#max_temp: 100
#gcode_id: C
#####################################################################
# Homing and Gantry Adjustment Routines
#####################################################################
[idle_timeout]
timeout: 1800
[safe_z_home]
## XY Location of the Z Endstop Switch
## Update -100,-100 to the XY coordinates of your endstop pin
## (such as 157,305) after going through Z Endstop Pin
## Location Definition step.
home_xy_position:201.4,295.7
speed:100
z_hop:5
[quad_gantry_level]
## 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
#--------------------------------------------------------------------
## Gantry Corners for 250mm Build
## Uncomment for 250mm build
#gantry_corners:
# -60,-10
# 310, 320
## Probe points
#points:
# 50,25
# 50,175
# 200,175
# 200,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
max_adjust: 15
#--------------------------------------------------------------------
speed: 200
horizontal_move_z: 10
retries: 5
retry_tolerance: 0.0075
max_adjust: 10
#####################################################################
# Displays
#####################################################################
#--------------------------------------------------------------------
[display]
# mini12864 LCD Display
lcd_type: uc1701
cs_pin: PC11
a0_pin: PD2
rst_pin: PC10
encoder_pins: ^PC6,^PC7
click_pin: ^!PA8
contrast: 63
#spi_bus: spi1
spi_software_mosi_pin: PA7
spi_software_miso_pin: PA6
spi_software_sclk_pin: PA5
[neopixel fysetc_mini12864]
# To control Neopixel RGB in mini12864 display
pin: PC12
chain_count: 3
initial_RED: 0.1
initial_GREEN: 0.5
initial_BLUE: 0.0
color_order: RGB
#[led_effect display_on]
#autostart: true
#frame_rate: 24
#leds:
# neopixel:fysetc_mini12864
#layers:
# static 0 0 top (1,1,1)
# 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=fysetc_mini12864 RED=1 GREEN=1 BLUE=1 INDEX=1 TRANSMIT=0
SET_LED LED=fysetc_mini12864 RED=1 GREEN=0 BLUE=0 INDEX=2 TRANSMIT=0
SET_LED LED=fysetc_mini12864 RED=1 GREEN=0 BLUE=0 INDEX=3
#####################################################################
# LED Control
#####################################################################
[led rear_leds]
white_pin: PB5
initial_WHITE: 1.0
[neopixel smart_leds]
pin: PD3
chain_count: 130 # 41 left + 45 front + 41 right + 3 SB
color_order: GRB
[led_effect chassis_idle]
autostart: true
frame_rate: 24
leds:
neopixel:smart_leds (1-127)
layers:
linearfade 10 1 top (0.1,0.1,1),(1,1,1)
[led_effect chassis_endprint]
autostart: false
frame_rate: 24
leds:
neopixel:smart_leds (1-127)
layers:
gradient 10 1 top (1,0,0),(0,1,0),(0,0,1)
[led_effect chassis_printing]
autostart: false
frame_rate: 24
leds:
neopixel:smart_leds (1-127)
layers:
static 10 1 top (1,1,1)
#####################################################################
# Macros
#####################################################################
[virtual_sdcard]
path: ~/gcode_files
[display_status]
[pause_resume]
[gcode_macro CENTER]
gcode:
G90
G1 X175 Y175 F6000
[gcode_macro HOME]
gcode:
G90
G28
G1 X150 Y150 Z50 F6000
[gcode_macro HOMEFRONT]
gcode:
G90
G28
G1 X150 Y0 Z50 F6000
[gcode_macro OCTOLAPSE_SNAP]
description: do nothing
gcode:
M114
[gcode_macro T0]
description: do nothing for T0 / tool change gcode (for Canvas compatibility)
gcode:
G4 P10 ; Dwell for 10ms just because
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
# change this if you need more or less extrusion
variable_extrude: 1.0
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
PAUSE_BASE
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F6000
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
G1 E{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESUME_BASE {get_params}
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
TURN_OFF_HEATERS
CANCEL_PRINT_BASE
[gcode_macro G32]
gcode:
G28
QUAD_GANTRY_LEVEL
G28
## Uncomment for for your size printer: (NO NEED TO HOME FOR G32)
#--------------------------------------------------------------------
## Uncomment for 250mm build
#G0 X125 Y125 Z30 F3600
## Uncomment for 300 build
#G0 X150 Y150 Z30 F3600
## Uncomment for 350mm build
#G0 X175 Y175 Z30 F3600
#--------------------------------------------------------------------
[gcode_macro PRINT_START]
# Use PRINT_START for the slicer starting script - please customise for your slicer of choice
gcode:
START_PRINT
[gcode_macro START_PRINT]
# Use PRINT_START for the slicer starting script - please customise for your slicer of choice
gcode:
set_led_effect effect=chassis_idle stop=1
set_led_effect effect=chassis_printing
#Get Bed and Extruder temperature from Slicer GCode
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(190)|float %}
#Preheat nozzle and bed
M104 S{EXTRUDER_TEMP} T0
M140 S{BED_TEMP}
#Wait for bed to stabilise before levelling
M190 S{BED_TEMP}
#Heat nozzle for cleaning
M109 S{EXTRUDER_TEMP} T0
G28
CLEAN_NOZZLE
G90
G32 ; home all axes
G1 Z10 F3000 ; move nozzle away from bed
M117 Printing
[gcode_macro END_PRINT]
gcode:
PRINT_END
[gcode_macro PRINT_END]
# Use PRINT_END for the slicer ending script - please customise for your slicer of choice
gcode:
M400 ; wait for buffer to clear
G92 E0 ; zero the extruder
G1 E-1.0 F3600 ; retract filament
G91 ; relative positioning
G0 Z5.00 ; move up to clear print
G90
TURN_OFF_HEATERS
M107 ; turn off fan
G90 ; absolute positioning
G0 X210 Y290 F3600 ; park nozzle at rear over bucket
set_led_effect effect=chassis_printing stop=1
set_led_effect effect=chassis_endprint
UPDATE_DELAYED_GCODE ID=idle_leds DURATION=300
[delayed_gcode idle_leds]
gcode:
set_led_effect effect=chassis_endprint stop=1
set_led_effect effect=chassis_printing stop=1
set_led_effect effect=chassis_idle
[gcode_macro CLEAN_NOZZLE]
# If you are putting your purge bucket at the rear left of the bed as per default installation, enable True on your location_bucket_rear
# variable. If you want to put your purge bucket elsewhere (perhaps the front), then set it to False. See diagrams and description
# further below on how to set your XY position.
variable_location_bucket_rear: True
# If you want the purging routine in your bucket enabled, set to True (and vice versa).
variable_enable_purge: False # don't purge for palette prints
# These parameters define your filament purging. The retract variable is used to retract right after purging to prevent unnecessary
# oozing. Some filament are particularly oozy and may continue to ooze out of the nozzle for a second or two after retracting. The
# ooze dwell variable makes allowance for this. Update as necessary. If you decided to not enable purge, you can ignore this section.
variable_purge_len: 15 ; Amount of filament, in mm, to purge.
variable_purge_spd: 150 ; Speed, in mm/min, of the purge.
variable_purge_temp_min: 190 ; Minimum nozzle temperature to permit a purge. Otherwise, purge will not occur.
variable_purge_ret: 0.5 ; Retract length, in mm, after purging to prevent slight oozing. Adjust as necessary.
variable_ooze_dwell: 2 ; Dwell/wait time, in seconds, after purging and retracting.
# Adjust this so that your nozzle scrubs within the brush. Currently defaulted to be a lot higher for safety. Be careful not to go too low!
variable_brush_top: 1
# These parameters define your scrubbing, travel speeds, safe z clearance and how many times you want to wipe. Update as necessary. Wipe
# direction is randomized based off whether the left or right bucket is randomly selected in the purge & scrubbing routine.
variable_clearance_z: 5 ; When traveling, but not cleaning, the clearance along the z-axis between nozzle and brush.
variable_wipe_qty: 3 ; Number of complete (A complete wipe: left, right, left OR right, left, right) wipes.
variable_prep_spd_xy: 3000 ; Travel (not cleaning) speed along x and y-axis in mm/min.
variable_prep_spd_z: 1500 ; Travel (not cleaning) speed along z axis in mm/min.
variable_wipe_spd_xy: 5000 ; Nozzle wipe speed in mm/min.
# These parameters define the size of the brush. Update as necessary. A visual reference is provided below. Note that orientation of
# parameters remain the same whether bucket is at rear or front.
#
# ← brush_width →
# _________________ ↑
# | | ↑ If you chose location_bucket_rear = True, Y position is acquired
# brush_start (x) | | brush_depth from your stepper_y position_max. Adjust your brush physically in
# |_________________| ↓ Y so that the nozzle scrubs within the brush.
# (y) ↓
# brush_front
# __________________________________________________________
# PRINTER FRONT
#
#
## For V1.8, you may need to measure where your brush is on the x axis and input manually into any of the variable_brush_start uncommented.
## For V2.4 250mm build, uncomment this below:
#variable_brush_start: 25
## For V2.4 300mm build, uncomment this below:
variable_brush_start: 50
## For V2.4 350mm build, uncomment this below:
#variable_brush_start: 263
## Starting position for purge (fixed)
variable_purge_start: 218
# This value is defaulted from brush location in CAD (rear left). Change if your brush width is different.
variable_brush_width: 45
## These are only used if location_bucket_rear is False. You specify a custom location in y axis for your brush - see diagram above. ##
variable_brush_front: 0
variable_brush_depth: 0
# These parameters define the size of your purge bucket. Update as necessary. If you decided to not enable purge, you can ignore
# this section. A visual reference is provided below. Note that orientation of parameters remain the same whether bucket is at rear
# or front.
#
# bucket_gap
# ← ---- →
# __________________________________________
# | | | |
# | | | |
# bucket_start (x) | |______| |
# | | | |
# | | | |
# |_________________|. . . |_________________|
# ← ------------- → ← ------------- →
# bucket_left_width bucket_right_width
# _______________________________________________________________________________________
# PRINTER FRONT
#
## For V2.4 250mm build, uncomment below
#variable_bucket_left_width: 42
## For V2.4 300mm build, uncomment below
#variable_bucket_left_width: 67
## For V2.4 350mm build, uncomment below
variable_bucket_left_width: 92
# These values are defaulted from bucket geometry in CAD (rear left location). Change only if you're using a custom bucket.
variable_bucket_right_width: 40
variable_bucket_gap: 22
# For V1.8, you may need to measure where your bucket start is and input into bucket_start. Otherwise, a value of 0 is for a default
# installation of purge bucket at rear left.
variable_bucket_start: 0
###############################################################################################################################################
###############################################################################################################################################
### From here on, unless you know what you're doing, it's recommended not to change anything. Feel free to peruse the code and reach out to me
### (edwardyeeks#6042) on Discord if you spot any problems!
###############################################################################################################################################
###############################################################################################################################################
# Placeholder. The variable will later be set to contain, at random, a number representing the left or right bucket.
variable_bucket_pos: 1
gcode:
# First, check if the axes are homed.
{% if "xyz" in printer.toolhead.homed_axes %}
## Save the gcode state in this macro instance.
SAVE_GCODE_STATE NAME=CLEAN_NOZZLE
## Set to absolute positioning.
G90
## Grab max position of Y-axis from config to use in setting a fixed y position for location_bucket_rear = True.
{% set Ry = printer.configfile.config["stepper_y"]["position_max"]|float %}
## Check if user enabled purge option or not.
{% if enable_purge %}
### Raise Z for travel.
G1 Z{brush_top + clearance_z} F{prep_spd_z}
### Check if user chose to use rear location.
{% if location_bucket_rear %}
G1 Y{Ry} F{prep_spd_xy}
{% else %}
G1 Y{brush_front + (brush_depth / 2)} F{prep_spd_xy}
{% endif %}
G1 X{purge_start} F{prep_spd_xy}
### Perform purge if the temp is up to min temp. If not, it will skip and continue executing rest of macro. Small retract after
### purging to minimize any persistent oozing at 5x purge_spd. G4 dwell is in milliseconds, hence * 1000 in formula.
{% if printer.extruder.temperature >= purge_temp_min %}
M83 ; relative mode
G1 E{purge_len} F{purge_spd}
G1 E-{purge_ret} F{purge_spd * 5}
G4 P{ooze_dwell * 1000}
G92 E0 ; reset extruder
{% endif %}
{% endif %}
## Position for wipe. Either left or right of brush based off bucket_pos to avoid unnecessary travel.
G1 Z{brush_top + clearance_z} F{prep_spd_z}
G1 X{brush_start + (brush_width * bucket_pos)} F{prep_spd_xy}
## Check if user chose to use rear location.
{% if location_bucket_rear %}
G1 Y{Ry}
{% else %}
G1 Y{brush_front + (brush_depth / 2)}
{% endif %}
## Move nozzle down into brush.
G1 Z{brush_top} F{prep_spd_z}
## Perform wipe. Wipe direction based off bucket_pos for cool random scrubby routine.
{% for wipes in range(1, (wipe_qty + 1)) %}
G1 X{brush_start + (brush_width * (1 - bucket_pos))} F{wipe_spd_xy}
G1 X{brush_start + (brush_width * bucket_pos)} F{wipe_spd_xy}
{% endfor %}
## Clear from area.
M117 Cleaned!
G1 Z{brush_top + clearance_z} F{prep_spd_z}
## Restore the gcode state to how it was before the macro.
RESTORE_GCODE_STATE NAME=CLEAN_NOZZLE
{% else %}
## raise error will stop any macros that clean_nozzle is referenced in from proceeding for safety.
{ action_raise_error("Please home your axes!") }
M117 Please home first!
{% endif %}
[respond]
[gcode_macro PA_TUNER]
description: Pressure Advance Tuning Macro
=========================================
parameters with defaults listed below:
TOOLHEAD=""
BED_X_LENGTH=235
BED_Y_LENGTH=235
FILAMENT_DIAMETER=1.75
EXTRUSION_WIDTH=0.4
LAYER_HEIGHT=0.3
SIDE_LENGTH=100
FAST_PRINT_SPEED=250
SLOW_PRINT_SPEED=75
COOLING_FAN_SPEED=255
PA_MIN=0.0
PA_MAX=1.0
LAYERS=60
BED_TEMP=110
PRINTING_TEMP=250
X_OFFSET=0
Y_OFFSET=0
STARTUP_MACRO=LOCAL_GENERIC_PA_START
END_MACRO=LOCAL_GENERIC_PA_END
=========================================
gcode:
# Set your own default parameters here
{% set bed_x = params.BED_X_LENGTH|default(printer.toolhead.axis_maximum.x)|float %}
{% set bed_y = params.BED_Y_LENGTH|default(printer.toolhead.axis_maximum.y)|float %}
{% set filament_d = params.FILAMENT_DIAMETER|default(printer.configfile.settings.extruder.filament_diameter)|float %}
{% set e_width = params.EXTRUSION_WIDTH|default(printer.configfile.settings.extruder.nozzle_diameter)|float %}
{% set tool = params.TOOLHEAD|default("") %}
{% set rect_side_len = params.SIDE_LENGTH|default(100.0)|float %}
{% set layer_h = params.LAYER_HEIGHT|default(0.2)|float %}
{% set fspeed = params.FAST_PRINT_SPEED|default(250.0)|float %}
{% set sspeed = params.SLOW_PRINT_SPEED|default(75.0)|float %}
{% set fan_speed = params.COOLING_FAN_SPEED|default(255.0)|float %}
{% set PA_low = params.PA_MIN|default(0.0)|float %}
{% set PA_high = params.PA_MAX|default(1.0)|float %}
{% set b_temp = params.BED_TEMP|default(110.0)|float %}
{% set p_temp = params.PRINTING_TEMP|default(250.0)|float %}
{% set off_x = params.X_OFFSET|default(0.0)|float %}
{% set off_y = params.Y_OFFSET|default(0.0)|float %}
{% set layer_num = params.LAYERS|default(60)|int %}
{% set startup_code = params.STARTUP_MACRO|default("LOCAL_GENERIC_PA_START PT=" ~ p_temp ~ " BT=" ~ b_temp)|string %}
{% set end_code = params.END_MACRO|default("LOCAL_GENERIC_PA_END EJECT=" ~ bed_y)|string %}
# End default parameters
{% set PA_const = (2 * ((PA_high - PA_low) / layer_num)) - PA_low %}
{% if PA_const < 0 %}
{% set PA_sign = " + " %}
{% else %}
{% set PA_sign = " - " %}
{% endif %}
{% set info_str = "Bed X Length: " ~ bed_x %}
RESPOND MSG="{info_str}"
{% set info_str = "Bed Y Length: " ~ bed_y %}
RESPOND MSG="{info_str}"
{% set info_str = "Bed X Offset: " ~ off_x %}
RESPOND MSG="{info_str}"
{% set info_str = "Bed Y Offset: " ~ off_y %}
RESPOND MSG="{info_str}"
{% set info_str = "Extrusion Width: " ~ e_width %}
RESPOND MSG="{info_str}"
{% set info_str = "Filament size: " ~ filament_d %}
RESPOND MSG="{info_str}"
{% set info_str = "Layer Height: " ~ layer_h %}
RESPOND MSG="{info_str}"
{% set info_str = "Bed Temperature: " ~ b_temp %}
RESPOND MSG="{info_str}"
{% set info_str = "Print Temperature: " ~ p_temp %}
RESPOND MSG="{info_str}"
{% set info_str = "Slow Printing Speed: " ~ sspeed %}
RESPOND MSG="{info_str}"
{% set info_str = "Fast Printing Speed: " ~ fspeed %}
RESPOND MSG="{info_str}"
{% set info_str = "Fan Speed: " ~ fan_speed %}
RESPOND MSG="{info_str}"
{% set info_str = "Length of Test Square: " ~ rect_side_len %}
RESPOND MSG="{info_str}"
{% set info_str = "Number of Layers: " ~ layer_num %}
RESPOND MSG="{info_str}"
{% set info_str = "Minimum Pressure Advance: " ~ PA_low %}
RESPOND MSG="{info_str}"
{% set info_str = "Maximum Pressure Advance: " ~ PA_high %}
RESPOND MSG="{info_str}"
{% set info_str = "Formula: Pressure Advance Value = Measured_Z_Height x " ~ (((PA_high - PA_low) / layer_num) / layer_h) ~ PA_sign ~ PA_const|abs %}
RESPOND MSG="{info_str}"
{% set g_cmd = tool %}
{ g_cmd }
{% set g_cmd = startup_code %}
{ g_cmd }
{% set g_cmd = "M220 S100" %}
{ g_cmd }
{% set g_cmd = "M221 S100" %}
{ g_cmd }
{% set g_cmd = "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=1 ACCEL=500" %}
{ g_cmd }
{% set g_cmd = "SET_PRESSURE_ADVANCE ADVANCE_LOOKAHEAD_TIME=0" %}
{ g_cmd }
{% set g_cmd = "G92 E0" %}
{ g_cmd }
{% set g_cmd = "M83" %}
{ g_cmd }
{% set current_x = namespace(value=((bed_x / 2) - (rect_side_len / 2))) %}
{% set current_y = namespace(value=((bed_y / 2) - (rect_side_len / 2))) %}
{% set current_z = namespace(value=layer_h) %}
# move the printhead to the starting position and prime nozzle
{% set g_cmd = "G1 X" ~ (current_x.value + off_x) ~ " Y" ~ (current_y.value + off_y) ~ " Z" ~ current_z.value ~ " E1.0 F" ~ (fspeed*60) %}
{ g_cmd }
{% set pressure_advance = 0.0 %}
{% set PA_msg = "SET_PRESSURE_ADVANCE ADVANCE=" ~ pressure_advance %}
{ PA_msg }
pa_line LSPEED={20} X_CORD={current_x.value} Y_CORD={current_y.value} X_L={rect_side_len} Y_L=0.0 FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + rect_side_len %}
{% set current_y.value = current_y.value + 0 %}
pa_line LSPEED={20} X_CORD={current_x.value} Y_CORD={current_y.value} X_L={0.0} Y_L={(rect_side_len/2)} FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + 0 %}
{% set current_y.value = current_y.value + (rect_side_len / 2) %}
pa_line LSPEED={20} X_CORD={current_x.value} Y_CORD={current_y.value} X_L=0.0 Y_L={(rect_side_len/2)} FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + 0 %}
{% set current_y.value = current_y.value + (rect_side_len / 2) %}
pa_line LSPEED={20} X_CORD={current_x.value} Y_CORD={current_y.value} X_L={0-rect_side_len} Y_L=0.0 FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value - rect_side_len %}
{% set current_y.value = current_y.value + 0 %}
pa_line LSPEED={20} X_CORD={current_x.value} Y_CORD={current_y.value} X_L=0.0 Y_L={0-rect_side_len} FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + 0 %}
{% set current_y.value = current_y.value - rect_side_len %}
{% set current_z.value = current_z.value + layer_h %}
{% set g_cmd = "G1 Z" ~ current_z.value %}
{ g_cmd }
#start cooling fan
{% set g_cmd = "M106 S" ~ fan_speed %}
{ g_cmd }
{% for i in range(layer_num) %}
{% set pressure_advance = (i / layer_num) * (PA_high - PA_low) + PA_low|float %}
{% set PA_msg = "SET_PRESSURE_ADVANCE ADVANCE=" ~ pressure_advance %}
{ PA_msg }
pa_line LSPEED={fspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L={rect_side_len} Y_L=0.0 FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + rect_side_len %}
{% set current_y.value = current_y.value + 0 %}
pa_line LSPEED={fspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L=0.0 Y_L={(rect_side_len/2)} FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + 0 %}
{% set current_y.value = current_y.value + (rect_side_len / 2) %}
pa_line LSPEED={sspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L=0.0 Y_L={(rect_side_len/2)} FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + 0 %}
{% set current_y.value = current_y.value + (rect_side_len / 2) %}
pa_line LSPEED={fspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L={0-rect_side_len} Y_L=0.0 FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value - rect_side_len %}
{% set current_y.value = current_y.value + 0 %}
pa_line LSPEED={sspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L=0.0 Y_L={0-rect_side_len} FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + 0 %}
{% set current_y.value = current_y.value - rect_side_len %}
{% set current_z.value = current_z.value + layer_h %}
{% set g_cmd = "G1 Z" ~ current_z.value %}
{ g_cmd }
{% endfor %}
#print two finishing layers at PA_MAX
{% set pressure_advance = PA_high|float %}
{% set PA_msg = "SET_PRESSURE_ADVANCE ADVANCE=" ~ pressure_advance %}
{ PA_msg }
pa_line LSPEED={fspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L={rect_side_len} Y_L=0.0 FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + rect_side_len %}
{% set current_y.value = current_y.value + 0 %}
pa_line LSPEED={fspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L=0.0 Y_L={(rect_side_len/2)} FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + 0 %}
{% set current_y.value = current_y.value + (rect_side_len / 2) %}
pa_line LSPEED={sspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L=0.0 Y_L={(rect_side_len/2)} FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + 0 %}
{% set current_y.value = current_y.value + (rect_side_len / 2) %}
pa_line LSPEED={fspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L={0-rect_side_len} Y_L=0.0 FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value - rect_side_len %}
{% set current_y.value = current_y.value + 0 %}
pa_line LSPEED={sspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L=0.0 Y_L={0-rect_side_len} FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + 0 %}
{% set current_y.value = current_y.value - rect_side_len %}
{% set current_z.value = current_z.value + layer_h %}
{% set g_cmd = "G1 Z" ~ current_z.value %}
{ g_cmd }
pa_line LSPEED={fspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L={rect_side_len} Y_L=0.0 FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + rect_side_len %}
{% set current_y.value = current_y.value + 0 %}
pa_line LSPEED={fspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L=0.0 Y_L={(rect_side_len/2)} FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + 0 %}
{% set current_y.value = current_y.value + (rect_side_len / 2) %}
pa_line LSPEED={sspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L=0.0 Y_L={(rect_side_len/2)} FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + 0 %}
{% set current_y.value = current_y.value + (rect_side_len / 2) %}
pa_line LSPEED={fspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L={0-rect_side_len} Y_L=0.0 FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value - rect_side_len %}
{% set current_y.value = current_y.value + 0 %}
pa_line LSPEED={sspeed} X_CORD={current_x.value} Y_CORD={current_y.value} X_L=0.0 Y_L={0-rect_side_len} FD={filament_d} EW={e_width} LH={layer_h} X_OFFS={off_x} Y_OFFS={off_y}
{% set current_x.value = current_x.value + 0 %}
{% set current_y.value = current_y.value - rect_side_len %}
{% set current_z.value = current_z.value + layer_h %}
{% set g_cmd = "G1 Z" ~ current_z.value %}
{ g_cmd }
{% set g_cmd = end_code %}
{ g_cmd }
{% set info_str = "Bed X Length: " ~ bed_x %}
RESPOND MSG="{info_str}"
{% set info_str = "Bed Y Length: " ~ bed_y %}
RESPOND MSG="{info_str}"
{% set info_str = "Bed X Offset: " ~ off_x %}
RESPOND MSG="{info_str}"
{% set info_str = "Bed Y Offset: " ~ off_y %}
RESPOND MSG="{info_str}"
{% set info_str = "Extrusion Width: " ~ e_width %}
RESPOND MSG="{info_str}"
{% set info_str = "Filament size: " ~ filament_d %}
RESPOND MSG="{info_str}"
{% set info_str = "Layer Height: " ~ layer_h %}
RESPOND MSG="{info_str}"
{% set info_str = "Bed Temperature: " ~ b_temp %}
RESPOND MSG="{info_str}"
{% set info_str = "Print Temperature: " ~ p_temp %}
RESPOND MSG="{info_str}"
{% set info_str = "Slow Printing Speed: " ~ sspeed %}
RESPOND MSG="{info_str}"
{% set info_str = "Fast Printing Speed: " ~ fspeed %}
RESPOND MSG="{info_str}"
{% set info_str = "Fan Speed: " ~ fan_speed %}
RESPOND MSG="{info_str}"
{% set info_str = "Length of Test Square: " ~ rect_side_len %}
RESPOND MSG="{info_str}"
{% set info_str = "Number of Layers: " ~ layer_num %}
RESPOND MSG="{info_str}"
{% set info_str = "Minimum Pressure Advance: " ~ PA_low %}
RESPOND MSG="{info_str}"
{% set info_str = "Maximum Pressure Advance: " ~ PA_high %}
RESPOND MSG="{info_str}"
{% set info_str = "Formula: Pressure Advance Value = Measured_Z_Height x " ~ (((PA_high - PA_low) / layer_num) / layer_h) ~ PA_sign ~ PA_const|abs %}
RESPOND MSG="{info_str}"
[gcode_macro pa_line]
gcode:
{% set zoomy = params.LSPEED|default(50.0)|float %}
{% set x_now = params.X_CORD|default(0.0)|float %}
{% set y_now = params.Y_CORD|default(0.0)|float %}
{% set x_lin = params.X_L|default(100.0)|float %}
{% set y_lin = params.Y_L|default(100.0)|float %}
{% set f_size = params.FD|default(1.75)|float %}
{% set e_size = params.EW|default(0.4)|float %}
{% set l_size = params.LH|default(0.2)|float %}
{% set xo = params.X_OFFS|default(0.0)|float %}
{% set yo = params.Y_OFFS|default(0.0)|float %}
{% set lin_length = (x_lin**2 + y_lin**2)**(1/2) %}
{% set e_len = lin_length / (f_size * f_size * 3.14159 * 0.25) %}
{% set e_num = e_len * e_size * l_size * 1.67 %}
{% set g_cmd = "G1 X" ~ (x_lin + x_now + xo) ~ " Y" ~ (y_lin + y_now + yo) ~ " E" ~ e_num ~ " F" ~ (zoomy*60) %}
{ g_cmd }
[gcode_macro LOCAL_GENERIC_PA_START ]
description: Generic startup gcode with a prime strip
gcode:
{% set b_t = params.BT|default(0.0)|float %}
{% set p_t = params.PT|default(0.0)|float %}
{% set g_cmd = "M140 S" ~ b_t %}
{ g_cmd }
{% set g_cmd = "M104 S" ~ p_t %}
{ g_cmd }
{% set g_cmd = "M190 S" ~ b_t %}
{ g_cmd }
{% set g_cmd = "G28" %}
{ g_cmd }
{% set g_cmd = "G1 Z10 F1500" %}
{ g_cmd }
{% set g_cmd = "M109 S" ~ p_t %}
{ g_cmd }
{% set g_cmd = "G92 E0" %}
{ g_cmd }
{% set g_cmd = "G1 Z2.0 F3000" %}
{ g_cmd }
{% set g_cmd = "G1 X0.1 Y20 Z0.3 F5000.0" %}
{ g_cmd }
{% set g_cmd = "G1 X0.1 Y200.0 Z0.3 F1500.0 E15" %}
{ g_cmd }
{% set g_cmd = "G1 X0.4 Y200.0 Z0.3 F5000.0" %}
{ g_cmd }
{% set g_cmd = "G1 X0.4 Y20 Z0.3 F1500.0 E30" %}
{ g_cmd }
{% set g_cmd = "G92 E0" %}
{ g_cmd }
{% set g_cmd = "G1 Z2.0 F3000" %}
{ g_cmd }
[gcode_macro LOCAL_GENERIC_PA_END ]
description: Generic ending gcode
gcode:
{% set y_done = params.EJECT|default(0.0)|float %}
{% set g_cmd = "G91" %}
{ g_cmd }
{% set g_cmd = "G1 Z10 F450" %}
{ g_cmd }
{% set g_cmd = "G90" %}
{ g_cmd }
{% set g_cmd = "M82" %}
{ g_cmd }
{% set g_cmd = "G1 X0 Y" ~ y_done %}
{ g_cmd }
{% set g_cmd = "M106 S0" %}
{ g_cmd }
{% set g_cmd = "M104 S0" %}
{ g_cmd }
{% set g_cmd = "M140 S0" %}
{ g_cmd }
{% set g_cmd = "M84" %}
{ g_cmd }
## Thermistor Types
## "EPCOS 100K B57560G104F"
## "ATC Semitec 104GT-2"
## "NTC 100K beta 3950"
## "Honeywell 100K 135-104LAG-J01"
## "NTC 100K MGB18-104F39050L32" (Keenovo Heater Pad)
## "AD595"
## "PT100 INA826"
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [stepper_z]
#*# position_endstop = -0.070
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment