Skip to content

Instantly share code, notes, and snippets.

@dzid26
Created March 12, 2025 00:59
Show Gist options
  • Save dzid26/08cb9e4419fdcc5c30a84237bdaf8578 to your computer and use it in GitHub Desktop.
Save dzid26/08cb9e4419fdcc5c30a84237bdaf8578 to your computer and use it in GitHub Desktop.
#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
# See docs/Config_Reference.md for a description of parameters.
# https://moonraker.readthedocs.io/en/latest/configuration/
[include plr.cfg]
[mcu]
serial:/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
restart_method: command
[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 6000
minimum_cruise_ratio: 0.5
max_z_velocity: 15
max_z_accel: 100
square_corner_velocity:3
[virtual_sdcard]
path:/home/mks/printer_data/gcodes
on_error_gcode:
TURN_OFF_HEATERS
CANCEL_PRINT_BASE
RESPOND TYPE=echo MSG="PRINT STOPPED WITH ERROR!"
G91 ;Relative positionning
G1 E-2 F500 ;Retract a bit
G1 E-2 Z0.2 F200 ;Retract and raise Z
G1 Z1 ;Raise Z more
M106 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed
G90
G1 X10 Y290 F6000
M84 X Y E ;Disable all steppers but Z
[pause_resume]
[display_status]
[idle_timeout]
gcode:
RESPOND TYPE=echo MSG="No operations in 10min!"
# A list of G-Code commands to execute on an idle timeout. See
# docs/Command_Templates.md for G-Code format. The default is to run
# "TURN_OFF_HEATERS" and "M84".
timeout: 600
[mcu rpi]
serial: /tmp/klipper_host_mcu
[adxl345]
cs_pin: rpi:None
spi_bus: spidev0.0
[verify_heater extruder]
max_error: 60
check_gain_time:20
hysteresis: 5
heating_gain: 2
[verify_heater heater_bed]
max_error: 180
check_gain_time:120
hysteresis: 5
heating_gain: 2
[resonance_tester]
accel_chip: adxl345
probe_points:
150, 150, 20 # an example
accel_per_hz:100
min_freq:1
max_freq:100
max_smoothing:0.2
hz_per_sec:0.5
[respond]
#default_type: echo
# Sets the default prefix of the "M118" and "RESPOND" output to one
# of the following:
# echo: "echo: " (This is the default)
# command: "// "
# error: "error!"
#default_prefix: echo:
# Directly sets the default prefix. If present, this value will
# override the "default_type".
#############################################################################################################
#GCODE_MACRO
#############################################################################################################
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
SAVE_VARIABLE VARIABLE=was_interrupted VALUE=False
RUN_SHELL_COMMAND CMD=clear_plr
clear_last_file
G31
TURN_OFF_HEATERS
CANCEL_PRINT_BASE
RESPOND TYPE=echo MSG="Cancel Print Success!"
G91 ;Relative positionning
G1 E-2 F500 ;Retract a bit
G1 E-2 Z0.2 F200 ;Retract and raise Z
G1 Z1 ;Raise Z more
M106 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed
G90
G1 X10 Y290 F6000
M84 X Y E ;Disable all steppers but Z
[gcode_macro M190]
rename_existing: M99190
gcode:
#Parameters
{% set s = params.S|float %}
M140 {% for p in params %}{'%s%s' % (p, params[p])}{% endfor %} ; Set bed temp
{% if s != 0 %}
TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={s-(120-s)*0.5} MAXIMUM={s} ; Wait for bed temp and leave remaining time to heat up the nozzle
{% endif %}
[gcode_macro M109]
rename_existing: M99109
gcode:
#Parameters
{% set s = params.S|float %}
M104 {% for p in params %}{'%s%s' % (p, params[p])}{% endfor %} ; Set hotend temp
{% if s != 0 %}
TEMPERATURE_WAIT SENSOR=extruder MINIMUM={s} MAXIMUM={s+1} ; Wait for hotend temp (within 1 degree)
{% endif %}
[gcode_macro START_PRINT]
gcode:
M84 E ; Disable E Motor for probe accuracy on direct drive systems
G90 ;Absolute positioning
# G92 E0 ; Reset Extruder distance to 0
# G1 E-1 ; Retracts filament to prevent blobs during probing
# G92 E0 ; Reset Extruder distance to 0
G28 ; home all axes
BED_MESH_PROFILE LOAD=default
# G92 E0 ; reset extruder
# G1 Z1.0 F3000 ; move z up little to prevent scratching of surface
# G1 X0.1 Y20 Z0.3 F5000.0 ; move to start-line position
# G1 X0.1 Y100.0 Z0.3 F500.0 E15 ; draw 1st line
# G1 X0.4 Y100.0 Z0.3 F5000.0 ; move to side a little
# G1 X0.4 Y20 Z0.3 F500.0 E30 ; draw 2nd line
# G92 E0 ; reset extruder
G1 Z1.0 F3000 ; move z up little to prevent scratching of surface
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
gcode:
RESPOND TYPE=echo MSG="Pause Print!"
##### set defaults #####
{% set x = params.X|default(10) %} #edit to your park position
{% set y = params.Y|default(290) %} #edit to your park position
{% set z = params.Z|default(10)|float %} #edit to your park position
{% set e = params.E|default(1) %} #edit to your retract length
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% set lift_z = z|abs %}
{% if act_z < (max_z - lift_z) %}
{% set z_safe = lift_z %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
PAUSE_BASE
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-{e} F500
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G1 Z{z_safe}
G90
G1 X{x} Y{y} F6000
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
[gcode_macro RESUME]
description: Resume the actual running print
rename_existing: RESUME_BASE
gcode:
RESPOND TYPE=echo MSG="RESUME Print!"
##### set defaults #####
{% if printer["filament_switch_sensor filament_sensor"].filament_detected == True %} # detect if occur filament runout ,True : filament exists.  False:filament runout
RESPOND TYPE=echo MSG="RESUME Print!"
{% set e = params.E|default(1) %} #edit to your retract length
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E{e} F400
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESUME_BASE {get_params}
{% else %}
RESPOND TYPE=echo MSG="Please Insert filament in Sensor!"
{% endif %}
[gcode_macro END_PRINT]
gcode:
G91 ;Relative positionning
G1 E-2 F500 ;Retract a bit
G1 E-2 Z0.2 F200 ;Retract and raise Z
G1 X5 Y5 F3000 ;Wipe out
G1 Z1 ;Raise Z more
M106 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed
G90 ;Absolute positionning
G1 X10 Y200 ;Present print
M84 X Y E ;Disable all steppers but Z
RESPOND TYPE=echo MSG="Finish Print!"
[gcode_macro LOAD_FILAMENT]
gcode:
G91
G1 E30 F300
G1 E10 F150
G90
[gcode_macro UNLOAD_FILAMENT]
gcode:
G91
G1 E-30 F300
G90
[gcode_macro LED_ON]
gcode:
SET_PIN PIN=my_led VALUE=1
[gcode_macro LED_OFF]
gcode:
SET_PIN PIN=my_led VALUE=0
[gcode_macro M205]
gcode:
M105
[gcode_arcs]
# resolution: 1.0
# An arc will be split into segments. Each segment's length will
# equal the resolution in mm set above. Lower values will produce a
# finer arc, but also more work for your machine. Arcs smaller than
# the configured value will become straight lines. The default is
# 1mm.
#############################################################################################################
#stepper,TMC2209
#############################################################################################################
[stepper_x]
step_pin: PD15
dir_pin: PD14
enable_pin: !PC7
microsteps: 16
rotation_distance: 40
endstop_pin: tmc2209_stepper_x: virtual_endstop
homing_retract_dist: 0
position_endstop: -12
position_min: -12
position_max: 302
homing_speed: 50
step_pulse_duration:0.000002
[tmc2209 stepper_x]
uart_pin:PE3
run_current:1.2
uart_address:3
interpolate: True
driver_sgthrs: 95
stealthchop_threshold:0
diag_pin: ^PD10
[stepper_y]
step_pin: PB7
dir_pin: PB6
enable_pin: !PB9
microsteps: 16
rotation_distance: 40
endstop_pin: tmc2209_stepper_y: virtual_endstop
homing_retract_dist: 0
position_endstop: -6
position_min: -6
position_max: 302
homing_speed: 50
step_pulse_duration:0.000002
[tmc2209 stepper_y]
uart_pin:PE4
run_current:1.2
uart_address:3
interpolate: True
driver_sgthrs: 95
stealthchop_threshold:0
diag_pin: ^PE0
[stepper_z]
step_pin: PB3
dir_pin: !PD7
enable_pin: !PB5
microsteps: 16
rotation_distance: 8
endstop_pin:probe:z_virtual_endstop
#position_endstop: 0.0
position_max: 355
position_min: -4
homing_speed:10
[stepper_z1]
step_pin: PA7
dir_pin: !PA6
enable_pin: !PC5
microsteps: 16
rotation_distance: 8
endstop_pin:probe:z_virtual_endstop
#position_endstop: 0.0
[extruder]
max_extrude_only_distance: 100.0
step_pin: PD1
dir_pin: !PD0
enable_pin: !PD4
microsteps: 16
rotation_distance: 4.59
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PA1
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA4
control: pid
pressure_advance:0.02
pressure_advance_smooth_time:0.035
max_extrude_cross_section:45
instantaneous_corner_velocity:10
max_extrude_only_distance: 100.0
max_extrude_only_velocity:2000
max_extrude_only_accel:10000
pid_Kp=24.522
pid_Ki=1.397
pid_Kd=107.590
min_temp: 0
max_temp: 305
min_extrude_temp: 150
[tmc2209 extruder]
uart_pin: PE7
run_current: 0.6
uart_address:3
#hold_current: 0.5
interpolate: True
[heater_bed]
heater_pin: PA2
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PA3
control: pid
# tuned for stock hardware with 50 degree Celsius target
pid_Kp: 54.027
pid_Ki: 0.770
pid_Kd: 800
min_temp: 0
max_temp: 105
[probe]
pin:PD13
x_offset:27
y_offset:-20
[filament_switch_sensor filament_sensor]
#pause_on_runout: True
# runout_gcode:
# RESPOND TYPE=error MSG="Filament Runout! Please change filament!"
#event_delay: 3.0
#pause_delay: 0.5
switch_pin:PD11
[safe_z_home]
home_xy_position: 123,170
speed: 80
z_hop: 5 # Move up 5mm
z_hop_speed: 10
#################################################
#Z stepper tilt adjustment
#################################################
[z_tilt]
z_positions: -8, 170
260, 170
points: -8, 170
260, 170
speed: 200
horizontal_move_z: 5
retries: 20
retry_tolerance: .005
#################################################
#bed mesh calibrate
#################################################
[bed_mesh]
speed:300
horizontal_move_z:5
mesh_min:17,15
mesh_max:280,280
probe_count:16,16
algorithm: bicubic
bicubic_tension: 0.3
fade_start: 0.2
fade_end: 5.0
mesh_pps:4,4
move_check_distance: 3
#split_delta_z: .025
#################################################
#adjust bed screws tilt
#################################################
[screws_tilt_adjust]
screw1: 4, 58
screw1_name: front left screw
screw2: 243, 58
screw2_name: front right screw
screw3: 243, 290
screw3_name: rear right screw
screw4: 4, 290
screw4_name: rear left screw
horizontal_move_z: 5.
speed: 300.
screw_thread: CW-M4
[heater_fan hotend_fan]
pin: PE11
kick_start_time: 0.1
# part fan and curtain fan
[multi_pin fan_pins]
pins: PE9,PE13
[fan_generic part_fan]
# pin:multi_pin:fan_pins
pin: PE9
kick_start_time: 0.1
[fan_generic curtain_fan]
pin: PE13
kick_start_time: 0.2
# replace M106
# treat M106 as normal fan
# treat M106 Px (aux or exhaust fan) as curtain fan)
[gcode_macro M106]
gcode:
{% set fan = ('curtain_fan' if params.P is defined else 'part_fan')|string %}
{% set speed = (params.S|float / 255 if params.S is defined else 1.0) %}
SET_FAN_SPEED FAN={fan} SPEED={speed}
[output_pin my_led]
pin:PC4
pwm: 1
value:1
cycle_time: 0.010
[controller_fan Fan_Board]
pin:PD3
fan_speed: 1.0
idle_timeout: 120
heater: heater_bed, extruder
stepper: stepper_x, stepper_y, stepper_z, stepper_z1
[input_shaper]
damping_ratio_x: 0.05
damping_ratio_y: 0.1
shaper_type_x = 3hump_ei
shaper_freq_x = 90
shaper_type_y = 2hump_ei
shaper_freq_y = 52
#
# [input_shaper]
# shaper_type_y = mzv
# shaper_freq_y = 32.0
# shaper_type_x = mzv
# shaper_freq_x = 50.6
[gcode_macro PRINT_START] # 将 PRINT_START 设置为开始打印时的宏,自定义打印前的动作
gcode:
SAVE_VARIABLE VARIABLE=was_interrupted VALUE=True
[gcode_macro PRINT_END]
gcode:
SAVE_VARIABLE VARIABLE=was_interrupted VALUE=False
RUN_SHELL_COMMAND CMD=clear_plr
clear_last_file
[axis_twist_compensation]
speed: 300
# The speed (in mm/s) of non-probing moves during the calibration.
# The default is 50.
horizontal_move_z: 5
# The height (in mm) that the head should be commanded to move to
# just prior to starting a probe operation. The default is 5.
calibrate_start_x: 20
# Defines the minimum X coordinate of the calibration
# This should be the X coordinate that positions the nozzle at the starting
# calibration position.
calibrate_end_x: 280
# Defines the maximum X coordinate of the calibration
# This should be the X coordinate that positions the nozzle at the ending
# calibration position.
calibrate_y: 150
# Defines the Y coordinate of the calibration
# This should be the Y coordinate that positions the nozzle during the
# calibration process. This parameter is recommended to
# be near the center of the bed
#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [probe]
#*# z_offset = 1.600
#*#
#*# [bed_mesh PC]
#*# version = 1
#*# points =
#*# -0.020000, 0.027500, 0.007500, -0.075000, -0.237500
#*# -0.085000, -0.032500, -0.015000, -0.072500, -0.207500
#*# -0.110000, -0.032500, 0.000000, -0.057500, -0.207500
#*# -0.112500, -0.037500, 0.010000, -0.052500, -0.177500
#*# -0.180000, -0.092500, -0.050000, -0.095000, -0.215000
#*# x_count = 5
#*# y_count = 5
#*# mesh_x_pps = 4
#*# mesh_y_pps = 4
#*# algo = bicubic
#*# tension = 0.3
#*# min_x = 17.0
#*# max_x = 285.0
#*# min_y = 15.0
#*# max_y = 282.0
#*#
#*# [axis_twist_compensation]
#*# z_compensations = 0.011667, -0.065833, 0.054167
#*# compensation_start_x = 20.0
#*# compensation_end_x = 280.0
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# -0.092948, -0.040896, -0.053851, -0.124299, -0.119754, -0.130201, -0.085649, -0.053604, -0.051552, -0.062007, -0.099210, -0.123033, -0.129345, -0.110668, -0.119479, -0.100802
#*# -0.075448, -0.030896, -0.056351, -0.116799, -0.117254, -0.115201, -0.053149, -0.001104, 0.003448, -0.014507, -0.066710, -0.103033, -0.134345, -0.118168, -0.119479, -0.090802
#*# -0.030448, 0.016604, -0.006351, -0.064299, -0.052254, -0.037701, 0.031851, 0.093896, 0.095948, 0.067993, 0.003290, -0.043033, -0.086845, -0.088168, -0.094479, -0.065802
#*# -0.107948, -0.068396, -0.086351, -0.111799, -0.092254, -0.065201, 0.021851, 0.098896, 0.103448, 0.077993, 0.008290, -0.038033, -0.086845, -0.088168, -0.091979, -0.050802
#*# -0.125448, -0.073396, -0.068851, -0.101799, -0.072254, -0.047701, 0.031851, 0.098896, 0.100948, 0.075493, 0.015790, -0.023033, -0.069345, -0.068168, -0.074479, -0.043302
#*# -0.107948, -0.060896, -0.058851, -0.074299, -0.044754, -0.027701, 0.039351, 0.098896, 0.103448, 0.090493, 0.040790, 0.016967, -0.014345, -0.008168, -0.001979, 0.044198
#*# -0.087948, -0.025896, -0.021351, -0.044299, -0.017254, -0.020201, 0.011851, 0.043896, 0.040948, 0.027993, -0.001710, -0.005533, -0.021845, -0.013168, -0.014479, 0.019198
#*# -0.110448, -0.065896, -0.066351, -0.079299, -0.064754, -0.085201, -0.060649, -0.031104, -0.041552, -0.047007, -0.066710, -0.053033, -0.059345, -0.048168, -0.044479, -0.000802
#*# -0.070448, -0.010896, -0.013851, -0.039299, -0.019754, -0.035201, -0.013149, 0.008896, -0.006552, -0.029507, -0.071710, -0.068033, -0.076845, -0.078168, -0.096979, -0.070802
#*# -0.025448, 0.006604, -0.001351, -0.016799, -0.009754, -0.007701, 0.059351, 0.108896, 0.090948, 0.042993, -0.034210, -0.058033, -0.081845, -0.088168, -0.096979, -0.058302
#*# -0.032948, 0.021604, 0.013649, -0.006799, 0.027746, 0.059799, 0.126851, 0.173896, 0.155948, 0.087993, -0.006710, -0.058033, -0.096845, -0.110668, -0.126979, -0.103302
#*# -0.032948, -0.003396, -0.018851, -0.031799, -0.007254, 0.027299, 0.119351, 0.183896, 0.165948, 0.110493, 0.008290, -0.038033, -0.071845, -0.070668, -0.064479, -0.008302
#*# 0.017052, 0.071604, 0.048649, 0.018201, 0.045246, 0.069799, 0.139351, 0.183896, 0.163448, 0.110493, 0.020790, -0.010533, -0.029345, -0.028168, -0.034479, -0.008302
#*# 0.047052, 0.081604, 0.051149, 0.015701, 0.022746, 0.017299, 0.066851, 0.116396, 0.100948, 0.060493, -0.004210, -0.013033, -0.016845, -0.010668, -0.014479, 0.031698
#*# -0.010448, 0.039104, 0.013649, -0.031799, -0.029754, -0.050201, -0.035649, -0.021104, -0.044052, -0.067007, -0.116710, -0.110533, -0.119345, -0.113168, -0.136979, -0.113302
#*# -0.050448, -0.023396, -0.041351, -0.059299, -0.044754, -0.075201, -0.075649, -0.061104, -0.076552, -0.094507, -0.121710, -0.110533, -0.111845, -0.110668, -0.126979, -0.090802
#*# min_x = 17.0
#*# max_x = 279.95000000000005
#*# min_y = 15.0
#*# max_y = 279.9
#*# x_count = 16
#*# y_count = 16
#*# mesh_x_pps = 4
#*# mesh_y_pps = 4
#*# algo = bicubic
#*# tension = 0.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment