### Klipper Architecture Setup Example Source: https://github.com/herfavor/klipper/blob/master/docs/Code_Overview.md Illustrates the initial steps for setting up a new architecture directory within Klipper, including Kconfig and Makefile support. It references the simulator directory as a minimal starting point. ```makefile # Example Makefile structure for a new architecture # Include generic C code include ../generic/Makefile.common # Define architecture-specific sources ARCH_SRCS :=\ $(ARCH_DIR)/main.c \ $(ARCH_DIR)/gpio.c \ $(ARCH_DIR)/timers.c # Add architecture-specific object files to the build OBJS += $(ARCH_SRCS:.c=.o) # Linker script and flags (example) LDFLAGS += -T $(ARCH_DIR)/linker.ld # Include common build rules include ../Makefile.common ``` -------------------------------- ### Copy and Edit Klipper Configuration Source: https://github.com/herfavor/klipper/blob/master/docs/Installation.md Demonstrates how to copy an example Klipper configuration file and open it for editing using nano. This is a common step after obtaining a configuration file. ```bash cp ~/klipper/config/example-cartesian.cfg ~/printer.cfg nano ~/printer.cfg ``` -------------------------------- ### Install Git and Klipper with OctoPi Source: https://github.com/herfavor/klipper/blob/master/docs/OctoPrint.md Commands to install Git if not present, clone the Klipper repository, and execute the installation script for OctoPi. This process sets up Klipper to run at system startup. ```bash sudo apt install git ``` ```bash cd ~ git clone https://github.com/Klipper3d/klipper ./klipper/scripts/install-octopi.sh ``` -------------------------------- ### KIAUH Installation Helper for Klipper Source: https://github.com/herfavor/klipper/blob/master/docs/Installation.md KIAUH (Klipper Install And Update Helper) is a third-party tool used to install Klipper and associated programs on various Linux-based systems, particularly those running Debian. It simplifies the setup process for Klipper and its ecosystem. ```markdown Installing via KIAUH Normally you would start with a base image for your SBC, RPiOS Lite for example, or in the case of an x86 Linux device, Ubuntu Server. Please note that Desktop variants are not recommended due to certain helper programs that can stop some Klipper functions from working and even mask access to some printer boards. KIAUH can be used to install Klipper and its associated programs on a variety of Linux-based systems that run a form of Debian. More information can be found at https://github.com/dw-0/kiauh ``` -------------------------------- ### Klipper Installation and Configuration Source: https://github.com/herfavor/klipper/blob/master/docs/Overview.md Guides users through the installation process, configuration parameters, and specific calibration techniques like bed leveling and resonance compensation. ```markdown ## Installation and Configuration - [Installation](Installation.md): Guide to installing Klipper. - [Octoprint](OctoPrint.md): Guide to installing Octoprint with Klipper. - [Config Reference](Config_Reference.md): Description of config parameters. - [Rotation Distance](Rotation_Distance.md): Calculating the rotation_distance stepper parameter. - [Config checks](Config_checks.md): Verify basic pin settings in the config file. - [Bed level](Bed_Level.md): Information on "bed leveling" in Klipper. - [Delta calibrate](Delta_Calibrate.md): Calibration of delta kinematics. - [Probe calibrate](Probe_Calibrate.md): Calibration of automatic Z probes. - [BL-Touch](BLTouch.md): Configure a "BL-Touch" Z probe. - [Manual level](Manual_Level.md): Calibration of Z endstops (and similar). - [Bed Mesh](Bed_Mesh.md): Bed height correction based on XY locations. - [Endstop phase](Endstop_Phase.md): Stepper assisted Z endstop positioning. - [Axis Twist Compensation](Axis_Twist_Compensation.md): A tool to compensate for inaccurate probe readings due to twist in X gantry. - [Resonance compensation](Resonance_Compensation.md): A tool to reduce ringing in prints. - [Measuring resonances](Measuring_Resonances.md): Information on using adxl345 accelerometer hardware to measure resonance. - [Pressure advance](Pressure_Advance.md): Calibrate extruder pressure. - [G-Codes](G-Codes.md): Information on commands supported by Klipper. - [Command Templates](Command_Templates.md): G-Code macros and conditional evaluation. - [Status Reference](Status_Reference.md): Information available to macros (and similar). - [TMC Drivers](TMC_Drivers.md): Using Trinamic stepper motor drivers with Klipper. - [Multi-MCU Homing](Multi_MCU_Homing.md): Homing and probing using multiple micro-controllers. - [Slicers](Slicers.md): Configure "slicer" software for Klipper. - [Skew correction](Skew_Correction.md): Adjustments for axes not perfectly square. - [PWM tools](Using_PWM_Tools.md): Guide on how to use PWM controlled tools such as lasers or spindles. - [Exclude Object](Exclude_Object.md): The guide to the Exclude Objects implementation. ``` -------------------------------- ### SBC OS Image Options for Klipper Source: https://github.com/herfavor/klipper/blob/master/docs/Installation.md This section details obtaining operating system images for Single Board Computers (SBCs) to run Klipper. It highlights popular front-end options like Fluidd and Mainsail, and their associated OS images or installation methods. ```markdown Obtaining an OS image for SBC's There are many ways to obtain an OS image for Klipper for SBC use, most depend on what front end you wish to use. Some manufacturers of these SBC boards also provide their own Klipper-centric images. The two main Moonraker-based front ends are [Fluidd](https://docs.fluidd.xyz/) and [Mainsail](https://docs.mainsail.xyz/), the latter of which has a premade install image ["MainsailOS"](https://docs-os.mainsail.xyz/), this has the option for Raspberry Pi and some OrangePi variants. Fluidd can be installed via KIAUH(Klipper Install And Update Helper), which is explained below and is a 3rd party installer for all things Klipper. OctoPrint can be installed via the popular OctoPi image or via KIAUH, this process is explained in [OctoPrint.md](OctoPrint.md) ``` -------------------------------- ### Compile Klipper Firmware Source: https://github.com/herfavor/klipper/blob/master/docs/Installation.md Steps to compile the Klipper firmware after configuring it using 'make menuconfig'. This involves navigating to the Klipper directory and running the 'make' command. ```bash cd ~/klipper/ make menuconfig make ``` -------------------------------- ### Klipper Configuration File Acquisition Source: https://github.com/herfavor/klipper/blob/master/docs/Installation.md Obtaining the correct printer configuration file (printer.cfg) is crucial for Klipper setup. Users can find pre-made files in the Klipper config directory, manufacturer websites, or create custom ones. ```markdown Obtain a Klipper Configuration File Most Klipper settings are determined by a "printer configuration file" printer.cfg, that will be stored on the host. An appropriate configuration file can often be found by looking in the Klipper [config directory](../config/) for a file starting with a "printer-" prefix that corresponds to the target printer. The Klipper configuration file contains technical information about the printer that will be needed during the installation. If there isn't an appropriate printer configuration file in the Klipper config directory then try searching the printer manufacturer's website to see if they have an appropriate Klipper configuration file. If no configuration file for the printer can be found, but the type of printer control board is known, then look for an appropriate [config file](../config/) starting with a "generic-" prefix. These example printer board files should allow one to successfully complete the initial installation, but will require some customization to obtain full printer functionality. It is also possible to define a new printer configuration from scratch. However, this requires significant technical knowledge about the printer and its electronics. It is recommended that most users start with an appropriate configuration file. If creating a new custom printer configuration file, then start with the closest example [config file](../config/) and use the Klipper [config reference](Config_Reference.md) for further information. ``` -------------------------------- ### Run Klipper simulation (system-wide install) Source: https://github.com/herfavor/klipper/blob/master/docs/Debugging.md Starts the Klipper simulation when the Python module is installed system-wide, simplifying the command. ```bash ./scripts/avrsim.py out/klipper.elf ``` -------------------------------- ### Configure and Build Klipper for Linux Process Source: https://github.com/herfavor/klipper/blob/master/docs/RPi_microcontroller.md Configures the Klipper microcontroller code for a 'Linux process' architecture using 'make menuconfig', then builds and installs the code. It also includes steps to stop and start the klippy service. ```makefile cd ~/klipper/ make menuconfig # In menuconfig: Set "Microcontroller Architecture" to "Linux process" sudo service klipper stop make flash sudo service klipper start ``` -------------------------------- ### Update Klipper Configuration with Serial Port Source: https://github.com/herfavor/klipper/blob/master/docs/Installation.md Shows an example of how to update the Klipper configuration file (`printer.cfg`) with the correct serial port for the microcontroller. This is a crucial step for Klipper to communicate with the printer's hardware. ```bash [mcu] serial: /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0 ``` -------------------------------- ### Laserweb Configuration for PWM Tool Source: https://github.com/herfavor/klipper/blob/master/docs/Using_PWM_Tools.md Provides example configurations for Laserweb to integrate with Klipper's PWM tool functionality. This includes settings for G-code start, end, homing, tool on/off, and laser intensity. ```gcode GCODE START: M5 ; Disable Laser G21 ; Set units to mm G90 ; Absolute positioning G0 Z0 F7000 ; Set Non-Cutting speed GCODE END: M5 ; Disable Laser G91 ; relative G0 Z+20 F4000 ; G90 ; absolute GCODE HOMING: M5 ; Disable Laser G28 ; Home all axis TOOL ON: M3 $INTENSITY TOOL OFF: M5 ; Disable Laser LASER INTENSITY: S ``` -------------------------------- ### Klipper Peripheral Integration Example Source: https://github.com/herfavor/klipper/blob/master/docs/Code_Overview.md Showcases examples of integrating additional peripherals into Klipper, referencing specific commits that demonstrate the process for different hardware components. ```c // Placeholder for peripheral integration code // This would involve specific HAL calls or direct register manipulation // depending on the peripheral and microcontroller. // Example: Initializing an SPI peripheral void init_spi_peripheral(void) { // SPI_Init(SPI_INSTANCE, &spi_config); } // Example: Reading data from an ADC channel int read_adc_channel(int channel) { // return ADC_Read(ADC_INSTANCE, channel); return 0; // Placeholder } ``` -------------------------------- ### Install gpiod on Debian-based Systems Source: https://github.com/herfavor/klipper/blob/master/docs/RPi_microcontroller.md Installs the Linux GPIO character device binary, which is necessary for advanced GPIO management. ```bash sudo apt-get install gpiod ``` -------------------------------- ### Install Klipper on BeagleBone Source: https://github.com/herfavor/klipper/blob/master/docs/Beaglebone.md Clones the Klipper repository and executes the installation script specifically designed for BeagleBone. This is the primary step for setting up Klipper. ```bash git clone https://github.com/Klipper3d/klipper.git ./klipper/scripts/install-beaglebone.sh ``` -------------------------------- ### Flash Klipper Firmware (RP2040) Source: https://github.com/herfavor/klipper/blob/master/docs/Installation.md Command to flash the compiled Klipper firmware onto RP2040-based micro-controllers. Note that RP2040 chips may require entering Boot mode prior to flashing. ```bash sudo service klipper stop make flash FLASH_DEVICE=first sudo service klipper start ``` -------------------------------- ### Start OctoPrint Service Source: https://github.com/herfavor/klipper/blob/master/docs/Beaglebone.md Starts the OctoPrint service using systemctl. After starting, it is recommended to wait a couple of minutes for the web server to become accessible. ```bash sudo systemctl start octoprint ``` -------------------------------- ### Multi-Stepper Example (CoreXY AWD) Source: https://github.com/herfavor/klipper/blob/master/docs/Config_Reference.md Example configuration for a CoreXY AWD setup using two stepper motors (a0, a1) to drive the same carriages (x, y). ```ini [stepper a0] carriages: x-y step_pin: ... dir_pin: ... enable_pin: ... rotation_distance: ... [stepper a1] carriages: x-y step_pin: ... dir_pin: ... enable_pin: ... rotation_distance: ... ``` -------------------------------- ### Install Klipper MCU Service Script Source: https://github.com/herfavor/klipper/blob/master/docs/RPi_microcontroller.md Installs the systemd service script for the klipper_mcu process, ensuring it runs before the main klippy process when using the host as a secondary MCU. ```bash cd ~/klipper/ && sudo cp ./scripts/klipper-mcu.service /etc/systemd/system/ && sudo systemctl enable klipper-mcu.service ``` -------------------------------- ### Flash Klipper Firmware (Atmega) Source: https://github.com/herfavor/klipper/blob/master/docs/Installation.md Command to flash the compiled Klipper firmware onto Atmega-based micro-controllers. Requires specifying the correct serial port via FLASH_DEVICE. ```bash sudo service klipper stop make flash FLASH_DEVICE=/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0 sudo service klipper start ``` -------------------------------- ### Cura START_PRINT Macro Example Source: https://github.com/herfavor/klipper/blob/master/docs/Slicers.md This G-code snippet demonstrates how to pass bed and extruder temperatures from Cura slicer variables to a START_PRINT macro. ```gcode START_PRINT BED_TEMP={material_bed_temperature_layer_0} EXTRUDER_TEMP={material_print_temperature_layer_0} ``` -------------------------------- ### Example: Plot 3D Mesh Visualization Source: https://github.com/herfavor/klipper/blob/master/docs/Bed_Mesh.md Shows an example of plotting a 3D mesh visualization (meshz) by connecting to Moonraker. This illustrates using a URL as the input source. ```bash graph_mesh.py plot meshz http://my-printer.local ``` -------------------------------- ### Configure OctoPrint to Start at Boot Source: https://github.com/herfavor/klipper/blob/master/docs/Beaglebone.md Copies the OctoPrint init script, sets execute permissions, copies the default configuration, and registers the service to start on boot. ```bash sudo cp ~/OctoPrint/scripts/octoprint.init /etc/init.d/octoprint sudo chmod +x /etc/init.d/octoprint sudo cp ~/OctoPrint/scripts/octoprint.default /etc/default/octoprint sudo update-rc.d octoprint defaults ``` -------------------------------- ### PrusaSlicer/SuperSlicer START_PRINT Macro Example Source: https://github.com/herfavor/klipper/blob/master/docs/Slicers.md This G-code snippet shows how to pass first layer temperatures from PrusaSlicer or SuperSlicer to a START_PRINT macro. ```gcode START_PRINT EXTRUDER_TEMP=[first_layer_temperature] BED_TEMP=[first_layer_bed_temperature] ``` -------------------------------- ### Install can-utils Source: https://github.com/herfavor/klipper/blob/master/docs/CANBUS_Troubleshooting.md Installs the can-utils package, which provides tools for capturing and analyzing CAN bus traffic. This is necessary for using the candump command. ```bash sudo apt-get update && sudo apt-get install can-utils ``` -------------------------------- ### G-code Action Examples Source: https://github.com/herfavor/klipper/blob/master/docs/Config_Changes.md Demonstrates various G-code actions and response functions within Klipper. Includes examples for emergency stops and informational/error responses. ```python action_emergency_stop() printer.gcode.action_respond_info() printer.gcode.action_respond_error() action_raise_error() ``` -------------------------------- ### Klipper Overview and Features Source: https://github.com/herfavor/klipper/blob/master/docs/Overview.md Provides a high-level overview of Klipper's features and links to related documentation for installation, configuration, and general information. ```markdown # Overview Welcome to the Klipper documentation. If new to Klipper, start with the [features](Features.md) and [installation](Installation.md) documents. ## Overview information - [Features](Features.md): A high-level list of features in Klipper. - [FAQ](FAQ.md): Frequently asked questions. - [Releases](Releases.md): The history of Klipper releases. - [Config changes](Config_Changes.md): Recent software changes that may require users to update their printer config file. - [Contact](Contact.md): Information on bug reporting and general communication with the Klipper developers. ``` -------------------------------- ### Load Cell Configuration Examples Source: https://github.com/herfavor/klipper/blob/master/docs/Config_Reference.md Example configuration snippets for load cells, demonstrating the use of gain and sample rate parameters for different sensor types. ```ini #gain: A-128 #sample_rate: 80 ``` ```ini #gain: 128 #sample_rate: 660 ``` -------------------------------- ### Run Klipper simulation with simulavr Source: https://github.com/herfavor/klipper/blob/master/docs/Debugging.md Starts the Klipper simulation using the compiled ELF file. The PYTHONPATH is set if the Python module is not installed system-wide. ```bash PYTHONPATH=/path/to/simulavr/build/pysimulavr/ ./scripts/avrsim.py out/klipper.elf ``` -------------------------------- ### Example bed_mesh Configuration Source: https://github.com/herfavor/klipper/blob/master/docs/Config_Reference.md An example of how to configure the [bed_mesh] section for a rectangular bed with specific probe counts and mesh boundaries. ```ini [bed_mesh] mesh_min: -100, -120 mesh_max: 100, 120 probe_count: 7, 7 horizontal_move_z: 10 mesh_pps: 4, 4 algorithm: bicubic bicubic_tension: 0.5 ``` -------------------------------- ### Dual Carriage Configuration Example Source: https://github.com/herfavor/klipper/blob/master/docs/Config_Reference.md Example configuration for setting up a dual carriage system, including primary carriage definition and stepper motor assignments. It also outlines the process for input shaper calibration with dual carriages. ```cfg [dual_carriage u] primary_carriage: x ... [stepper dc_stepper] carriages: u-y ... ``` -------------------------------- ### Example GPIO Configuration for RPi 3B+ Source: https://github.com/herfavor/klipper/blob/master/docs/RPi_microcontroller.md Demonstrates how to interpret the output of `gpiodetect` and `gpioinfo` to configure a specific GPIO pin (GPIO20) for Klipper usage on a Raspberry Pi 3B+. ```text Example usage on a RPi 3B+ where Klipper uses GPIO20 for a switch: $ gpiodetect gpiochip0 [pinctrl-bcm2835] (54 lines) gpiochip1 [raspberrypi-exp-gpio] (8 lines) $ gpioinfo gpiochip0 - 54 lines: line 0: unnamed unused input active-high ... line 20: unnamed "klipper" output active-high [used] ... gpiochip1 - 8 lines: line 0: unnamed unused input active-high In Klipper configuration, this pin would be referenced as: gpiochip0/gpio20 ``` -------------------------------- ### Installing and Using hid-flash for Klipper Source: https://github.com/herfavor/klipper/blob/master/docs/Bootloaders.md Instructions to install the hid-flash utility and use it to upload the Klipper binary to a board with the HID bootloader. Requires libusb-1.0. ```bash sudo apt install libusb-1.0 cd ~/klipper/lib/hidflash make ~/klipper/lib/hidflash/hid-flash ~/klipper/out/klipper.bin ``` -------------------------------- ### Moonraker Web API Interaction Source: https://github.com/herfavor/klipper/blob/master/docs/Installation.md Klipper can be interacted with using front-end applications that retrieve information through the Moonraker web API. This is a common method for controlling Klipper-enabled 3D printers. ```markdown Interacting with Klipper Klipper is a 3d printer firmware, so it needs some way for the user to interact with it. Currently the best choices are front ends that retrieve information through the [Moonraker web API](https://moonraker.readthedocs.io/) and there is also the option to use [Octoprint](https://octoprint.org/) to control Klipper. The choice is up to the user on what to use, but the underlying Klipper is the same in all cases. We encourage users to research the options available and make an informed decision. ``` -------------------------------- ### Klipper GPIO Input/Output Support Example Source: https://github.com/herfavor/klipper/blob/master/docs/Code_Overview.md Provides an example of how to implement basic GPIO input and output support for a new microcontroller architecture in Klipper. This involves defining functions for controlling and reading GPIO pins. ```c // Example C code for GPIO output #include "compiler.h" #include "gpio.h" #include "board.h" // Define GPIO pin for an LED #define LED_PIN BOARD_GPIO_PIN(PORT, PIN) void set_led(int state) { if (state) { gpio_set_pin_state(LED_PIN, 1); } else { gpio_set_pin_state(LED_PIN, 0); } } // Example C code for GPIO input int read_button(void) { return gpio_get_pin_state(BUTTON_PIN); } ``` -------------------------------- ### Klipper Documentation and Website Source: https://github.com/herfavor/klipper/blob/master/docs/Releases.md Information about the official Klipper documentation website and the availability of example configuration files. ```APIDOC Official Documentation: Website: http://klipper3d.org/ The website provides comprehensive documentation on Klipper's features, configuration, and usage. Example Configuration Files: Numerous example configuration files are provided for common 3D printer models, aiding users in setting up Klipper. ``` -------------------------------- ### Install simulavr dependencies and build .deb packages Source: https://github.com/herfavor/klipper/blob/master/docs/Debugging.md Installs necessary packages on Debian-based systems and generates .deb files for system-wide installation of simulavr. ```bash sudo apt update sudo apt install g++ make cmake swig rst2pdf help2man texinfo make cfgclean python debian sudo dpkg -i build/debian/python3-simulavr*.deb ``` -------------------------------- ### Klipper Configuration File Structure Source: https://github.com/herfavor/klipper/blob/master/docs/Config_Reference.md Example of Klipper configuration file structure, showing how different modules and settings are organized. ```ini # Example Klipper Configuration [mcu] serial: /dev/serial/by-id/usb-Klipper_stm32f407xx_... [stepper_x] step_pin: PA4 dir_pin: PA6 enable_pin: !PA2 ... [replicape] revision: B3 host_mcu: mcu [palette2] serial: /dev/ttyAMA0 ``` -------------------------------- ### Install and Compile OpenOCD Source: https://github.com/herfavor/klipper/blob/master/docs/Bootloaders.md Installs necessary dependencies, clones the OpenOCD repository, configures the build with Raspberry Pi GPIO support, and installs the compiled software. This process can take a significant amount of time. ```bash sudo apt-get update sudo apt-get install autoconf libtool telnet mkdir ~/openocd cd ~/openocd/ git clone http://openocd.zylin.com/openocd cd openocd ./bootstrap ./configure --enable-sysfsgpio --enable-bcm2835gpio --prefix=/home/pi/openocd/install make make install ``` -------------------------------- ### BL-Touch Configuration Example Source: https://github.com/herfavor/klipper/blob/master/docs/BLTouch.md Example INI configuration for setting up the BL-Touch sensor pin and control pin in Klipper. It includes the necessary syntax for pull-up resistors on the sensor pin. ```INI [bltouch] sensor_pin: ^P1.24 control_pin: P1.26 ``` -------------------------------- ### Klipper Protocol Example Commands Source: https://github.com/herfavor/klipper/blob/master/docs/Protocol.md Illustrates a sequence of human-readable commands used in the Klipper messaging protocol for controlling micro-controller actions. ```text set_digital_out pin=PA3 value=1 set_digital_out pin=PA7 value=1 schedule_digital_out oid=8 clock=4000000 value=0 queue_step oid=7 interval=7458 count=10 add=331 queue_step oid=7 interval=11717 count=4 add=1281 ``` -------------------------------- ### Multi-Endstop Example (Dual Y-axis) Source: https://github.com/herfavor/klipper/blob/master/docs/Config_Reference.md Example configuration for a Y-axis driven by two independent stepper motors, each with its own endstop via extra_carriage definitions. ```ini [extra_carriage y1] primary_carriage: y endstop_pin: ... [stepper sy1] carriages: y1 ... ``` -------------------------------- ### Example: Plot Animated Rapid Path Source: https://github.com/herfavor/klipper/blob/master/docs/Bed_Mesh.md Demonstrates how to plot an animated rapid path using the graph_mesh.py script, connecting via Klipper's Unix socket. This is a practical example of using the '-a' and input arguments. ```bash graph_mesh.py plot -a rapid ~/printer_data/comms/klippy.sock ``` -------------------------------- ### Install OctoPrint Source: https://github.com/herfavor/klipper/blob/master/docs/Beaglebone.md Clones the OctoPrint repository, sets up a virtual environment, and installs OctoPrint. This is an optional step if you wish to use OctoPrint with Klipper. ```bash git clone https://github.com/foosel/OctoPrint.git cd OctoPrint/ virtualenv venv ./venv/bin/python setup.py install ``` -------------------------------- ### BeagleBone Hardware Pin Designation Example Source: https://github.com/herfavor/klipper/blob/master/docs/Beaglebone.md Illustrates how pins on a BeagleBone can be configured for different functions using overlays. It shows example pin multiplexing and the process of editing uEnv.txt to load overlays. ```text P9_20 - i2c2_sda/can0_tx/spi1_cs0/gpio0_12/uart1_ctsn P9_19 - i2c2_scl/can0_rx/spi1_cs1/gpio0_13/uart1_rtsn P9_24 - i2c1_scl/can1_rx/gpio0_15/uart1_tx P9_26 - i2c1_sda/can1_tx/gpio0_14/uart1_rx ``` -------------------------------- ### Safe Z Home Configuration Example Source: https://github.com/herfavor/klipper/blob/master/docs/BLTouch.md Example INI configuration for the `[safe_z_home]` section in Klipper. This section defines parameters for safely homing the Z axis after probe activation, including XY position, speed, and Z hop settings. ```INI [safe_z_home] home_xy_position: 100, 100 speed: 50 z_hop: 10 z_hop_speed: 5 ``` -------------------------------- ### Enabling Klipper API Server Source: https://github.com/herfavor/klipper/blob/master/docs/API_Server.md Instructions on how to start the Klipper host software with the API server enabled, creating a Unix Domain Socket for client connections. ```bash ~/klipper-env/bin/python ~/klipper/klippy/klippy.py ~/printer.cfg -a /tmp/klippy_uds -l /tmp/klippy.log ``` -------------------------------- ### Klipper Configuration File Naming and Structure Source: https://github.com/herfavor/klipper/blob/master/docs/Example_Configs.md Details on selecting appropriate filename prefixes (printer, generic, kit, sample, example) and the required `.cfg` suffix, including year-specific suffixes for printer configs. It also specifies allowed characters for filenames and the requirement for config files to be runnable without errors. ```APIDOC Config Filename Guidelines: Prefixes: - printer: For stock printers from mainstream manufacturers. - generic: For 3D printer boards usable in many printer types. - kit: For 3D printers assembled according to widely used specifications. - sample: For config "snippets" for copy-pasting. - example: For describing printer kinematics. Suffix: - All config files must end in `.cfg`. - `printer` config files must end in a year followed by `.cfg` (e.g., `-2019.cfg`). Filename Characters: - Allowed: `A-Z`, `a-z`, `0-9`, `-`, `.` - Disallowed: Spaces or special characters. Requirements: - `printer`, `generic`, and `kit` config files must start without error. - Add new config files to `test/klippy/printers.test`. - Config files should be for the "stock" configuration of the printer. - Only specify devices present on the given printer or board. - Do not specify `pressure_advance`, `max_extrude_only_velocity`, `max_extrude_only_accel`, `[virtual_sdcard]`, or `[temperature_host]`. - Define macros only for printer-specific functionality or common slicer g-codes. - Use `field: value` syntax. - Prefer `gear_ratio` over `rotation_distance` when applicable. - Avoid defining default field values. - Lines should not exceed 80 columns. - Avoid attribution or revision messages. ``` -------------------------------- ### Klipper Startup Commands Source: https://github.com/herfavor/klipper/blob/master/docs/MCU_Commands.md Provides essential commands for initial micro-controller and peripheral configuration. These commands execute immediately upon receipt. ```APIDOC set_digital_out pin=%u value=%c - Configures a given pin as a digital output GPIO and sets its level to low (0) or high (1). - Useful for initial LED values and stepper driver micro-stepping pins. - Parameters: - pin: The GPIO pin to configure (integer). - value: The digital value to set (0 for low, 1 for high). set_pwm_out pin=%u cycle_ticks=%u value=%hu - Configures a given pin for hardware-based Pulse-Width-Modulation (PWM). - Parameters: - pin: The GPIO pin to configure (integer). - cycle_ticks: The number of MCU clock ticks for each on/off cycle. A value of 1 requests the fastest possible cycle time. - value: The PWM duty cycle, ranging from 0 (fully off) to 255 (fully on). ``` -------------------------------- ### Klippy Host Code Entry Point Source: https://github.com/herfavor/klipper/blob/master/docs/Code_Overview.md Describes the initial execution flow of the Klippy host code, including argument parsing, configuration loading, printer object instantiation, and serial connection setup. ```python Initial execution starts in **klippy/klippy.py**. This reads the command-line arguments, opens the printer config file, instantiates the main printer objects, and starts the serial connection. ``` -------------------------------- ### Identify Micro-controller Serial Port Source: https://github.com/herfavor/klipper/blob/master/docs/Installation.md Command to list available serial ports, helping to identify the unique identifier for the micro-controller. This is crucial for the flashing process. ```bash ls /dev/serial/by-id/* ``` -------------------------------- ### Running Multiple Klipper Instances Source: https://github.com/herfavor/klipper/blob/master/docs/FAQ.md Demonstrates how to run multiple instances of the Klipper host software on the same machine. This requires custom configuration for each instance, including separate configuration files, log files, and pseudo-ttys. ```bash ~/klippy-env/bin/python ~/klipper/klippy/klippy.py ~/printer.cfg -l /tmp/klippy.log ``` ```bash ~/klippy-env/bin/python ~/klipper/klippy/klippy.py ~/printer2.cfg -l /tmp/klippy2.log -I /tmp/printer2 ``` -------------------------------- ### SCREWS_TILT_CALCULATE G-Code Commands and Output Source: https://github.com/herfavor/klipper/blob/master/docs/Manual_Level.md Example of using the SCREWS_TILT_CALCULATE command in Klipper, including the G-code commands sent and the expected output for bed screw adjustments. ```gcode Send: G28 Recv: ok Send: SCREWS_TILT_CALCULATE Recv: // 01:20 means 1 full turn and 20 minutes, CW=clockwise, CCW=counter-clockwise Recv: // front left screw (base) : x=-5.0, y=30.0, z=2.48750 Recv: // front right screw : x=155.0, y=30.0, z=2.36000 : adjust CW 01:15 Recv: // rear right screw : y=155.0, y=190.0, z=2.71500 : adjust CCW 00:50 Recv: // read left screw : x=-5.0, y=190.0, z=2.47250 : adjust CW 00:02 Recv: ok ``` -------------------------------- ### OctoPrint Serial Port Configuration Source: https://github.com/herfavor/klipper/blob/master/docs/OctoPrint.md Instructions for configuring OctoPrint's serial connection settings to communicate with Klipper. This involves adding a specific serial port path and selecting it. ```text ~/printer_data/comms/klippy.serial ``` -------------------------------- ### Flash Micro-controller with Klipper Source: https://github.com/herfavor/klipper/blob/master/docs/FAQ.md This example demonstrates the commands to stop the Klipper service, flash the micro-controller with the correct device path, and then restart the Klipper service. It assumes the FLASH_DEVICE variable is set correctly. ```bash sudo service klipper stop make flash FLASH_DEVICE=/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0 sudo service klipper start ``` -------------------------------- ### Fine-grained Bed Screw Adjustments Configuration Source: https://github.com/herfavor/klipper/blob/master/docs/Manual_Level.md Configuration example for enabling fine-grained bed leveling adjustments in Klipper. This involves defining additional nozzle coordinates for more precise screw adjustments. ```ini [bed_screws] screw1: 100, 50 screw1_fine_adjust: 0, 0 screw2: 100, 150 screw2_fine_adjust: 300, 300 screw3: 150, 100 screw3_fine_adjust: 0, 100 ``` -------------------------------- ### Klipper gcode_macro for Start/End Print Source: https://github.com/herfavor/klipper/blob/master/docs/Slicers.md Defines custom macros in the Klipper configuration file for printer start and end sequences. This allows for easier modification of start/end steps without re-slicing. ```Klipper Configuration [gcode_macro START_PRINT] # Add your start print G-code here [gcode_macro END_PRINT] # Add your end print G-code here ``` -------------------------------- ### Identify Klipper Microcontroller Serial Port Source: https://github.com/herfavor/klipper/blob/master/docs/Installation.md Lists the available serial ports on the system, which is necessary to identify the unique name for the microcontroller after flashing Klipper. The output helps in configuring the 'serial' parameter in the Klipper configuration file. ```bash ls /dev/serial/by-id/* ``` -------------------------------- ### Python Board Alias Example Source: https://github.com/herfavor/klipper/blob/master/docs/SDCard_Updates.md This Python code snippet shows how to create an alias for an existing board definition in Klipper. Aliases are useful for reusing configurations or providing alternative names for board definitions, simplifying the setup process. ```python BOARD_ALIASES = { ..., 'my-new-board': BOARD_DEFS['generic-lpc1768'], } ``` -------------------------------- ### Klipper Device Specific Documents Source: https://github.com/herfavor/klipper/blob/master/docs/Overview.md Documentation for specific hardware integrations and flashing methods, including Raspberry Pi, Beaglebone, and CAN bus configurations. ```markdown ## Device Specific Documents - [Example configs](Example_Configs.md): Information on adding an example config file to Klipper. - [SDCard Updates](SDCard_Updates.md): Flash a micro-controller by copying a binary to an sdcard in the micro-controller. - [Raspberry Pi as Micro-controller](RPi_microcontroller.md): Details for controlling devices wired to the GPIO pins of a Raspberry Pi. - [Beaglebone](Beaglebone.md): Details for running Klipper on the Beaglebone PRU. - [Bootloaders](Bootloaders.md): Developer information on micro-controller flashing. - [Bootloader Entry](Bootloader_Entry.md): Requesting the bootloader. - [CAN bus](CANBUS.md): Information on using CAN bus with Klipper. - [CAN bus troubleshooting](CANBUS_Troubleshooting.md): Tips for troubleshooting CAN bus. - [TSL1401CL filament width sensor](TSL1401CL_Filament_Width_Sensor.md) - [Hall filament width sensor](Hall_Filament_Width_Sensor.md) - [Eddy Current Inductive probe](Eddy_Probe.md) - [Load Cells](Load_Cell.md) ``` -------------------------------- ### Logic Analyzer Setup for CAN Bus Source: https://github.com/herfavor/klipper/blob/master/docs/CANBUS_Troubleshooting.md Utilize Sigrok Pulseview software with a USB logic analyzer to diagnose CAN bus signaling. Connect CH0 to CAN Rx, CH1 to CAN Tx, and GND to GND. Configure Pulseview with a CAN decoder and appropriate settings for bit timing analysis. ```bash candump -tz -Ddex can0,#FFFFFFFF cansend can0 123#121212121212 ``` -------------------------------- ### Run simulavr with signal wave generation Source: https://github.com/herfavor/klipper/blob/master/docs/Debugging.md Starts the simulavr simulation and generates a .vcd file for signal wave analysis by specifying the ports to track. ```bash PYTHONPATH=/path/to/simulavr/src/python/ ./scripts/avrsim.py out/klipper.elf -t PORTA.PORT,PORTC.PORT ``` -------------------------------- ### Verify NumPy Installation Source: https://github.com/herfavor/klipper/blob/master/docs/Measuring_Resonances.md Checks if the NumPy library is correctly installed and accessible within the Klipper Python environment. ```python ~/klippy-env/bin/python -c 'import numpy;' ``` -------------------------------- ### Install Matplotlib for Graphing Source: https://github.com/herfavor/klipper/blob/master/docs/Debugging.md Installs the 'matplotlib' Python package, which is required for generating graphs with Klipper's analysis tools. ```bash sudo apt-get update sudo apt-get install python-matplotlib ``` -------------------------------- ### CMake Configuration for Boot Stage 2 Source: https://github.com/herfavor/klipper/blob/master/lib/pico-sdk/rp2040/boot_stage2/CMakeLists.txt This snippet demonstrates how Klipper's CMake scripts handle the selection of the boot stage 2 file. It prioritizes environment variables and cached variables, providing fallback mechanisms and error checking for the specified file's existence. This ensures a robust build process for different configurations. ```cmake if (DEFINED ENV{PICO_DEFAULT_BOOT_STAGE2_FILE}) set(PICO_DEFAULT_BOOT_STAGE2_FILE $ENV{PICO_DEFAULT_BOOT_STAGE2_FILE}) message("Using PICO_DEFAULT_BOOT_STAGE2_FILE from environment ('${PICO_DEFAULT_BOOT_STAGE2_FILE}')") elseif (PICO_DEFAULT_BOOT_STAGE2_FILE) # explicitly set, so cache it set(PICO_DEFAULT_BOOT_STAGE2_FILE "${PICO_DEFAULT_BOOT_STAGE2_FILE}" CACHE STRING "boot stage 2 source file" FORCE) endif() set(PICO_BOOT_STAGE2_COMPILE_TIME_CHOICE_NAME compile_time_choice) # local var if (NOT PICO_DEFAULT_BOOT_STAGE2_FILE) if (DEFINED ENV{PICO_DEFAULT_BOOT_STAGE2}) set(PICO_DEFAULT_BOOT_STAGE2 $ENV{PICO_DEFAULT_BOOT_STAGE2}) message("Using PICO_DEFAULT_BOOT_STAGE2 from environment ('${PICO_DEFAULT_BOOT_STAGE2}')") endif() if (NOT DEFINED PICO_DEFAULT_BOOT_STAGE2) set(PICO_DEFAULT_BOOT_STAGE2 ${PICO_BOOT_STAGE2_COMPILE_TIME_CHOICE_NAME}) endif() set(PICO_DEFAULT_BOOT_STAGE2 "${PICO_DEFAULT_BOOT_STAGE2}" CACHE STRING "boot stage 2 short name" FORCE) set(PICO_DEFAULT_BOOT_STAGE2_FILE "${CMAKE_CURRENT_LIST_DIR}/${PICO_DEFAULT_BOOT_STAGE2}.S") endif() if (NOT EXISTS ${PICO_DEFAULT_BOOT_STAGE2_FILE}) message(FATAL_ERROR "Specified boot stage 2 source '${PICO_DEFAULT_BOOT_STAGE2_FILE}' does not exist.") endif() pico_register_common_scope_var(PICO_DEFAULT_BOOT_STAGE2_FILE) # needed by function below set(PICO_BOOT_STAGE2_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "") add_library(boot_stage2_headers INTERFACE) target_include_directories(boot_stage2_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) ``` -------------------------------- ### Klipper Host Software Execution Source: https://github.com/herfavor/klipper/blob/master/docs/FAQ.md The core command for running the Klipper host software. It requires a Python environment, the Klipper installation path, a printer configuration file, and a log file path. ```python ~/klippy-env/bin/python ~/klipper/klippy/klippy.py ~/printer.cfg -l /tmp/klippy.log ``` -------------------------------- ### Klipper Micro-controller Initialization and Task Scheduling Source: https://github.com/herfavor/klipper/blob/master/docs/Code_Overview.md Describes how the micro-controller code starts execution, initializes components using DECL_INIT(), and runs periodic tasks using DECL_TASK(). It highlights the role of sched_main() and the importance of avoiding long delays in task functions. ```C /* Micro-controller code execution starts in architecture specific code (e.g., src/avr/main.c) */ /* ... */ sched_main(); /* Located in src/sched.c */ /* Inside sched_main(): */ /* Run all functions tagged with DECL_INIT() */ /* Then repeatedly run all functions tagged with DECL_TASK() */ ``` -------------------------------- ### Example G-code for Temperature Probe Calibration Source: https://github.com/herfavor/klipper/blob/master/docs/Eddy_Probe.md An example of how to initiate the temperature probe calibration process using the TEMPERATURE_PROBE_CALIBRATE command. ```gcode TEMPERATURE_PROBE_CALIBRATE PROBE=my_probe TARGET=80 ``` -------------------------------- ### Sensorless Homing Configuration Example Source: https://github.com/herfavor/klipper/blob/master/docs/TMC_Drivers.md Provides an example of how to configure the homing speed for sensorless homing in the Klipper printer configuration file. ```ini [stepper_x] rotation_distance: 40 homing_speed: 20 ... ```