Repository navigation
feat(sequencer): flat programs (StackAxisType.NONE) - a single plane is one burst per FOV, with or without a piezo - #877
Draft
hongquanli wants to merge 6 commits into
Conversation
A single-plane acquisition has had no legal program shape: the loop always names a stepper or piezo axis. None (2) is a program that moves nothing; validate() accepts it only with n_layers 1, dz 0 and no return move, ignores stack_axis_id, and refuses a channel z offset (BadChannel with the index): with no axis to offset along it would be silently ignored. Older firmware answers BadStackAxis for the unknown value, so a flat program fails loud there instead of being misread. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…program stack_range_ok() has no range to check for a flat program and accepts any stack_start (SEQ_RUN's argument is ignored, as validate() pinned n_layers 1 and dz 0); command_stack() arms the settle gate as already elapsed and makes no HAL call, so the first exposure is scheduled on the first tick and no DAC or axis is ever written. finish() needs no change: validate() forbids a return move for None. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ge for StackAxisType.NONE The host enum gains NONE = 2 (the header cross-check test requires both sides to change together); validate() applies the firmware's three rules (one layer, no step, no return move; the axis id is ignored) and refuses a channel z offset on a flat program; check_stack_range() has nothing to check. WIRE_VERSION stays 2: the layout is unchanged and older firmware answers BadStackAxis. A second golden vector, FLAT_HEX / 0xCE65, is pinned in Python and in the firmware's wire test, so the two sides cannot drift apart. The simulator needed no change: a flat program runs its channels once from any stack start on both serial fakes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…eligible without a piezo StackPlan decides once per acquisition how a burst drives its z axis: NONE for a single plane (with or without a piezo), PIEZO for a stack (which needs the piezo range). build_program() takes the plan instead of the piezo range and flip, emits a NONE loop (axis id NONE_ID, dz 0, no return move) for a single plane, and refuses a flat plan with more than one layer or a channel z offset. A single plane without a piezo is eligible; a stack without one keeps its reason. The worker still calls build_program() with the old arguments; the next commit moves it to the plan. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…or without a piezo The worker decides a StackPlan once per acquisition and builds its program from it; a single plane is a flat (NONE) program, so a system without a piezo is eligible. The burst path no longer touches the piezo on a flat run: the stack start is 0 (the controller ignores it), the capture metadata carries no piezo z, and the per-level piezo bookkeeping and the move back after a failed burst run only when there is a piezo. The log line says 'flat (no stack axis)' instead of a layer count. End to end, in simulation: a two-FOV single-plane acquisition without a piezo uploads one NONE program, the controller fires one burst per FOV, and the images and files match the software-sequenced run; on a piezo system the same acquisition is flat too and keeps the piezo position in its metadata. The harness compares data files only (the save-job runner's warning log appears with its first warning, a matter of timing). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…t exposure when a piezo exists Review finding on the branch: on a piezo system a single plane used to run as a 1-layer PIEZO program whose first PREP waited z_settle_us before the first trigger, which in practice settled the piezo right after the per-FOV laser AF offset move (an open-loop move with no settle of its own). A None program fired on the first tick, so the first channel could be exposed while the piezo was still moving. The engine's None branch now honours z_settle_us once, as the wait before the first exposure (still no DAC or axis write). StackPlan.settle_us() sends the piezo settle for a flat program when a piezo exists and 0 when there is none (nothing can have moved), so a system without a piezo gains no wait. The engine test runs with a 50 ms settle and pins both the wait and that nothing else is waited for; the builder and end-to-end tests pin 0 and the piezo settle respectively. Also drops the redundant 'self.piezo is not None' guard (set_use_piezo refuses use_piezo without a piezo). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A single-plane acquisition (one Z, several channels per position) has had no legal sequencer program: the loop always names a stepper or piezo stack axis, and the worker's eligibility check admitted only acquisitions whose z-stack uses the piezo. This PR gives the program a flat shape and lets a single plane run as one hardware-sequenced burst per position, on systems with or without a piezo. Stacked on #656 (base branch
feat/hardware-sequencer-worker); retargeted when it merges.One wire value, the same rules on both sides
StackAxisType::None = 2(firmware) /StackAxisType.NONE = 2(host). Valid only withn_layers == 1,dz == 0and no return move;stack_axis_idis ignored (the host writesNONE_ID); a channelz_offseton a flat program is refused (BadChannelwith the channel index), because there is no axis to offset along. The layout is unchanged andWIRE_VERSIONstays 2: older firmware does not know the value and answersBadStackAxis, so a flat program fails loud there instead of being misread.seq::validate()applies the three rules;SeqEngine::stack_range_ok()has no range to check and accepts anySEQ_RUNstack start;command_stack()makes no HAL call, so no DAC or axis is ever written, and honoursz_settle_usonce as the wait before the first exposure (see below).finish()needs no change (no return move).SequencerProgram.validate(),check_stack_range()as a no-op; the header cross-check test ties the two enums together.FLAT_HEXwith CRC0xCE65, asserted byte for byte in Python and in the firmware's wire test, so the two sides cannot drift.The one wait a flat program keeps (please confirm)
On a piezo system a single plane used to run as a 1-layer piezo program whose first PREP waited
z_settle_us(MULTIPOINT_PIEZO_DELAY_MS) before the first trigger. In practice that settled the piezo right after the per-FOV laser-AF offset move, which is open loop and has no settle of its own. A flat program that fired on the first tick would expose the first channel while that piezo may still be moving, so the engine honoursz_settle_usonce for a flat program, and the host sends the piezo settle only when a piezo exists and 0 without one (StackPlan.settle_us()). A system without a piezo gains no wait; piezo systems keep the timing they had. This came out of the branch's review and is a small amendment to the design; the alternative was a host-side sleep keyed on "laser AF moved the piezo".Worker
StackPlandecides once per acquisition how a burst drives z:NONEfor a single plane (with or without a piezo),PIEZOfor a stack (which needs the piezo range).build_program()takes the plan instead of the piezo range and flip. On a flat run the burst path never touches the piezo: the stack start is 0, the capture metadata carries no piezo z, and the per-level piezo bookkeeping and the move back after a failed burst run only when there is a piezo. A single plane without a piezo is now eligible; a z-stack without one keeps its reason.Tests
Firmware: 6 validation tests, 2 engine tests (nothing moves, any stack start runs), 2 wire tests (the flat golden and its parse). Host: the flat golden and its round trip, the NONE rules, the range check, a simulator run on both fakes,
StackPlanand the flat builder, eligibility, and two end-to-end runs in simulation: a two-FOV single plane without a piezo uploads one NONE program, the controller fires one burst per FOV, and the images and data files match the software-sequenced run; on a piezo system the same acquisition is flat and keeps the piezo position in its metadata. Whole native suite 348, host sequencer and worker suites green; both firmware images build. One fresh-context review pass ran on the branch; its one Important finding is the settle above, fixed here; its minors are listed below.Reflash note
A controller flashed with sequencer firmware from before this branch does not know the
Nonevalue and refuses every single-plane sequenced run withBadStackAxis(loud, but it does not yet say why). Reflash before running single planes sequenced; a host-side hint naming the remedy is a follow-up.Review minors, deferred
kWireVersioncomment inseq_wire.hlacks the "v2 also admits None" note the host comment has.coordinates.csvto assert there is no piezo column on a run without a piezo.if start_um is not Noneguards in the burst path, as the plan prescribed; on a flat piezo run the move back after a failed burst is a harmless redundant write.seq_engine.hstart/stack_range_ok,seq_wire.hkOpSeqRun,Microcontroller.seq_run, one worker comment) does not mentionNone;StackPlanhas no__post_init__against a hand-built piezo plan without a range.Hand-off when this merges into #656
#790 builds one single-channel program per channel: its
build_programcall(s) takestack=now. #792 is on wire version 3:FLAT_HEX/kFlatHexstart03there andFLAT_CRC16is recomputed withcrc16_ccitt_false;seq_types.hkeeps both that branch's additions andNone = 2.🤖 Generated with Claude Code