herosdevices.hardware.santec.slm200 - Heros Devices 0.11.1 documentation

Skip to content
Back to top
View this page

# herosdevices.hardware.santec.slm200

HERO driver and functions to control a Santec SLM.

## Module Contents

herosdevices.hardware.santec.slm200.msg = ''

herosdevices.hardware.santec.slm200.FPGA_STATUS

herosdevices.hardware.santec.slm200.VIDEO_MODE

herosdevices.hardware.santec.slm200.CMD_CONTROL

herosdevices.hardware.santec.slm200.CMD_STATUSREQUEST

herosdevices.hardware.santec.slm200.CMD_STATUSRESPONSE

herosdevices.hardware.santec.slm200.CMD_IMAGEDATA

class herosdevices.hardware.santec.slm200.SLM200(serial_number: str, config_dict: dict, default_config: str | None = None, keep_device_open: bool = True, channel: int = 0)

  Bases: `herosdevices.core.templates.DisplayDeviceTemplate`

  Driver for a Santec SLM200 spatial light modulator.

  The images can be transferred to the SLM200 via USB or DVI. This driver, however, only supports communication via USB. Since image upload via USB takes roughly 150ms, this driver is limited to around 6Hz of refresh rate. Precise and externally synchronized timing is only possible in USB mode.

  In USB mode (also called memory mode) images can be pushed via USB and stored in one of 128 memory slots. The image slot displayed on the SLM can be set randomly by the driver or an advance from one slot to the next can be triggered by a software trigger, and internal timer, or a logic signal (Trigger IN SMB jack).

  The SLM contains an FPGA that the computer communicates with by writing to an output FIFO/pipe and reading from an input FIFO/pipe. These two FIFOs are transparently accessed through the FTDI driver (D3xx) which provides methods to read and write these FIFOs/pipes.

  This driver is reverse engineered by looking at the data the vendor software sends via USB. This was achieved by looking at the API calls to the functions FT_WritePipe and FT_ReadPipe in the D3XX.dll which handles the communication with the FTDI USB3.0 chip (FT601).

  MIN_SLOT: int = 1
  MAX_SLOT: int = 128
  IMAGE_SIZE: tuple[int] = (1200, 1920)
  default_config_dict: dict
  firmware_versions = ['2018021001', '2018021101', '2018020001', '2017080002', '2015010001']
  trigger_functions
  serial_number
  channel = 0
  firmware: str | None = None
  streaming_mode: bool = False
  request_sleep: float = 0.015
  write(buffer: bytes) → None

    Stream buffered data to the SLM.

  write_command(cmd_dict: dict, payload: bytes, seq_id: int = 0) → None

    Send a command to the SLM.

  read(length: int) → bytes

    Read length bytes from the device.

  read_command(length: int) → dict

    Read a command response from the SLM.

    Parameters:

      length – Length of the response to read in byte

  request(cmd_dict: dict, payload: bytes, buffer: bytes | None = None, trials: int = 100, request_sleep: float | None = None) → str

    Send a request to the SLM and wait for a response.

    Parameters:

      - cmd_dict – Dictionary containing command metadata

      - payload – Payload to send, unused when buffer is used

      - buffer – Pre-assembled buffer to send

      - trials – Number of trials to attempt

      - request_sleep – Sleep time between retries

    Returns:

      Status

  firmware_serialnumber() → str

    Get the serial number of the santec firmware running on the SLM.

    This not the same as the serial number used to identify the FTDI chip.

    Returns:

      Serial number.

  video_mode(mode: int | str = 'USB') → bool

    Set the video source the SLM draws the images from.

    Parameters:

      mode – Video source. 0 = USB/Memory, 1 = DVI.

    Returns:

      Status of the operation.

  contrast_level(value: int) → bool

    Set the contrast/gamma level of the LCOS.

    Parameters:

      value – Value between 0 and 1023.

    Returns:

      Status of the operation.

  trigger_output(on: bool | None = None) → bool

    Activate the trigger output of the SLM.

    This is especially useful in DVI mode orwhen software/automatic triggers are used.

    Parameters:

      on – Determines whether the trigger output should be activated If not set the current status is returned

    Returns:

      Status of the operation.

  do_phase_calibration(wavelength: int, max_phase: int = 2) → bool

    Calibrate the change of the lights phase as function of the bit value of each pixel.

    This can be used to adapt for different wavelength of the light and to change the maximum phase change for the maximum pixel value of 1023 (10bit).

    Attention

    This command takes some minutes to finish!

    Parameters:

      - wavelength – Wavelength of the indicent light in nm

      - max_phase – Maximum phase change in units of pi

    Returns:

      Status of the operation.

  trigger_software_fire() → bool

    Fire a software trigger. Only works if the trigger mode was set to manual before.

    Returns:

      Status of the operation

  trigger(mode: str | None = None) → str

    Set or query the trigger mode.

    Hint

    The SLM can be triggered from four different sources:

      - none : The image selected by `display_slot()` is displayed continuously and no trigger changes this.

      - manual : The image in the next slot is displayed when the software trigger `trigger_software_fire()` is called.

      - auto : The change to the next image is periodically triggered by an internal timer.

      - external : The change to the next image happens when a logic pulse on the trigger in SMB-connector is received.

    Parameters:

      mode – Name of the trigger mode to set. If no argument is given, the current trigger mode is returned

    Returns:

      The trigger mode

  keep_device_open = True
  default_config: str
  get_device() → collections.abc.Iterator[None]

    Yield a device handle.

        # use the device in a with statement
        with self.get_device() as slm:
            slm.do_something()

  open() → Any

    Open the device handler and assign it to self._device.

  teardown() → None

    Release the device handler and potentially de-initialize the API.

  reset() → None

    Reset the device by closing and re-opening the handler.

  get_status() → dict

    Get a dict with the current device status.

    Returns:

      A dict with the device status

  property config_dict: dict

    Get a copy of the configuration dict.

    Returns:

      Copy of the configuration dict

  update_configuration(new_config_dict: dict, merge: bool = True) → None

    Update the configuration dict with new configuration.

    Each dict key corresponds a (new) configuration name. Each value is a dict with config property -> config value.

    Parameters:

      - new_config_dict – A dict of configurations where the keys are the configuration names

      - merge – If `True`, the new dict is recursively merged with the current set config dict. If `False` the old configurations with the provided names (keys) are overwritten.

  get_configuration() → dict

    Get the currently active configuration.

    Returns:

      The currently active configuration.

  configure(config: str = '') → bool

    Configure the device with the known configuration config.

    To add a configuration to the device, use `update_configuration()`.

    Parameters:

      config – Key (name) of the configuration

  set_configuration
  push_image(slot: int, image: numpy.typing.NDArray[numpy.uint16], display_now: bool = True) → bool

    Upload an image into a specified memory slot.

    Parameters:

      - slot – Slot number

      - image – The image

      - display_now – Flag whether to display the image immediately

  display_slot(slot: int = 1) → bool

    Set the memory slot to display on the SLM.

    Parameters:

      slot – Slot number

herosdevices.hardware.santec.slm200.logger