Skip to content

Fix and test STAR setup discard of mounted tips#1161

Open
HaamsRee wants to merge 3 commits into
PyLabRobot:mainfrom
HaamsRee:fix-star-setup-tip-discard
Open

Fix and test STAR setup discard of mounted tips#1161
HaamsRee wants to merge 3 commits into
PyLabRobot:mainfrom
HaamsRee:fix-star-setup-tip-discard

Conversation

@HaamsRee

@HaamsRee HaamsRee commented Jul 8, 2026

Copy link
Copy Markdown

Summary

Fixes STAR backend setup behavior when tips are already mounted on single channels. #1159

Previously, STARBackend.setup() called initialize_pip() when tip presence was detected. That made the C0DI initialization command run with active channels (tm1...), so firmware could try to discard mounted tips as part of DI.

This PR changes the mounted-tip setup path to:

  1. Run pip channel initialization with inactive channels (tm0...) so C0DI does not discard tips.
  2. Discard the mounted tips separately using the existing C0TR tip-discard path.
  3. Re-query tip presence and raise if tips remain.

The normal initialize_pip() behavior is unchanged.

Motivation

On a STAR with 4 channels spaced at 18 mm, setup-time discard through C0DI caused the tips to hit the waste slope and continue downward, bending tips. A Hamilton Method Editor trace showed that Hamilton initializes with inactive channels and then performs the actual discard with C0TR.

Tests

Added STAR backend tests for:

  • existing initialize_pip() active DI command behavior,
  • setup-only inactive DI command behavior,
  • setup-time TR discard command using the detected tip-presence pattern.

Ran:

uv run pytest pylabrobot/liquid_handling/backends/hamilton/STAR_tests.py -q --tb=short --disable-warnings --color=no

Result:

110 passed, 13 warnings, 81 subtests passed

Comment on lines +2098 to +2101
has_tips = any(tip_presences)
if has_tips:
await self._initialize_pip_without_tip_discard()
elif not initialized:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this initialize call not be gated by if initialized?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention was to keep somewhat consistent with the old behavior.

The old behavior, if I'm understanding correctly, is:

If not initialized or there's any tip left on the channels, do initialize_pip(). initialize_pip() then does the C0DI with tm1&. That works fine when there are no tips, but crashes, at least in my case, with tips.

So I split the two conditions. If there are tips present, call the new _initialize_pip_without_tip_discard() which sends C0DI but with tm0& instead. This does the initialization but the tips stay afterward. If there are no tips, just do the old initialize_pip().

But since _initialize_pip_without_tip_discard() doesn't discard tips, we need to actually discard the tips to complete the initialization as Method Editor does. This is checked and done below. And the check won't run if it went the initialize_pip() route at the start since there were no tips to begin with.

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.

2 participants