Skip to content

v1 Mantis: the sequencer, and events read by their content - #1622

Merged
BioCam merged 1 commit into
mainfrom
mantis-v1-02-sequencer-events
Nov 13, 2026
Merged

BioCam merged 1 commit into
mainfrom
mantis-v1-02-sequencer-events

Conversation

@BioCam

@BioCam BioCam commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

The Problem

Every motion on the Mantis runs through its sequencer: a queue on the motion board that plays valve states and moves in order, each held for a set time. The device also reports, unasked, when a motor starts, finishes, homes or faults, and when a queued item plays. Without a sequencer and without reading those reports, nothing can move safely: a wait cannot know its move finished, and a motor fault goes unnoticed.

PR Content/Solution

  • Events (driver/events.py): every report the device sends unasked is decoded by its content (motion started, move done, home done, motor error, sequence progress, sequencer stopped, input changed) and logged in words; an unknown one is logged by its number. A motor-error report fails every waiting motion at once.
  • Sequencer: clear, start, stop, abort and queueing a valve write (_queue_ppi_write), each sent once. A full queue (200 items) answers -1; the write is sent again under the next item number until it is queued, for at most default_queue_full_timeout (60 s), so no item can play twice. A wait for an item does not miss a report that arrived with the reply.
  • Simulation: a 200-item queue that plays at once when started.

This is the base the arm and pump PRs queue through; it has no user-facing call of its own beyond default_queue_full_timeout.

On the device

A Mantis v4 on Windows (D2XX); only the chip valves switched, the pump stayed off:

result
queue depth, not started 200: free 199 down to 0, then -1; the slots come back after a clear
a queue write sent twice under one packet number queued twice, so a queue write is never resent
hold time 1 ms per step: a hold of 500 played after 508-513 ms, ~20 ms of it the round trip
stop while running the queue plays out, then the device reports it stopped
abort while running stops after the current item; the rest stays queued and plays at the next start. Only a clear drops items, and a clear does not stop a running sequencer
stop or abort while idle the queue is kept, no report
queue stays full / item never reported MantisTimeoutError after the set time; every retry under a new item
out-of-range arguments ValueError, nothing sent

🤖 Generated with Claude Code

@BioCam
BioCam added this pull request to stack #1625 November 12, 2026 18:47
@BioCam
BioCam force-pushed the mantis-v1-02-sequencer-events branch from fea73e8 to 7a6f95a Compare November 12, 2026 19:00
@BioCam
BioCam force-pushed the mantis-v1-02-sequencer-events branch from 7a6f95a to d275e0c Compare November 12, 2026 21:05
@BioCam
BioCam marked this pull request as ready for review November 12, 2026 21:18
@BioCam
BioCam requested a review from a team as a code owner November 12, 2026 21:18
Base automatically changed from mantis-v1-01-read-state to main November 13, 2026 08:03
Events are decoded in a pure module (motion started, move done, home
done, motor error, sequence progress, sequencer stopped, input changed)
and logged by what they carry; a code not decoded is logged by its
number. A waiter matches on the payload, and a motor-error event fails
every motion waiter at once.

The sequencer's clear, start, stop and abort are raw calls sent once. A
queued PPI write numbers its item from 1 to 0x7FFF and is sent once; a
reply of -1 free slots is sent again under the next item until queued,
for at most default_queue_full_timeout. A queue write is never resent: a
v4 queued a frame written twice under one packet number as two items. A
wait for a queue item does not miss a report that came with the reply.
The simulated driver holds a 200-item queue that plays at once when
started.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BioCam
BioCam force-pushed the mantis-v1-02-sequencer-events branch from d275e0c to 16b39af Compare November 13, 2026 08:03
@BioCam
BioCam merged commit 30fce1b into main Nov 13, 2026
41 of 42 checks passed
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