Skip to content

Latest commit

 

History

History
75 lines (53 loc) · 3.06 KB

File metadata and controls

75 lines (53 loc) · 3.06 KB

opto-trigger

Python driver for the Arduino DMD_trig firmware and externally triggered multi-pattern DMD playback via Micro-Manager / pycromanager.

For project overview, hardware requirements, and assembly instructions see the top-level README.

Important: camera synchronization

The Arduino and DMD run independently of the camera. Frames are not guaranteed to capture a specific pattern slot. To use this safely alongside camera acquisition, either:

  • use optical filters that block DMD-illuminated wavelengths from the detection path, or
  • call runner.stop_sequence(arduino) before each exposure and runner.run_sequence(seq, arduino) again afterwards.

Install

From this folder:

python -m pip install -e .

Run from Python (script or notebook)

from opto_trigger import run_example_session

timings = run_example_session(
    arduino_port="/dev/tty.usbmodemXXXX",  # use COM10 on Windows
    lines=["CYAN", "GREEN"],
    exposure_ms=50,
    settle_ms=2,
    run_seconds=10,
    csv_log="logs/flash_events.csv",
)

A worked notebook example is in dmd_trig_example.ipynb.

Hardware-specific values

The following defaults are set for the tested hardware (Lumencor AuraIII + Mightex Polygon1000G) and will need updating for other systems:

Location Value What to change
runner.MicroManagerDmdTriggerRunner dmd_label = "MightexPolygon1000" Your DMD's Micro-Manager device label
runner.MicroManagerDmdTriggerRunner dmd_illuminator_label = "LightEngine" Your LED controller's device label
runner.MicroManagerDmdTriggerRunner intensity_suffix = "_Intensity" Property suffix for per-channel intensity
runner.MicroManagerDmdTriggerRunner TriggerType = "2" External-trigger mode property value for your DMD
examples.run_example_session height = 1140, width = 912 Your DMD's pixel dimensions
arduino.ArduinoDmdTrigController DEFAULT_LINES Arduino pin numbers for each LED channel
call site dmd_start_settle_ms, exposure_ms, settle_ms Timing for your hardware

Serial protocol

Commands sent by the Python driver to the firmware:

Command Effect
SET <pin...> Set LED output pins and reset cycle index
TIME <ms> Set LED on-time per trigger cycle
SETTLE <ms> Set LED-off settle time before trigger pulse
ACK <0|1> Enable/disable DMD acknowledgment waiting
RUN Start cycling
STOP Stop cycling, all LEDs off
PING No-op keepalive

The firmware reports FLASH <index> <millis> on each LED activation and ACK_TIMEOUT if the DMD fails to acknowledge.

Notes

  • LED line names (CYAN, GREEN, UV) map to firmware pins via ArduinoDmdTrigController.DEFAULT_LINES.
  • If ACK mode is enabled and the firmware emits ACK_TIMEOUT, run_example_session() raises a RuntimeError.
  • The example generates synthetic stripe patterns for validation. Replace with real patterns for your experiment.
  • CSV logging captures FLASH, ACK_TIMEOUT, and other monitor events with host timestamps.