Skip to content

Instantly share code, notes, and snippets.

@Traxmaxx
Created August 20, 2022 11:15
Show Gist options
  • Save Traxmaxx/698ed0179d4efcaf9f04e7097ceb37f8 to your computer and use it in GitHub Desktop.
Save Traxmaxx/698ed0179d4efcaf9f04e7097ceb37f8 to your computer and use it in GitHub Desktop.
Ender 5 Pro Klipper configuration - 4.2.2 Board with Stock Extruder & Hot-End & BLTouch v3.1 on Klipper v0.10.0-554
######################################################################
# Start Print and End Print
######################################################################
# Replace the slicer's custom start and end g-code scripts with
# START_PRINT and END_PRINT.
[gcode_macro START_PRINT]
gcode:
{% set BED_TEMP = params.BED_TEMP|default(80)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(215)|float %}
# Start bed heating
M140 S{BED_TEMP}
# Use absolute coordinates
# Wait for bed to reach temperature
M190 S{BED_TEMP}
# Set and wait for nozzle to reach temperature
M109 S{EXTRUDER_TEMP}
# Home the printer
G28
# Calibrate Mesh
BED_MESH_CALIBRATE
G90
# Reset the G-Code Z offset (adjust Z offset if needed)
SET_GCODE_OFFSET Z=0.0
# Move the nozzle near the bed
G1 Z5 F3000
# Move the nozzle very close to the bed
G1 Z0.15 F300
[gcode_macro END_PRINT]
gcode:
G91 ;Relative positioning
G1 E-2 F2700 ;Retract a bit
G1 E-2 Z0.2 F2400 ;Retract and raise Z
G1 X5 Y5 F3000 ;Wipe out
G1 Z10 ;Raise Z more
G90 ;Absolute positioning
G28 X0 Y0 ;Present print
M106 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed
M84 X Y E ;Disable all steppers but Z
######################################################################
# Filament Change
######################################################################
# M600: Filament Change. This macro will pause the printer, move the
# tool to the change position, and retract the filament 50mm. Adjust
# the retraction settings for your own extruder. After filament has
# been changed, the print can be resumed from its previous position
# with the "RESUME" gcode.
[pause_resume]
[gcode_macro M600]
gcode:
{% set X = params.X|default(50)|float %}
{% set Y = params.Y|default(0)|float %}
{% set Z = params.Z|default(10)|float %}
SAVE_GCODE_STATE NAME=M600_state
PAUSE
G91
G1 E-.8 F2700
G1 Z{Z}
G90
G1 X{X} Y{Y} F3000
G91
G1 E-50 F1000
RESTORE_GCODE_STATE NAME=M600_state
######################################################################
# Beeper
######################################################################
# M300 : Play tone. Beeper support, as commonly found on usual LCD
# displays (i.e. RepRapDiscount 2004 Smart Controller, RepRapDiscount
# 12864 Full Graphic). This defines a custom I/O pin and a custom
# GCODE macro. Usage:
# M300 [P<ms>] [S<Hz>]
# P is the tone duration, S the tone frequency.
# The frequency won't be pitch perfect.
[gcode_macro M300]
gcode:
{% set S = params.S|default(1000)|int %} ; S sets the tone frequency
{% set P = params.P|default(100)|int %} ; P sets the tone duration
{% set L = 0.5 %} ; L varies the PWM on time, close to 0 or 1 the tone gets a bit quieter. 0.5 is a symmetric waveform
{% if S <= 0 %} ; dont divide through zero
{% set F = 1 %}
{% set L = 0 %}
{% elif S >= 10000 %} ;max frequency set to 10kHz
{% set F = 0 %}
{% else %}
{% set F = 1/S %} ;convert frequency to seconds
{% endif %}
SET_PIN PIN=BEEPER_Pin VALUE={L} CYCLE_TIME={F} ;Play tone
G4 P{P} ;tone duration
SET_PIN PIN=BEEPER_Pin VALUE=0
# Cancel object (aka Marlin/RRF M486 commands) support
#
# Enable object exclusion
[exclude_object]
[gcode_macro M486]
gcode:
# Parameters known to M486 are as follows:
# [C<flag>] Cancel the current object
# [P<index>] Cancel the object with the given index
# [S<index>] Set the index of the current object.
# If the object with the given index has been canceled, this will cause
# the firmware to skip to the next object. The value -1 is used to
# indicate something that isn’t an object and shouldn’t be skipped.
# [T<count>] Reset the state and set the number of objects
# [U<index>] Un-cancel the object with the given index. This command will be
# ignored if the object has already been skipped
{% if 'exclude_object' not in printer %}
{action_raise_error("[exclude_object] is not enabled")}
{% endif %}
{% if 'T' in params %}
EXCLUDE_OBJECT RESET=1
{% for i in range(params.T | int) %}
EXCLUDE_OBJECT_DEFINE NAME={i}
{% endfor %}
{% endif %}
{% if 'C' in params %}
EXCLUDE_OBJECT CURRENT=1
{% endif %}
{% if 'P' in params %}
EXCLUDE_OBJECT NAME={params.P}
{% endif %}
{% if 'S' in params %}
{% if params.S == '-1' %}
{% if printer.exclude_object.current_object %}
EXCLUDE_OBJECT_END NAME={printer.exclude_object.current_object}
{% endif %}
{% else %}
EXCLUDE_OBJECT_START NAME={params.S}
{% endif %}
{% endif %}
{% if 'U' in params %}
EXCLUDE_OBJECT RESET=1 NAME={params.U}
{% endif %}
# Mainsail klipper definitions
#
# Copyright (C) 2021 Alex Zellner <alexander.zellner@googlemail.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license
#
# Version 1.11
# add [include mainsail.cfg] to your printer.cfg to include it to your printer.cfg
# modify x_park, y_park, z_park_delta and extrude value at the macro _TOOLHEAD_PARK_PAUSE_CANCEL if needed
# use variable_park: False at CANCEL_PRINT to disallow the parking move
[virtual_sdcard]
path: ~/gcode_files
on_error_gcode:
CANCEL_PRINT
[pause_resume]
[display_status]
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
variable_park: True
gcode:
## Move head and retract only if not already in the pause state and park set to true
{% if printer.pause_resume.is_paused|lower == 'false' and park|lower == 'true'%}
_TOOLHEAD_PARK_PAUSE_CANCEL
{% endif %}
TURN_OFF_HEATERS
M106 S0
CANCEL_PRINT_BASE
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
gcode:
PAUSE_BASE
_TOOLHEAD_PARK_PAUSE_CANCEL
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
##### read extrude from _TOOLHEAD_PARK_PAUSE_CANCEL macro #####
{% set extrude = printer['gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL'].extrude %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
M83
G1 E{extrude} F2100
{% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %}
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESUME_BASE {get_params}
[gcode_macro _TOOLHEAD_PARK_PAUSE_CANCEL]
description: Helper: park toolhead used in PAUSE and CANCEL_PRINT
variable_extrude: 1.0
gcode:
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
{% set z_park_delta = 2.0 %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - z_park_delta) %}
{% set z_safe = z_park_delta %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
M83
G1 E-{extrude} F2100
{% if printer.gcode_move.absolute_extrude |lower == 'true' %} M82 {% endif %}
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G91
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F6000
{% if printer.gcode_move.absolute_coordinates|lower == 'false' %} G91 {% endif %}
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
[server]
host: 0.0.0.0
port: 7125
enable_debug_logging: False
klippy_uds_address: /tmp/klippy_uds
[authorization]
trusted_clients:
10.0.0.0/8
127.0.0.0/8
192.168.0.0/16
FE80::/10
::1/128
cors_domains:
http://*.local
[database]
database_path: /home/pi/.moonraker_database
[file_manager]
config_path: /home/pi/klipper_config
log_path: /home/pi/klipper_logs
[octoprint_compat]
[history]
[update_manager]
channel: dev
refresh_interval: 168
[update_manager mainsail]
type: web
channel: stable
repo: mainsail-crew/mainsail
path: ~/mainsail
# [power device_name]
# type: klipper_device
# # The type of device. Can be either gpio, klipper_device, rf,
# # tplink_smartplug, tasmota, shelly, homeseer, homeassistant, loxonev1,
# # smartthings, mqtt or hue.
# # This parameter must be provided.
# off_when_shutdown: False
# # If set to True the device will be powered off when Klipper enters
# # the "shutdown" state. This option applies to all device types.
# # The default is False.
# on_when_job_queued: False
# # If set to True the device will power on if a job is queued while the
# # device is off. This allows for an automated "upload, power on, and
# # print" approach directly from the slicer, see the configuration example
# # below for details. The default is False.
# locked_while_printing: False
# # If True, locks the device so that the power cannot be changed while the
# # printer is printing. This is useful to avert an accidental shutdown to
# # the printer's power. The default is False.
# restart_klipper_when_powered: False
# # If set to True, Moonraker will schedule a "FIRMWARE_RESTART" to command
# # after the device has been powered on. If it isn't possible to immediately
# # schedule a firmware restart (ie: Klippy is disconnected), the restart
# # will be postponed until Klippy reconnects and reports that startup is
# # complete. Prior to scheduling the restart command the power device will
# # always check Klippy's state. If Klippy reports that it is "ready", the
# # FIRMWARE_RESTART will be aborted as unnecessary.
# # The default is False.
# bound_service:
# # Can be set to any service Moonraker is authorized to manage with the
# # exception of the moonraker service itself. See the tip below this section
# # for details on what services are authorized. When a bound service has
# # been set the service will be started when the device powers on and stopped
# # when the device powers off. The default is no service is bound to the
# # device.
# This file contains pin mappings for the Creality "v4.2.7" board. To
# use this config, during "make menuconfig" select the STM32F103 with
# a "28KiB bootloader" and serial (on USART1 PA10/PA9) communication.
# If you prefer a direct serial connection, in "make menuconfig"
# select "Enable extra low-level configuration options" and select
# serial (on USART3 PB11/PB10), which is broken out on the 10 pin IDC
# cable used for the LCD module as follows:
# 3: Tx, 4: Rx, 9: GND, 10: VCC
# Flash this firmware by copying "out/klipper.bin" to a SD card and
# turning on the printer with the card inserted. The firmware
# filename must end in ".bin" and must not match the last filename
# that was flashed.
# See docs/Config_Reference.md for a description of parameters.
[stepper_x]
step_pin: PC2
dir_pin: !PB9
enable_pin: !PC3
microsteps: 16
rotation_distance: 40
endstop_pin: ^PA5
position_endstop: 0
position_max: 220
homing_speed: 50
[stepper_y]
step_pin: PB8
dir_pin: !PB7
enable_pin: !PC3
microsteps: 16
rotation_distance: 40
endstop_pin: ^PA6
position_endstop: 0
position_max: 220
homing_speed: 50
[stepper_z]
step_pin: PB6
dir_pin: PB5
enable_pin: !PC3
microsteps: 16
rotation_distance: 4
endstop_pin: probe:z_virtual_endstop
position_max: 250
position_min: 0
[bltouch]
sensor_pin = ^PB1
control_pin = PB0
x_offset = 44
y_offset = 5
probe_with_touch_mode = True
pin_up_touch_mode_reports_triggered = True
# stow_on_each_sample = False
[safe_z_home]
home_xy_position: 110,110 # Change coordinates to the center of your print bed
speed: 50
z_hop: 10 # Move up 10mm
z_hop_speed: 5
[bed_mesh]
speed: 30
horizontal_move_z: 10
mesh_min: 44,5
mesh_max: 220,210
probe_count: 3,3
[extruder]
max_extrude_only_distance: 100.0
step_pin: PB4
dir_pin: PB3
enable_pin: !PC3
microsteps: 16
rotation_distance: 31.289
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PA1
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC5
pressure_advance: 0.624
min_temp: 0
max_temp: 250
[heater_bed]
heater_pin: PA2
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC4
control: pid
pid_Kp: 54.027
pid_Ki: 0.770
pid_Kd: 948.182
min_temp: 0
max_temp: 130
[screws_tilt_adjust]
screw1: 0, 0
screw1_name: back right screw
screw2: 155, 30
screw2_name: back left screw
screw3: 0, 185
screw3_name: front right screw
screw4: 155, 185
screw4_name: front left screw
horizontal_move_z: 10.
speed: 50.
screw_thread: CW-M4
[fan]
pin: PA0
[mcu]
serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
restart_method: command
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100
[gcode_arcs]
resolution: 1.0
[display] # RET6 12864 LCD
lcd_type: st7920
cs_pin: PB12
sclk_pin: PB13
sid_pin: PB15
encoder_pins: ^PB14, ^PB10
click_pin: ^!PB2
[output_pin BEEPER_Pin]
pin: PC6
pwm: True
value: 0
shutdown_value: 0
cycle_time: 0.001
scale: 1
[include mainsail.cfg]
[include macros.cfg]
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [bltouch]
#*# z_offset = 2.410
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 0.022500, 0.015000, 0.088750
#*# -0.026250, 0.002500, 0.130000
#*# -0.061250, -0.056250, 0.030000
#*# tension = 0.2
#*# min_x = 44.0
#*# algo = lagrange
#*# y_count = 3
#*# mesh_y_pps = 2
#*# min_y = 5.0
#*# x_count = 3
#*# max_y = 210.0
#*# mesh_x_pps = 2
#*# max_x = 220.0
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 25.804
#*# pid_ki = 1.410
#*# pid_kd = 118.055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment