Skip to content

Commit

Permalink
Merge pull request #149 from Frix-x/develop
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Frix-x authored Apr 16, 2023
2 parents 7c45c4a + 490654b commit 5fe6459
Show file tree
Hide file tree
Showing 23 changed files with 158 additions and 48 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

> Klippain - the pain-free recipe for (french)bread and butter Klipper configuration!
![Klippain](./docs/klippain.png)

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.

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**.
Expand Down
3 changes: 2 additions & 1 deletion config/hardware/accelerometers/adxl345_ebb.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ axes_map: x,y,z
[resonance_tester]
accel_chip: adxl345
probe_points:
150,150,20
-1,-1,-1


# Include the IS calibration macros to unlock them when
# an accelerometer is installed on the machine
[include ../../../macros/helpers/resonance_override.cfg]
[include ../../../macros/calibration/IS_shaper_calibrate.cfg]
[include ../../../macros/calibration/IS_vibrations_measurement.cfg]
3 changes: 2 additions & 1 deletion config/hardware/accelerometers/adxl345_rpi.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ axes_map: -z,y,x
[resonance_tester]
accel_chip: adxl345
probe_points:
150,150,20
-1,-1,-1


# Include the IS calibration macros to unlock them when
# an accelerometer is installed on the machine
[include ../../../macros/helpers/resonance_override.cfg]
[include ../../../macros/calibration/IS_shaper_calibrate.cfg]
[include ../../../macros/calibration/IS_vibrations_measurement.cfg]
3 changes: 2 additions & 1 deletion config/hardware/accelerometers/adxl345_sb2040.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ axes_map: x,y,z
[resonance_tester]
accel_chip: adxl345
probe_points:
150,150,20
-1,-1,-1


# Include the IS calibration macros to unlock them when
# an accelerometer is installed on the machine
[include ../../../macros/helpers/resonance_override.cfg]
[include ../../../macros/calibration/IS_shaper_calibrate.cfg]
[include ../../../macros/calibration/IS_vibrations_measurement.cfg]
3 changes: 2 additions & 1 deletion config/hardware/accelerometers/adxl345_sht.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ axes_map: x,y,z
[resonance_tester]
accel_chip: adxl345
probe_points:
150,150,20
-1,-1,-1


# Include the IS calibration macros to unlock them when
# an accelerometer is installed on the machine
[include ../../../macros/helpers/resonance_override.cfg]
[include ../../../macros/calibration/IS_shaper_calibrate.cfg]
[include ../../../macros/calibration/IS_vibrations_measurement.cfg]
3 changes: 2 additions & 1 deletion config/hardware/accelerometers/adxl345_skr.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ axes_map: -z,y,x
[resonance_tester]
accel_chip: adxl345
probe_points:
150,150,20
-1,-1,-1


# Include the IS calibration macros to unlock them when
# an accelerometer is installed on the machine
[include ../../../macros/helpers/resonance_override.cfg]
[include ../../../macros/calibration/IS_shaper_calibrate.cfg]
[include ../../../macros/calibration/IS_vibrations_measurement.cfg]
3 changes: 2 additions & 1 deletion config/hardware/accelerometers/adxl345_usb.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ axes_map: -z,y,x
[resonance_tester]
accel_chip: adxl345
probe_points:
150,150,20
-1,-1,-1


# Include the IS calibration macros to unlock them when
# an accelerometer is installed on the machine
[include ../../../macros/helpers/resonance_override.cfg]
[include ../../../macros/calibration/IS_shaper_calibrate.cfg]
[include ../../../macros/calibration/IS_vibrations_measurement.cfg]
14 changes: 14 additions & 0 deletions config/hardware/axis/Z/V0_1.8d_TR8x4_z.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[stepper_z]
rotation_distance: 4
microsteps: 32
full_steps_per_rotation: 200

[tmc2209 stepper_z]
interpolate: False
run_current: 0.2
sense_resistor: 0.110
# stealthchop_threshold: 999999

# We also include the default wiring and speeds from here to avoid duplicating
[include default_wiring_1M.cfg]
[include default_speed.cfg]
14 changes: 14 additions & 0 deletions config/hardware/axis/Z/V0_1.8d_TR8x8_z.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[stepper_z]
rotation_distance: 8
microsteps: 32
full_steps_per_rotation: 200

[tmc2209 stepper_z]
interpolate: False
run_current: 0.2
sense_resistor: 0.110
# stealthchop_threshold: 999999

# We also include the default wiring and speeds from here to avoid duplicating
[include default_wiring_1M.cfg]
[include default_speed.cfg]
8 changes: 8 additions & 0 deletions config/hardware/axis/Z/default_wiring_1M.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[stepper_z]
step_pin: Z_STEP
dir_pin: Z_DIR
enable_pin: !Z_ENABLE
endstop_pin: Z_STOP

[tmc2209 stepper_z]
uart_pin: Z_TMCUART
11 changes: 3 additions & 8 deletions config/hardware/axis/Z/default_wiring_3M.cfg
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
[stepper_z]
step_pin: Z_STEP
dir_pin: Z_DIR
enable_pin: !Z_ENABLE
endstop_pin: Z_STOP

[tmc2209 stepper_z]
uart_pin: Z_TMCUART
# In this file we include the first motor
[include default_wiring_1M.cfg]

# And then, add a 2nd and 3rd motor...
[stepper_z1]
step_pin: Z1_STEP
dir_pin: Z1_DIR
Expand Down
13 changes: 13 additions & 0 deletions config/hardware/axis/default_120mm.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[stepper_x]
position_min: 0
position_endstop: 120
position_max: 120

[stepper_y]
position_min: 0
position_endstop: 120
position_max: 120

[stepper_z]
position_max: 120
position_min: -5
5 changes: 5 additions & 0 deletions config/hardware/probes/no_probe.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# When no probe is installed on the machine, there is still the need to define a corresponding default START_PRINT sequence.
# If you want to write your own sequence, have a look at your overrides.cfg file!
[gcode_macro _USER_VARIABLES]
variable_startprint_actions: "bed_soak", "chamber_soak", "extruder_heating", "purge", "clean", "z_offset", "primeline"
gcode:
8 changes: 8 additions & 0 deletions config/software/tilting/bedscrews_120mm.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Bed screws leveling definition
[bed_screws]
screw1: 60,5
screw1_name: front screw
screw2: 5,115
screw2_name: back left
screw3: 115,115
screw3_name: back right
Binary file added docs/klippain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions macros/base/homing/homing_overide.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ gcode:
{ action_respond_info("Homing X") }
{% endif %}
{% if sensorless_homing_enabled %}
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current %}
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current %}
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current|float %}
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current|float %}
{% set new_current_x = sensorless_current_factor * old_current_x %}
{% set new_current_y = sensorless_current_factor * old_current_y %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={new_current_x}
Expand All @@ -123,8 +123,8 @@ gcode:
{ action_respond_info("Homing Y") }
{% endif %}
{% if sensorless_homing_enabled %}
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current %}
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current %}
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current|float %}
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current|float %}
{% set new_current_x = sensorless_current_factor * old_current_x %}
{% set new_current_y = sensorless_current_factor * old_current_y %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={new_current_x}
Expand All @@ -145,8 +145,8 @@ gcode:
{ action_respond_info("Homing Y") }
{% endif %}
{% if sensorless_homing_enabled %}
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current %}
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current %}
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current|float %}
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current|float %}
{% set new_current_x = sensorless_current_factor * old_current_x %}
{% set new_current_y = sensorless_current_factor * old_current_y %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={new_current_x}
Expand All @@ -165,8 +165,8 @@ gcode:
{ action_respond_info("Homing X") }
{% endif %}
{% if sensorless_homing_enabled %}
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current %}
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current %}
{% set old_current_x = printer.configfile.config['tmc2209 stepper_x'].run_current|float %}
{% set old_current_y = printer.configfile.config['tmc2209 stepper_y'].run_current|float %}
{% set new_current_x = sensorless_current_factor * old_current_x %}
{% set new_current_y = sensorless_current_factor * old_current_y %}
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={new_current_x}
Expand Down
12 changes: 5 additions & 7 deletions macros/base/start_print.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ gcode:
# Set the variables to be used in all the modules based on the slicer parameters
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=bed_temp VALUE={BED_TEMP}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=extruder_temp VALUE={EXTRUDER_TEMP}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=z_adjust VALUE={Z_ADJUST}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=soak VALUE={SOAK}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=chamber_temp VALUE={CHAMBER_TEMP}
SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=chamber_maxtime VALUE={CHAMBER_MAXTIME}
Expand Down Expand Up @@ -123,6 +122,10 @@ gcode:
{% endif %}
{% endfor %}

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

# Final material parameters
SET_GCODE_OFFSET Z_ADJUST={material.additional_z_offset} MOVE=1
{% if filter_enabled %}
Expand Down Expand Up @@ -241,7 +244,7 @@ gcode:
{% endif %}

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

Expand Down Expand Up @@ -347,7 +350,6 @@ gcode:
# a measurement of the probe on the physical Z endstop probe, and then a measurement of the center of the bed (or mesh)
# 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
{% set FL_SIZE = printer["gcode_macro START_PRINT"].fl_size %}
{% set Z_ADJUST = printer["gcode_macro START_PRINT"].z_adjust %}

{% set zcalib_plugin_enabled = printer["gcode_macro _USER_VARIABLES"].zcalib_plugin_enabled %}
{% set bed_mesh_enabled = printer["gcode_macro _USER_VARIABLES"].bed_mesh_enabled %}
Expand All @@ -362,10 +364,6 @@ gcode:
G28 Z
{% endif %}

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


[gcode_macro _MODULE_BED_MESH]
gcode:
Expand Down
18 changes: 13 additions & 5 deletions macros/calibration/calibrate.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,30 @@ description: Calibrate the printer flow or pressure advance
gcode:
# Type of calibration
{% set TYPE = params.TYPE|default("")|string|lower %}
# Define vars with safe default values for ABS (main material I'm using)

# Define print vars with safe default values
{% set BED_TEMP = params.BED_TEMP|default(printer["gcode_macro _USER_VARIABLES"].print_default_bed_temp)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(printer["gcode_macro _USER_VARIABLES"].print_default_extruder_temp)|float %}
{% set MATERIAL = params.MATERIAL|default("ABS")|string %}

{% set center_x = printer.toolhead.axis_maximum.x|float / 2 %}
{% set center_y = printer.toolhead.axis_maximum.y|float / 2 %}

{% if TYPE=="flow" %}
# 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)
{% set computed_size = (center_x - 20)|string + '_' + (center_y - 20)|string + '_' + (center_x + 20)|string + '_' + (center_y + 20)|string %}

# Call the standard START_PRINT with almost no soaking time and no chamber temp requirement (we want to go fast!)
# Also no bed mesh needed for this one as it's a small center print
START_PRINT EXTRUDER_TEMP={EXTRUDER_TEMP} BED_TEMP={BED_TEMP} MATERIAL={MATERIAL} SOAK=1 SIZE=130_130_170_170
START_PRINT EXTRUDER_TEMP={EXTRUDER_TEMP} BED_TEMP={BED_TEMP} MATERIAL={MATERIAL} SOAK=1 SIZE={computed_size}
FLOW_MULTIPLIER_CALIBRATION EXTRUSION_WIDTH=0.471
END_PRINT FILTER_TIME=0

{% elif TYPE=="pressure_advance" %}
# 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)
{% set computed_size = (center_x - 60)|string + '_' + (center_y - 60)|string + '_' + (center_x + 60)|string + '_' + (center_y + 60)|string %}

# Call the standard START_PRINT with almost no soaking time and no chamber temp requirement (we want to go fast!)
# A bed mesh is needed for this one as it's a large print (120mm sized square)
START_PRINT EXTRUDER_TEMP={EXTRUDER_TEMP} BED_TEMP={BED_TEMP} MATERIAL={MATERIAL} SOAK=1 SIZE=90_90_210_210
START_PRINT EXTRUDER_TEMP={EXTRUDER_TEMP} BED_TEMP={BED_TEMP} MATERIAL={MATERIAL} SOAK=1 SIZE={computed_size}
PRESSURE_ADVANCE_CALIBRATION
END_PRINT FILTER_TIME=0

Expand Down
16 changes: 16 additions & 0 deletions macros/helpers/resonance_override.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[gcode_macro TEST_RESONANCES]
rename_existing: BASE_TEST_RESONANCES
description: Runs input shaper test at the center of the bed
gcode:
{% set Tx, Ty = printer["gcode_macro _USER_VARIABLES"].resonnance_test_point_xy|map('float') %}
{% set Tz = printer["gcode_macro _USER_VARIABLES"].resonnance_test_z_clearance|float %}

{% if Tx == -1 and Ty == -1 %}
{% set max_x = printer.toolhead.axis_maximum.x|float %}
{% set max_y = printer.toolhead.axis_maximum.y|float %}

BASE_TEST_RESONANCES POINT={max_x / 2},{max_y / 2},{Tz} {rawparams}
{% else %}
BASE_TEST_RESONANCES POINT={Tx},{Ty},{Tz} {rawparams}
{% endif %}

5 changes: 3 additions & 2 deletions scripts/graph_vibrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
###### SPEED AND VIBRATIONS PLOTTING SCRIPT ######
##################################################
# Written by Frix_x#0161 #
# @version: 1.1
# @version: 1.2

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

Expand Down Expand Up @@ -173,7 +174,7 @@ def parse_log(logname, opts):

def extract_speed(logname, opts):
try:
speed = re.search('sp(.+?)n', logname).group(1)
speed = re.search('sp(.+?)n', os.path.basename(logname)).group(1)
except AttributeError:
opts.error("File %s does not contain speed in its name and therefore "
"is not supported by graph_vibrations.py script." % (logname,))
Expand Down
12 changes: 12 additions & 0 deletions user_templates/overrides.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
# ------------------------------------------------------------------------------------------


#-------------------------#
# START_PRINT SEQUENCE #
#-------------------------#

## The START_PRINT sequence is modular and fully customizable. A default START_PRINT sequence is auto-populated based on
## your probe choice (TAP, Dockable, Inductive), but if for some reasons you still want to modify it, please uncomment the
## following `variable_startprint_actions` definition. You can use any number of action or even duplicate some actions if needed.
## Available actions: "bed_soak", "chamber_soak", "extruder_heating", "tilt_calib", "z_offset", "bedmesh", "purge", "clean", "primeline"
##
# variable_startprint_actions: "action1", "action2", ...


#-------------------------#
# EXTRUDER/BED PIDs #
#-------------------------#
Expand Down
Loading

0 comments on commit 5fe6459

Please sign in to comment.