Skip to content

Instantly share code, notes, and snippets.

@tomohulk
Created June 20, 2019 00:55
Show Gist options
  • Save tomohulk/bd4955ba105b653bb81680927b4d1f87 to your computer and use it in GitHub Desktop.
Save tomohulk/bd4955ba105b653bb81680927b4d1f87 to your computer and use it in GitHub Desktop.
printer.cfg for Ender3 and the Klipper firmware.
# 2018 Creality Ender 3
# AVR atmega1284p
# Flash Command(s)
# * avrdude -p atmega1284p -c arduino -b 57600 -P /dev/ttyUSB0 -U out/klipper.elf.hex
# * make flash
# ================================================================================
# Stepper Definitions
# ================================================================================
# ================================================================================
[stepper_x]
step_pin: PD7
dir_pin: !PC5
enable_pin: !PD6
step_distance: .0125
endstop_pin: ^PC2
position_endstop: 0
position_max: 235
homing_speed: 50
# ================================================================================
[stepper_y]
step_pin: PC6
dir_pin: !PC7
enable_pin: !PD6
step_distance: .0125
endstop_pin: ^PC3
position_endstop: 0
position_max: 235
homing_speed: 50
# ================================================================================
[stepper_z]
step_pin: PB3
dir_pin: PB2
enable_pin: !PA5
step_distance: .0025
# Default Ender 3 Endstop pin is ~PC4. However, this has been replaced
# with z_virtual_endstop to use a virtual endstop instead of the z switch
endstop_pin: probe:z_virtual_endstop
# The z position is defined as a negative number to allow the calculation
# of the Z offset on the touch sensor. If it's not a negative number, errors
# will be generated when an attempt is made to move below the Z axis minimum
# during calibration.
position_min: -3
position_max: 240
homing_speed: 5
# ================================================================================
# BLTouch Definition
# ================================================================================
[bltouch]
sensor_pin: ^PC4
control_pin: PA4
x_offset: -47.0
y_offset: -5.0
z_offset: 2.6
speed: 5.0
sample_retract_dist: 8.0
samples: 2
# ================================================================================
[bed_mesh]
speed: 80
horizontal_move_z: 5
min_point: 50,30
max_point: 230,230
probe_count: 5,5
# ================================================================================
[extruder]
step_pin: PB1
dir_pin: !PB0
enable_pin: !PD6
# This is done in mm/step, not step/mm like other firmwares.
# PS C:\> [Math]::Round( (cur_e_step * ((120 - mm_left) / 100)), 6 )
#step_distance: 0.010526
step_distance: 0.010315
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PD5
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA7
control: pid
# Settings to allow for e calibration.
min_extrude_temp: 10
max_extrude_only_distance: 150.0
pid_Kp: 21.527
pid_Ki: 1.063
pid_Kd: 108.982
min_temp: 0
max_temp: 250
# pressure advance settings
pressure_advance: 1.10
pressure_advance_lookahead_time: 0.015
# ================================================================================
[heater_bed]
heater_pin: PD4
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA6
control: pid
# PID values were tuned using Stock bed at 50c
pid_Kp: 54.027
pid_Ki: 0.770
pid_Kd: 948.182
min_temp: 0
max_temp: 130
# ================================================================================
[fan]
pin: PB4
# ================================================================================
[mcu]
serial: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AH06OEVF-if00-port0
# ================================================================================
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
# ================================================================================
[display]
lcd_type: st7920
cs_pin: PA3
sclk_pin: PA1
sid_pin: PC1
encoder_pins: ^PD2, ^PD3
click_pin: ^!PC0
# ================================================================================
# Homing Override:
# This section is called any time a G28 [home] is called.
# G1 Z10 F600; Move Z Axis up 10mm so it doesn't hit anything
# G28 X Y; Home X and Y
# G1 X166 Y120 F6000; Move the probe to bed center
# G28 Z; Home Z
# ================================================================================
[homing_override]
set_position_z:0
gcode:
G1 Z10 F600
G28 X Y
G1 X166 Y120 F6000
G28 Z
# ================================================================================
# GCode Macros:
# These macros intercept gcode and replace them with the macro defined.
# GCode WIKI: https://reprap.org/wiki/G-code
# ================================================================================
# ================================================================================
# GCode Macro: START_PRINT
# Add START_PRINT in your slicers starting script.
# ================================================================================
[gcode_macro START_PRINT]
gcode:
G28; Home all axes
BED_MESH_CALIBRATE
G92 E0; Reset Extruder
G1 Z5.0 F3000; Move Z Axis up little to prevent scratching of Heat Bed
G1 X0.1 Y20 Z0.3 F5000.0; Move to start position
G1 X0.1 Y200.0 Z0.3 F1500.0 E15; Draw the first line
G1 X0.4 Y200.0 Z0.3 F5000.0; Move to side a little
G1 X0.4 Y20 Z0.3 F1500.0 E30; Draw the second line
G92 E0; Reset Extruder
G1 Z5.0 F3000; Move Z Axis up little to prevent scratching of Heat Bed
# ================================================================================
# GCode Macro: END_PRINT
# Add END_PRINT in your slicers ending script
# ================================================================================
[gcode_macro END_PRINT]
gcode =
G1 Y190 F1500; bring Y up front
G10 ; set tool offset? or retract?
G91; Relative Positioning
G1 Z+10; Move Z up so it doesn't hit anything
G1 E-10 F300; Retrack-10
G90; Absolute Positioning
G1 X10 Y220 F2000; Move to X10, Y220
M104 S0; Turn off Extrude (set it to 0)
M140 S0; Turn off Bed (set it to 0)
M106 S0; turn off cooling fan
M84; Disable steppers
# ================================================================================
# GCode Macro G29
# Fires when G29 is sent to the printer
# ================================================================================
[gcode_macro G29]
gcode:
G1 Z10 F600
G4 P200
G1 Z10 F600
G4 P100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment