PyPDM
Python3 library for controlling Alphanov's PDM laser sources. Currently supported PDM protocol version is from 3.4 to 3.7. Daisy-chain configuration for multiple devices is supported, so it is possible to use many PDMs with only one serial link. ALPhANOV's LFIPico picosecond laser is also supported.
What's new in 2.1
- Support for ALPhANOV's LFIPico laser (
LFIPicoclass), based on the LFIPico Hexa Programming Manual v1.1. - LFIPico diode currents are raised and lowered progressively, by steps of 20% of their full scale every second:
set_low_power,set_high_powerandswitch_offblock during the ramp, the*_stepsmethods allow running it with a timer. - Control window for PDM and LFIPico devices: install with
pip install pypdm[gui](PyQt6), then runpypdm-gui. - Serial reads now time out (1 s by default, see
Link(dev, timeout=...)) and raiseResponseTimeoutinstead of blocking forever when a device does not respond. - Real-device tests: PDM address is configurable with
--device-address, LFIPico tests are enabled with--lfipico-device.
What's new in 2.0
- Explicit support for protocol 3.7:
software_control_modeandcontrol_mode_selection. - Minimum required Python raised to 3.10.
Installation
The library can be installed using pip3:
pip3 install pypdm
Documentation
A quick documentation is available on Read the Docs. A simple usage example is also provided below.
Requirements
This library requires:
- Python >= 3.10
- pyserial
Safety
When a PDM object is deleted, the library may try to switch off the laser source for safety. However, you shall not rely on this behavior and always beware of dangers when using laser equipments! Please always wear laser safety goggles or use any appropriate safety equipment to prevent any harmful accident.
Usage example
Basic laser activation in continuous mode
import pypdm
pdm = pypdm.PDM(1, 'COM0')
# Set offset current in mA.
pdm.offset_current = 30
pdm.activation = True
# Apply new settings to the device.
pdm.apply()
Basic laser configuration for pulsed operation
import pypdm
pdm = pypdm.PDM(1, 'COM0')
# Set pulse power to 50%
pdm.current_source = pypdm.CurrentSource.NUMERIC
pdm.current_percentage = 50
pdm.activation = True
# Apply new settings to the device.
pdm.apply()
List of available properties
import pypdm
pdm = pypdm.PDM(1, 'COM0')
print('Mode:', pdm.mode)
print('Synchronization source:', pdm.sync_source)
print('Delay line type:', pdm.delay_line_type)
print('Frequency (Hz):', pdm.frequency)
print('Pulse width (ps):', pdm.pulse_width)
print('Delay (ps):', pdm.delay)
print('Offset current (mA):', pdm.offset_current)
print('Current (%):', pdm.current_percentage)
print('Current (mA):', pdm.current)
print('Temperature (C°):', pdm.temperature)
print('Maximum current (mA):', pdm.maximum_current)
print('Maximum mean current (mA):', pdm.maximum_mean_current)
print('Current source:', pdm.current_source)
print('Interlock status:', pdm.interlock_status)
print('Activation:', pdm.activation)
# Protocol 3.7 only:
print('Software control mode:', pdm.software_control_mode) # requires protocol 3.7
print('Control mode selection:', pdm.control_mode_selection) # requires protocol 3.7
Use of two sources in daisy-chain configuration
import pypdm
pdm1 = pypdm.PDM(1, 'COM0')
pdm2 = pypdm.PDM(2, pdm1)
LFIPico
The LFIPico board address is 51 by default. Its two amplifying diodes can be driven in low power mode (SMD2 current, in A) or high power mode (SMD2 at maximum, SMD1 current in %). Activating the laser resets the currents to 0, so set_low_power and set_high_power set the currents after activation. The seed diode (trigger, frequency, delay) is not documented by the manufacturer and is not supported yet.
import pypdm
pico = pypdm.LFIPico('COM0')
print('Firmware version:', pico.firmware_version)
print('Alarms:', pico.alarms)
# Low power mode, SMD2 current in A.
pico.set_low_power(0.05)
# High power mode, SMD1 current in percentage of maximum.
pico.set_high_power(20)
# Switch off both diodes.
pico.activation = False
pico.full_activation = False
pico.apply()
Control window
A small control window for PDM and LFIPico devices, inspired by ALPhANOV's LFIPico software, is provided. It requires PyQt6:
pip3 install pypdm[gui]
pypdm-gui
Select the device type, serial port and address, then connect. The window provides laser activation and the device settings:
- PDM: synchronization source, delay line, frequency, pulse width, delay, offset current, current source and current, and control modes for protocol 3.7. Status shows interlock, mode and temperature.
- LFIPico: low/high power mode and adjustment. Status shows alarms. Trigger, frequency and delay settings are not documented by the manufacturer and are not available.
PDM settings changes are applied immediately. The laser is switched off when disconnecting or closing the window.
Testing
To test the package with a real device, you can use pytest and enable the "real" tests using the real marker.
Make sure your device is connected (for example, /dev/ttyUSB0 on Linux or COM3 on Windows) and that you have installed the required test dependencies (pytest).
To run all standard tests (not requiring hardware), use:
pytest
To run tests involving a real device, use:
pytest -m real --device /dev/ttyUSB0
Replace /dev/ttyUSB0 with the appropriate serial port for your platform.
The --device parameter specifies the serial port of the device to be used during "real" tests.
Tests marked with @pytest.mark.real will actually access the physical device. If the PDM address is not 1, specify it with --device-address:
pytest tests -m real --device /dev/ttyUSB0 --device-address 2
LFIPico tests (marker real_lfipico) never activate the laser emission. They are enabled with --lfipico-device (or PYPDM_LFIPICO_DEVICE):
pytest tests --lfipico-device=/dev/ttyUSB1
Metadata
Release files for pypdm 2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pypdm-2.1.tar.gz | 44.2 kB | Without provenance | Details for pypdm-2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pypdm-2.1-py3-none-any.whl | Python 3 | none | any | Details for pypdm-2.1-py3-none-any.whl |
Total release size: 85.7 kB
Release files / pypdm-2.1.tar.gz
| Download URL | pypdm-2.1.tar.gz |
|---|---|
| Size | 44.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72b1765ed6865400fb004f1042f845584dfee26209516f69c79d3214a7139ae4
|
|
BLAKE2b-256 checksum How to use checksums |
7f2c79f8a2b60baa67a1fe101223a399f2935ea23b0e45a431bb452592c99d99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.13.17 Darwin/25.6.0
|
Release files / pypdm-2.1-py3-none-any.whl
| Download URL | pypdm-2.1-py3-none-any.whl |
|---|---|
| Size | 41.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ac9329b4df9ef77ad9631a753a9460b6433b56b82b004bf619e521465ecfc0d
|
|
BLAKE2b-256 checksum How to use checksums |
0d9d2d77e8568fc02b15c8694f4dd322dc2789e37b44160f62e119794a4514ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.13.17 Darwin/25.6.0
|
Security for pypdm 2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.