AuxAxis: push home_preclear_mm via HOMECFG

Tells the auxcnc ESP how far (in steps) to back off if HOME is
invoked while the limit switch is already tripped. The ESP now
hard-fails instead of zeroing blindly when the switch stays active
after the preclear move. Default 10 mm; set home_preclear_mm=0 to
disable the preclear and revert to immediate failure.
This commit is contained in:
2026-05-03 14:54:56 +02:00
parent 683fa673ae
commit 9526ad797d

View File

@@ -66,6 +66,14 @@ DEFAULTS = {
'home_slow_sps': 250, # ≈ 10 mm/s
'home_backoff_steps': 400, # ≈ 16 mm
'home_maxtravel_steps': 200000,
# If HOME starts with the limit switch already tripped the ESP
# first moves this many steps away from the limit and then
# rechecks. If the switch is still active afterward, HOME hard-
# fails (refuses to set zero blindly when we may already be past
# the home position). Default ≈ 10 mm @ 25 steps/mm. Set to 0 to
# disable the preclear move (HOME then fails immediately if the
# switch reads active at start, matching the original behaviour).
'home_preclear_mm': 10.0,
'step_max_sps': 4000, # ≈ 160 mm/s normal-move cap
'step_accel_sps2': 12000,
'step_start_sps': 200,
@@ -500,8 +508,14 @@ class AuxAxis(object):
def _push_homecfg(self):
c = self._cfg
zero_steps = self._mm_to_steps(c['home_position_mm'])
# preclear: how far (in steps) the ESP backs off if HOME is
# invoked while the limit switch is already tripped. Computed
# from home_preclear_mm so the operator configures it in mm.
spm = float(c.get('steps_per_mm', 1.0)) or 1.0
preclear_steps = int(round(abs(float(c['home_preclear_mm'])) * spm))
cmd = ('HOMECFG dir=%s fast=%d slow=%d backoff=%d maxtravel=%d '
'zero=%d accel=%d step_max=%d step_start=%d limit_low=%d') % (
'zero=%d accel=%d step_max=%d step_start=%d limit_low=%d '
'preclear=%d') % (
c['home_dir'],
int(c['home_fast_sps']),
int(c['home_slow_sps']),
@@ -512,6 +526,7 @@ class AuxAxis(object):
int(c['step_max_sps']),
int(c['step_start_sps']),
1 if c['limit_low'] else 0,
preclear_steps,
)
self._rpc(cmd, topic='homecfg', timeout=3.0)