Skip to content

Commit

Permalink
improved development soak TTC test
Browse files Browse the repository at this point in the history
  • Loading branch information
moggieuk committed Dec 3, 2024
1 parent 29d4b0a commit 1bcb514
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/base/mmu_parameters.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ selector_max_accel: 1200 # Never to be exceeded selector accelaration regardles
# up = tool is selected and filament is allowed to freely move through gate
# down = to grip filament
# move = ready the servo for selector move (optional - defaults to up)
# V2.4 on: These positions are only for initial config they are replaced with calibrated servo positions in `mmu_vars.cfg`
# V2.4.0 on: These positions are only for initial config they are replaced with calibrated servo positions in `mmu_vars.cfg`
#
# Note that leaving the servo active when down can stress the electronics and is not recommended with EASY-BRD or ERB board
# unless the 5v power supply has been improved and it is not necessary with standard ERCF builds
Expand Down
3 changes: 3 additions & 0 deletions config/base/mmu_parameters.cfg.vs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
########################################################################################################################
# Happy Hare MMU Software
#
# Template file for MMU's with Virtual Selector (Type-B designs like Box Turtle, Night Owl, Angry Beaver, ...)
# This file omits selector and selector-servo configuration and a few other options that don't make sense
#
# EDIT THIS FILE BASED ON YOUR SETUP
#
# Copyright (C) 2022 moggieuk#6538 (discord) [email protected]
Expand Down
16 changes: 8 additions & 8 deletions extras/mmu/mmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ def __init__(self, config):
self.test_disable_encoder = config.getint('test_disable_encoder', 0, minval=0, maxval=1)
self.test_force_in_print = config.getint('test_force_in_print', 0, minval=0, maxval=1)

self.test_always_wait = config.getint('test_always_wait', 0, minval=0, maxval=1) # PAUL TEMP
self.test_sync_movequeues = config.getint('test_sync_movequeues', 0, minval=0, maxval=1) # PAUL TEMP
self.ttc_always_wait = bool(config.getint('ttc_always_wait', 0, minval=0, maxval=1)) # PAUL TEMP
self.ttc_sync_movequeues = bool(config.getint('ttc_sync_movequeues', 0, minval=0, maxval=1)) # PAUL TEMP

# Klipper tuning (aka hacks)
# Timer too close is a catch all error, however it has been found to occur on some systems during homing and probing
Expand Down Expand Up @@ -4964,7 +4964,7 @@ def _do_form_tip(self, test=False):
# All moves return: actual (relative), homed, measured, delta; mmu_toolhead.get_position[1] holds absolute position
#
def trace_filament_move(self, trace_str, dist, speed=None, accel=None, motor="gear", homing_move=0, endstop_name="default", track=False, sync=False, wait=False, encoder_dwell=False):
sync = sync or self.test_sync_movequeues # PAUL TEMP added test_sync_movequeues
sync = sync or self.ttc_sync_movequeues # PAUL TEMP added ttc_sync_movequeues
self.mmu_toolhead.unsync() # Precaution
encoder_start = self.get_encoder_distance(dwell=encoder_dwell)
pos = self.mmu_toolhead.get_position()
Expand Down Expand Up @@ -5340,7 +5340,7 @@ def sync_gear_to_extruder(self, sync, gate=None, grip=False, current=False):

# PAUL
# XXX We used to wait() every sync change call. Keeping this logic as a reminder in case of issues with new conditional logic
if self.test_always_wait:
if self.ttc_always_wait:
self.movequeues_wait() # Safety but should not be required(?)
return self.mmu_toolhead.sync(MmuToolHead.GEAR_SYNCED_TO_EXTRUDER if sync else None) == MmuToolHead.GEAR_SYNCED_TO_EXTRUDER
# PAUL ^^^
Expand All @@ -5364,11 +5364,12 @@ def wrap_sync_gear_to_extruder(self):

# This is used to protect just the mmu_toolhead sync state and is used to wrap individual moves. Typically
# the starting state will be unsynced so this will simply unsync at the end of the move. It does not manage
# grip (servo) movment or current control since that would lead to unecessary "flutter" and prematurely wear
# grip (servo) movment control since that would lead to unecessary "flutter" and prematurely wear
@contextlib.contextmanager
def _wrap_sync_mode(self, sync_mode):
prev_sync_mode = self.mmu_toolhead.sync_mode
self.mmu_toolhead.sync(sync_mode)
self._restore_gear_current() # PAUL added
try:
yield self
finally:
Expand All @@ -5394,14 +5395,13 @@ def _restore_gear_current(self):

@contextlib.contextmanager
def _wrap_gear_current(self, percent=100, reason=""):
self.gear_restore_percent_run_current = self.gear_percentage_run_current
self._adjust_gear_current(percent, reason)
# PAUL don't understand comment below.. logic doesn't feel right
self.gear_restore_percent_run_current = percent # This will force restoration to this current not original (collision detection case)
try:
yield self
finally:
self.gear_restore_percent_run_current = 100
self._restore_gear_current()
self.gear_restore_percent_run_current = 100

@contextlib.contextmanager
def _wrap_extruder_current(self, percent=100, reason=""):
Expand Down
10 changes: 8 additions & 2 deletions extras/mmu/mmu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,15 @@ def cmd_MMU_TEST(self, gcmd):
if gcmd.get_int('TTC_TEST', 0, minval=0, maxval=1):
loop = gcmd.get_int('LOOP', 5, minval=1, maxval=1000)
for i in range(loop):
if self.mmu.mmu_machine.multigear:
self.mmu.select_gate(random.randint(0, self.mmu.num_gates - 1))
stop_on_endstop = random.randint(0, 1) * 2 - 1
self.mmu.gcode.run_script_from_command("MMU_TEST_HOMING_MOVE MOTOR=extruder MOVE=10 ENDSTOP=extruder STOP_ON_ENDSTOP=%d DEBUG=1" % stop_on_endstop)
self.mmu.mmu_toolhead.get_last_move_time() # Try to provoke TTC
motor = "extruder" if random.randint(0, 1) else "gear+extruder"
self.mmu.gcode.run_script_from_command("MMU_TEST_HOMING_MOVE MOTOR=%s MOVE=5 ENDSTOP=toolhead STOP_ON_ENDSTOP=%d DEBUG=1" % (motor, stop_on_endstop))
if random.randint(0, 1):
self.mmu.gcode.run_script_from_command("MMU_TEST_MOVE MOTOR=%s MOVE=5 DEBUG=1" % motor)
if random.randint(0, 1):
self.mmu.mmu_toolhead.get_last_move_time() # Try to provoke TTC

if gcmd.get_int('AUTO_CALIBRATE', 0, minval=0, maxval=1):
gate = gcmd.get_int('GATE', 0, minval=-2, maxval=8)
Expand Down

0 comments on commit 1bcb514

Please sign in to comment.