KlipperLab
A Raspberry Pi in a case beside a blank config file sheet, cabled by USB to a blue microcontroller board wired to a black-framed 3D printer with blue filament.
fundamentals

How Klipper Works: Host, MCU, and printer.cfg

How Klipper works from G-code to step pulses: host planning, MCU timing, printer.cfg changes, protocol communication, and when to reflash firmware.

By KlipperLab Editorial · ·Updated · 6 min read

Klipper splits printer firmware between a Linux host and one or more microcontrollers. The host interprets G-code, plans motion, and calculates when motors need to step. The MCU performs scheduled hardware operations, including step pulses and sensor reads. The printer’s configuration lives on the host, so most setup changes are text edits followed by a restart. Klipper installation guide, Features, MCU commands, G-code reference

For board choices and connection requirements, start with Klipper hardware requirements.

The host and MCU have different jobs

The host process is called Klippy. Much of it is Python, with C helpers for work such as generating and compressing step timings. It loads the printer configuration and builds software objects representing the toolhead, extruder, and other configured components. The microcontroller runs separately compiled firmware written in C. Klipper code overview

ComponentResponsibilityWhat a change usually affects
Linux host running KlippyG-code interpretation, motion planning, configurationPrinter behavior and available host modules
MCU firmwareTimed pin operations, step generation, hardware communicationBoard-specific build and communication settings
printer.cfg and included filesWiring assignments, kinematics, limits, macrosThe machine definition loaded by Klippy
Browser interfaceDisplays status and sends user requests through its backendControls and presentation

Mainsail, Fluidd, and OctoPrint are interface choices for the same underlying Klipper system. For a missing control, check the browser interface. For a controller connection failure, check the host-to-MCU connection. Klipper Features, Installation guide

From G-code to a planned move

A move begins with a command such as G1. The host interprets its coordinates in the current G-code state, including absolute or relative positioning and the selected feed rate. It passes the resulting request to the toolhead and kinematics code. Klipper code overview

Klipper’s kinematics documentation describes look-ahead: the planner considers adjacent moves when choosing speeds at their junctions. It describes each move using acceleration, cruising, and deceleration phases. On short moves, a phase may have zero duration. Setting a high maximum velocity does not guarantee that a short segment reaches that velocity.

The planner then needs a relationship between position and time for each motor. An iterative solver calculates the times at which that motor crosses successive step positions. The host compresses those timings into commands for the MCU. The code overview follows this path from G-code handling to the controller’s timer interrupt.

Kinematics translate head motion into motor motion

A Cartesian axis, a CoreXY belt system, and a delta mechanism require different mappings between the requested tool position and individual motor positions. On CoreXY, X and Y motion involve coordinated movement of both belt motors. On delta machines, the relationship depends on the tower geometry. Select the kinematics that match the printer’s mechanism. Klipper kinematics documentation

Verify the endstops, stepper direction, and homing before tuning. Klipper configuration checks

The extruder has its own motion calculation synchronized with the toolhead. Pressure advance adjusts extrusion to compensate for changes in pressure, and calibration depends on the extruder, nozzle, and filament. Klipper code overview, Pressure advance documentation

Use the pressure advance calibration procedure to tune that setting.

The host-to-MCU protocol

Klippy communicates with the controller using Klipper’s compact binary protocol. The controller receives encoded commands and sends responses carrying status or measurements. Klipper protocol reference, MCU commands

The protocol reference describes a data dictionary that identifies the commands, parameters, and responses available in a firmware build. The host obtains that dictionary when connecting. Message blocks also carry sequence information and a checksum, allowing the communication layer to detect transmission problems and manage delivery.

The host connects to the MCU over a serial connection or CAN bus, depending on the hardware and firmware build. Check the MCU connection directly when the browser interface loads but the controller reports a connection error. Klipper configuration reference, Installation guide

How the MCU turns a schedule into pulses

The controller stores scheduled work and uses hardware timer interrupts to execute it. A step sequence can describe a starting interval, a number of steps, and an interval adjustment. The MCU applies the interval adjustment after each step. Klipper code overview, MCU commands

Startup also configures controller objects for the selected hardware. Klipper’s MCU command documentation explains how the host checks configuration state, allocates objects, and finalizes that configuration. The same compiled controller firmware can therefore serve different printer configurations when the required hardware capabilities and build settings match.

With multiple MCUs, the host synchronizes their clocks so operations can share a timing model despite clock drift. Each board needs a compatible firmware build and its own configuration entry. Klipper code overview, Configuration reference

printer.cfg defines the machine

Configuration sections associate readable names with machine components. A [printer] section selects kinematics and motion limits. A [stepper_x] section describes one configured stepper, while [mcu] identifies the controller connection. Heater and sensor sections describe their hardware and limits. The configuration reference defines each option.

Use [include ...] sections to load macros or other configuration groups from separate files. Back up each included file along with printer.cfg. Klipper configuration reference

Keep a working copy, change one group of related settings at a time, and record why you changed it. Record the board revision and firmware build settings alongside the files.

Restarting, saving, and reflashing are different

ChangeNormal actionWhy
Edit a configuration option or macroSave the files, run RESTART when idle, then run STATUSKlippy reloads the configuration and reports its state
Apply a calibration result that supports savingSAVE_CONFIGKlipper overwrites the main configuration file with the saved result and restarts the host software
Clear an MCU error after correcting its causeFIRMWARE_RESTARTAlso resets the MCU error state
Change a board-specific firmware build settingSet the board’s options in make menuconfig, run make, then follow the board’s flashing instructionsThese settings are compiled into the MCU firmware
Update Klipper softwareFollow Klipper’s upgrade procedure and rebuild and flash the MCU if Klipper requests itSome updates only require updating the host software

Klipper G-code reference, Configuration checks, Installation guide, Upgrade FAQ

Back up printer.cfg before using SAVE_CONFIG and review the changes afterward. If a host update produces a reflash warning, follow the full upgrade procedure in the FAQ.

Macros are host-side command templates

A [gcode_macro ...] section defines a command sequence using Klipper’s template system. Templates can read parameters and printer status and generate G-code. Klipper command templates

The command template guide highlights a subtle behavior: Klipper evaluates an entire macro before executing the generated commands. Reading a status value later in the same template therefore does not automatically observe a change caused by an earlier generated command. Design multi-stage behavior with that timing in mind.

Movement macros also inherit G-code state unless they explicitly manage it. The official guide demonstrates saving and restoring that state and selecting a positioning mode before requesting a move. Review copied macros for machine assumptions and coordinates, just as you would review copied pin assignments.

Verify the machine definition before tuning

Klipper’s configuration checks start with basic temperature and emergency-stop checks, then cover heaters, steppers, endstops, and homing. Complete them after installation or a material wiring change. A configuration that loads without a syntax error has not yet passed those physical checks.

Input shaping helps reduce ringing caused by printer vibration. Klipper Features

Once the printer definition is correct, use the ADXL345 input shaper setup guide for resonance measurement. If the extra host and maintenance remain a deciding factor, Klipper vs Marlin compares the firmware workflows.

Evidence and limits. Klipper’s online documentation was checked on November 25, 2026. The commands and checks were reviewed against the documentation only.

Sources

  1. Klipper: Installation
  2. Klipper: Code Overview
  3. Klipper: Kinematics
  4. Klipper: Protocol
  5. Klipper: MCU Commands
  6. Klipper: Configuration Reference
  7. Klipper: G-Codes
  8. Klipper: Command Templates
  9. Klipper: Frequently Asked Questions
  10. Klipper: Configuration Checks
  11. Klipper: Pressure Advance
  12. Klipper: Features

Related