Skip to main content

PyPDM

Documentation Status

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.

What's new in 2.0

  • Explicit support for protocol 3.7: software_control_mode and control_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)

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.

Metadata

Release files for pypdm 2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypdm 2.0
File Size Uploaded
pypdm-2.0.tar.gz 29.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pypdm 2.0
File Interpreter ABI Platform
pypdm-2.0-py3-none-any.whl Python 3 none any Details

Total release size: 56.9 kB

Release files / pypdm-2.0.tar.gz

Download URL pypdm-2.0.tar.gz
Size 29.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9eee6f1911b541d1776043624a0340d909ac0db572ce2e776936ddb452a8a049
BLAKE2b-256 checksum
How to use checksums
38f24b4ea86fb7a1e6dda2b3ac904af59269aec9985fd048d41ed6f6e7277c34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.12 Darwin/25.2.0

Release files / pypdm-2.0-py3-none-any.whl

Download URL pypdm-2.0-py3-none-any.whl
Size 27.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbe2bb3361227ceae8471906d83c980fad128c5e7be413aef8d5bd9b6f75b584
BLAKE2b-256 checksum
How to use checksums
f08b244d8bbcc345d0f8b713f27fddda8aeb0322df6aeae87348c7538f3e6ae3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.12 Darwin/25.2.0

Release history Release notifications | RSS feed

This release

2.0 This release

2 release files

1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page