diff --git a/README.md b/README.md index 186369ba9..2c3beb08b 100644 --- a/README.md +++ b/README.md @@ -54,27 +54,33 @@ If I want my printer to light itself on fire, I should be able to make my printe - [temperature_mcu: add reference_voltage](https://github.com/DangerKlippers/danger-klipper/pull/99) ([klipper#5713](https://github.com/Klipper3d/klipper/pull/5713)) +- [stepper: current_change_dwell_time](https://github.com/DangerKlippers/danger-klipper/pull/90) + +- [homing: min_home_dist](https://github.com/DangerKlippers/danger-klipper/pull/90) + If you're feeling adventurous, take a peek at the extra features in the bleeding-edge branch: - - [dmbutyugin's advanced-features branch](https://github.com/DangerKlippers/danger-klipper/pull/69) [dmbutyugin/advanced-features](https://github.com/dmbutyugin/klipper/commits/advanced-features) +- [dmbutyugin's advanced-features branch](https://github.com/DangerKlippers/danger-klipper/pull/69) [dmbutyugin/advanced-features](https://github.com/dmbutyugin/klipper/commits/advanced-features) - - [stepper: high precision stepping protocol](https://github.com/DangerKlippers/danger-klipper/pull/69) +- [stepper: high precision stepping protocol](https://github.com/DangerKlippers/danger-klipper/pull/69) - - [extruder: sync extruder motion with input shaper](https://github.com/DangerKlippers/danger-klipper/pull/69) +- [extruder: sync extruder motion with input shaper](https://github.com/DangerKlippers/danger-klipper/pull/69) - - [extruder: new print_pa_tower utility](https://github.com/DangerKlippers/danger-klipper/pull/69) +- [extruder: new print_pa_tower utility](https://github.com/DangerKlippers/danger-klipper/pull/69) - - [input_shaper: smooth input shapers](https://github.com/DangerKlippers/danger-klipper/pull/69) +- [input_shaper: smooth input shapers](https://github.com/DangerKlippers/danger-klipper/pull/69) - - [input_shaper: new print_ringing_tower utility](https://github.com/DangerKlippers/danger-klipper/pull/69) +- [input_shaper: new print_ringing_tower utility](https://github.com/DangerKlippers/danger-klipper/pull/69) ## Switch to Danger Klipper + > [!NOTE] > Any add-on modules you are using will need to be reinstalled after switching to Danger Klipper. This includes things like Beacon support, led-effect, etc. > > Any data in ~/printer_data such as printer configs and macros will be unaffected. ### Manually clone the repository + If desired, make a backup copy of your existing Klipper installation by running: ```bash @@ -89,6 +95,7 @@ sudo systemctl restart klipper ``` ### Using KIAUH + For users that are not comfortable using Git directly, [KIAUH](https://github.com/dw-0/kiauh) is able to use custom repositories. To do this, add the Danger Klipper repo to KIAUH's repo list and run the script with the following commands: @@ -99,6 +106,7 @@ echo "DangerKlippers/danger-klipper" >> ~/kiauh/klipper_repos.txt ``` From the KIAUH menu select: + - 6 ) Settings - 1 ) Set custom Klipper repository - Select the number corresponding to DangerKlipper from the list shown @@ -107,6 +115,7 @@ From the KIAUH menu select: - 'Q' to quit ### Adding a git-remote to the existing installation + ```bash cd ~/klipper git remote add danger https://github.com/DangerKlippers/danger-klipper.git @@ -118,6 +127,7 @@ sudo systemctl restart moonraker ``` --- + "Dangerous Klipper for dangerous users" Klipper is a 3d-Printer firmware. It combines the power of a general diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 3a2b5abdc..e10c618c3 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -218,6 +218,11 @@ position_max: # Speed to use on the retract move after homing in case this should # be different from the homing speed, which is the default for this # parameter +#min_home_dist: +# Minimum distance (in mm) for toolhead before sensorless homing. If closer +# than `min_home_dist` to endstop, it moves away to this distance, then homes. +# If further, it directly homes and retracts to `homing_retract_dist`. +# The default is equal to `homing_retract_dist`. #second_homing_speed: # Velocity (in mm/s) of the stepper when performing the second home. # The default is homing_speed/2. @@ -3481,6 +3486,9 @@ run_current: #home_current: # The amount of current (in amps RMS) to configure the driver to use # during homing procedures. The default is to not reduce the current. +#current_change_dwell_time: +# The amount of time (in seconds) to wait after changing homing current. +# The default is 0.5 seconds. #sense_resistor: 0.110 # The resistance (in ohms) of the motor sense resistor. The default # is 0.110 ohms. @@ -3577,6 +3585,9 @@ run_current: #home_current: # The amount of current (in amps RMS) to configure the driver to use # during homing procedures. The default is to not reduce the current. +#current_change_dwell_time: +# The amount of time (in seconds) to wait after changing homing current. +# The default is 0.5 seconds. #sense_resistor: 0.110 # The resistance (in ohms) of the motor sense resistor. The default # is 0.110 ohms. @@ -3621,6 +3632,7 @@ uart_pin: run_current: #hold_current: #home_current: +#current_change_dwell_time: #sense_resistor: 0.110 #stealthchop_threshold: 0 # See the "tmc2208" section for the definition of these parameters. @@ -3692,6 +3704,9 @@ run_current: #home_current: # The amount of current (in amps RMS) to configure the driver to use # during homing procedures. The default is to not reduce the current. +#current_change_dwell_time: +# The amount of time (in seconds) to wait after changing homing current. +# The default is 0.5 seconds. #sense_resistor: # The resistance (in ohms) of the motor sense resistor. This # parameter must be provided. @@ -3775,6 +3790,9 @@ run_current: #home_current: # The amount of current (in amps RMS) to configure the driver to use # during homing procedures. The default is to not reduce the current. +#current_change_dwell_time: +# The amount of time (in seconds) to wait after changing homing current. +# The default is 0.5 seconds. #rref: 12000 # The resistance (in ohms) of the resistor between IREF and GND. The # default is 12000. @@ -3899,6 +3917,9 @@ run_current: #home_current: # The amount of current (in amps RMS) to configure the driver to use # during homing procedures. The default is to not reduce the current. +#current_change_dwell_time: +# The amount of time (in seconds) to wait after changing homing current. +# The default is 0.5 seconds. #sense_resistor: 0.075 # The resistance (in ohms) of the motor sense resistor. The default # is 0.075 ohms. diff --git a/klippy/extras/homing.py b/klippy/extras/homing.py index 12decd06d..4f43d7e2a 100644 --- a/klippy/extras/homing.py +++ b/klippy/extras/homing.py @@ -240,9 +240,9 @@ def _set_current_homing(self, homing_axes): for rail in affected_rails: ch = rail.get_tmc_current_helper() - if ch is not None: + if ch is not None and ch.needs_home_current_change(): ch.set_current_for_homing(print_time) - self.toolhead.dwell(0.5) + self.toolhead.dwell(ch.current_change_dwell_time) def _set_current_post_homing(self, homing_axes): print_time = self.toolhead.get_last_move_time() @@ -254,9 +254,9 @@ def _set_current_post_homing(self, homing_axes): for rail in affected_rails: ch = rail.get_tmc_current_helper() - if ch is not None: + if ch is not None and ch.needs_home_current_change(): ch.set_current_for_normal(print_time) - self.toolhead.dwell(0.5) + self.toolhead.dwell(ch.current_change_dwell_time) def home_rails(self, rails, forcepos, movepos): # Notify of upcoming homing operation @@ -284,8 +284,12 @@ def home_rails(self, rails, forcepos, movepos): # Perform second home if hi.retract_dist: needs_rehome = False - if any([dist < hi.retract_dist for dist in homing_axis_distances]): + retract_dist = hi.retract_dist + if any( + [abs(dist) < hi.min_home_dist for dist in homing_axis_distances] + ): needs_rehome = True + retract_dist = hi.min_home_dist logging.info("needs rehome: %s", needs_rehome) # Retract @@ -293,13 +297,12 @@ def home_rails(self, rails, forcepos, movepos): homepos = self._fill_coord(movepos) axes_d = [hp - sp for hp, sp in zip(homepos, startpos)] move_d = math.sqrt(sum([d * d for d in axes_d[:3]])) - retract_r = min(1.0, hi.retract_dist / move_d) + retract_r = min(1.0, retract_dist / move_d) retractpos = [ hp - ad * retract_r for hp, ad in zip(homepos, axes_d) ] self.toolhead.move(retractpos, hi.retract_speed) if not hi.use_sensorless_homing or needs_rehome: - self.toolhead.dwell(0.5) # Home again startpos = [ rp - ad * retract_r for rp, ad in zip(retractpos, axes_d) @@ -309,6 +312,7 @@ def home_rails(self, rails, forcepos, movepos): for endstop in endstops: # re-querying a tmc endstop seems to reset the state # otherwise it triggers almost immediately upon second home + # this seems to be an adequate substitute for a 2 second dwell. endstop[0].query_endstop(print_time) hmove = HomingMove(self.printer, endstops) hmove.homing_move(homepos, hi.second_homing_speed) diff --git a/klippy/extras/tmc2130.py b/klippy/extras/tmc2130.py index 374a53608..f3b6f7577 100644 --- a/klippy/extras/tmc2130.py +++ b/klippy/extras/tmc2130.py @@ -212,6 +212,9 @@ def __init__(self, config, mcu_tmc): self._home_current = config.getfloat( "home_current", self.run_current, above=0.0, maxval=MAX_CURRENT ) + self.current_change_dwell_time = config.getfloat( + "current_change_dwell_time", 0.5, above=0.0 + ) self.prev_current = self.run_current self.req_hold_current = self.hold_current self.sense_resistor = config.getfloat( @@ -224,6 +227,9 @@ def __init__(self, config, mcu_tmc): self.fields.set_field("ihold", ihold) self.fields.set_field("irun", irun) + def needs_home_current_change(self): + return self._home_current != self.run_current + def set_home_current(self, new_home_current): self._home_current = min(MAX_CURRENT, new_home_current) diff --git a/klippy/extras/tmc2240.py b/klippy/extras/tmc2240.py index 5d7f3f08e..de8ca986a 100644 --- a/klippy/extras/tmc2240.py +++ b/klippy/extras/tmc2240.py @@ -281,6 +281,9 @@ def __init__(self, config, mcu_tmc): self._home_current = config.getfloat( "home_current", self.run_current, above=0.0, maxval=self.max_cur ) + self.current_change_dwell_time = config.getfloat( + "current_change_dwell_time", 0.5, above=0.0 + ) self.prev_current = self.run_current self.req_hold_current = self.hold_current current_range = self._calc_current_range(self.run_current) @@ -292,6 +295,9 @@ def __init__(self, config, mcu_tmc): self.fields.set_field("ihold", ihold) self.fields.set_field("irun", irun) + def needs_home_current_change(self): + return self._home_current != self.run_current + def set_home_current(self, new_home_current): self._home_current = min(self.max_cur, new_home_current) diff --git a/klippy/extras/tmc2660.py b/klippy/extras/tmc2660.py index 85a891969..5aa020f97 100644 --- a/klippy/extras/tmc2660.py +++ b/klippy/extras/tmc2660.py @@ -126,6 +126,9 @@ def __init__(self, config, mcu_tmc): self._home_current = config.getfloat( "home_current", self.current, above=0.0, maxval=MAX_CURRENT ) + self.current_change_dwell_time = config.getfloat( + "current_change_dwell_time", 0.5, above=0.0 + ) self._prev_current = self.current self.sense_resistor = config.getfloat("sense_resistor") vsense, cs = self._calc_current(self.current) @@ -144,6 +147,9 @@ def __init__(self, config, mcu_tmc): "idle_timeout:ready", self._handle_ready ) + def needs_home_current_change(self): + return self._home_current != self.current + def set_home_current(self, new_home_current): self._home_current = min(MAX_CURRENT, new_home_current) diff --git a/klippy/extras/tmc5160.py b/klippy/extras/tmc5160.py index ecf8d3ac8..fa0fe0632 100644 --- a/klippy/extras/tmc5160.py +++ b/klippy/extras/tmc5160.py @@ -265,6 +265,9 @@ def __init__(self, config, mcu_tmc): self._home_current = config.getfloat( "home_current", self.run_current, above=0.0, maxval=MAX_CURRENT ) + self.current_change_dwell_time = config.getfloat( + "current_change_dwell_time", 0.5, above=0.0 + ) self._prev_current = self.run_current self.req_hold_current = self.hold_current self.sense_resistor = config.getfloat( @@ -277,6 +280,9 @@ def __init__(self, config, mcu_tmc): self.fields.set_field("ihold", ihold) self.fields.set_field("irun", irun) + def needs_home_current_change(self): + return self._home_current != self.run_current + def set_home_current(self, new_home_current): self._home_current = min(MAX_CURRENT, new_home_current) diff --git a/klippy/stepper.py b/klippy/stepper.py index 77f3b26c5..0a79f88ea 100644 --- a/klippy/stepper.py +++ b/klippy/stepper.py @@ -454,6 +454,9 @@ def __init__( self.use_sensorless_homing = config.getboolean( "use_sensorless_homing", endstop_is_virtual ) + self.min_home_dist = config.getfloat( + "min_home_dist", self.homing_retract_dist, minval=0.0 + ) if self.homing_positive_dir is None: axis_len = self.position_max - self.position_min @@ -493,6 +496,7 @@ def get_homing_info(self): "positive_dir", "second_homing_speed", "use_sensorless_homing", + "min_home_dist", ], )( self.homing_speed, @@ -502,6 +506,7 @@ def get_homing_info(self): self.homing_positive_dir, self.second_homing_speed, self.use_sensorless_homing, + self.min_home_dist, ) return homing_info diff --git a/test/klippy/tmc.cfg b/test/klippy/tmc.cfg index 560691d73..1d68007d7 100644 --- a/test/klippy/tmc.cfg +++ b/test/klippy/tmc.cfg @@ -43,6 +43,7 @@ use_sensorless_homing: true cs_pin: PG2 run_current: .7 home_current: .5 +current_change_dwell_time: 1 sense_resistor: 0.220 diag1_pin: !PK7