Skip to content

Instantly share code, notes, and snippets.

@brandonmartinez
Last active January 7, 2024 12:00
Show Gist options
  • Save brandonmartinez/83fcd59fdc0c0070f90a6ca460303500 to your computer and use it in GitHub Desktop.
Save brandonmartinez/83fcd59fdc0c0070f90a6ca460303500 to your computer and use it in GitHub Desktop.
My klipper printer.cfg for the Ender 3 S1 Plus
# Based on: https://github.com/Klipper3d/klipper/blob/master/config/printer-creality-ender3-s1plus-2022.cfg
# This file contains pin mappings for the stock 2022 Creality Ender 3
# S1 Plus. To use this config check the STM32 Chip on the Mainboard,
# during "make menuconfig" select accordingly either the
# STM32F103 with "28KiB bootloader" or the STM32F401 with
# "64KiB bootloader" and serial (on USART1 PA10/PA9) for both.
# For a direct serial connection, in "make menuconfig" select
# "Enable extra low-level configuration options" and Serial
# (on USART2 PA3/PA2), which is on the 10 pin IDC cable used
# for the LCD module as follows: 3: Tx, 4: Rx, 9: GND, 10: VCC
# Flash this firmware by copying "out/klipper.bin" to a SD card and
# turning on the printer with the card inserted. The filename
# must be changed to "firmware.bin"
# With STM32F401, you might need to put "firmware.bin" in a
# folder on the SD card called "STM32F4_UPDATE" in order to flash.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PC2
dir_pin: PB9
enable_pin: !PC3
microsteps: 16
rotation_distance: 40
endstop_pin: !PA5
position_endstop: -10
position_max: 316
position_min: -15
homing_speed: 50
[stepper_y]
step_pin: PB8
dir_pin: PB7
enable_pin: !PC3
microsteps: 16
rotation_distance: 40
endstop_pin: !PA6
position_endstop: -10
position_max: 304
position_min: -15
homing_speed: 50
[stepper_z]
step_pin: PB6
dir_pin: !PB5
enable_pin: !PC3
microsteps: 16
rotation_distance: 8
endstop_pin: probe:z_virtual_endstop
position_max: 300
position_min: -4
[extruder]
step_pin: PB4
dir_pin: PB3
enable_pin: !PC3
microsteps: 16
gear_ratio: 42:12
rotation_distance: 26.359
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PA1
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC5
control: pid
pid_Kp: 23.561
pid_Ki: 1.208
pid_Kd: 114.859
min_temp: 0
max_temp: 260
max_extrude_only_distance: 100.0
[heater_bed]
heater_pin: PA7
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC4
control: pid
pid_Kp: 71.867
pid_Ki: 1.536
pid_Kd: 840.843
min_temp: 0
max_temp: 100
[heater_fan hotend_fan]
pin: PC0
[fan]
pin: PA0
[mcu]
serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
restart_method: command
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 2000
max_z_velocity: 5
max_z_accel: 100
# Be sure to review https://www.klipper3d.org/Bed_Level.html and adjust bltouch/x_offset, bltouch/y_offset
# I recommend doing a manual bed leveling (paper test) on a new machine, then run through the probe
# calibration found here: https://www.klipper3d.org/Probe_Calibrate.html
[bltouch]
sensor_pin: ^PC14
control_pin: PC13
x_offset: -31
y_offset: -41.9
#z_offset: 0
probe_with_touch_mode: true
stow_on_each_sample: false
# After that, you can run the bed mesh calibration found here: https://www.klipper3d.org/Bed_Mesh.html
# Remember, *ANY* changes to your bed invalidate the mesh, so you'll need to re-run the Z-Offset
# calibration again: https://www.klipper3d.org/Probe_Calibrate.html#calibrating-probe-z-offset
# Then re-run the bed mash calibration
[bed_mesh]
speed: 120
horizontal_move_z: 10
mesh_min: 20, 20
mesh_max: 265, 258
probe_count: 4,4
algorithm: bicubic
[safe_z_home]
home_xy_position: 187, 192
speed: 75
z_hop: 10
z_hop_speed: 5
move_to_previous: true
[filament_switch_sensor e0_sensor]
switch_pin: !PC15
pause_on_runout: false
runout_gcode: PAUSE
runout_gcode:
M600
insert_gcode:
M117 Filament inserted
event_delay: 3.0
pause_delay: 0.0001
[pause_resume]
recover_velocity: 25
# The Following Based on:
# https://github.com/Klipper3d/klipper/blob/master/config/sample-macros.cfg
# https://pastebin.com/Bsi0C03E
[gcode_macro START_PRINT]
gcode:
# Get Printer built volume dimensions
{% set X_MAX = printer.toolhead.axis_maximum.x|default(100)|float %}
{% set Y_MAX = printer.toolhead.axis_maximum.y|default(100)|float %}
{% set Z_MAX = printer.toolhead.axis_maximum.z|default(100)|float %}
# Get Nozzle diameter and filament width for conditioning
{% set NOZZLE = printer.extruder.nozzle_diameter|default(0.4)|float %}
{% set FILADIA = printer.extruder.filament_diameter|default(1.75)|float %}
# Set Start coordinates of priming lines
{% set X_START = 10.0|default(10.0)|float %}
{% set Y_START = 20.0|default(20.0)|float %}
# Calculate Primer line extrusion volume and filament length
{% set PRIMER_WIDTH = 0.75 * NOZZLE %}
{% set PRIMER_HEIGHT = 0.70 * NOZZLE %}
{% set PRIMER_SECT = PRIMER_WIDTH * PRIMER_HEIGHT %}
{% set PRIMER_VOL = PRIMER_SECT * (X_MAX - 3 * X_START) %}
{% set FILA_SECT = 3.1415 * ( FILADIA / 2.0)**2 %}
{% set FILA_LENGTH = 1.55 * PRIMER_VOL / FILA_SECT %}
# 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 %}
# Home
G28
# Preheat nozzle and bed
M104 S{EXTRUDER_TEMP} T0
M140 S{BED_TEMP}
# Move up to clean bed
G1 Y{Y_MAX - 20} Z{Z_MAX/4.0} F6000
# Heat nozzle and bed
M190 S{BED_TEMP}
M109 S{EXTRUDER_TEMP} T0
# Precondition extruder
G92 E0
G1 X{X_START} Y{Y_START} Z{PRIMER_HEIGHT} F6000.0 ; Move to start position
G1 X{X_MAX - 2 * X_START} Y{Y_START} Z{PRIMER_HEIGHT} F2000.0 ; Draw the first line
G1 X{X_MAX - 2 * X_START} Y{Y_START + PRIMER_WIDTH} Z{PRIMER_HEIGHT} ; Move to side a little
G1 X{X_START} Y{Y_START + PRIMER_WIDTH} Z{PRIMER_HEIGHT} F2000.0 ; Draw the second line
G92 E0 ; Reset Extruder
G1 Z2.0 F600
G1 Z0.2 F600
G1 Z2.0 F600
[gcode_macro END_PRINT]
gcode:
# Get Printer built volume dimensions
{% set X_MAX = printer.toolhead.axis_maximum.x|default(100)|float %}
{% set Y_MAX = printer.toolhead.axis_maximum.y|default(100)|float %}
# Fix-up extruder
G91
G1 E-2 F2700
G1 E-1.5 Z0.2 F2400
G1 X5 Y5 F6000
G1 Z10
G90
# Present print
G1 Z{printer.toolhead.position.z + 10} F600
G1 X{X_MAX / 2} Y{Y_MAX} F6000
M106 S0
M104 S0
M140 S0
# Disable Steppers
M84 X Y E
# The follow macros are for use with pause/resume and the filamnet switch sensor
# Based on: https://www.reddit.com/r/ender5plus/comments/kb5oe9/klipper_m600_filament_change/
# And: https://github.com/KevinOConnor/klipper/issues/1354
[gcode_macro PARK_MACRO]
gcode:
{% set X = params.X|default(0)|float %}
{% set Y = params.Y|default(0)|float %}
{% set Z = params.Z|default(30)|float %}
M117 PARKING...
G91
G1 E-3.14 F1500
G1 Z{Z}
G90
G1 X{X} Y{Y} F3000
[gcode_macro UNLOAD]
gcode:
G91
G1 E5.0 F1200
G1 E3.0 F1600
G1 E-13.14 F7000
G1 E-100 F3000 # This is a partial unload for the E5, but you need to adjust the default setting for max extrusion from 50
G90
[gcode_macro M600]
gcode:
PAUSE_MACRO
UNLOAD
[gcode_macro PAUSE_MACRO]
gcode:
PAUSE
PARK_MACRO
SET_IDLE_TIMEOUT TIMEOUT=7200
[gcode_macro PURGE]
gcode:
M117 PURGING...
G91
G1 E45.0 F250
G90
[gcode_macro LOAD_FILAMENT]
gcode:
M117 LOADING...
G91
G1 E25.0 F1000
G1 E100 F2500
G4 P900
G1 E45.0 F250
G90
[gcode_macro RESUME_MACRO]
gcode:
M117 RESUMING...
RESUME
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment