A Python wrapper for the Photon etc / NKT Photonics Laser Line Tunable Filter (LLTF) DLL. This wrapper provides a clean, class-based interface for controlling LLTF devices with automatic grating selection and comprehensive error handling.
- Error Handling: Comprehensive error checking
- Simulation Mode: Virtual device support for development and testing without hardware
- Type Hints: Full type annotation support for better IDE integration
- Context Manager: Supports
withstatement for automatic resource cleanup - XML Configuration: Reads device specifications directly from manufacturer-provided XML files
- Automatic Grating Selection: Automatically selects the appropriate grating (0 or 1), with option for manual override.
-
Clone this repository:
git clone https://github.com/evanbray1/LLTF-tools.git cd LLTF-tools -
Install PE_Filter SDK: You must install the PE_Filter SDK provided by Photon Etc. This includes the
PE_Filter_SDK.dlllibrary that must be accessible to your Python environment (either in your system PATH or in the same directory as the running script). -
Place XML Configuration: Place your device's XML configuration file in the
xml_files/directory:- Your XML file should be named with your device's serial number (e.g.,
M000010263.xml) - This file is provided by NKT Photonics and contains critical device specifications
- The wrapper will automatically detect XML files in the
xml_files/directory
- Your XML file should be named with your device's serial number (e.g.,
from lltf_wrapper import LLTF
# Initialize LLTF (automatically finds XML file in xml_files/ directory)
lltf = LLTF()
# Connect to device
lltf.initialize()
# Set wavelength (auto-selects appropriate grating)
lltf.set_wavelength(550) # nm
# Get current wavelength
current_wl = lltf.get_wavelength()
print(f"Current wavelength: {current_wl} nm")
# Close connection
lltf.close()from lltf_wrapper import LLTF
with LLTF() as lltf:
lltf.initialize()
lltf.set_wavelength(650)
wavelength = lltf.get_wavelength()
print(f"Set to: {wavelength} nm")
# Connection automatically closedfrom lltf_wrapper import LLTF
lltf = LLTF()
lltf.initialize(simulate=True) # No hardware required
# All methods work the same way
lltf.set_wavelength(750)
current = lltf.get_wavelength()
lltf.close()For quick start with minimal code:
python examples/demo_basic.pyFor comprehensive examples and features:
python examples/demo_advanced.pyThe demo scripts demonstrate:
- Basic initialization and connection
- Wavelength setting with automatic grating selection
- Manual grating selection
- Error handling for invalid wavelengths
- Context manager usage
- Simulation mode
- Python 3.6+
- Windows
- PE_Filter SDK supplied by Photon Et
- Device XML configuration file (placed in xml_files/ directory)
The LLTF has two internal gratings, each covering different wavelength ranges:
-
Automatic Selection (default): The wrapper automatically chooses the grating based on your target wavelength and the ranges defined in your device's XML file.
-
Manual Selection: You can force a specific grating using the
gratingparameter:lltf.set_wavelength(600, grating=0) # Force grating 0
-
Range Validation: The wrapper validates wavelengths against both regular and extended ranges, issuing warnings for extended range usage.
- Ensure your device's XML file is in the
xml_files/directory - Check that the file has a
.xmlextension
- Ensure you have installed the PE_Filter SDK from Photon Etc
- Make sure
PE_Filter_SDK.dllis in your system PATH or in a locatable directory. The .dll path can also be supplied during initialization withLLTF(xml_config_path="/path/to/xml/file")
- Check your device's specifications using
get_grating_ranges() - Verify the wavelength is within your device's capabilities