Skip to content

Commit 5fe6459

Browse files
authored
Merge pull request #149 from Frix-x/develop
* Fixed sensorless homing * Fixed a bug that could happens in some very specific case in graph_vibrations.py when user is not "pi" and started with "sp..." (it matched a Regex) * Improvement to not wait for the nozzle temperature before doing a chamber heatsoak * Fixed the Z_ADJUST feature that could not be applied when the user would override the START_PRINT sequence without specifying a call to the z_offset module. Now Z_ADJUST is applied everytime at the end of the sequence to be sure we make use of it * Moved the START_PRINT sequence override into the override.cfg template file to make it more user-friendly. Also improved the associated comment to make it more clear that defaults are already included for each type of probes * Better management of the resonnance test position by using variables. Now it will use center of bed by default or the user input in the corresponding variable (and not the previously hardcoded position that needed an override). * New full and stock V0 support (bugs to be expected) * Added a logo-banner to Klippain * Enhancement of the "CALIBRATE" macro to adapt to the bed size automatically
2 parents 7c45c4a + 490654b commit 5fe6459

23 files changed

+158
-48
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
> Klippain - the pain-free recipe for (french)bread and butter Klipper configuration!
44
5+
![Klippain](./docs/klippain.png)
6+
57
Klippain is a generic and modular Klipper configuration for CoreXY 3D printers. I use it on my Voron V2.4 (V2.1237), my Voron Trident, my custom TriZero, and my heavily modified Prusa i3 MK3s. Other CoreXY printer owners (Voron, VZbot, Ender5, ...) have also reported no issues using it.
68

79
The files are frequently updated with new features that I create, but also with merged PRs from users. **Always** look, think, understand, and adjust to your own. But that should work in most cases. You can reach me in the Voron Discord: I'm **Frix_x#0161**.

config/hardware/accelerometers/adxl345_ebb.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ axes_map: x,y,z
88
[resonance_tester]
99
accel_chip: adxl345
1010
probe_points:
11-
150,150,20
11+
-1,-1,-1
1212

1313

1414
# Include the IS calibration macros to unlock them when
1515
# an accelerometer is installed on the machine
16+
[include ../../../macros/helpers/resonance_override.cfg]
1617
[include ../../../macros/calibration/IS_shaper_calibrate.cfg]
1718
[include ../../../macros/calibration/IS_vibrations_measurement.cfg]

config/hardware/accelerometers/adxl345_rpi.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ axes_map: -z,y,x
1111
[resonance_tester]
1212
accel_chip: adxl345
1313
probe_points:
14-
150,150,20
14+
-1,-1,-1
1515

1616

1717
# Include the IS calibration macros to unlock them when
1818
# an accelerometer is installed on the machine
19+
[include ../../../macros/helpers/resonance_override.cfg]
1920
[include ../../../macros/calibration/IS_shaper_calibrate.cfg]
2021
[include ../../../macros/calibration/IS_vibrations_measurement.cfg]

config/hardware/accelerometers/adxl345_sb2040.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ axes_map: x,y,z
88
[resonance_tester]
99
accel_chip: adxl345
1010
probe_points:
11-
150,150,20
11+
-1,-1,-1
1212

1313

1414
# Include the IS calibration macros to unlock them when
1515
# an accelerometer is installed on the machine
16+
[include ../../../macros/helpers/resonance_override.cfg]
1617
[include ../../../macros/calibration/IS_shaper_calibrate.cfg]
1718
[include ../../../macros/calibration/IS_vibrations_measurement.cfg]

config/hardware/accelerometers/adxl345_sht.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ axes_map: x,y,z
66
[resonance_tester]
77
accel_chip: adxl345
88
probe_points:
9-
150,150,20
9+
-1,-1,-1
1010

1111

1212
# Include the IS calibration macros to unlock them when
1313
# an accelerometer is installed on the machine
14+
[include ../../../macros/helpers/resonance_override.cfg]
1415
[include ../../../macros/calibration/IS_shaper_calibrate.cfg]
1516
[include ../../../macros/calibration/IS_vibrations_measurement.cfg]

config/hardware/accelerometers/adxl345_skr.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ axes_map: -z,y,x
66
[resonance_tester]
77
accel_chip: adxl345
88
probe_points:
9-
150,150,20
9+
-1,-1,-1
1010

1111

1212
# Include the IS calibration macros to unlock them when
1313
# an accelerometer is installed on the machine
14+
[include ../../../macros/helpers/resonance_override.cfg]
1415
[include ../../../macros/calibration/IS_shaper_calibrate.cfg]
1516
[include ../../../macros/calibration/IS_vibrations_measurement.cfg]

config/hardware/accelerometers/adxl345_usb.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ axes_map: -z,y,x
1111
[resonance_tester]
1212
accel_chip: adxl345
1313
probe_points:
14-
150,150,20
14+
-1,-1,-1
1515

1616

1717
# Include the IS calibration macros to unlock them when
1818
# an accelerometer is installed on the machine
19+
[include ../../../macros/helpers/resonance_override.cfg]
1920
[include ../../../macros/calibration/IS_shaper_calibrate.cfg]
2021
[include ../../../macros/calibration/IS_vibrations_measurement.cfg]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[stepper_z]
2+
rotation_distance: 4
3+
microsteps: 32
4+
full_steps_per_rotation: 200
5+
6+
[tmc2209 stepper_z]
7+
interpolate: False
8+
run_current: 0.2
9+
sense_resistor: 0.110
10+
# stealthchop_threshold: 999999
11+
12+
# We also include the default wiring and speeds from here to avoid duplicating
13+
[include default_wiring_1M.cfg]
14+
[include default_speed.cfg]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[stepper_z]
2+
rotation_distance: 8
3+
microsteps: 32
4+
full_steps_per_rotation: 200
5+
6+
[tmc2209 stepper_z]
7+
interpolate: False
8+
run_current: 0.2
9+
sense_resistor: 0.110
10+
# stealthchop_threshold: 999999
11+
12+
# We also include the default wiring and speeds from here to avoid duplicating
13+
[include default_wiring_1M.cfg]
14+
[include default_speed.cfg]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[stepper_z]
2+
step_pin: Z_STEP
3+
dir_pin: Z_DIR
4+
enable_pin: !Z_ENABLE
5+
endstop_pin: Z_STOP
6+
7+
[tmc2209 stepper_z]
8+
uart_pin: Z_TMCUART

config/hardware/axis/Z/default_wiring_3M.cfg

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
[stepper_z]
2-
step_pin: Z_STEP
3-
dir_pin: Z_DIR
4-
enable_pin: !Z_ENABLE
5-
endstop_pin: Z_STOP
6-
7-
[tmc2209 stepper_z]
8-
uart_pin: Z_TMCUART
1+
# In this file we include the first motor
2+
[include default_wiring_1M.cfg]
93

4+
# And then, add a 2nd and 3rd motor...
105
[stepper_z1]
116
step_pin: Z1_STEP
127
dir_pin: Z1_DIR
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[stepper_x]
2+
position_min: 0
3+
position_endstop: 120
4+
position_max: 120
5+
6+
[stepper_y]
7+
position_min: 0
8+
position_endstop: 120
9+
position_max: 120
10+
11+
[stepper_z]
12+
position_max: 120
13+
position_min: -5

config/hardware/probes/no_probe.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# When no probe is installed on the machine, there is still the need to define a corresponding default START_PRINT sequence.
2+
# If you want to write your own sequence, have a look at your overrides.cfg file!
3+
[gcode_macro _USER_VARIABLES]
4+
variable_startprint_actions: "bed_soak", "chamber_soak", "extruder_heating", "purge", "clean", "z_offset", "primeline"
5+
gcode:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Bed screws leveling definition
2+
[bed_screws]
3+
screw1: 60,5
4+
screw1_name: front screw
5+
screw2: 5,115
6+
screw2_name: back left
7+
screw3: 115,115
8+
screw3_name: back right

docs/klippain.png

1.18 MB
Loading

macros/base/homing/homing_overide.cfg

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ gcode:
103103
{ action_respond_info("Homing X") }
104104
{% endif %}
105105
{% if sensorless_homing_enabled %}
106-
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current %}
107-
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current %}
106+
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current|float %}
107+
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current|float %}
108108
{% set new_current_x = sensorless_current_factor * old_current_x %}
109109
{% set new_current_y = sensorless_current_factor * old_current_y %}
110110
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={new_current_x}
@@ -123,8 +123,8 @@ gcode:
123123
{ action_respond_info("Homing Y") }
124124
{% endif %}
125125
{% if sensorless_homing_enabled %}
126-
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current %}
127-
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current %}
126+
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current|float %}
127+
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current|float %}
128128
{% set new_current_x = sensorless_current_factor * old_current_x %}
129129
{% set new_current_y = sensorless_current_factor * old_current_y %}
130130
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={new_current_x}
@@ -145,8 +145,8 @@ gcode:
145145
{ action_respond_info("Homing Y") }
146146
{% endif %}
147147
{% if sensorless_homing_enabled %}
148-
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current %}
149-
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current %}
148+
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current|float %}
149+
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current|float %}
150150
{% set new_current_x = sensorless_current_factor * old_current_x %}
151151
{% set new_current_y = sensorless_current_factor * old_current_y %}
152152
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={new_current_x}
@@ -165,8 +165,8 @@ gcode:
165165
{ action_respond_info("Homing X") }
166166
{% endif %}
167167
{% if sensorless_homing_enabled %}
168-
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current %}
169-
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current %}
168+
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current|float %}
169+
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current|float %}
170170
{% set new_current_x = sensorless_current_factor * old_current_x %}
171171
{% set new_current_y = sensorless_current_factor * old_current_y %}
172172
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={new_current_x}

macros/base/start_print.cfg

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ gcode:
2424
# Set the variables to be used in all the modules based on the slicer parameters
2525
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=bed_temp VALUE={BED_TEMP}
2626
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_temp VALUE={EXTRUDER_TEMP}
27-
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=z_adjust VALUE={Z_ADJUST}
2827
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=soak VALUE={SOAK}
2928
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=chamber_temp VALUE={CHAMBER_TEMP}
3029
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=chamber_maxtime VALUE={CHAMBER_MAXTIME}
@@ -123,6 +122,10 @@ gcode:
123122
{% endif %}
124123
{% endfor %}
125124

125+
# Fine adjustement of z offset (from the slicer profile). This is used to do a custom adjustement
126+
# when using textured/smooth PEI sheets, or for a special material from the slicer, etc...
127+
SET_GCODE_OFFSET Z_ADJUST={Z_ADJUST} MOVE=1
128+
126129
# Final material parameters
127130
SET_GCODE_OFFSET Z_ADJUST={material.additional_z_offset} MOVE=1
128131
{% if filter_enabled %}
@@ -241,7 +244,7 @@ gcode:
241244
{% endif %}
242245

243246
# Heat the hotend to the safe temperature to spread some heat as well
244-
M109 S{safe_extruder_temp}
247+
M104 S{safe_extruder_temp}
245248
# Wait for the temperature of the chamber to be reached (default max: 15min)
246249
HEATSOAK_CHAMBER TEMP={CHAMBER_TEMP} MAXTIME={CHAMBER_MAXTIME}
247250

@@ -347,7 +350,6 @@ gcode:
347350
# a measurement of the probe on the physical Z endstop probe, and then a measurement of the center of the bed (or mesh)
348351
# If it's a TAP probe or inductive probe or no Z calibration, then it's only a G28 Z to get a correct Z offset measurement
349352
{% set FL_SIZE = printer["gcode_macro START_PRINT"].fl_size %}
350-
{% set Z_ADJUST = printer["gcode_macro START_PRINT"].z_adjust %}
351353

352354
{% set zcalib_plugin_enabled = printer["gcode_macro _USER_VARIABLES"].zcalib_plugin_enabled %}
353355
{% set bed_mesh_enabled = printer["gcode_macro _USER_VARIABLES"].bed_mesh_enabled %}
@@ -362,10 +364,6 @@ gcode:
362364
G28 Z
363365
{% endif %}
364366

365-
# Fine adjustement of z offset (from the slicer profile). This is used to do a custom adjustement
366-
# when using textured/smooth PEI sheets, or for a special material, etc...
367-
SET_GCODE_OFFSET Z_ADJUST={Z_ADJUST} MOVE=1
368-
369367

370368
[gcode_macro _MODULE_BED_MESH]
371369
gcode:

macros/calibration/calibrate.cfg

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,30 @@ description: Calibrate the printer flow or pressure advance
33
gcode:
44
# Type of calibration
55
{% set TYPE = params.TYPE|default("")|string|lower %}
6-
# Define vars with safe default values for ABS (main material I'm using)
6+
7+
# Define print vars with safe default values
78
{% set BED_TEMP = params.BED_TEMP|default(printer["gcode_macro _USER_VARIABLES"].print_default_bed_temp)|float %}
89
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(printer["gcode_macro _USER_VARIABLES"].print_default_extruder_temp)|float %}
910
{% set MATERIAL = params.MATERIAL|default("ABS")|string %}
11+
12+
{% set center_x = printer.toolhead.axis_maximum.x|float / 2 %}
13+
{% set center_y = printer.toolhead.axis_maximum.y|float / 2 %}
1014

1115
{% if TYPE=="flow" %}
16+
# No bed mesh needed for this one as it's a small center print so we compute the size manually (default flow size is 40mm)
17+
{% set computed_size = (center_x - 20)|string + '_' + (center_y - 20)|string + '_' + (center_x + 20)|string + '_' + (center_y + 20)|string %}
18+
1219
# Call the standard START_PRINT with almost no soaking time and no chamber temp requirement (we want to go fast!)
13-
# Also no bed mesh needed for this one as it's a small center print
14-
START_PRINT EXTRUDER_TEMP={EXTRUDER_TEMP} BED_TEMP={BED_TEMP} MATERIAL={MATERIAL} SOAK=1 SIZE=130_130_170_170
20+
START_PRINT EXTRUDER_TEMP={EXTRUDER_TEMP} BED_TEMP={BED_TEMP} MATERIAL={MATERIAL} SOAK=1 SIZE={computed_size}
1521
FLOW_MULTIPLIER_CALIBRATION EXTRUSION_WIDTH=0.471
1622
END_PRINT FILTER_TIME=0
1723

1824
{% elif TYPE=="pressure_advance" %}
25+
# A bed mesh is needed for this one as it's a large print so we compute the size manually (default PA size is 120mm)
26+
{% set computed_size = (center_x - 60)|string + '_' + (center_y - 60)|string + '_' + (center_x + 60)|string + '_' + (center_y + 60)|string %}
27+
1928
# Call the standard START_PRINT with almost no soaking time and no chamber temp requirement (we want to go fast!)
20-
# A bed mesh is needed for this one as it's a large print (120mm sized square)
21-
START_PRINT EXTRUDER_TEMP={EXTRUDER_TEMP} BED_TEMP={BED_TEMP} MATERIAL={MATERIAL} SOAK=1 SIZE=90_90_210_210
29+
START_PRINT EXTRUDER_TEMP={EXTRUDER_TEMP} BED_TEMP={BED_TEMP} MATERIAL={MATERIAL} SOAK=1 SIZE={computed_size}
2230
PRESSURE_ADVANCE_CALIBRATION
2331
END_PRINT FILTER_TIME=0
2432

macros/helpers/resonance_override.cfg

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[gcode_macro TEST_RESONANCES]
2+
rename_existing: BASE_TEST_RESONANCES
3+
description: Runs input shaper test at the center of the bed
4+
gcode:
5+
{% set Tx, Ty = printer["gcode_macro _USER_VARIABLES"].resonnance_test_point_xy|map('float') %}
6+
{% set Tz = printer["gcode_macro _USER_VARIABLES"].resonnance_test_z_clearance|float %}
7+
8+
{% if Tx == -1 and Ty == -1 %}
9+
{% set max_x = printer.toolhead.axis_maximum.x|float %}
10+
{% set max_y = printer.toolhead.axis_maximum.y|float %}
11+
12+
BASE_TEST_RESONANCES POINT={max_x / 2},{max_y / 2},{Tz} {rawparams}
13+
{% else %}
14+
BASE_TEST_RESONANCES POINT={Tx},{Ty},{Tz} {rawparams}
15+
{% endif %}
16+

scripts/graph_vibrations.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
###### SPEED AND VIBRATIONS PLOTTING SCRIPT ######
55
##################################################
66
# Written by Frix_x#0161 #
7-
# @version: 1.1
7+
# @version: 1.2
88

99
# CHANGELOG:
10+
# v1.2: fixed a bug that could happen when username is not "pi" (thanks @spikeygg)
1011
# v1.1: better graph formatting
1112
# v1.0: first version of the script
1213

@@ -173,7 +174,7 @@ def parse_log(logname, opts):
173174

174175
def extract_speed(logname, opts):
175176
try:
176-
speed = re.search('sp(.+?)n', logname).group(1)
177+
speed = re.search('sp(.+?)n', os.path.basename(logname)).group(1)
177178
except AttributeError:
178179
opts.error("File %s does not contain speed in its name and therefore "
179180
"is not supported by graph_vibrations.py script." % (logname,))

user_templates/overrides.cfg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919
# ------------------------------------------------------------------------------------------
2020

2121

22+
#-------------------------#
23+
# START_PRINT SEQUENCE #
24+
#-------------------------#
25+
26+
## The START_PRINT sequence is modular and fully customizable. A default START_PRINT sequence is auto-populated based on
27+
## your probe choice (TAP, Dockable, Inductive), but if for some reasons you still want to modify it, please uncomment the
28+
## following `variable_startprint_actions` definition. You can use any number of action or even duplicate some actions if needed.
29+
## Available actions: "bed_soak", "chamber_soak", "extruder_heating", "tilt_calib", "z_offset", "bedmesh", "purge", "clean", "primeline"
30+
##
31+
# variable_startprint_actions: "action1", "action2", ...
32+
33+
2234
#-------------------------#
2335
# EXTRUDER/BED PIDs #
2436
#-------------------------#

0 commit comments

Comments
 (0)