From f095d809c19b75bb3e35e4fbcd47eb00896b7a92 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Wed, 25 Sep 2024 18:39:04 -0700 Subject: [PATCH] feat(klipper): input shaping config --- nixos/klipper/default.nix | 24 +++++++++++- nixos/klipper/ender3v3se.cfg | 52 +++++++++++++++++++++---- nixos/klipper/macros.cfg | 75 +++++++++++++++--------------------- 3 files changed, 97 insertions(+), 54 deletions(-) diff --git a/nixos/klipper/default.nix b/nixos/klipper/default.nix index 0e84ae5f..55d7f528 100644 --- a/nixos/klipper/default.nix +++ b/nixos/klipper/default.nix @@ -22,8 +22,30 @@ in { ./macros.cfg ]; settings = { - # allow the z_offset to be saved by moonraker + # allow settings to be saved by moonraker bltouch.z_offset = mkDefault 1.85; + extruder = { + control = "pid"; + #stock defaults provided by someone + #pid_Kp = 27.142000; + #pid_Ki = 1.371000; + #pid_Kd = 134.351000; + #recent PID_CALIBRATE results + pid_Kp = 30.573; + pid_Ki = 1.742; + pid_Kd = 134.141; + }; + heater_bed = { + control = "pid"; + #stock defaults provided by someone + #pid_Kp = 66.371000; + #pid_Ki = 0.846000; + #pid_Kd = 1301.702000; + #recent PID_CALIBRATE results + pid_Kp = 64.742; + pid_Ki = 0.684; + pid_Kd = 1531.969; + }; }; }; }; diff --git a/nixos/klipper/ender3v3se.cfg b/nixos/klipper/ender3v3se.cfg index 0e456bd4..118a2cb2 100644 --- a/nixos/klipper/ender3v3se.cfg +++ b/nixos/klipper/ender3v3se.cfg @@ -26,7 +26,6 @@ logging:true pin:PB0 [extruder] -control:pid dir_pin:PB3 enable_pin:!PC3 filament_diameter:1.750000 @@ -36,9 +35,6 @@ max_temp:260 microsteps:16 min_temp:0 nozzle_diameter:0.400000 -pid_Kd:134.351000 -pid_Ki:1.371000 -pid_Kp:27.142000 rotation_distance:7.440000 sensor_pin:PC5 sensor_type:EPCOS 100K B57560G104F @@ -64,13 +60,9 @@ switch_pin:!PC15 [filter] [heater_bed] -control:pid heater_pin:PB2 max_temp:100 min_temp:0 -pid_kd:1301.702000 -pid_ki:0.846000 -pid_kp:66.371000 sensor_pin:PC4 sensor_type:EPCOS 100K B57560G104F @@ -180,6 +172,26 @@ run_current:0.800000 sense_resistor:0.150000 uart_pin:PB14 +[endstop_phase] + +[input_shaper] +# https://www.klipper3d.org/Resonance_Compensation.html +#shaper_type: ei +# docs claim it's better for bedslingers... +shaper_type_y: ei +# print #1 measure try 1 +#shaper_freq_x: 42.04730 +#shaper_freq_y: 41.18993 +# print #1 measure try 2 +#shaper_freq_x: 39.02439 +#shaper_freq_y: 40.00000 +# print #5 feelings... +shaper_freq_x: 35.6 +shaper_freq_y: 36.8 + +[gcode_arcs] +resolution:0.15 + [bed_mesh] algorithm:bicubic horizontal_move_z:5 @@ -206,3 +218,27 @@ min_x = 30.0 max_x = 207.0 min_y = 30.0 max_y = 215.48000000000002 + +[gcode_macro _CLIENT_VARIABLE] +description: fluidd configuration +#variable_use_custom_pos:False ; use custom park coordinates for x,y [True/False] +#variable_custom_park_x:0.0 ; custom x position; value must be within your defined min and max of X +#variable_custom_park_y:0.0 ; custom y position; value must be within your defined min and max of Y +#variable_custom_park_dz:2.0 ; custom dz value; the value in mm to lift the nozzle when move to park position +variable_retract:6.0 ; the value to retract while PAUSE +variable_cancel_retract:9.0 ; the value to retract while CANCEL_PRINT +variable_speed_retract:40.0 +variable_unretract:6.0 ; the value to unretract while RESUME +variable_speed_unretract:30.0 +variable_speed_hop:10.0 +variable_speed_move:50.0 +variable_park_at_cancel:True ; allow to move the toolhead to park while execute CANCEL_PRINT [True/False] +#variable_park_at_cancel_x:None ; different park position during CANCEL_PRINT [None/Position as Float]; park_at_cancel must be True +#variable_park_at_cancel_y:None ; different park position during CANCEL_PRINT [None/Position as Float]; park_at_cancel must be True +variable_use_fw_retract:False ; disabled because retract amounts above are larger than the usual +variable_idle_timeout:600 ; time in sec until idle_timeout kicks in. Value 0 means that no value will be set or restored +variable_runout_sensor:"filament_sensor" +variable_user_pause_macro:"" ; will be executed after the klipper base pause (PAUSE_BASE) function +variable_user_resume_macro:"" ; will be executed before the klipper base resume (RESUME_BASE) function +variable_user_cancel_macro:"" ; will be executed before the klipper base cancel (CANCEL_PRINT_BASE) function +gcode: diff --git a/nixos/klipper/macros.cfg b/nixos/klipper/macros.cfg index 66881810..3126760e 100644 --- a/nixos/klipper/macros.cfg +++ b/nixos/klipper/macros.cfg @@ -1,12 +1,10 @@ [gcode_macro PID_EXTRUDER] gcode: PID_CALIBRATE HEATER=extruder TARGET=210 - SAVE_CONFIG [gcode_macro PID_BED] gcode: PID_CALIBRATE HEATER=heater_bed TARGET=60 - SAVE_CONFIG [gcode_macro FILAMENT_LOAD] gcode: @@ -83,52 +81,39 @@ gcode: description: End of printing variable_machine_depth: 220 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 z50 ;Raise Z more - G90 ;Absolute positioning - G1 X0 Y{machine_depth} ;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 - BEEP - -[gcode_macro PRINT_STOP] -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 Z50 ;Raise Z more - G90 ;Absolute positionning - - G1 X0 Y200 ;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 + {% set can_extrude = printer.extruder.can_extrude %} + G92 E0 ; Reset Extruder + G91 ;Relative positioning + {% if can_extrude %} + ;Retract a bit + G1 E-{printer.firmware_retraction.retract_length} F{printer.firmware_retraction.retract_speed * 60} + G1 E-3 F{printer.firmware_retraction.retract_speed * 60} ;Retract a bit + {% endif %} + {% if can_extrude %} + G1 E-3 Z0.2 F2400 ;Retract and raise Z + G1 E-3 F{printer.firmware_retraction.retract_speed * 60} ;Retract a bit more + {% else %} + G1 Z0.2 F2400 + {% endif %} + G1 X5 Y5 F3000 ;Wipe out + {% if can_extrude %} + G1 E-8 Z50 ;Raise Z more and retract even more to prevent leaking as extruder cools + {% else %} + G1 Z50 + {% endif %} + G90 ;Absolute positioning + G1 X0 Y{machine_depth} ;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 + BEEP [gcode_macro CANCEL_PRINT] description: Cancel the actual running print rename_existing: CANCEL_PRINT_BASE gcode: - TURN_OFF_HEATERS - CANCEL_PRINT_BASE - 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 Z50 ;Raise Z more - G90 ;Absolute positionning - - G1 X0 Y200 ;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 + TURN_OFF_HEATERS + CANCEL_PRINT_BASE + END_PRINT