Skip to content

COO-Utilities/thorlabs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

from ppc102 import Ppc102Controller

Thorlabs_controllers

Low-level Python modules to send commands to Thorlabs motion controllers.

Currently Supported Models

  • FW102C - fw102c.py
  • PPC102 - ppc102.py

Features

  • Connect to Thorlabs controllers over serial through a terminal server
  • Query state and parameters
  • Move individual axes to absolute or relative positions

Usage

FW102C Example

from hispec.util import fw102c

controller = fw102c.FilterWheelController()
controller.set_connection(ip='192.168.29.100', port=10010)
controller.connect()

# Print filter wheel current position
print(controller.get_pos())

# Move filter wheel to filter 5
controller.move(5)

# For a comprehensive list of classes and methods, use the help function
help(fw102c)

PPC102 Example

    from hispec.util.thorlabs.ppc102 import PPC102_Coms

# log = false will now print to command line
dev = Ppc102Controller(ip="", port="", log=False)

# Open connection
dev.open()

# set voltage on channel 1 and get result (open loop control)
dev.set_output_volts(channel=1, volts=100)
res = dev.get_output_volts(channel=1)

# switch channels to closed loop
dev.set_loop(channel=1, loop=2)
dev.set_loop(channel=2, loop=2)

# set positions on channel 1 or 2 and get result
dev.set_pos(channel=1, pos=5.0)
dev.set_pos(channel=2, pos=-5.0)
cur_pos1 = dev.get_pos(channel=1)
cur_pos2 = dev.get_pos(channel=2)

# switch channels to open loop
dev.set_loop(channel=1, loop=1)
dev.set_loop(channel=2, loop=1)

# Set voltages to zero
dev.set_output_volts(channel=1, volts=0)
dev.set_output_volts(channel=2, volts=0)

# close socket connection
dev.disconnect()

🧪 Testing

Unit tests are located in tests/ directory.

TODO: Make "Mock test" for PPC102 get_pos and get_status which threw errors and was removed. Assumed to be due to the byte and int convertion

To run tests from the project root based on what you need: Software check:

pytest -m unit

Connection Test:

pytest -m default

Functionality Test:

pytest -m functional

About

Low-level Python modules to send commands to Thorlabs motion controllers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages