Skip to content

Instantly share code, notes, and snippets.

@rhukster
Created December 27, 2021 23:19
Show Gist options
  • Save rhukster/1fa5cbb469319e4630eb27dc03a89adf to your computer and use it in GitHub Desktop.
Save rhukster/1fa5cbb469319e4630eb27dc03a89adf to your computer and use it in GitHub Desktop.
Klipper - BLV MGN Cube, tmc2209, sensorless homing x/y, ezable probe z, triple-z leveling
# Mainsail
[include mainsail.cfg]
# Printer settings
[force_move]
enable_force_move: True
[virtual_sdcard]
path: ~/gcode_files
[display_status]
[pause_resume]
[stepper_x]
step_pin: PE9
dir_pin: PF1
enable_pin: !PF2
microsteps: 32
rotation_distance: 40.055
endstop_pin: tmc2209_stepper_x:virtual_endstop
position_endstop: -2
position_min: -2
position_max: 320
homing_speed: 50
homing_retract_dist: 0
[stepper_y]
step_pin: PE11
dir_pin: PE8
enable_pin: !PD7
microsteps: 32
rotation_distance: 40.045
endstop_pin: tmc2209_stepper_y:virtual_endstop
position_endstop: -4
position_min: -4
position_max: 320
homing_speed: 50
homing_retract_dist: 0
[stepper_z]
step_pin: PE13
dir_pin: PC2
enable_pin: !PC0
microsteps: 32
rotation_distance: 4.027
endstop_pin: probe:z_virtual_endstop
position_max: 330
position_min: -10.0
homing_speed: 10
homing_retract_dist: 3.0
homing_retract_speed: 20
[stepper_z1]
step_pin: PD15 # this is E1
dir_pin: PE7
enable_pin: !PA3
microsteps: 32
rotation_distance: 4.027
[stepper_z2]
step_pin: PD13 # this is E2
dir_pin: PG9
enable_pin: !PF0
microsteps: 32
rotation_distance: 4.027
[extruder]
step_pin: PE14
dir_pin: PA0
enable_pin: !PC3
microsteps: 16
rotation_distance: 8.14
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PB1 # Heat0
sensor_pin: PF4 # T1 Header
sensor_type: ATC Semitec 104GT-2
control = pid
pid_kp = 30.866
pid_ki = 1.524
pid_kd = 156.261
min_temp: 0
max_temp: 325
min_extrude_temp: 160
pressure_advance: 0.066
[tmc2209 stepper_x]
uart_pin: PC13
run_current: 1
sense_resistor = 0.075
stealthchop_threshold: 0
diag_pin: ^PB10
driver_SGTHRS: 128
[tmc2209 stepper_y]
uart_pin: PE3
run_current: 1
sense_resistor = 0.075
stealthchop_threshold: 0
diag_pin: ^PE12
driver_SGTHRS: 128
[tmc2209 stepper_z]
uart_pin: PE1
run_current: 1
sense_resistor = 0.075
stealthchop_threshold: 0
[tmc2209 stepper_z1]
uart_pin: PD1
run_current: 1
sense_resistor = 0.075
stealthchop_threshold: 0
[tmc2209 stepper_z2]
uart_pin: PD6
run_current: 1
sense_resistor = 0.075
stealthchop_threshold: 0
[tmc2209 extruder]
uart_pin: PD4
run_current: 0.847
stealthchop_threshold: 0
[heater_bed]
heater_pin: PD12
sensor_pin: PF3 # T0
sensor_type: NTC 100K beta 3950 # Keenevo AC bed
control = pid
pid_kp = 56.809
pid_ki = 0.645
pid_kd = 1250.509
min_temp: 0
max_temp: 130
[probe]
pin: !PG8
x_offset: -36.0
y_offset: 0.
#z_offset = 6.430
speed: 10.0
lift_speed: 20.0
samples: 2
samples_result: median
sample_retract_dist: 2.0
samples_tolerance: 0.2
samples_tolerance_retries: 5
[fan]
pin: PC8
[heater_fan fan1]
pin: PE5
#[heater_fan fan2]
#pin: PE6
[mcu]
serial: /dev/serial/by-id/usb-Klipper_stm32f407xx_310019000D5052424E303920-if00
[printer]
kinematics: corexy
max_velocity: 1500
max_accel: 9000
max_z_velocity: 20
max_z_accel: 150
max_accel_to_decel: 9000
square_corner_velocity: 5
[safe_z_home]
home_xy_position: 160,160
speed: 200
z_hop: 10 # Move up a bit
z_hop_speed: 5
[z_tilt]
z_positions:
356,51
356,302
-40,175
points:
310,10
310,310
45,174
speed: 200
horizontal_move_z: 10
retries: 5
retry_tolerance: 0.02
[bed_mesh]
speed: 300
horizontal_move_z: 10
mesh_min: 10,10
mesh_max: 284,310
probe_count: 4,4
fade_start: 1.0
fade_end: 10.0
split_delta_z: .01 # The amount of Z difference (in mm) along a move that will trigger a split
move_check_distance: 3
mesh_pps: 2,2
algorithm: bicubic
relative_reference_index: 12 # point index in the mesh to reference all z values to.
########################################
# EXP1 / EXP2 (display) pins
########################################
[board_pins]
aliases:
# EXP1 header
EXP1_1=PG4, EXP1_3=PD11, EXP1_5=PG2, EXP1_7=PG6, EXP1_9=<GND>,
EXP1_2=PA8, EXP1_4=PD10, EXP1_6=PG3, EXP1_8=PG7, EXP1_10=<5V>,
# EXP2 header
EXP2_1=PB14, EXP2_3=PG10, EXP2_5=PF11, EXP2_7=PF12, EXP2_9=<GND>,
EXP2_2=PB13, EXP2_4=PB12, EXP2_6=PB15, EXP2_8=<RST>, EXP2_10=PF13
# Pins EXP2_1, EXP2_6, EXP2_2 are also MISO, MOSI, SCK of bus "spi2"
# See the sample-lcd.cfg file for definitions of common LCD displays.
[gcode_macro MOTORS_OFF]
gcode:
M84
[gcode_macro G34]
gcode:
Z_TILT_ADJUST
G28
#fluidd macros
[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
#End fluidd macros
#macros
[delayed_gcode _Startup]
# execute when the delay duration has elapsed.
initial_duration: 1.0 # If set to 0 the delayed_gcode will not execute on startup Default is 0.
gcode:
M117 Welcome!
M117 BLV Cube V1.2 is Ready :)
SET_FAN_SPEED FAN=Chamber_light SPEED=0.15
[gcode_macro UNLOAD_FILAMENT]
gcode:
SAVE_GCODE_STATE NAME=unload_state
G91 ;relative positioning
M117 Heating...
M109 S{params.TEMP|default(215, true)} ; Heat up hotend to provided temp or 220 as default as that should work OK with most filaments.
M117 Unloading filament...
G0 E-5 F3600 ;extract filament to cold end area
G4 P3000 ;wait for three seconds
G0 E5 F3600 ;push back the filament to smash any stringing
G0 E-15 F3600 ;Extract back fast in the cold zone
G0 E-130 F300 ;Continue extraction slowly, allow the filament time to cool solid before it reaches the gears
M117 Filament unloaded!
RESTORE_GCODE_STATE NAME=unload_state
[gcode_macro LOAD_FILAMENT]
gcode:
SAVE_GCODE_STATE NAME=load_state
G91 ;relative positioning
M117 Heating...
M109 S{params.TEMP|default(215, true)} ; Heat up hotend to provided temp or 220 as default as that should work OK with most filaments.
M117 Loading filament...
G0 E100 F600 ; Load the filament into the hotend area.
G4 P1000
G0 E40 F100 ; Purge
M400
TURN_OFF_HEATERS
M117 Filament loaded!
RESTORE_GCODE_STATE NAME=load_state
[gcode_macro PRIME_LINE]
gcode:
M109 S210; wait for extruder to heat up
G1 Z5 F3000 ; lift
G1 X5 Y10 F12000 ; move to prime
G1 Z0.3 F3000 ; get ready to prime
G92 E0 ; reset extrusion distance
G1 Y80 E16 F1200 ; prime nozzle
G1 Y100 F15000 ; quick wipe
[gcode_macro z_tilt]
gcode:
Z_TILT_ADJUST
[gcode_macro START_PRINT]
gcode:
SAVE_GCODE_STATE NAME=start_print_state
G21 ;metric values
G90 ;absolute positioning
M82 ;set extruder to absolute mode
G28 ;home
M117 Heating...
M190 S{params.BED_TEMP|default(printer.heater_bed.target, true) }; wait for bed to heat up
M109 S150 ; Wait for extruder to reach 150 so an inductive probe (if present) is at a predictable temp. Also allows the bed heat to spread a little.
Z_TILT_ADJUST ;Adjust bed tilt
G28 Z ;Home again as Z will have changed after tilt adjustment and bed heating.
BED_MESH_CALIBRATE ; Calibrate bed mesh
G0 X10 Y310 Z10 F6000 ; Park in the back and wait for extruder
M109 S{params.EXTRUDER_TEMP|default(printer.extruder.target, true) }; wait for extruder to heat up
M117 Printing...
RESTORE_GCODE_STATE NAME=start_print_state
# The end_print macro is also called from CANCEL_PRINT.
[gcode_macro END_PRINT]
gcode:
SAVE_GCODE_STATE NAME=end_print_state
M104 S0 ;extruder heater off
M140 S0 ;heated bed heater off
G91 ;relative positioning
G1 Z10 E-2 F3600 ;retract the filament a bit before lifting the nozzle.
G1 E-2 F3600 ;retract filament even more
G90 ;absolute positioning
G0 X10 Y310 ; Park in the back
M84 ;steppers off
M107 ; part cooling fan off
M117 Done.
RESTORE_GCODE_STATE NAME=end_print_state
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# -0.361486, -0.177754, -0.009124, -0.017933
#*# -0.081798, 0.049079, 0.148810, 0.081798
#*# 0.076765, 0.158249, 0.219283, 0.062607
#*# 0.292901, 0.231552, 0.179013, 0.000000
#*# tension = 0.2
#*# min_x = 10.0
#*# algo = bicubic
#*# y_count = 4
#*# mesh_y_pps = 2
#*# min_y = 10.0
#*# x_count = 4
#*# max_y = 310.0
#*# mesh_x_pps = 2
#*# max_x = 283.99
#*#
#*# [probe]
#*# z_offset = 6.430
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment