Rewrite Mettler Toledo SICS scale backend with I0 command discovery, protocol simulator, and tests#979
Conversation
… validation, device discovery, and chatterbox simulator
A valid response arriving just past the timeout threshold was being discarded because the timeout check preceded the non-empty check. Sleep moved to only occur between empty reads. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…n, gate execution-only code; round chatterbox to 0.01mg
…e and MT-SICS response parsing
…G_LEVEL_IO logging
… (matching STAR pattern)
…entation, notebook logging before setup
…backend and chatterbox tests
…MT-SICS chatterbox and parsing tests
… measure_temperature, robust stop, rename chatterbox to simulator, remove deprecated methods
…e name, update notebooks
…quires_mt_sics_command gating to all commands
|
Note: I would like to rename the backend to |
…ub.com/BioCam/pylabrobot into create-mettler-toledo-SICS-scale-sytem
There was a problem hiding this comment.
why does this need its own file?
There was a problem hiding this comment.
In theory it doesn't, but I wanted to highlight how PLR is currently not systematically capturing what firmware versions for integrated devices are supported.
It could live in the backend (future driver).
But for discoverability it might still be worth considering adding it as a separate file -> if a backend/driver folder doesn't have a file with the PLR-standardised name, we know we are not tracking supported firmware versions.
There was a problem hiding this comment.
why is a firmware level simulator useful?
There was a problem hiding this comment.
Because it enables complete in silico runs of the actual device, rather than an abstract class above it.
This is very useful for running the exact commands and responses e.g. in a closed-loop experimental systems that might depend on specific responses.
With this specific one we can after (1) generate synthetic data for the simulation, (2) run e.g. a Bayesian optimisation process for liquid transfer optimisation completely in silico while generating and testing real hardware/firmware responses, minimising the risk of something breaking midway in a multi-day experiment.
Hi everyone,
PyLabRobot currently only has one programmatically controllable scale integrated - the "Mettler Toledo scale".
But in reality this is an oversimplification: Mettler Toledo manufactures a whole array of programmable scales, known as "Automated Precision Weighing Modules". The one we typically refer to is the WX series APW Module, which is the one sold in Hamilton's Liquid Verification Kit.
However, this scale is only one of many that uses the Mettler Toledo Standard Interface Command Set (MT-SICS), a serial protocol shared across Mettler Toledo's Automated Precision Weigh Modules (WXS, WMS, WX series). These devices range from 0.1 mg analytical balances to multi-kilogram industrial weigh modules, but they all speak the same serial command protocol.
This PR rewrites the PLR backend based on the MT-SICS spec and hardware validation on a physical WXS205SDU WXA-Bridge (firmware: 1.10). A single backend now handles any MT-SICS device - during
.setup(), it queries the device to discover exactly which commands that specific model supports, and gates methods accordingly. No hardcoded model assumptions.The Problems
ZCandTCwere sent to devices that don't support them, causing silent failures (ESsyntax errors with a mystery comment "For some reason, this will always return a syntax error").I2response).DAT/TIMreturned only the first field.send_commandreturned a single line. Multi-line commands (I0,I50,M27) could not be used.ScaleChatterboxBackendreturned a fixed dummy weight with no physics.PR Content / Solutions
Core architecture:
@requires_mt_sics_commandare gated at runtime against the device's actual command list.shlex.splitparsing withMettlerToledoResponsedataclass replacing rawList[str].send_commandreads until statusA, handlingB-status continuation lines.C(cancel) if available, flushes the buffer. Never clears zero/tare state.confirmed_firmware_versions.pywith setup-time warnings for untested versions.Simulator (evolution of the Chatterbox pattern):
MettlerToledoSICSSimulatorinherits from the backend, overridessend_commandwith mock responses. Where a Chatterbox returns fixed dummy values, the Simulator maintains physics state (weight, tare, temperature) as settable instance variables. All 55 commands handled.Coverage:
protocol.md) and full 194-command reference (mt_sics_commands.md).request_supported_methods()discovery.Future Work for MT-SICS
This PR covers the WXS205SDU thoroughly. For other MT-SICS devices:
mt_sics_commands.md.Happy to discuss any of the design decisions - especially around the Simulator pattern and interrupt safety, as those could be useful templates for other PLR device drivers.