From 972137b871e3de6c564f6231589d19f05ca99c4e Mon Sep 17 00:00:00 2001 From: Mirko Holler Date: Thu, 29 Oct 2026 11:39:00 +0100 Subject: [PATCH] fix(aerotech): DDG1 trigger edge rising by default (opto output, measured) The PSO opto output (J7-6/7 sourcing from J7-25 +5 V) into a 50 Ohm input is high inside the window in both directions (measured on the PandA TTLIN3, 2026-10-29). DDG1 EXT is 50 Ohm as well, so the tested wiring needs a rising edge. "falling" stays available for the open collector / differential outputs (not tested). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01M8zoDyJxbBLmjZCEPUo5FM --- csaxs_bec/devices/aerotech/README.md | 17 ++++++++++------- csaxs_bec/scans/scans_v4/aerotech_cont_grid.py | 12 +++++++----- .../tests_scans/test_aerotech_cont_grid_scan.py | 10 ++++++---- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/csaxs_bec/devices/aerotech/README.md b/csaxs_bec/devices/aerotech/README.md index a82c9e0e..d04ec221 100644 --- a/csaxs_bec/devices/aerotech/README.md +++ b/csaxs_bec/devices/aerotech/README.md @@ -83,9 +83,10 @@ scans.aerotech_cont_grid(dev.aerox, 0, 1, 0.01, dev.aeroy, 0, 1, 0.1, exp_time=0 `"panda"` (test setup: PandA configured and armed once, every line checked with `wait_lines_done`; `readout_time`, `shutter_delay` arguments) or `None` (no trigger hardware, motion tests) -- `trigger_edge` (DDG1): `"falling"` (default) for the active low PSO open collector (J7-8) - or differential (J7-1/2) output, `"rising"` for the opto output (J7-6/7). The PandA has - the same choice as device config `trigger_edge` (default `"rising"`, opto wiring). +- `trigger_edge` (DDG1): `"rising"` (default) for the opto output (J7-6/7, the tested + wiring), `"falling"` for the active low open collector (J7-8) or differential (J7-1/2) + output (not tested). The PandA has the same choice as device config `trigger_edge` + (default `"rising"`, opto wiring). - run-up / run-out = twice the ramp distance `v^2 / (2 * acceleration)` + `v * settle_time` (default 0.15 s, measured 2026-10-28: the following error needs ~100-200 ms after the ramp at 1 mm/s / 10 mm/s^2). In a snake the run-out of a line is the run-up of the next. @@ -102,9 +103,11 @@ Soft test 2026-10-28 (scan sequence on the hardware, trigger_source=None, 1x1 mm going forward and at X = 0.76 going backward (window 0.25..0.76). PSO output polarity: the PSO status bit "Output 1" is high outside the window. Open collector -(J7-8) and differential outputs are active low; the opto output (J7-6/7, JP16 normally open) -conducts inside the window. Check on the wiring day that the trigger receiver input goes -high when X enters the window (e.g. park X inside / outside and read `TTLIN3.VAL`). +(J7-8) and differential outputs are active low (manual, not tested); the opto output +(J7-6/7, JP16 normally open) conducts inside the window. Measured 2026-10-29 with the opto +output sourcing from J7-25 (+5 V -> J7-6, J7-7 -> signal, J7-24 -> ground) into the 50 Ohm +TTLIN3: high inside the window in both directions, i.e. a rising edge at the line start. +The DDG1 EXT input is 50 Ohm as well, so the same wiring with `trigger_edge="rising"`. Second client on the ASCII interface: only `~STATUS` (server command) is safe in parallel. Controller commands of all clients run on the library task by default and are refused @@ -116,7 +119,7 @@ Wiring: | Signal | From | To | |--------|------|----| -| line trigger | Npaq J7 "PSO INTERFACE" (rear, User I/O, 25-pin D-sub): pin 8 open collector (TTL, active low) + pin 24 common, or pins 6/7 opto output, or pins 1/2 RS-422 | DDG1 EXT | +| line trigger | Npaq J7 "PSO INTERFACE" (rear, User I/O, 25-pin D-sub), opto output (tested): J7-25 (+5 V) -> J7-6, J7-7 -> signal, J7-24 -> ground; rising edge. Alternatives (not tested, falling edge): pin 8 open collector + pin 24 common, pins 1/2 RS-422 | DDG1 EXT (50 Ohm) | | exposure trigger | detector trigger (DDG2 AB) | Npaq UINT1 (J12 pins 1+/2-, 5 V opto, 5-15 mA) | Commissioning of the scan: diff --git a/csaxs_bec/scans/scans_v4/aerotech_cont_grid.py b/csaxs_bec/scans/scans_v4/aerotech_cont_grid.py index ba9a5523..5d3fb258 100644 --- a/csaxs_bec/scans/scans_v4/aerotech_cont_grid.py +++ b/csaxs_bec/scans/scans_v4/aerotech_cont_grid.py @@ -25,9 +25,11 @@ line) and checked for completeness in complete. Trigger sources (trigger_source): "ddg": PSO output -> DDG1 EXT (beamline). Every trigger starts one DDG1 burst of frames_per_line gates (shutter / detectors / MCS). After each line the scan - checks that the MCS card counted the line's frames. trigger_edge: the Npaq open collector (J7-8) and - differential (J7-1/2) PSO outputs are active low, so the window entry is a - falling edge (default); the opto output (J7-6/7) gives a rising edge. + checks that the MCS card counted the line's frames. trigger_edge: the Npaq opto + output (J7-6/7, sourcing from J7-25 +5 V, into the 50 Ohm DDG input) is high + inside the window, so the window entry is a rising edge (default, measured + 2026-10-29 on the PandA); the open collector (J7-8) and differential (J7-1/2) + outputs are active low according to the manual: "falling". "panda": PSO output -> PandABox TTLIN3 (device pandatrig, test setup). The PandA is configured and armed once and sends the shutter pulse and the detector gates of each line. @@ -143,7 +145,7 @@ class AerotechContGrid(ScanBase): exp_time: DefaultArgType.ExposureTime, relative: DefaultArgType.Relative = False, trigger_source: str | None = "ddg", - trigger_edge: str = "falling", + trigger_edge: str = "rising", trigger_device: str = "pandatrig", readout_time: float = 0.0, shutter_delay: float | None = None, @@ -170,7 +172,7 @@ class AerotechContGrid(ScanBase): exp_time (float): Exposure time (period of the detector gates) in seconds. relative (bool): Whether the positions are relative to the current position. Default is False. trigger_source (str | None): "ddg" (beamline, DDG1/MCS), "panda" (PandABox line trigger) or None (no trigger hardware). Default is "ddg". - trigger_edge (str): DDG1 external trigger edge, "falling" (PSO open collector / differential output) or "rising" (opto output). Default is "falling". + trigger_edge (str): DDG1 external trigger edge, "rising" (opto output, J7-6/7) or "falling" (open collector / differential output). Default is "rising". trigger_device (str): Name of the PandaLineTrigger device for trigger_source="panda". Default is "pandatrig". readout_time (float): Detector readout time, gate width = exp_time - readout_time (trigger_source="panda"). Default is 0. shutter_delay (float | None): Delay from the line trigger to the first exposure in s. Default: DDG1 shutter delay for "ddg", 0 otherwise. diff --git a/tests/tests_scans/test_aerotech_cont_grid_scan.py b/tests/tests_scans/test_aerotech_cont_grid_scan.py index f775af0d..de65cc24 100644 --- a/tests/tests_scans/test_aerotech_cont_grid_scan.py +++ b/tests/tests_scans/test_aerotech_cont_grid_scan.py @@ -269,19 +269,21 @@ def test_pre_scan_arms_once_after_calibration( mock.call.fast_axis.arm_line_trigger( line["trigger_low"], 2 * line["line_end"] - line["line_start"] ), - mock.call.ddg1.set_trigger(2), # falling edge: PSO open collector / differential + mock.call.ddg1.set_trigger(1), # rising edge: PSO opto output ] -def test_ddg_rising_edge_for_opto_output(v4_scan_assembler, device_manager, nth_done_status_mock): - scan = _assemble(v4_scan_assembler, device_manager, trigger_edge="rising") +def test_ddg_falling_edge_for_open_collector_output( + v4_scan_assembler, device_manager, nth_done_status_mock +): + scan = _assemble(v4_scan_assembler, device_manager, trigger_edge="falling") scan.prepare_scan() scan.fast_axis = mock.MagicMock() scan.ddg1 = mock.MagicMock() scan._premove_motor_status = nth_done_status_mock(resolve_after=1) scan.actions.pre_scan_all_devices = mock.MagicMock() scan.pre_scan() - scan.ddg1.set_trigger.assert_called_once_with(1) + scan.ddg1.set_trigger.assert_called_once_with(2) def test_invalid_trigger_edge_aborts(v4_scan_assembler, device_manager):