Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sanmadjack/d1e97149dd17c2d845d08d746c5e0c01 to your computer and use it in GitHub Desktop.
Save sanmadjack/d1e97149dd17c2d845d08d746c5e0c01 to your computer and use it in GitHub Desktop.
Klipper Ender 3 Sprite SKR Mini E3 V2.0 BLTouch SFS V2 Printer Config
################################################################
# Configuration for printer composed of:
# Creality Ender 3
# SKR Mini E3 v2 Mainboard
# Raspberry Pi 3 Model B Plus Rev 1.3
# Bltouch bed level sensor
# Creality Sprite Extruder Pro
# BTT SFS V2.0 Smart Filament Sensor
################################################################
# Custom macros are used to contain standardized code, slicer gcode calls these macros.
# The g-code below is used in Orca Slicer, but can be used in Prusa Slicer with minimal modifications.
# Start g-code is intended to use adaptive bed meshes, together with Orca Slicer's support.
# Omit PRINT_MIN, PRINT_MAX, MESH_ALGORITHM, and PROBE_COUNT to disable adaptive bed mesh.
# The load and unload macros don't work great (if at all), as the direct drive head really needs to be loaded and unloaded manually.
################################################################
# Start G-Code:
# SET_PRINT_STATS_INFO TOTAL_LAYER=[total_layer_count]
# START_PRINT EXTRUDER_TEMP={first_layer_temperature[0]} BED_TEMP={first_layer_bed_temperature[0]} PRINT_MIN={adaptive_bed_mesh_min[0]},{adaptive_bed_mesh_min[1]} PRINT_MAX={adaptive_bed_mesh_max[0]},{adaptive_bed_mesh_max[1]} MESH_ALGORITHM=[bed_mesh_algo] PROBE_COUNT={bed_mesh_probe_count[0]},{bed_mesh_probe_count[1]}
################################################################
# End g-code:
# END_PRINT MAX_Z={first_layer_print_max[2]}
# ; total layers count = [total_layer_count]
################################################################
# Before layer change g-code:
# ;BEFORE_LAYER_CHANGE
# ;[layer_z]
# G92 E0
################################################################
# After layer change g-code:
# ;AFTER_LAYER_CHANGE
# SET_PRINT_STATS_INFO CURRENT_LAYER={layer_num + 1}
# ;{layer_z}
################################################################
# Change gilament g-code:
# PAUSE
################################################################
# Pause g-code:
# M0
################################################################
[include mainsail.cfg]
[include timelapse.cfg]
[stepper_x]
step_pin: PB13
dir_pin: !PB12
enable_pin: !PB14
microsteps: 16
rotation_distance: 40
endstop_pin: ^PC0
position_endstop: 0
position_max: 247
homing_speed: 50
[tmc2209 stepper_x]
uart_pin: PC11
tx_pin: PC10
uart_address: 0
run_current: 0.580
stealthchop_threshold: 999999
[stepper_y]
step_pin: PB10
dir_pin: !PB2
enable_pin: !PB11
microsteps: 16
rotation_distance: 40
endstop_pin: ^PC1
position_endstop: 0
position_max: 235
homing_speed: 50
[tmc2209 stepper_y]
uart_pin: PC11
tx_pin: PC10
uart_address: 2
run_current: 0.580
stealthchop_threshold: 999999
[stepper_z]
step_pin: PB0
dir_pin: PC5
enable_pin: !PB1
microsteps: 16
rotation_distance: 8
endstop_pin: probe:z_virtual_endstop
#position_endstop: 0.0
position_max: 250
position_min: -10
[tmc2209 stepper_z]
uart_pin: PC11
tx_pin: PC10
uart_address: 1
run_current: 1.160
stealthchop_threshold: 999999
[extruder]
step_pin: PB3
dir_pin: !PB4
enable_pin: !PD2
microsteps: 16
gear_ratio: 3.5:1
rotation_distance: 26.095
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PC8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA0
#control: pid
#pid_Kp: 21.527
#pid_Ki: 1.063
#pid_Kd: 108.982
min_temp: 0
max_temp: 300
min_extrude_temp: 170
max_extrude_only_distance: 1000.0
[tmc2209 extruder]
uart_pin: PC11
tx_pin: PC10
uart_address: 3
run_current: 0.650
stealthchop_threshold: 999999
# The switch sensor cable (red/blue) is plugged into EO-STOP (PC15),
# and the motion sensor cable (green/black) into PWR-DET (PC12).
# This is becayse PWR-DET doesn't provide power, while E0-STOP provides 5V.
# These use the prefix "filament_sensor" so that the home assistant moonraker integration will pick them up.
[filament_switch_sensor filament_sensor_presence]
switch_pin: PC15
pause_on_runout: False
runout_gcode:
FILAMENT_RUNOUT
# insert_gcode:
# M117 Filament switch inserted
[filament_motion_sensor filament_sensor_motion]
switch_pin: PC12
detection_length: 10
extruder: extruder
pause_on_runout: False
runout_gcode:
FILAMENT_STUCK
# # insert_gcode:
# M117 Filament encoder inserted
[safe_z_home]
home_xy_position: 117.5,117.5 # Change coordinates to the center of your print bed
z_hop: 10 # Move up 10mm
z_hop_speed: 5
[bltouch]
sensor_pin: ^PC14
control_pin: PA1
x_offset: -31.8
y_offset: -40.5
#z_offset: 4 # z_offset is saved in SAVE_CONFIG section below
speed:35
samples:3
samples_result: median
samples_tolerance: 0.0075
samples_tolerance_retries: 10
probe_with_touch_mode: true
stow_on_each_sample: false
[bed_mesh]
speed: 80
horizontal_move_z: 5
mesh_min: 20,20
mesh_max: 190,190
probe_count: 5,5
[heater_bed]
heater_pin: PC9
sensor_type: ATC Semitec 104GT-2
sensor_pin: PC3
#control: pid
#pid_Kp: 54.027
#pid_Ki: 0.770
#pid_Kd: 948.182
min_temp: 0
max_temp: 130
[temperature_fan mcu_fan]
pin: PC7
sensor_type: temperature_mcu
sensor_mcu: mcu
control: watermark
min_temp: 10
max_temp: 65
target_Temp: 25
[fan]
pin: PC6
[mcu]
serial: /dev/serial/by-id/usb-Klipper_stm32f103xe_35FFDC054246303038681457-if00
[screws_tilt_adjust]
screw1: 74,47
screw1_name: front left screw
screw2: 245, 47
screw2_name: front right screw
screw3: 245, 217
screw3_name: rear right screw
screw4: 74,217
screw4_name: rear left screw
screw_thread: CW-M4
[bed_screws]
screw1: 30.5, 37
screw1_name: Front left screw
screw2: 30.5, 207
screw2_name: Rear left screw
screw3: 204.5, 207
screw3_name: Rear right screw
screw4: 204.5, 37
screw4_name: Front right screw
[virtual_sdcard]
path: ~/printer_data/gcodes
[display_status]
[pause_resume]
[respond]
[save_variables]
filename: ~/printer_data/variables.cfg # UPDATE THIS FOR YOUR PATH!!!
[exclude_object]
[gcode_macro FILAMENT_RUNOUT]
gcode:
M300 S1 P10
M600
M300 S1 P10
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
variable_park: True
gcode:
## Move head and retract only if not already in the pause state and park set to true
#{% if printer.pause_resume.is_paused|lower == 'false' and park|lower == 'true'%}
# _TOOLHEAD_PARK_PAUSE_CANCEL
#{% endif %}
END_PRINT
BASE_CANCEL_PRINT
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
gcode:
PAUSE_BASE
_TOOLHEAD_PARK_PAUSE_CANCEL
[gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL]
description: Helper: park toolhead used in PAUSE and CANCEL_PRINT
variable_extrude: 2.0
gcode:
{% set timeout = printer.configfile.settings.idle_timeout.timeout %}
{ "SET_IDLE_TIMEOUT TIMEOUT=3600" if timeout < 3600 }
##### set park positon for x and y #####
# default is your max position 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 %}
# {% set z_park_delta = 5.0 %}
{% set x_park = 125 %}
{% set y_park = 50 %}
{% set z_park_delta = 50 %}
##### calculate safe lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - z_park_delta) %}
{% set z_safe = z_park_delta %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
M83
G1 E-{extrude} F2100
{% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %}
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G91
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F6000
{% if printer.gcode_move.absolute_coordinates|lower == 'false' %} G91 {% endif %}
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
[gcode_macro M600]
gcode:
SAVE_GCODE_STATE NAME=M600_state
PAUSE
RESTORE_GCODE_STATE NAME=M600_state
; This pauses the print if the filament motion sensor detects the filament is not moving.
; Since this can also occur when filament has runout, we check the filament presence dectector before pausing the print.
; This is so the FILAMENT_RUNOUT can do its job and wait to pause until the printer has consumed the filament in the tube.
[gcode_macro FILAMENT_STUCK]
gcode:
{% if printer["filament_switch_sensor filament_sensor_presence"].filament_detected %}
M117 Filament stuck!
SAVE_GCODE_STATE NAME=FILAMENT_STUCK_state
PAUSE
RESTORE_GCODE_STATE NAME=FILAMENT_STUCK_state
{% endif %}
; From https://www.reddit.com/r/klippers/comments/lnadlr/runout_sensor_macro/?utm_source=share&utm_medium=ios_app&utm_name=iossmf
; This detects the runout sensor being activated, but allows it to continue printing until the plastic in the tube is mostly consumed.
; This is a direct drive setup, this would not work with the extruder next to the sensor.
[gcode_macro FILAMENT_RUNOUT]
variable_filament_consumed: 0
variable_filament_length: 250 # length between the sensor and extruder
gcode:
# save current filament consumption
SET_GCODE_VARIABLE MACRO=FILAMENT_RUNOUT VARIABLE=filament_consumed VALUE={printer.print_stats.filament_used}
# start checking filament consumption
UPDATE_DELAYED_GCODE ID=DELAY_M600 DURATION=1
[delayed_gcode DELAY_M600]
gcode:
# use set for easier reading
{% set consumed=printer["gcode_macro FILAMENT_RUNOUT"].filament_consumed %}
{% set length=printer["gcode_macro FILAMENT_RUNOUT"].filament_length %}
# check if predetermine length is reached
{% if printer.print_stats.filament_used|float <= (consumed|float + length|float) %}
# start looping this script every second
UPDATE_DELAYED_GCODE ID=DELAY_M600 DURATION=1
{% else %}
M600
{% endif %}
[gcode_macro MOVE_TO_SERVICING_POSITION]
variable_z_offset: 0
variable_x: 125
variable_y: 50
variable_z: 80
gcode:
{% set z = z + z_offset %}
RESPOND TYPE=echo MSG='Moving to servicing position at {x}, {y}, {z}'
G1 X{x} Y{y} Z{z} ; move to the position
[gcode_macro UNLOAD_FILAMENT]
gcode:
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(220)|float %}
M104 S{EXTRUDER_TEMP}
{% if printer.toolhead.homed_axes != "xyz" %}
G28
MOVE_TO_SERVICING_POSITION
{% endif %}
RESPOND TYPE=echo MSG='Waiting for nozzle to heat'
M109 S{EXTRUDER_TEMP}
RESPOND TYPE=echo MSG='Retracting filament'
M83 ; set extruder to relative
G1 E10 F300 ; extrude a little to soften tip
G1 E-100 F3000 ; jerk the filament out of the melt zone
M104 S0 ; Set nozzle temp to zero
{% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %}
M400
M118 E1 Unload done
[gcode_macro LOAD_FILAMENT]
gcode:
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(220)|float %}
M104 S{EXTRUDER_TEMP}
{% if printer.toolhead.homed_axes != "xyz" %}
G28
MOVE_TO_SERVICING_POSITION
{% endif %}
RESPOND TYPE=echo MSG='Waiting for nozzle to heat'
M109 S{EXTRUDER_TEMP}
RESPOND TYPE=echo MSG='Advancing filament'
M83 ; set extruder to relative
G1 E100 F300 ; prime nozzle with filament
{% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %}
M400
M118 E1 Load done
[gcode_macro END_PRINT]
gcode:
CLEAR_PAUSE
# Turn off bed, extruder, and fan
TURN_OFF_HEATERS
M106 S0
# Move nozzle away from print while retracting
G91
G1 X-2 Y-2 E-1 F300
# Raise nozzle by 10mm
G1 Z50 F3000
#PRESENT_PRINT_BED
G90
# Disable steppers
#M84
[gcode_macro START_PRINT]
gcode:
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(190)|float %}
{% set PRINT_MIN = params.PRINT_MIN|default([printer.toolhead.axis_minimum.x+20,printer.toolhead.axis_minimum.y+20] | join(","))|string %}
{% set PRINT_MAX = params.PRINT_MAX|default([printer.toolhead.axis_maximum.x-20,printer.toolhead.axis_maximum.y-20] | join(","))|string %}
{% set MESH_ALGORITHM = params.MESH_ALGORITHM|default("lagrange")|string %}
{% set PROBE_COUNT = params.PROBE_COUNT|default("5,5")|string %}
G90 ; use absolute coordinates
M83 ; extruder relative mode
M104 S150 ; set temporary nozzle temp to prevent oozing during homing
M140 S{BED_TEMP} ; set final bed temp
G4 S30 ; allow partial nozzle warmup
G28 ; home all axis
BED_MESH_CALIBRATE mesh_min={PRINT_MIN} mesh_max={PRINT_MAX} ALGORITHM={MESH_ALGORITHM} PROBE_COUNT={PROBE_COUNT} ADAPTIVE=1 ADAPTIVE_MARGIN=0
#BED_MESH_CALIBRATE
#BED_MESH_PROFILE LOAD=default
MOVE_TO_SERVICING_POSITION
M104 S{EXTRUDER_TEMP} ; set final nozzle temp
M190 S{BED_TEMP} ; wait for bed temp to stabilize
M109 S{EXTRUDER_TEMP} ; wait for nozzle temp to stabilize
# G1 Z0.28 F240
# G92 E0
# G1 X2.0 Y140 E10 F1500 ; first purge line
# G1 X2.3 Y140 F5000
# G92 E0
# G1 X2.3 Y10 E10 F1200 ; second purge line
G92 E0
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
[static_digital_output usb_pullup_enable]
pins: !PA14
[board_pins]
aliases:
# EXP1 header
EXP1_1=PB5, EXP1_3=PA9, EXP1_5=PA10, EXP1_7=PB8, EXP1_9=<GND>,
EXP1_2=PA15, EXP1_4=<RST>, EXP1_6=PB9, EXP1_8=PB15, EXP1_10=<5V>
# See the sample-lcd.cfg file for definitions of common LCD displays.
[display]
lcd_type: emulated_st7920
en_pin: EXP1_7
spi_software_sclk_pin: EXP1_6
spi_software_mosi_pin: EXP1_8
spi_software_miso_pin: PA3
encoder_pins: ^EXP1_5, ^EXP1_3
click_pin: ^!EXP1_2
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [bltouch]
#*# z_offset = 3.900
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 0.230000, 0.050000, -0.195000, -0.340000
#*# 0.237500, 0.040000, -0.160000, -0.385000
#*# 0.172500, 0.015000, -0.227500, -0.457500
#*# 0.137500, -0.047500, -0.270000, -0.487500
#*# x_count = 4
#*# y_count = 4
#*# mesh_x_pps = 2
#*# mesh_y_pps = 2
#*# algo = bicubic
#*# tension = 0.2
#*# min_x = 54.2903
#*# max_x = 165.68030000000002
#*# min_y = 54.2907
#*# max_y = 165.6807
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 21.254
#*# pid_ki = 1.389
#*# pid_kd = 81.298
#*#
#*# [heater_bed]
#*# control = pid
#*# pid_kp = 69.736
#*# pid_ki = 1.560
#*# pid_kd = 779.294
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment