Skip to content

add two-pass soft homing for X/Y and skip rehome on subsequent loading position presses#13

Open
hongquanli wants to merge 1 commit into
pharmbio:masterfrom
hongquanli:soft-homing-xy
Open

add two-pass soft homing for X/Y and skip rehome on subsequent loading position presses#13
hongquanli wants to merge 1 commit into
pharmbio:masterfrom
hongquanli:soft-homing-xy

Conversation

@hongquanli

Copy link
Copy Markdown

Summary

Adds a two-pass (coarse → back off → slow) homing routine for the X and Y axes to eliminate run-to-run jitter caused by speed-dependent limit-switch trip hysteresis. The "Go to Loading Position" button now only triggers homing on the first press of a session; subsequent presses move via absolute coordinates, avoiding plate-to-plate calibration drift.

What's changed

software/control/_def.py — 5 new MachineConfiguration constants for the soft-homing fine pass: SOFT_HOMING_VELOCITY_X/Y_mm (4.0 mm/s), SOFT_HOMING_ACCELERATION_X/Y_mm, and SOFT_HOMING_BACK_OFF_MM (3.0 mm).

software/control/microcontroller.py

  • New soft_home_x() / soft_home_y() / soft_home_xy() methods. Each performs coarse-home → back-off → lowered MAX_VELOCITY → fine-home, with a try/finally covering everything after the velocity is lowered so any timeout in the fine pass still restores the original values.
  • New connection_session_id counter, incremented inside attempt_connection() on every successful (re)connect. Used by the navigation layer to invalidate cached "homed" state across firmware position-counter resets.
  • A Python-side mirror of per-axis MAX_VELOCITY/ACCELERATION, kept in sync inside set_max_velocity_acceleration so the soft-home save/restore uses the actually-programmed values (not the MACHINE_CONFIG defaults, which may have been overridden by other code).

software/control/core/navigation.py

  • New has_been_homed property: True iff a soft-home was committed in the current microcontroller session (compares _homed_at_session_id against the microcontroller's current connection_session_id).
  • loading_position_enter gains a with_homing kwarg. With with_homing=False, the function moves via absolute coordinates without re-homing, but refuses to run unless has_been_homed is True (raises RuntimeError).
  • Snapshot-and-check guard around the XY homing sequence: wait_till_operation_is_completed auto-recovers from timeouts by calling attempt_connection(), which bumps connection_session_id. If a reconnect happens mid-homing, the homed-state commit is skipped so the next attempt re-homes from scratch.
  • Replaces single-pass home_x()/home_y() calls in the loading-position flow with the new soft_home_* variants.

software/control/gui_hcs.py — "Go to Loading Position" button passes with_homing=not has_been_homed. First press of the session homes; subsequent presses skip.

Why

Mechanical limit switches have speed-dependent trip hysteresis: the position at which they activate depends on the approach velocity. The pre-existing single-pass home approached the switch at full MAX_VELOCITY, which introduced run-to-run home-position jitter. Over a session of many plate exchanges, this caused visible plate-to-plate calibration drift.

The two-pass approach (coarse pass at MAX_VELOCITY to find the switch quickly, then a slow second pass for a velocity-independent trip point) removes that dependence. The session-aware skip-rehome removes the trip exposure entirely once a clean home is established within a session.

Test plan

  • Manual: with stage in an arbitrary position, click "Go to Loading Position". Confirm full homing routine runs (logs homing - in loading position).
  • Manual: click "Go to Loading Position" again from a different stage position later in the same session. Confirm it skips homing (logs no-homing - in loading position, fast move via absolute coordinates).
  • Hardware repeatability: measure home-position spread over ~10 consecutive homes; compare to pre-PR baseline.
  • Manual reconnect: disconnect/reconnect microcontroller mid-session; confirm next "Go to Loading" press re-homes (does not skip).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant