Skip to content

Instantly share code, notes, and snippets.

@mpalpha
Last active January 12, 2022 23:38
Show Gist options
  • Save mpalpha/2951f91275ae945489ba8b22353bacee to your computer and use it in GitHub Desktop.
Save mpalpha/2951f91275ae945489ba8b22353bacee to your computer and use it in GitHub Desktop.
klipper config for Creativity ELF - raspberry pi 4 + dragonfly BMS hotend + orbiter + 5x TMC2209 (uart) + FYSTEC black pei magnetic bed + abl via mini ir sensor (by david crocker)
[input_shaper]
shaper_type_y: ei
shaper_freq_y: 47.8
shaper_type_x: 2hump_ei
shaper_freq_x: 60.8
shaper_type: mzv
[static_digital_output reset_display]
pins: !PC6, !PD13 # disable unsupported display
[stepper_x]
step_pin: PE3
dir_pin: PE2
enable_pin: !PE4
microsteps: 16
rotation_distance: 40
endstop_pin: PA15
position_endstop: 300
position_max: 300
homing_speed: 60
homing_retract_dist: 3
[tmc2209 stepper_x]
uart_pin:PC13
interpolate: True
run_current: 0.600
hold_current: 0.300
stealthchop_threshold: 30
driver_SGTHRS: 105
uart_address:3
[stepper_y]
step_pin: PE0
dir_pin: PB9
enable_pin: !PE1
microsteps: 16
rotation_distance: 40
endstop_pin: PA12
position_endstop: 300
position_max: 300
homing_speed: 60
homing_retract_dist: 3
[tmc2209 stepper_y]
uart_pin:PC13
interpolate: True
run_current: 0.600
hold_current: 0.300
stealthchop_threshold: 30
driver_SGTHRS: 105
uart_address:2
[stepper_z]
step_pin: PB5
dir_pin: !PB4
enable_pin: !PB8
microsteps: 16
rotation_distance: 8
endstop_pin: probe:z_virtual_endstop
position_min: -3
position_max: 340
#homing_speed: 5
#second_homing_speed: 0.5
#homing_retract_dist: 0.5
[tmc2209 stepper_z]
uart_pin: PC13
interpolate: true
run_current: 0.300
hold_current: 0.200
stealthchop_threshold: 30
uart_address: 1
[stepper_z1]
step_pin: PA6
dir_pin: !PA1
enable_pin: !PA3
microsteps: 16
rotation_distance: 8
[tmc2209 stepper_z1]
uart_pin: PC13
interpolate: true
run_current: 0.300
hold_current: 0.200
stealthchop_threshold: 30
uart_address: 0
[extruder]
step_pin: PD6
dir_pin: !PD3
enable_pin: !PB3
microsteps: 16
rotation_distance: 4.582
nozzle_diameter: 0.450
filament_diameter: 1.750
heater_pin: PC3
sensor_type: ATC Semitec 104GT-2
sensor_pin: PC1
control = pid
pid_kp = 26.580
pid_ki = 1.656
pid_kd = 106.654
pressure_advance: 0.03
min_temp: 0
max_temp: 300
max_extrude_only_distance: 151
max_extrude_cross_section:5
pwm_cycle_time:.05
[tmc2209 extruder]
uart_pin:PC7
interpolate: True
run_current: 0.30
hold_current: 0.2
stealthchop_threshold: 5
driver_HSTRT: 0
driver_TBL: 2
driver_HEND: 2
driver_TOFF: 6
uart_address:0
driver_SGTHRS: 100 #related to homing speed
[heater_bed]
heater_pin: PA0
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC0
pwm_cycle_time: 0.017
max_power: 0.6
min_temp: 0
max_temp: 120
control = pid
pid_kp = 65.362
pid_ki = 1.175
pid_kd = 909.344
[fan]
pin: PB1
# adxl345 section
#[mcu rpi]
#serial: /tmp/klipper_host_mcu
[mcu]
serial: /dev/ttyAMA0
restart_method: command
[printer]
kinematics: corexy
max_velocity: 300
max_accel: 5300 #Max 4000
max_accel_to_decel: 3975
max_z_velocity: 25 #Max 15 for 12V TMC Drivers, can increase for 24V
max_z_accel: 250
square_corner_velocity: 5.0
#[adxl345]
#cs_pin: rpi:None
#[resonance_tester]
#accel_chip: adxl345
#probe_points:
# 150,150,20 # an example
# Keeps Debug LED off / not floating
#[static_digital_output debug_led]
#pins: !PB7
[probe]
pin: ^PA8
x_offset: 0
y_offset: -50
#z_offset: 0.5
lift_speed:0.5
speed: 0.25
samples: 4
#samples: 3
sample_retract_dist: 0.5
samples_result: average
#samples_tolerance: 0.0025
samples_tolerance_retries: 15
activate_gcode:
#TMC_SENDDELAY # wait 200ms before descending to avoid false triggers
deactivate_gcode:
#TMC_SENDDELAY # wait 200ms after descending to avoid false triggers
[gcode_macro TMC_SENDDELAY]
gcode:
SET_TMC_FIELD STEPPER=stepper_x FIELD=SENDDELAY VALUE=2
SET_TMC_FIELD STEPPER=stepper_y FIELD=SENDDELAY VALUE=2
SET_TMC_FIELD STEPPER=stepper_z FIELD=SENDDELAY VALUE=2
SET_TMC_FIELD STEPPER=stepper_z1 FIELD=SENDDELAY VALUE=2
SET_TMC_FIELD STEPPER=extruder FIELD=SENDDELAY VALUE=2
[stable_z_home]
gcode:
# The G-code to run before each probe attempt. The default is none.
retries: 25
# The maximum number of probe attempts allowed. The default is 20.
#window:
# The number of samples to use in the tolerance window. The default is 4.
retry_tolerance: 0.005
# The maximum range between the min and max values of the Z offset in the window
# to consider the offset stable and complete the procedure. The default is
# 0.0025mm.
#[homing_heaters
#steppers: stepper_z
#heaters: extruder, heater_bed
[homing_override]
set_position_z: 3
axes: z
gcode:
G90 ; Uncomment these 2 lines to blindly lift the Z 3mm at start
G1 Z3 F600 ; Move Z up a bit to prevent scratching
G28 X0 Y0
G0 X150 Y200 F3000 ; Go to X100,Y200
SET_HOME_CURRENT
STABLE_Z_HOME
SET_PRINT_CURRENT
[z_tilt]
z_positions:
#Nozzle position over leadscrews
325,150
-25,150
points:
10,200
290,200
#speed: 100
#horizontal_move_z: 3
retries: 25
retry_tolerance: 0.005
[bed_mesh]
#horizontal_move_z: 3
mesh_min: 40, 40
mesh_max: 260,260
fade_start: 0.6
fade_end: 10.0
probe_count: 5,5
algorithm: bicubic
relative_reference_index: 12
#[safe_z_home]
#home_xy_position: 150,200
#speed: 75
#z_hop: 3
#z_hop_speed: 3
[pause_resume]
recover_velocity: 50.
[gcode_arcs]
resolution: .25
[bed_screws]
screw1: 30,20
screw2: 270,20
screw3: 270,280
screw4: 30,280
[screws_tilt_adjust]
screw1: 30,50
screw1_name: front left screw
screw2: 270,50
screw2_name: front right screw
screw3: 270,290
screw3_name: rear right screw
screw4: 30,290
screw4_name: rear left screw
horizontal_move_z: 4
speed: 40
screw_thread: CCW-M4
# For konovo pwc v1.0 or mks 3.0 PWC (model 2019)
#
# use psu control plugin and externally power rpi
# set auto on and off in psu control plugin
# set mcu power to usb 5v via jumper on robin nano v1.2
# on gcode command = SET_PIN PIN=power VALUE=1
# off gcode command = SET_PIN PIN=power VALUE=0
# uncomment the following
#[output_pin power]
#pin:PB2
#value: 0
#shutdown_value: 0
#
#
#
# For elf pwc v2.0 (model 2020+)
#
# use psu control plugin and externally power rpi
# set auto on and off in psu control plugin
# set mcu power to usb 5v via jumper on robin nano v1.2
# on gcode command = SET_PIN PIN=power VALUE=0
# off gcode command = SET_PIN PIN=power VALUE=1
# uncomment the following
[output_pin power]
pin:!PB2
#value: 1
shutdown_value: 1.0
[verify_heater extruder]
hysteresis: 10
[virtual_sdcard]
path: /home/pi/sdcard
# This adds the 'respond' G-Code that you can use to send M118 commands back to host
[respond]
[gcode_macro NOTIFY]
# Notify macro
gcode:
{% if 'MSG' in params %}
RESPOND TYPE=command MSG="action:notification {params.MSG}"
{% endif %}
[gcode_macro M80]
gcode:
SET_PIN PIN=power VALUE=0
STATUS
[gcode_macro M81]
gcode:
SET_PIN PIN=power VALUE=1
STATUS
[gcode_macro SET_HOME_CURRENT]
gcode:
# read driver configs
{% set XCFG = printer.configfile.settings['tmc2209 stepper_x'] %}
{% set YCFG = printer.configfile.settings['tmc2209 stepper_y'] %}
{% set ZCFG = printer.configfile.settings['tmc2209 stepper_z'] %}
{% set Z1CFG = printer.configfile.settings['tmc2209 stepper_z1'] %}
{% set ECFG = printer.configfile.settings['tmc2209 extruder'] %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={XCFG.hold_current}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={YCFG.hold_current}
SET_TMC_CURRENT STEPPER=stepper_z CURRENT={ZCFG.hold_current}
SET_TMC_CURRENT STEPPER=stepper_z1 CURRENT={Z1CFG.hold_current}
SET_TMC_CURRENT STEPPER=extruder CURRENT={ECFG.hold_current}
# Pause to ensure driver stall flag is clear
G4 P1000
[gcode_macro SET_PRINT_CURRENT]
gcode:
# read driver configs
{% set XCFG = printer.configfile.settings['tmc2209 stepper_x'] %}
{% set YCFG = printer.configfile.settings['tmc2209 stepper_y'] %}
{% set ZCFG = printer.configfile.settings['tmc2209 stepper_z'] %}
{% set Z1CFG = printer.configfile.settings['tmc2209 stepper_z1'] %}
{% set ECFG = printer.configfile.settings['tmc2209 extruder'] %}
# reset all steppers current
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={XCFG.run_current}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={YCFG.run_current}
SET_TMC_CURRENT STEPPER=stepper_z CURRENT={ZCFG.run_current}
SET_TMC_CURRENT STEPPER=stepper_z1 CURRENT={Z1CFG.run_current}
SET_TMC_CURRENT STEPPER=extruder CURRENT={ECFG.run_current}
# Pause to ensure driver stall flag is clear
G4 P1000
[gcode_macro ZUP]
gcode:
SET_GCODE_OFFSET Z_ADJUST=0.01 MOVE=1
[gcode_macro ZDOWN]
gcode:
SET_GCODE_OFFSET Z_ADJUST=-0.01 MOVE=1
[gcode_macro LAZY_HOME]
gcode:
{% if "x" not in printer.toolhead.homed_axes %}
G28 X
{% endif %}
{% if "y" not in printer.toolhead.homed_axes %}
G28 Y
{% endif %}
{% if "z" not in printer.toolhead.homed_axes %}
G28 Z
{% endif %}
G90 ; Uncomment these 2 lines to blindly lift the Z 2mm at start
G1 Z3 F300 ; Move Z up a bit to prevent scratching
G0 X150 Y200 F1500 ; Go to X100,Y100 at 25mm/s
[gcode_macro G29]
gcode:
BED_MESH_CLEAR
#now proceed to home as normal
LAZY_HOME
#mesh bed level
BED_MESH_CALIBRATE METHOD=automatic
## Raise Z for safe parking/transit
G0 Z3 F1500
[gcode_macro G34]
gcode:
#now proceed to home as normal
LAZY_HOME
SET_HOME_CURRENT
Z_TILT_ADJUST
SET_PRINT_CURRENT
G28 Z
## Raise Z for safe parking/transit
G0 Z3 F1500
#[gcode_macro M280 P0 S160]
#gcode:
# BLTOUCH_DEBUG COMMAND=reset
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
default_parameter_X: 230
default_parameter_Y: 230
default_parameter_Z: 10
gcode:
M104 S0
M140 S0
M141 S0
M106 S0
CLEAR_PAUSE
RESET_SD
BASE_CANCEL_PRINT
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
default_parameter_X: 230
default_parameter_Y: 230
default_parameter_Z: 10
gcode:
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
G91
G1 E-1.7 F2100
G1 Z{Z}
G90
G1 X{X} Y{Y} F6000
G91
[gcode_macro RESUME]
rename_existing: BASE_RESUME
gcode:
G91
G1 E1.7 F2100
G91
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1
BASE_RESUME
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 0.014167, -0.160833, -0.261667, -0.375833, -0.355833
#*# -0.055833, -0.128333, -0.215833, -0.217500, -0.148333
#*# 0.101667, -0.022500, 0.016667, 0.000000, 0.120000
#*# 0.141667, 0.121667, 0.054167, 0.242500, 0.357500
#*# 0.301667, 0.325000, 0.371667, 0.419167, 0.677500
#*# tension = 0.2
#*# min_x = 43.0
#*# algo = bicubic
#*# y_count = 5
#*# mesh_y_pps = 2
#*# min_y = 20.0
#*# x_count = 5
#*# max_y = 250.0
#*# mesh_x_pps = 2
#*# max_x = 280.0
#*#
#*# [probe]
#*# z_offset = 1.025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment