Skip to main content

Functions and examples to control Thorlabs KLC controllers (KLC101) through serial commands with Python

Project description

KLCserial

Functions and examples to control Thorlabs KLC controllers (KLC101) through serial commands with Python.

The official software can be found on the Supplier Download Site. Documentation is also available through the same website. The serial commands have been partially assembled from the Thorlabs Motion Controllers Host-Controller Communications Protocol.

There is no specific documentation for the KLC101 so I assembled commands from other stages.

Requirements

Needs serial and pyserial (both of them are needed for this to work somehow), best installed through:

pip install serial pyserial

Usage

Simply run

pip install KLCserial

Then in your Python script invoke the functions by

from KLCserial import KLC
klc = KLC()

With klc you can then call all functions and methods of the controllers.

Look at example.py. There are a few more commands implemented than shown in the example but they appear not to be too helpful for most applications.

Serial ports

By default the openKLC()-function will use all the ports found under /dev/serial/by-id/*Kinesis_LC_Controller* (Windows: COM[0-255], not tested) and try to connect through serial.

You need write-access to the tty-port. Either run as the admin or change the permissions or the ownership on the serial port, preferably with a udev rule, e.g. something like /etc/udev/rules.d/80-usb-serial.rules

SUBSYSTEM=="tty", MODE="0666"

(After changing run as root: udevadm control --reload-rules && udevadm trigger)

License

This project is licensed under the Apache-2.0 license. Copyright 2025 iancynk

Acknowledgement

You're welcome!

Comments and suggestions highly welcome.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

klcserial-0.26.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

klcserial-0.26-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file klcserial-0.26.tar.gz.

File metadata

  • Download URL: klcserial-0.26.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for klcserial-0.26.tar.gz
Algorithm Hash digest
SHA256 ad9a3d57d7a30acc86caeb4afe85daddf1cd97d3a9bc7619f147bbfd747045f4
MD5 96db0dd1703b0ff09971943e9f74200f
BLAKE2b-256 e56ae7a0960a23f3b0f01c0272f8d25842a08ae69e07ab3f60d33b364e739c9b

See more details on using hashes here.

File details

Details for the file klcserial-0.26-py3-none-any.whl.

File metadata

  • Download URL: klcserial-0.26-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for klcserial-0.26-py3-none-any.whl
Algorithm Hash digest
SHA256 6b2b5c56246e99085f841046dcd32b52a1136beb94c536097a3cd8de59146196
MD5 c448049c4ec9b51ceb8cef563510ee7e
BLAKE2b-256 7e3413c362142bc3cc3c16a69b8aee00a7103190dbdc77e8f0689c493436b3ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page