Skip to content

v1 Mantis: read the motors, the arm encoder and the pressure board; the v4 LED bar - #1621

Merged
BioCam merged 3 commits into
mainfrom
mantis-v1-01-read-state
Nov 13, 2026
Merged

BioCam merged 3 commits into
mainfrom
mantis-v1-01-read-state

Conversation

@BioCam

@BioCam BioCam commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

The Problem

#1612 connects to a Mantis, clamps the plate and reads the chip tags, but nothing else the device knows can be read: where each motor is, whether it is in fault, what the pressure lines read, whether the pump runs. Every later step (bringing the arm up, moving, priming, dispensing) has to check those first. The v4 also has an LED bar on the front that PyLabRobot cannot show anything on.

PR Content/Solution

  • Motor reads on the driver, for each motor: request_motor_status, request_motor_position (the demand position, not a measurement), request_encoder_position, request_following_error_configuration, request_motor_currents, request_motor_configuration.
  • Arm encoders: request_absolute_encoder_position reads board 11 again until the reading is valid (each motor's first read is not).
  • mantis.pump, built when the pressure board answers: measure_pressure, request_controller_status, request_controller_enabled, request_pump_on, request_feedback_sensor_parameters, for the "bottle", "chip" and "vacuum" lines. Setup reads the sensors' calibration from the device. None of these reads changes the device.
  • mantis.led_bar (v4 only; None on a v3, like plate_clamp): set_color (one colour, or one per LED), start_animation, stop_animation, turn_off. While show_actions is on (the default) the bar shows what the device is doing: blue during setup, green when done, then the idle wave; off at stop. Each colour is an attribute checked on assignment (setup_color, setup_done_color, error_color, dispense_progress_color; later PRs add their actions'). show_progress(done=..., total=...) turns the bar into a progress bar, sending a frame only when the number of lit LEDs changes (each frame holds the link ~62 ms). An LED fault only warns; it never fails the action. The LED count is a unit value, saved like the clamp levels.
  • Older saved files load: a unit value a file saved before this PR lacks comes from the configuration folder, else the recording, with one warning naming it.
  • The pressure sensors' calibration is read at every setup, never saved: on the device its offsets change between sessions, so a saved value would go stale.
  • Simulation answers every new read, and simulates the LED bar.

Usage

  1. What state is the device in?
await mantis.driver.request_motor_status(motor=2)  # 0: no fault
await mantis.driver.request_absolute_encoder_position(motor=0)  # 153.99
await mantis.pump.request_pump_on()  # False
await mantis.pump.measure_pressure(controller="bottle")  # ~1.0 psi, vented
  1. The LED bar
await mantis.led_bar.set_color(color="green")
await mantis.led_bar.set_color(color=["red", "green"] * 10)  # one per LED
await mantis.led_bar.start_animation(effect="wave")
await mantis.led_bar.turn_off()

mantis.led_bar.setup_color = "magenta"  # checked here
await mantis.led_bar.show_progress(done=3, total=8)  # 8 of 20 LEDs

mantis = Mantis(name="mantis", declared_configuration_json="my_mantis.json", show_actions=False)

On the device

A Mantis v4 on Windows (D2XX):

result
setup v4, firmware confirmed; the pressure board read only for its firmware and the three sensor calibrations
18 motor reads, encoders (also after a power cycle) every reply's layout, length and status equal to the recorded ones (160 compared)
pressure board pump off, controllers off; the sensor offsets read differently between sessions, which is why they are read at every setup
LED bar blue, green, then the wave at setup; every colour and the animation as sent; one colour per LED, left to right; frames in the recorded shape; bad colours and effects refused with nothing sent
show_actions=False only the idle wave at setup, straight to off at stop
a file saved before the LED bar loads, with one warning naming where the LED count came from
USB pulled at idle, then setup in the same process the next call raises at once; one log line, nothing sent over the dead link; reconnects with the same writes
stop the bar goes straight off
colour attributes, show_progress a changed setup colour shown at setup; the bar fills 2, 8, 12, 20 LEDs, a repeat and a bad value send nothing

🤖 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-01-read-state branch from 38a9597 to 1724cdf Compare November 12, 2026 19:00
… the v4 LED bar

The driver reads each motor's status, demand position, servo encoder
position, following-error check, currents and configuration, and the
arm motors' absolute encoders on board 11, read again until valid: each
motor's first read after connecting is not.

A pump feature is built when the pressure board answers. It measures
each line's pressure and reads each controller's status, whether it is
enabled, whether the pump runs and each feedback sensor's calibration.
Setup reads the calibration into the device configuration at every
setup; it is never written, saved nor declared, as the device re-zeroes
its offsets between sessions. None of these reads changes the device.

An LED bar feature is built on a v4 whose board 12 answers; a v3 has
none. It shows one colour or one per LED, starts and stops a firmware
animation, and turns off. Setup shows blue, green for a second, then
the idle animation; stop turns it off; an LED fault only warns.
show_actions=False shows only the idle animation. The LED count is a
unit block, NumberOfLed, saved like the clamp levels. Each action's
colour is an attribute of the bar, checked when it is set; each bar has
its own. show_progress lights a share of the LEDs from the left and
sends nothing when that many are lit already. The status display for
later actions comes with it: nesting, the error colour and the dispense
fill. The plate clamp shows none.
The simulation answers above the wire.

A declared file saved before a unit block or a non-fitted device field
existed still loads: each value it lacks comes from the folder, else
the generation's recording, with one warning. After the link is lost,
stop and setup close it without sending, with one warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BioCam
BioCam force-pushed the mantis-v1-01-read-state branch from 1724cdf to a79786b 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
@BioCam
BioCam merged commit 7fca79d into main Nov 13, 2026
26 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