Skip to main content

A python library/GUI to access and control motors via the APT protocol.

Project description

pyThorlabsAPT

pyThorlabsAPT is a Python library/GUI interface to control any motor compatible with the Thorlabs APT communication protocol. The package is composed of two parts, a low-level driver to perform basic operations, and a high-level GUI, written with PyQt5, which can be easily embedded into other GUIs. The low-level driver is essentially a wrapper of the excellent package thorlabs_apt, with a few tweaks to speed up loading time and error handling. Since thorlabs_apt is not available via pip, its code has been embedded in the code of this package, here.

Table of Contents

Installation

The package uses the Thorlabs APT.dll shared library, and therefore it only works under Windows. To install, follow these steps:

  1. Install the script via the package manager pip,
pip install pyThorlabsAPT
  1. Install the APT software from here. The version of the software (32 or 64 bit) must match the one of your python installation.

  2. Locate the file APT.dll which has been installed on your computer by the APT software. This file will typically be in the folder "[APT Installation Folder]\APT Server", where [APT Installation Folder] is the installation folder of the APT software (typically [APT Installation Folder] = C:\Program Files\Thorlabs\APT). Copy the APT.dll into one of these locations:

    • C:\Windows\System32.
    • The folder of your python application.
    • Inside the "[Python packages folder]\pyThorlabsAPT horlabs_apt". Most of the times [Python packages folder] = "[Python folder]\Lib\site-packages".

These steps are enough to run the low-level driver of pyThorlabsAPT. In order to use the GUI, it is necessary to install additional libraries, specified in the requirements.txt file,

pip install abstract_instrument_interface>=0.6
pip install "PyQt5>=5.15.6"
pip install "pyqtgraph>=0.12.4"
pip install numpy

Usage via the low-level driver

pyThorlabsAPT can be used to control a device from the command line or from your Python script.

Example

from pyThorlabsAPT.driver import pyThorlabsAPT
instrument = pyThorlabsAPT()
available_devices = instrument.list_devices()
print(available_devices)
instrument.connect_device(device_addr = available_devices[0][0])
instrument.hardware_info
instrument.move_home()
instrument.move_by(10)
instrument.is_in_motion # returns True when instrument is moving
instrument.position = 10 # Goes to position 10

Most of the properties and methods of the class pyThorlabsAPT are actually inherited from the thorlabs_apt package. Here below the main properties and methods are summarized for quick reference.

Properties

Property Type Description
Can be set?
Notes
position float Read or set current position of the motor. Yes
stage_info (float,float,int,float) Read current stage parameters No

Methods

Method Returns Description
list_devices() list Returns a list of all available devices. Each element of the list identifies a different device, and it is a three-element list in the form [address,identity,model]. The string address contains the physical address of the device. The string idn contains the 'identity' of the device. The string model contains the device model.
connect_device(device_addr: str) (str,int) Attempt to connect to the device identified by the address in the string device_addr. It returns a list of two elements. The first element is a string containing either the address of the connected device or an error message. The second element is an integer, equal to 1 if connection was succesful or to 0 otherwise.
disconnect_device() (str,int) Attempt to disconnect the currently connected device. It returns a list of two elements. The first element is a string containing info on succesful disconnection or an error message. The second element is an integer, equal to 1 if disconnection was succesful or to 0 otherwise.
move_home()
move_by(movement: float) int Set the zero to the currently connected (if any) console. The returned value is 1 if the operation was successful, or 0 if any error occurred.
set_stage_axis_info(min:float, max:float, units:int, pitch:float)

Usage as a stand-alone GUI interface

The installation sets up an entry point for the GUI. Just typing

pyThorlabsAPT

in the command prompt will start the GUI.

Embed the GUI within another GUI

The GUI controller can also be easily integrated within a larger graphical interface, as shown in the [TO DO]

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

pyThorlabsAPT-0.11.tar.gz (186.8 kB view details)

Uploaded Source

Built Distribution

pyThorlabsAPT-0.11-py3-none-any.whl (186.5 kB view details)

Uploaded Python 3

File details

Details for the file pyThorlabsAPT-0.11.tar.gz.

File metadata

  • Download URL: pyThorlabsAPT-0.11.tar.gz
  • Upload date:
  • Size: 186.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pyThorlabsAPT-0.11.tar.gz
Algorithm Hash digest
SHA256 afca7503f43fe0221cbfad9228583e76c0db7875994e8efadafceaf7a61844d9
MD5 b4dcda272c8bbd77ee2ee7c30bbc85c6
BLAKE2b-256 87904f28bcc71f1f3d21e0ddd5be70ffb6c8e004ed2123b51e6a7c38b54f0519

See more details on using hashes here.

File details

Details for the file pyThorlabsAPT-0.11-py3-none-any.whl.

File metadata

  • Download URL: pyThorlabsAPT-0.11-py3-none-any.whl
  • Upload date:
  • Size: 186.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for pyThorlabsAPT-0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 70bf302e4db4ffef452900801b28a661afd854b14522d1818682395c33387f67
MD5 8dad9dfa5f816a556df1e0f1c40c1dda
BLAKE2b-256 240b059445cbcc783cab17915ddd0ca411240a3e2412f55f186000af39b2553b

See more details on using hashes here.

Supported by

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