Quick Tips For Converting to Klipper

I’ve recently converted my Anycubic Kossel Linear Plus 3D printer firmware over from Marlin to Klipper. Along the way I’ve stumbled over some issues that are likely common to a lot of folk making this conversion, regardless of what printer or mainboard they end up using. What follows are a few of the tricks I picked up along the way to help you with your Klipper conversion.

#1: Converting Pinout

Converting from Marlin to Klipper can cause a number of issues, most prominent for me was the difficulty in figuring out which pins correlated to which IDs in Klipper. For instance ATMega2560 pin #60 is called PF6 in Klipper. There seem to be two ways of getting around this.

First you can identify the pin numbers from marlin by searching through the board definition .h files. You can find these by searching, or by navigating to Marlin/src/pins/[board_name].h. In my case I was using the MKS Gen L v2.1, which is based on the classic RAMPS board. The definition for this specific board is found at Marlin\src\pins\ramps\pins_MKS_GEN_L_V21.h. Therein you will find some pin numbers specific to this board as well as an import of the remainder of the pins from the generic RAMPS board at Marlin\src\pins\ramps\pins_RAMPS.h.

These pin numbers can then be converted to Klipper aliases/IDs by looking up the ID referenced by each ar# definition (eg: PD9 or PA23) under the ATMEGA2560 section of this file: https://github.com/Klipper3d/klipper/blob/master/config/sample-aliases.cfg

Another method seems to be using the Klipper config option pin_map: arduino which should let you use the ar# style designation as described above.

A third method is described here, although I have not personally used it:

https://mmone.github.io/klipper/FAQ.html#how-do-i-convert-a-marlin-pin-number-to-a-klipper-pin-name

#2: Setting Up TMC2209 On MKS Gen L 2.1 (and likely others).

I had a lot of trouble getting started when I first attempted to upgrade my stepper drivers from the classic A4988s to the shiny new TMC2209s which boast quieter motors using StealthChop technology, higher heat dissipation allowing for better performance with passive cooling alone, sensorless homing, and more.

I quickly ran into trouble with Klipper not recognizing the drivers via UART and throwing IFCNT errors indicating failed communication. The fix for this is simple but not really detailed anywhere else on the web! For the MKS Gen L and my drivers, you need to configure both the UART Rx as well as Tx pins. These pin assignments can be looked up as described above, and should appear as follows (example from my Anycubic Kossel Config on the MKS Gen L 2.1):

[tmc2209 stepper_a]
 uart_pin: PK1
 tx_pin: PG1
 diag_pin: ^PE5
 run_current: 0.8
 stealthchop_threshold: 999999

[tmc2209 stepper_b]
 uart_pin: PK2
 tx_pin: PF5
 diag_pin: ^PJ1
 run_current: 0.8
 stealthchop_threshold: 999999

[tmc2209 stepper_c]
 uart_pin: PK3
 tx_pin: PL7
 diag_pin: ^PD2
 run_current: 0.8
 stealthchop_threshold: 999999

#3: Reversed Display Cables

A big pitfall which I ran across with the MKS Gen L 2.1 board and the original Anycubic Kossel display is the ribbon cable orientation. Labeled EXP1 and EXP2, these ribbon cables carry the power, input, and display wires to the front-facing display of the printer. Moving from the original Trigorilla board to the MKS Gen L board however, these cables need to be inserted into the new mainboard flipped 180 degrees. There is a plastic tab on the ribbon cables, which seems designed to prevent precisely the flip I am suggesting, however this must be a manufacturing/compatibility issue. What you need to do is cut or shave off this plastic tab from the ribbon cable (I have used an X-acto in the past which is dangerous for the fingers, but found it a ton easier to just cut it off with a flush cutter this most recent upgrade).

You certainly can try it the “wrong way” first to see if it works, it doesn’t appear to damage the screen (at least in my case, but do at your own risk). If the screen doesn’t light up at all (no backlight) then the cables are reversed.

Conclusion

I hope the above tips are helpful to others trying to upgrade their machines, and will try to write up some more when I have some more time. See below for my full configuration files. Until next time, all the best and happy printing!

Example Configurations:

Klipper w/ MKS Gen L 2.1 (w/ TMC2209 drivers):
[include mainsail.cfg]
[include macros.cfg]

[stepper_a]
step_pin: PF0
dir_pin: PF1
enable_pin: !PD7
microsteps: 16
rotation_distance: 40
#endstop_pin: ^PE5 #X-Min, PE4:X-Max
endstop_pin: ^PE4
homing_speed: 60

[tmc2209 stepper_a]
uart_pin: PK1
tx_pin: PG1
#diag_pin: ^PE5
run_current: 0.8
stealthchop_threshold: 999999

[stepper_b]
step_pin: PF6
dir_pin: PF7
enable_pin: !PF2
microsteps: 16
rotation_distance: 40
#endstop_pin: ^PJ1  #Y-Min, PJ0:Y-Max
endstop_pin: ^PJ0  #Y-Min, PJ0:Y-Max

[tmc2209 stepper_b]
uart_pin: PK2
tx_pin: PF5
#diag_pin: ^PJ1
run_current: 0.8
stealthchop_threshold: 999999

[stepper_c]
step_pin: PL3
dir_pin: PL1
enable_pin: !PK0
microsteps: 16
rotation_distance: 40
#endstop_pin: ^PD3  #Z-Min, PD2:Z-Max
endstop_pin: ^PD2

[tmc2209 stepper_c]
uart_pin: PK3
tx_pin: PL7
#diag_pin: ^PD2
run_current: 0.8
stealthchop_threshold: 999999

[extruder]
step_pin: PA4
dir_pin: PA6
enable_pin: !PA2
microsteps: 16
#rotation_distance: 33.333
#rotation_distance: 11.1
rotation_distance: 8
nozzle_diameter: 0.5
filament_diameter: 1.750
heater_pin: PB4
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK5
control: pid
pid_Kp: 25.349
pid_Ki: 1.216
pid_Kd: 132.130
min_extrude_temp: 150
min_temp: 0
max_temp: 275

[tmc2209 extruder]
uart_pin: PK4
tx_pin: PL5
#diag_pin: ^PD2
run_current: 0.8

[heater_bed]
heater_pin: PH5
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK6
control: pid
pid_kp: 73.517
pid_ki: 1.132
pid_kd: 1193.728
min_temp: 0
max_temp: 130

[fan]
pin: PH6
kick_start_time: 0.200

#[heater_fan extruder_cooler_fan]
#pin: PH6

# if you want to use your probe for DELTA_CALIBRATE you will need that
[probe]
pin: ^PD3
#z_offset: 16.4
samples: 3

[mcu]
serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0

[printer]
kinematics: delta
max_velocity: 250
max_accel: 2500
max_z_velocity: 200
#delta_radius: 110
minimum_z_position: -5

[idle_timeout]
timeout: 360

[delta_calibrate]
radius: 105
horizontal_move_z: 25
speed: 75

[bed_mesh]
speed: 100
horizontal_move_z: 25
mesh_radius: 100
mesh_origin: 0,0
round_probe_count: 5
algorithm: bicubic
mesh_pps: 2, 2

# "RepRapDiscount 2004 Smart Controller" type displays
[display]
lcd_type: hd44780
rs_pin: PH1
e_pin: PH0
d4_pin: PA1
d5_pin: PA3
d6_pin: PA5
d7_pin: PA7
encoder_pins: ^PC6, ^PC4
click_pin: ^!PC2
kill_pin: ^!PG0

[filament_switch_sensor runout_sensor]
#pause_on_runout: True
runout_gcode: PAUSE
#insert_gcode: RESUME
event_delay: 3.0
pause_delay: 0.5
switch_pin: PE3  
Klipper w/ Original Tri-Gorilla Board:
[include mainsail.cfg]
[include macros.cfg]

[stepper_a]
step_pin: PF0
dir_pin: !PF1
enable_pin: !PD7
microsteps: 16
rotation_distance: 40
endstop_pin: ^PE4
homing_speed: 60
# The next parameter needs to be adjusted for
# your printer. You may want to start with 280
# and meassure the distance from nozzle to bed.
# This value then needs to be added.
#position_endstop: 280
#arm_length: 269.0

[stepper_b]
step_pin: PF6
dir_pin: !PF7
enable_pin: !PF2
microsteps: 16
rotation_distance: 40
endstop_pin: ^PJ0

[stepper_c]
step_pin: PL3
dir_pin: !PL1
enable_pin: !PK0
microsteps: 16
rotation_distance: 40
endstop_pin: ^PD2

[extruder]
step_pin: PA4
dir_pin: !PA6
enable_pin: !PA2
microsteps: 16
#rotation_distance: 33.333
#rotation_distance: 11.1
rotation_distance: 8
nozzle_diameter: 0.5
filament_diameter: 1.750
heater_pin: PB4
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK5
control: pid
pid_Kp: 25.349
pid_Ki: 1.216
pid_Kd: 132.130
min_extrude_temp: 150
min_temp: 0
max_temp: 275

[heater_bed]
heater_pin: PH5
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK6
control: pid
pid_kp: 73.517
pid_ki: 1.132
pid_kd: 1193.728
min_temp: 0
max_temp: 130

[fan]
pin: PH6
kick_start_time: 0.200

[heater_fan extruder_cooler_fan]
pin: PL5

# if you want to use your probe for DELTA_CALIBRATE you will need that
[probe]
pin: ^PD3
#z_offset: 16.4
samples: 3

[mcu]
serial: /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_0001-if00-port0

[printer]
kinematics: delta
max_velocity: 250
max_accel: 2500
max_z_velocity: 200
#delta_radius: 110
minimum_z_position: -5

[idle_timeout]
timeout: 360

[delta_calibrate]
radius: 105
horizontal_move_z: 25
speed: 75

[bed_mesh]
speed: 100
horizontal_move_z: 25
mesh_radius: 100
mesh_origin: 0,0
round_probe_count: 5
algorithm: bicubic
mesh_pps: 2, 2

# "RepRapDiscount 2004 Smart Controller" type displays
[display]
lcd_type: hd44780
rs_pin: PH1
e_pin: PH0
d4_pin: PA1
d5_pin: PA3
d6_pin: PA5
d7_pin: PA7
encoder_pins: ^PC6, ^PC4
click_pin: ^!PC2
kill_pin: ^!PG0

[filament_switch_sensor runout_sensor]
#pause_on_runout: True
runout_gcode: PAUSE
#insert_gcode: RESUME
event_delay: 3.0
pause_delay: 0.5
switch_pin: PE3  

Leave a Reply

Your email address will not be published. Required fields are marked *