Skip to content

Instantly share code, notes, and snippets.

@bistory
Last active April 25, 2024 18:34
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bistory/c12a3bc4cec287776b07e1536e2137ac to your computer and use it in GitHub Desktop.
Save bistory/c12a3bc4cec287776b07e1536e2137ac to your computer and use it in GitHub Desktop.
Anycubic i3 Mega configuration for Klipper (with TMC2209 + SPI, BMG extruder with stock motor, pressure advance and BLTouch clone)
# This file contains pin mappings for the Anycubic i3 Mega with
# Ultrabase from 2017. (This config may work on an Anycubic i3 Mega v1
# prior to the Ultrabase if you comment out the definition of the
# endstop_pin in the stepper_z1 section.) To use this config, the
# firmware should be compiled for the AVR atmega2560.
# See the example.cfg file for a description of available parameters.
[stepper_x]
step_pin: PF0
dir_pin: !PF1
enable_pin: !PD7
microsteps: 16
rotation_distance: 40
endstop_pin: ^!PE5
position_min: -7
position_endstop: -5
position_max: 220
homing_speed: 200.0
[stepper_y]
step_pin: PF6
dir_pin: PF7
enable_pin: !PF2
microsteps: 16
rotation_distance: 40
endstop_pin: ^!PL7
position_endstop: 0
position_max: 220
homing_speed: 200.0
[stepper_z]
step_pin: PL3
dir_pin: PL1
enable_pin: !PK0
microsteps: 16
rotation_distance: 8
endstop_pin: ^!PD3
position_endstop: 0.0
position_min: -2
position_max: 205
homing_speed: 20.0
[stepper_z1]
step_pin: PC1
dir_pin: PC3
enable_pin: !PC7
microsteps: 16
rotation_distance: 8
endstop_pin: ^!PL6
[extruder]
step_pin: PA4
dir_pin: !PA6
enable_pin: !PA2
microsteps: 16
rotation_distance: 7.923940992
nozzle_diameter: 0.400
filament_diameter: 1.750
max_extrude_only_distance: 120.0
heater_pin: PB4
sensor_type: ATC Semitec 104GT-2
sensor_pin: PK5
control: pid
#215
pid_Kp=27.860
pid_Ki=1.895
pid_Kd=102.385
#200
pid_Kp=28.367
pid_Ki=1.854
pid_Kd=108.505
min_temp: 0
max_temp: 265
#min_extrude_temp: 0
#pressure_advance: 0.537 # Titan
pressure_advance: 0.4644 # eSun + BMG
#pressure_advance: 0
# The amount of raw filament to push into the extruder during
# extruder acceleration. An equal amount of filament is retracted
# during deceleration. It is measured in millimeters per
# millimeter/second. The default is 0, which disables pressure
# advance.
pressure_advance_smooth_time: 0.040
# A time range (in seconds) to use when calculating the average
# extruder velocity for pressure advance. A larger value results in
# smoother extruder movements. This parameter may not exceed 200ms.
# This setting only applies if pressure_advance is non-zero. The
# default is 0.040 (40 milliseconds).
[heater_fan extruder_fan]
#pin: PL5
pin: PH6
[heater_bed]
heater_pin: PH5
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK6
control: pid
pid_Kp=76.304
pid_Ki=1.657
pid_Kd=878.444
min_temp: 0
max_temp: 110
[fan]
#pin: PH6
pin: PL5
[mcu]
serial: /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0
[printer]
kinematics: cartesian
max_velocity: 300
##max_accel: 3000
max_accel: 1600
max_z_velocity: 20
max_z_accel: 60
#square_corner_velocity: 5.0
[heater_fan stepstick_fan]
pin: PH4
[endstop_phase]
[pause_resume]
recover_velocity: 60.
# When capture/restore is enabled, the speed at which to return to
# the captured position (in mm/s). Default is 50.0 mm/s.
# Filament Switch Sensor. Support for filament insert and runout detection
# using a switch sensor, such as an endstop switch.
[filament_switch_sensor filament_sensor]
pause_on_runout: True
# When set to True, a PAUSE will execute immediately after a runout
# is detected. Note that if pause_on_runout is False and the
# runout_gcode is omitted then runout detection is disabled. Default
# is True.
runout_gcode:
M118 Filament Runout Detected
# A list of G-Code commands to execute after a filament runout is
# detected. See docs/Command_Templates.md for G-Code format. If
# pause_on_runout is set to True this G-Code will run after the
# PAUSE is complete. The default is not to run any G-Code commands.
insert_gcode:
M118 Filament Load Detected
# A list of G-Code commands to execute after a filament insert is
# detected. See docs/Command_Templates.md for G-Code format. The
# default is not to run any G-Code commands, which disables insert
# detection.
#event_delay: 3.0
# The minimum amount of time in seconds to delay between events.
# Events triggered during this time period will be silently
# ignored. The default is 3 seconds.
#pause_delay: 0.5
# The amount of time to delay, in seconds, between the pause command
# dispatch and execution of the runout_gcode. It may be useful to
# increase this delay if Octoprint exhibits strange pause behavior.
# Default is 0.5 seconds.
switch_pin: ^!PD2
# The pin on which the switch is connected. This parameter must be
# provided.
# BLTouch probe. One may define this section (instead of a probe
# section) to enable a BLTouch probe. A virtual
# "probe:z_virtual_endstop" pin is also created (see the "probe"
# section above for the details).
[bltouch]
sensor_pin: ^PE4
# Pin connected to the BLTouch sensor pin. Most BLTouch devices
# require a pullup on the sensor pin (prefix the pin name with "^").
# This parameter must be provided.
control_pin: PB5
# Pin connected to the BLTouch control pin. This parameter must be
# provided.
#pin_move_time: 0.680
# The amount of time (in seconds) that it takes the BLTouch pin to
# move up or down. The default is 0.680 seconds.
stow_on_each_sample: False
# This determines if Klipper should command the pin to move up
# between each probe attempt when performing a multiple probe
# sequence. Read the directions in docs/BLTouch.md before setting
# this to False. The default is True.
probe_with_touch_mode: True
# If this is set to True then Klipper will probe with the device in
# "touch_mode". The default is False (probing in "pin_down" mode).
#pin_up_reports_not_triggered: True
# Set if the BLTouch consistently reports the probe in a "not
# triggered" state after a successful "pin_up" command. This should
# be True for a genuine BLTouch; some BLTouch clones may require
# False. The default is True.
pin_up_touch_mode_reports_triggered: False
# Set if the BLTouch consistently reports a "triggered" state after
# the commands "pin_up" followed by "touch_mode". This should be
# True for a genuine BLTouch; some BLTouch clones may require
# False. The default is True.
#set_output_mode:
# Request a specific sensor pin output mode on the BLTouch V3.0 (and
# later). This setting should not be used on other types of probes.
# Set to "5V" to request a sensor pin output of 5 Volts (only use if
# the controller board needs 5V mode and is 5V tolerant on its input
# signal line). Set to "OD" to request the sensor pin output use
# open drain mode. The default is to not request an output mode.
x_offset: 26.0
# The distance (in mm) between the probe and the nozzle along the
# x-axis. The default is 0.
y_offset: 0.0
# The distance (in mm) between the probe and the nozzle along the
# y-axis. The default is 0.
z_offset: 2.060
# The distance (in mm) between the bed and the nozzle when the probe
# triggers. This parameter must be provided.
#speed:
# Speed (in mm/s) of the Z axis when probing. The default is 5mm/s.
#samples: 1
# The number of times to probe each point. The probed z-values
# will be averaged. The default is to probe 1 time.
#sample_retract_dist: 2.0
# The distance (in mm) to retract between each sample if
# sampling more than once. Default is 2mm.
# Mesh Bed Leveling. One may define a [bed_mesh] config section
# to enable move transformations that offset the z axis based
# on a mesh generated from probed points. Note that bed_mesh
# and bed_tilt are incompatible, both cannot be defined.
[bed_mesh]
speed: 180
# The speed (in mm/s) of non-probing moves during the
# calibration. The default is 50.
horizontal_move_z: 5
# The height (in mm) that the head should be commanded to move to
# just prior to starting a probe operation. The default is 5.
mesh_min: 19,12
#min_point: 19,32
#min_point: 0,32
# Defines the minimum x,y coodinate of the mesh for rectangular beds. This
# that this does not necessarily define the last point probed, only
# coordinate is relative to the probe's location. This will be the first
# the maximum coordinate. This parameter must be provided.
# point probed, nearest to the origin. This parameter must be provided for
# rectangular beds.
mesh_max: 199,200
#max_point: 199,212
#max_point: 175,198
# Defines the maximum x,y coordinate of the mesh for rectangular beds.
# Adheres to the same principle as mesh_min, however this will be the
# furthest point probed from the bed's origin. This parameter must be
# provided for rectangular beds.
probe_count: 5,5
# A comma separated pair of integer values (X,Y) defining the number
# of points to probe along each axis. A single value is also valid,
# in which case that value will be for both axes. Default is 3,3
# which probes a 3x3 grid.
#fade_start: 1.0
# The z-axis position in which to start phasing z-adjustment out.
# Default is 1.0.
#fade_end: 0.0
# The gcode z position in which phasing out completes. When set
# to a value below fade_start, fade is disabled. It should be
# noted that fade may add unwanted scaling along the z-axis of a
# print. If a user wishes to enable fade, a value of 10.0 is
# recommended. Default is 0.0, which disables fade.
#fade_target:
# The z position in which fade should converge. When this value is set
# to a non-zero value it must be within the range of z-values in the mesh.
# Users that wish to converge to the z homing position should set this to 0.
# Default is the average z value of the mesh.
#split_delta_z: .025
# The amount of Z difference (in mm) along a move that will
# trigger a split. Default is .025.
#move_check_distance: 5.0
# The distance (in mm) along a move to check for split_delta_z.
# This is also the minimum length that a move can be split. Default
# is 5.0.
#mesh_pps: 2,2
# A comma separated pair of integers (X,Y) defining the number of
# points per segment to interpolate in the mesh along each axis. A
# "segment" can be defined as the space between each probed
# point. The user may enter a single value which will be applied
# to both axes. Default is 2,2.
#algorithm: lagrange
# The interpolation algorthm to use. May be either "langrange"
# or "bicubic". This option will not affect 3x3 grids, which
# are forced to use lagrange sampling. Default is lagrange.
#bicubic_tension: .2
# When using the bicubic algoritm the tension parameter above
# may be applied to change the amount of slope interpolated.
# Larger numbers will increase the amount of slope, which
# results in more curvature in the mesh. Default is .2.
#relative_reference_index:
# A point index in the mesh to reference all z values to. Enabling
# this parameter produces a mesh relative to the probed z position
# at the provided index.
[tmc2209 stepper_x]
uart_pin: PD0
# The pin connected to the TMC2208 PDN_UART line. This parameter
# must be provided.
#tx_pin:
# If using separate receive and transmit lines to communicate with
# the driver then set uart_pin to the receive pin and tx_pin to the
# transmit pin. The default is to use uart_pin for both reading and
# writing.
interpolate: True
# If true, enable step interpolation (the driver will internally step
# at a rate of 256 micro-steps). The default is True.
run_current: 0.850
# The amount of current (in amps) to configure the driver to use
# during stepper movement. This parameter must be provided.
hold_current: 0.500
# The amount of current (in amps) to configure the driver to use
# when the stepper is not moving. The default is to use the same
# value as run_current.
#sense_resistor: 0.110
# The resistance (in ohms) of the motor sense resistor. The default
# is 0.110 ohms.
stealthchop_threshold: 999999
# The velocity (in mm/s) to set the "stealthChop" threshold to. When
# set, "stealthChop" mode will be enabled if the stepper motor
# velocity is below this value. The default is 0, which disables
# "stealthChop" mode.
#uart_address: 1
# The address of the TMC2209 chip for UART messages (an integer
# between 0 and 3). This is typically used when multiple TMC2209
# chips are connected to the same UART pin. The default is zero.
#driver_IHOLDDELAY: 8
#driver_TPOWERDOWN: 20
#driver_TBL: 2
#driver_TOFF: 3
#driver_HEND: 0
#driver_HSTRT: 5
#driver_PWM_AUTOGRAD: True
#driver_PWM_AUTOSCALE: True
#driver_PWM_LIM: 12
#driver_PWM_REG: 8
#driver_PWM_FREQ: 1
#driver_PWM_GRAD: 14
#driver_PWM_OFS: 36
#driver_SGTHRS: 0
# Set the given register during the configuration of the TMC2209
# chip. This may be used to set custom motor parameters. The
# defaults for each parameter are next to the parameter name in the
# above list.
[tmc2209 stepper_y]
uart_pin: PD1
# The pin connected to the TMC2208 PDN_UART line. This parameter
# must be provided.
#tx_pin:
# If using separate receive and transmit lines to communicate with
# the driver then set uart_pin to the receive pin and tx_pin to the
# transmit pin. The default is to use uart_pin for both reading and
# writing.
interpolate: True
# If true, enable step interpolation (the driver will internally step
# at a rate of 256 micro-steps). The default is True.
run_current: 0.850
# The amount of current (in amps) to configure the driver to use
# during stepper movement. This parameter must be provided.
hold_current: 0.500
# The amount of current (in amps) to configure the driver to use
# when the stepper is not moving. The default is to use the same
# value as run_current.
#sense_resistor: 0.110
# The resistance (in ohms) of the motor sense resistor. The default
# is 0.110 ohms.
stealthchop_threshold: 999999
# The velocity (in mm/s) to set the "stealthChop" threshold to. When
# set, "stealthChop" mode will be enabled if the stepper motor
# velocity is below this value. The default is 0, which disables
# "stealthChop" mode.
[tmc2209 extruder]
uart_pin: PJ1
# The pin connected to the TMC2208 PDN_UART line. This parameter
# must be provided.
#tx_pin:
# If using separate receive and transmit lines to communicate with
# the driver then set uart_pin to the receive pin and tx_pin to the
# transmit pin. The default is to use uart_pin for both reading and
# writing.
interpolate: True
# If true, enable step interpolation (the driver will internally step
# at a rate of 256 micro-steps). The default is True.
run_current: 0.850
# The amount of current (in amps) to configure the driver to use
# during stepper movement. This parameter must be provided.
hold_current: 0.500
# The amount of current (in amps) to configure the driver to use
# when the stepper is not moving. The default is to use the same
# value as run_current.
#sense_resistor: 0.110
# The resistance (in ohms) of the motor sense resistor. The default
# is 0.110 ohms.
stealthchop_threshold: 0
# The velocity (in mm/s) to set the "stealthChop" threshold to. When
# set, "stealthChop" mode will be enabled if the stepper motor
# velocity is below this value. The default is 0, which disables
# "stealthChop" mode.
[tmc2209 stepper_z]
uart_pin: PJ0
# The pin connected to the TMC2208 PDN_UART line. This parameter
# must be provided.
#tx_pin:
# If using separate receive and transmit lines to communicate with
# the driver then set uart_pin to the receive pin and tx_pin to the
# transmit pin. The default is to use uart_pin for both reading and
# writing.
interpolate: True
# If true, enable step interpolation (the driver will internally step
# at a rate of 256 micro-steps). The default is True.
run_current: 0.580
# The amount of current (in amps) to configure the driver to use
# during stepper movement. This parameter must be provided.
hold_current: 0.5
# The amount of current (in amps) to configure the driver to use
# when the stepper is not moving. The default is to use the same
# value as run_current.
#sense_resistor: 0.110
# The resistance (in ohms) of the motor sense resistor. The default
# is 0.110 ohms.
stealthchop_threshold: 999999
# The velocity (in mm/s) to set the "stealthChop" threshold to. When
# set, "stealthChop" mode will be enabled if the stepper motor
# velocity is below this value. The default is 0, which disables
# "stealthChop" mode.
[tmc2209 stepper_z1]
uart_pin: PH3
# The pin connected to the TMC2208 PDN_UART line. This parameter
# must be provided.
#tx_pin:
# If using separate receive and transmit lines to communicate with
# the driver then set uart_pin to the receive pin and tx_pin to the
# transmit pin. The default is to use uart_pin for both reading and
# writing.
interpolate: True
# If true, enable step interpolation (the driver will internally step
# at a rate of 256 micro-steps). The default is True.
run_current: 0.580
# The amount of current (in amps) to configure the driver to use
# during stepper movement. This parameter must be provided.
hold_current: 0.5
# The amount of current (in amps) to configure the driver to use
# when the stepper is not moving. The default is to use the same
# value as run_current.
#sense_resistor: 0.110
# The resistance (in ohms) of the motor sense resistor. The default
# is 0.110 ohms.
stealthchop_threshold: 999999
# The velocity (in mm/s) to set the "stealthChop" threshold to. When
# set, "stealthChop" mode will be enabled if the stepper motor
# velocity is below this value. The default is 0, which disables
# "stealthChop" mode.
# Enable the "M118" and "RESPOND" extended commands.
[respond]
[gcode_arcs]
resolution: 0.2
# An arc will be split into segments. Each segment's length will
# equal the resolution in mm set above. Lower values will produce a
# finer arc, but also more work for your machine. Arcs smaller than
# the configured value will become straight lines. The default is
# 1mm.
#[gcode_macro G29]
#gcode: BED_MESH_CALIBRATE
[gcode_macro m205]
gcode:
[mcu rpi]
serial: /tmp/klipper_host_mcu
[adxl345]
cs_pin: rpi:None
[input_shaper]
shaper_freq_x: 49.6
shaper_type_x: 3hump_ei
shaper_freq_y: 40.2
shaper_type_y: 2hump_ei
[resonance_tester]
accel_chip: adxl345
probe_points:
100,100,20 # an example
@jbrandek
Copy link

Hi thanks for the conf file, do you have the uart conection diagram that you use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment