Alberto Grespan

Klipper on an Ender 3

— January 11, 2021


This post will take you through the process of getting Klipper up and running from my experience of doing so on an Ender 3 Pro with some mods. I’m going to try to keep this post as up to date as possible while I learn/use new things.

Whats Klipper?

Klipper is a 3d-Printer firmware. It combines the power of a general purpose computer with one or more micro-controllers. — Klipper Website

This means that Klipper will use the Raspberry PI CPU to calculate printer movements and then compress and transmit them to the micro-controller board for execution.

Installation Through Fluidd

What’s Fluidd? “Fluidd is a free and Open Source Klipper Web interface for managing your 3d Printer.” — Fluidd GitHub

Installing Klipper through Fluidd is an easy task. To install it you’ll need to download FluiddPI, a Raspbian based distro for Fluidd that comes with Klipper and everything you need pre-installed.

The following instructions will guide you through the process of putting the OS in the Raspberry PI.

Now on the Raspberry PI we need to build the software for the micro-controller. For this follow the steps in Building and flashing the micro-controller. In my case Flashing via USB did not worked and I had to manually by scp the .bin build file out of the Raspberry PI into my computer for then to pasted it into the SD Card and rename it to firmware.bin that the micro-controller recognize it and flash it.

For the final installation step we need to create the printer.cfg file. This file will contain details details on the printer such as pins, stepper motor directions, drivers, probe, etc… We will talk about this in the Configuration File section

Installation Alternatives

FluiddPI is not the only way to install Klipper. In fact there are other more popular ones. Like MainsailOS, KIAUH, and there’s always the manual approach. I haven’t experimented with any of these but MainsailOS seems to be very similar to what we did with Fluidd. KIAUH seems to be a script that will allow for custom and different setups.

Configuration File

My configuration file aka printer.cfg is based on a SKR 1.4 Turbo micro-controller with TMC 2209 drivers with sensorless homing, an original BL-Touch v3 and a BMG extruder clone.

I’m not going to get into my configuration details in here, but you can look at them in my GitHub repo. If your setup is different than mine look into Klipper’s config examples for more guidance.

There are a couple of things that I should mention.

Marlin for port mappings

While I was working on the mappings for my setup and wasn’t sure about something I used Marlin as the source of truth. This because I had a working configuration there.

For example for the SKR 1.4 I used this Marlin PIN mappings to look for probe pins and ensuring others were correct.

Proper Coordinates and Homing

At first I thought that by setting up position_max: 235 on X and Y was more than enough but in reality it was different.

Things I had to account for and measure to get proper homing:

After these changes homing was working as expected.

Calibrating Probe

In my case as I’ve mentioned before I have a BL-Touch. This type of probe even though it’s very popular it might be more delicate problematic than others.

There are a couple of things we need to do with the probe to make it work as intended:

PID Tuning

Before you start ensure that your bed and or hotend is at room temperature.

This is the command to calibrate the hotend/extruder:

PID_CALIBRATE HEATER=extruder TARGET=200

This is the command to calibrate the heated bed:

PID_CALIBRATE HEATER=heater_bed TARGET=60

Once any of the above command run SAVE_CONFIG for it to save the values to the printer.cfg file.

Bed leveling

There are multiple ways to do bed leveling. As I have a probe I used the following two methods. Screw tilt Adjust and then Mesh Bed Leveling. Keep in mind that the former will throw the latter off-board so my recommendation is to do it in such order.

Screw Tilt Adjust

For this we need to do 4 things:

  1. Measure the screw diameter (Mine is M4)
  2. Know your probe offsets for X and Y
  3. Measure where are the screws located in the bed (both X and Y references)
  4. Once you know your screws location add your probe offsets
  5. Home G28 and then run SCREWS_TILT_CALCULATE and repeat the tilt calculate procedure until flat

For example based on the above my configuration ended like this:

[screws_tilt_adjust]
screw1: 74,47
screw1_name: front left screw
screw2: 245, 47
screw2_name: front right screw
screw3: 245, 217
screw3_name: rear right screw
screw4: 74,217
screw4_name: rear left screw
screw_thread: CW-M4

Note: screw2 and screw3 X coordinate is 245 after adding (sum) the X position with X probe offset; this forced me to change position_max to 245 to be able to reach that coordinate.

Interpreting the output is simple. CW 00:15 Turn clockwise 1/4 of a turn. CCW 00:45 counter clockwise 3/4 of a turn.

For more information check adjusting bed leveling screws using the bed probe.

Mesh Bed Leveling

Mesh bed leveling is simpler than the Screw Tilt Adjust. The most important thing is knowing what are the mesh limits and the amount of probe points you’ll want. For example:

[bed_mesh]
speed: 80
horizontal_move_z: 5
mesh_min: 18,18
mesh_max: 175,202
probe_count: 5,5
algorithm: bicubic

After this run BED_MESH_CALIBRATE and wait for the results, then SAVE_CONFIG to keep those numbers in the configuration file.

For more information check bed mesh configuration.

Calibrating Rotation Distance

For X, Y, and Z I “Obtained rotation_distance by inspecting the hardware” as this is the simplest way to do so. For E I went with the usual way e-steps calibration, but I recommend following this guide.

As I have a BMG extruder clone with a 3:1 gear ration I added this value to the configuration and ended with the following:

[extruder]
step_pin: P2.13
dir_pin: !P0.11
enable_pin: !P2.12
rotation_distance: 22.95 # Calculated distance
microsteps: 16
gear_ratio: 3:1 # BMG gear ratio
...

For more information check extruder configuration.

Pressure Advance

Pressure Advance in Klipper is the same as Marlin’s Linear Advance but the tuning part is different, and it seems to work better in Klipper (maybe it’s the way of tuning it).

Note: the calculated pressure advance value is dependent on the extruder, the nozzle, and the filament spool.

Steps for doing so can be found here, but in short:

Once the print is done, we proceed to the next step, measuring and doing the math to get our Pressure Advance value. Follow the official tuning pressure advance guide for how to measure and calculate the value.

I’ll explain how to set the Pressure Advance value within the slicer in a per filament basis in the Slicers section.

Macros

Macros are what you’ll think they are; a set of commands that are called from a single invocation.

These are the macros I currently have:

Check the macros in my printer.cfg file.

Slicers

There are some Slicer requirements from Klipper. Most of the things are related to slicer features you should not use to avoid issues. Other than those I’m going to use this section to explain how to use Macros in you slicer.

For PrusaSlicer for example:

Adding the START_PRINT macro and passing whatever first layer temp to it:

START_PRINT BED_TEMP="M140 S[first_layer_bed_temperature]" EXTRUDER_TEMP="M104 S[first_layer_temperature]" ;

Adding the END_PRINT macro:

END_PRINT ;

Add the Pressure Advance command to a filament:

SET_PRESSURE_ADVANCE ADVANCE=0.544 ;

That’s how a macro is used from within the slicer.