Giter Site home page Giter Site logo

alexshkarin / pylablib Goto Github PK

View Code? Open in Web Editor NEW
121.0 8.0 28.0 2.75 MB

Python package for device control and experiment automation

Home Page: http://pylablib.readthedocs.io

License: GNU General Public License v3.0

Python 99.77% Cython 0.23%
automation experiment instrument instrument-control laboratory

pylablib's People

Contributors

alexshkarin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pylablib's Issues

Device not opened error using M30X stage

Hi,

I am using PyLabLib to control my M30X stage but run into an error when setting up the stage. The error says the "Device Not Opened".

pylablib.devices.Thorlabs.base.ThorlabsBackendError: backend exception: D2XXException(3) ('Device Not Opened')

Also, the list is empty when I look for my device using Thorlabs.list_kinesis_devices().

It looks like PyLabLib can detect the device when I do the following:

dev=Thorlabs.BasicKinesisDevice(sernumber)
dev.blink()
dev.get_device_info()

TDeviceInfo(serial_no=sernumber, model_no='M30X\x00XY', fw_ver='1.0.1', hw_type=3, hw_ver=1, mod_state=0, nchannels=1, notes='M30X/M30XY')

pylablib.devices.IMAQ.IMAQ.IMAQCamera: read_trigger method is not asserting when external trigger is pressed

Hi!

I am working on a script which grabs frames from a c-arm camera using a PCIe-1433 frame grabber. The frames must be grabbed when a pedal is pressed down; pressing and holding the pedal results in a repeated rising voltage edge at a consistent rate until the pedal is no longer pressed. In other words, the frame grabber must be synchronized with the camera capture. I also have a working LabView block diagram which provides me the correct trigger parameters, so I know my configure_trigger_in method is set up correctly.

The issue that I keep coming up against is that the read_trigger method is not asserting when I press down the external trigger pedal. I want to make 100% sure that I am correctly setting up my trigger line code, so I can turn my attention to the hardware itself if necessary.

Here is a script which first opens the frame grabber connected to the camera, then configures the input trigger, then continuously reads the trigger line for a rising edge. When there is a rising edge, it prints "asserted". I have also set up a timer which cancels the while loop after 30 seconds.

from pylablib.devices import IMAQ
import time

# identify frame grabber
cam = IMAQ.IMAQCamera('FPD::0')

# configure trigger in with corretc parameters
cam.configure_trigger_in('ext', trig_line=0, trig_pol='high', trig_action='buffer', timeout=1000.0)

# set 30 sec timer for while loop
timeout = time.time() + 30

# while loop continuously reads trigger line
while True:
    
    # checks trigger line value: 
        # if 0, then unasserted -> continue
        # if not 0, then asserted -> print "asserted" then continue
    while cam.read_trigger('ext', trig_line=0, trig_pol='high') == 0:
        
        # checks timer
        if time.time() > timeout:
            print('timeout')
            break
    
    else:
        print('asserted')
        
        # checks timer
        if time.time() > timeout:
            print('timeout')
            break
        
        continue
    
    break

cam.close()

A successful read_trigger line would print multiple "asserted" whenever the external trigger pedal is pressed. However, I get no "asserted" for the entire 30 sec timer when I am pressing the pedal.

Is there something wrong with my script's trigger setup?

IMAQCamera.setup_acquisition() costs very long execuation time

Hi,

Thanks for your contributions to the awsome project. I find it very useful to acquire high throughoutput video via the IMAQ wrapper.

The library works well though I found a minor issue when initilizing the camera interface. It take much longer time than the native application such as the NI-MAX.

With the help of breakpoints, I located the line self._max_nbuff=self._find_max_nbuff() of the method def setup_acquisition(self, mode="sequence", nframes=100) in IMAQ.py, which might cause the issue. With hard-coded self._max_nbuff=5000 instead, the script runs much more smooth.

Notes: My setup is NI PCIe-1433 frame grabber combined with a GL2048R InGaAs line camera. And I use cam0.setup_acquisition(mode="sequence", nframes=100) to initilize the camera.

Some data retrieving functions of AndorSDK2Lib return error

Hello,

I am trying to retrieve acquired data from an Andor camera with the wrapped GetMostRecentImage, GetImage or GetAcquired data from Andor library and facing the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1, in <lambda>
    func_args=self._prepare_arguments(argnames,prep_argtypes,kwargs,argprep)
  File "...\lib\site-packages\pylablib\core\utils\ctypes_wrap.py", line 163, in _prepare_arguments
    v=functions.call_cut_args(p,**kwargs) if hasattr(p,"__call__") else p
  File "...\lib\site-packages\pylablib\core\utils\functions.py", line 309, in call_cut_args
    return func(*args,**cut_kwargs)
  File "...\lib\site-packages\pylablib\core\utils\ctypes_wrap.py", line 324, in prep
    n=args[size_arg_pos]
IndexError: tuple index out of range

For these functions a size argument is required, which is the dimensions of the camera chip. I am getting these readings as pylablib.devices.Andor.AndorSDK2.lib.GetDetector() and the output is a turple of length 2 representing size in pixels. For example, size = (1024, 1024). Then I feed it to the pylablib.devices.Andor.AndorSDK2.lib.GetMostRecentImage(size). Here is a little snippet I wrote to reproduce:

Reproduce:

from pylablib.devices import Andor
lib = Andor.AndorSDK2.lib
cam = Andor.AndorSDK2Camera(0)
cam.open()

cam.set_temperature(-85, enable_cooler=False)
cam.set_fan_mode("full")
cam.set_cooler(True)
cam.set_acquisition_mode("single")
cam.set_read_mode("fvb")
cam.set_exposure(1)
gridsize = lib.GetDetector()

if cam.get_read_mode() == "fvb":
            size = gridsize[0]
elif cam.get_read_mode() == "image":
            size =  gridsize[0] *  gridsize[1]

cam.start_acquisition()
lib.WaitForAcquisition()
lib.GetMostRecentImage(size)
cam.stop_acquisition()
cam.close()

Next Release Date?

Dear Alex,

Hope you are doing great!

I just wanted to ask if you have a planned release date for the next update of the library. I am working on a camera plugin for pymodaq (https://github.com/CEMES-CNRS/PyMoDAQ) and if that's not too far away in the future I will postpone the release to avoid putting the dev branch in the setup.py (it's about that princeton instrument camera buffer fix).

Thank you very much in advance,

take care

Nico

Thorlabs.list_kinesis_devices() returns an empty list - macOS

I'm trying to connect to a KDC101 thorlabs controller from macOS.
I have been able to work my way around some ft232 issues I had prior to this, but I am currently stuck at an empty list when performing Thorlabs.list_kinesis_devices() :
`from pylablib.devices import Thorlabs

listdevices = Thorlabs.list_kinesis_devices()
print(listdevices)`
for which the output, without errors, is:
[ ]

I am fairly new at this, so i have a couple of theories that may be wrong.
First one; my macOS version is 13.x.x (ventura) for which I couldnt find the VCP drivers (only for macos 11/12, which i installed in case the 'version' field was outdated). This might be the problem?
Second one; Obviously, I have not installed any Thorlabs supplied DLLs. However, seeing these are not available for linux users and they seem to not be having issues, I don't think this is creating the problem.
Third one; Does pyLabLib not work on macOS? I cannot find any posts or information on its compatibility with it. Should i start thinking of getting a windows virtual machine or linux? I would rather avoid that if possible...

Any help or tips would be very much appreciated.

ThorLabs KLD101 support

I am setting up an experiment using the KLD101 laser diode driver.

This library doesn't appear to support this device yet, but supports several other "Kinesis" devices. Please let me know if that is not correct.

If it isn't supported, I plan to spend some time adding this laser driver.

Could anyone familiar with this code base give me a ballpark of the effort required to support this device?

Kinesis Piezo Motor Channel 3 not Working

Hi,
The channel 3 with a KIM101 Piezo Controller is not working properly as it switched automaticlly to channel 4.

In the following example the channel 3 is enabled correctly at the KIM101. However, the channel is not moving and the "move_by" function seems to have no effect.

from pylablib.devices import Thorlabs
stage = Thorlabs.KinesisPiezoMotor("XXXXXXXX")

stage.enable_channels((3,))
print(stage.get_enabled_channels())
stage.move_by(1000, auto_enable=False, channel=3)

stage.close()

When "auto_enable" is True, the channel 3 will be enable in the line above for a short moment (also at the device), but the "move_by" function switches to channel 4 and channel 4 is moving instead.

from pylablib.devices import Thorlabs
stage = Thorlabs.KinesisPiezoMotor("XXXXXXXX")

stage.enable_channels((3,))
print(stage.get_enabled_channels())
stage.move_by(1000, channel=3)

stage.close()

I had a quick look at the implementation, however I think the problem is in some Hex commands sent to the KIM101 but I am not sure.

All the other channels work properly, just channel 3 switched automaticlly to channel 4 every time.

Princeton Instruments PICam library Windows Error

Hi,
I am trying to setup pyLabLib to work with a PIXIS 100F, with PiCam installed on the PC.
I have tried using the example code from https://pylablib.readthedocs.io/en/stable/devices/Picam.html, but it fails if I try to list devices or connect to the camera (terminal below).
I have tried setting pll.par["devices/dlls/picam"] (even though PiCam is in the default install directory C:\Program Files\Princeton Instruments\PICam\Runtime) but there is no difference.
Any ideas what could be causing the problem?
Thanks!
image

KIM101

Hi,
from a Linux environment I'm trying to connect to a KIM101 but
In [1]: from pylablib.devices import Thorlabs
In [2]: Thorlabs.list_kinesis_devices()

results in
Segmentation fault (core dumped)

while
In [1]: from pylablib.devices import Thorlabs
In [2]: x = Thorlabs.KinesisPiezoMotor("XXXXXXXX")
in a LibFtdiException

I've seen from another bug (#27 ) another user is able to use a KIM101, but I didn't want to "pollute" the discussion.

Any suggestion on how to move forward?

Thorlabs UC480 Camera snap/grab image sizes

Hi, I'm using a throlabs UC480 Camera but am struggling to get the right sized image from the grab/snap functions. The camera is 1024x1280 pixels but the data is returned as 1280x3. Using the _read_buffer() function appears to return the full data:

image

image

image

Is there any way to get the 1024x1280 image from grab/snap or do you know the file those functions are taken from as i can't seem to find it?

ANDOR iVac connection problem

Hello!

Thank you for creating this package! I started using the pyLabLib to control my ANDOR iVac 316 detector few days ago, and had successfully acquired signals with the acquisition settings I input. However, after a while on the same day, the spectrometer returned an array of zeros when I run the exact same code. Therefore, I switch back to using the ANDOR Solis software to check if the spectrometer is responding or not. When I was using the software by ANDOR, the connection between the software and the device was fine, the cooling function worked, except it kept returning an array of zeros no matter what settings I made. I also tried to call the device through LABVIEW (which had worked previously), but it also had the same problem despite the connection was fine. This problem persists ever since I run the following few codes:

from pylablib.devices import Andor
import pylablib as pll
pll.par["devices/dlls/andor_sdk2"] = "D:/Andor SDK"
Andor.get_cameras_number_SDK2()
cam = Andor.AndorSDK2.AndorSDK2Camera()
cam.set_read_mode("fvb")
cam.set_exposure(0.1) # set exposure to 100ms
cam.start_acquisition()
frame = cam.snap()
cam.stop_acquisition()
cam.close()

Restarting the computer or reinstalling the SDK (version 2.103.30022.0) doesn't work. At this point I am wondering if it is because I used the function incorrectly, causing the hardware to malfunction or not responding anymore. But since it returns a array of zeros, I don't think the sensors inside the spectrometer are damaged, it is more like the shutter is closed and no light is detected. Have you encountered any situation like this? Would be grateful if you could look into this issue for me, thanks!

BSC 201 Stepper Motor Controller control using send_comm functions

Hello,

I have recently started using pylablib and it's been great so far with motor controller stages. I recently tried to use with a BSC 201 - Single Channel Stepper Motor Controller and I had some questions regarding some issues I am facing.

I was only able to connect this controller using the Thorlabs.BasicKinesisDevice("Serial Number") command. For Generic kinesis devices connected, the only way to control them and change parameters seems to be through the send_comm and send_comm functions listed below based on message ID's from the APT communication protocol as they don't have specific functions compared to other classes within the module. Please let me know if I'm wrong about this.

image

I have the APT communications protocol with the list of the messages for specific functions on the device. However no action is taken when I input the message ID, I also don't get any error output from the code.

I have an example below to home the connected device;

FROM APT COMM PROT:

image

I tried implement the message above;

Case 1: I did a conversion to hex

image

Case 2: I did not convert to hex

image

Both times, there was still no action performed by the stage. Please let me know if there is any other step I need to be taking to enable functions on the connected stage. From the APT communications protocol, Message ID seems to be byte 0 and byte 1. I wonder if I should be splitting this up somehow?

Thanks so much for putting this together and looking forward to your response.

Regards,
Manny

Arcus Stepper Motors - "single axis stage" for stepper motors

Hi, thank you very much for creating this package!

I was wondering if you are planning to add functionality to connect Arcus stepper motors since the current code only seems to include 2-axis and 4-axis. I was not able to connect DMX-J-SA-17 using GenericPerformaxStage, Performax4EXStage nor Performax2EXStage. Maybe I am using it wrong? I use 64 bit dll from their website and the following:

import pylablib as pll

pll.par["devices/dlls/arcus_performax"] = "C:/simplifiedPath/PerformaxCom.dll"

from pylablib.devices import Arcus

print(Arcus.list_usb_performax_devices())

stage = Arcus.GenericPerformaxStage() # this alternated with the other 2

What I see as return is: [(0, 'jsa00', 'Performax USB', '\\\\?\\usb#vid_1589&pid_a101#jsa00#{3c5e1462-5695-4e18-876b-f3f3d08aaf18}', '1589', 'a101')]

and then:
Traceback (most recent call last): File "c:\simplifiedPath\DMXcontrolTest.py", line 15, in <module> stage = Arcus.Performax4EXStage() File "C:\simplifiedPath\Python39\site-packages\pylablib\devices\Arcus\performax.py", line 119, in __init__ super().__init__(idx=idx) File "C:\simplifiedPath\Python39\site-packages\pylablib\devices\Arcus\performax.py", line 50, in __init__ self.open() File "C:\simplifiedPath\Python39\site-packages\pylablib\devices\Arcus\performax.py", line 68, in open raise ArcusError("can't connect to the stage with index {}".format(self.idx)) pylablib.devices.Arcus.ArcusPerformaxDriver_lib.ArcusError: can't connect to the stage with index 0

I may be using it wrong, but I would welcome to learn how to do it right please!

KDC 101 Error Backend exception: D2XXException(3) ('Device Not Opened')

Hello,

Firstly, thanks a lot for the great work done on this. Stumbled across it while trying to automate certain thorlabs stages and I believe it will be very useful.

I am running into issues with connecting the stage. I am able to detect the controller (KDC101 - Brushed Motor Controller) that is connected.

image

However, when I connect to the stage, I get the following error

image

image

Please any insights into why I am getting this error will be appreciated.

plotting of data

Hi Alex,

first of all, very impressive work on pylablib! I just discovered it and the communication with instruments is very easy to use. I am currently using matlab in my lab but am running into slow GUIs and other difficulties and would like to switch to a python-based measurement framework. I had a look at qcodes too, but it seems the driver database of pylablib is really great. I got the NiDAQ card running and Andor camera running in no time.

I was hoping you could tell me if you have included functionality for live plotting of data. For instance, I would like to see the counts gathered by a NiDAQ card plotted in a live graph inside a gui that can also be used to set measurement parameters. Do you have any pointers on how to start this?

IMAQdx grabbing only partial image

I am using pylablib.devices.IMAQdx and am experiencing an issue with the raw image frames. Both snap() and grab() seem to only capture a portion of the image. I've attached examples taken using NI MAX (software_image.png) and the IMAQdx library (imaqdx_image.png) for comparison. I have tried four different cameras including the webcam, but they all have the issue. I have also examined the raw image frame and have confirmed that every 4th entry is zero (pixel format of BGRA). This confuses me though because the size of the image array should be WxHx4 instead of WxHx3. Below I have the simple script I am using to examine the raw frame...

from pylablib.devices.IMAQdx import IMAQdx

# Open Camera
device = IMAQdx.IMAQdxCamera("cam5")

# Send settings
device.enable_raw_readout("frame")  # camera format: RGBA 8 Packed
device.set_attribute_value("AcquisitionAttributes/VideoMode", "1920x1520 MJPG 30.00fps")
device.set_attribute_value("CameraAttributes/Exposure/Value", 150000)

# Get image
pic = device.snap()  # value: array([66, 101, 102, 0, 66, 101, 102, 0, ..., 75, 108, 111, 0], dtype=uint8)
pic_size = pic.size  # value: 8755200 (which is 1920*1520*3)

# Close camera
device.close()

Please let me know if you are aware of any solution to this, I have been struggling for two weeks now. Thank you in advance!

Specs:
Windows 10 64-bit
Python 3.10 (also tried with 3.6)
pylablib v1.4.1 (also tried all other available versions)
LabVIEW 2021 with Vision Assistant, MAX, IMAQ, IMAQdx, IMAQ IO

From NI MAX:
software_image
From pylablib.IMAQdx:
imaqdx_image

connect Andor Ultra888 with pylablib on Jupyter notebook

I try to use jupyter notebook to connect pylablib with andor camera and change path where my andor solis located. but it still runs likes this
image
what wrong with it? However,I‘d like to know what‘s means of
cb55a35edd0c35384947e419b7e2b78
because I find the example which path is Andor soli but not Andor SDK3. did it just mean where the dlls of sdk3 located ?
’’thanks

A note for Basler Pylon_C_vX_Y.dll library (for documentation)

On the documentation page for Basler, there is a mention of the path to Pylon_C_vX_Y.dll (currently Pylon_C_v7_4.dll). I initially could not find this library in my local installation path. I eventually found out that this library is NOT installed when installing the "camera user" version of the suite. One should use the "developer" or "custom" version to include this library in the installation (this option is prompted when using installation wizard but it doesn't explain what the difference is). I don't know if this is worth including in the actual documentations but I thought I'd leave a note in case someone else runs into the same confusion.

Can't list devices because FT232DeviceBackend won't load correctly

I have pyft232 installed automatically as a dependency of pylablib, and when I'm just trying to list connected Thorlabs Kinesis devices, I get this error.

Traceback (most recent call last):
  File "/home/liam/Documents/GitHub/shg-polarization-scan/main.py", line 118, in <module>
    print(pylablib.devices.Thorlabs.list_kinesis_devices())
  File "/home/liam/user_python/lib/python3.10/site-packages/pylablib/devices/Thorlabs/kinesis.py", line 26, in list_kinesis_devices
    return KinesisDevice.list_devices(filter_ids=filter_ids)
  File "/home/liam/user_python/lib/python3.10/site-packages/pylablib/devices/Thorlabs/kinesis.py", line 101, in list_devices
    dids=comm_backend.FT232DeviceBackend.list_resources(desc=True)
AttributeError: module 'pylablib.core.devio.comm_backend' has no attribute 'FT232DeviceBackend'. Did you mean: 'PyUSBDeviceBackend'?

Exposure time in Basler camera broken

exp=self.get_attribute_value("ExposureTimeAbs",error_on_missing=False)

Getting setting exposure time does not work.
My camera has a "ExposureTime" attribute but not "ExposureTimeAbs", as the get all config shows.

If I remove the "Abs", I can get / set the exposure time.

Cameras are Basler Dart daA1280-54um and daA2500-14um

Newport Module not detecting picomotors

I have the Newport picomotor controller 8742 connected to the computer using a USB port. I am trying to run this simple 2 line code, but its output is 0, instead of 2 (I have 2 picomotors connected to the controller).

from pylablib.devices import Newport
print(Newport.get_usb_devices_number_picomotor())

Can someone please help me find why this code is not detecting the picomotors? Thanks.

BSC 203 - Detected, but unable to communicate

I know pyLabLib wasn't tested on the Thorlabs BSC 203, but when I can see it when I ask for a list of Thorlabs APT devices. However, whenever I try to communicate with it I get an error, stating that it sent less information than was expected. The thorlabs_apt_device 0.3.4 package recommends enabling virtual comm ports, but I don't know if that would be the case for pyLabLib.

I noticed in kinesis.py that the program should recognize a serial number starting in 70 as a BSC.03, but couldn't find specific code related to that... In any case it does correctly identify the serial number of my device, so it is getting some sort of communication through.

Has anyone experienced this sort of issue? I would be happy to (try to) contribute with BSC 203 support, and pointers on where to start and what to adapt would be greatly appreciated.

CS126CU camera operation

Hi Alex,

first of all, great job on pylablib, found it really straightforward to use and it brings all the functionality I need.

I am successfully operating a Thorlabs motorized translation stage and a DCC1545M camera using pylablib. However I have some issues using a more recent CS126CU Kiralux camera. I am able to connect to the camera with pylablib and change the settings (exposure, ROI, etc.). But as soon as I start image acquisition (e.g. cam.snap, cam.start_acquisition) I get the following error -> see appended image.

color_cam_error

I also tried running the cam-control software with the same result. Do you have any idea how to resolve this error?

IMAQ timeout error

Hi,

I discovered a units conversion issue when calling a function multiple times in the IMAQ.py library.

In IMAQFrameGrabber.configure_trigger_in, the timeout input is converted from seconds to milliseconds (Line 272) which is then stored in self.triggers_in.

When IMAQFrameGrabber.setup_acquisition is called, it calls IMAQFrameGrabber._set_triggers_in_cfg (Line 463). This uses the values stored in self.triggers_in as inputs into IMAQFrameGrabber.configure_trigger_in including the timeout (in ms) even though the function expects the input to be in seconds. Each time IMAQFrameGrabber.setup_acquisition is called the stored timeout is increased by a factor of 1000 because of the seconds to milliseconds conversion.

Best,
Kelly.

Add software trigger support for pvcam

For my application it would be nice to support send_software_trigger() for the pvcam, just like some of the other cameras already do.

So:

camera = PhotoMetrics.PvcamCamera()
self.cam.set_trigger_mode('e_soft_edge')
self.cam.start_acquisition()
# fire software trigger
self.cam.send_software_trigger() # <-- this is not implemented yet, will do so
self.cam.read_newest_image()

I figured out how to implement it and I'll file a pull request early next week.

BUG: Cannot create Thorlabs.KinesisMotor from a serial number

Cannot connect to a Thorlabs KST101 motor controller. pylablib.devices.Thorlabs.list_kinesis_devices() detects a correct serial number, but creation an instance of pylablib.devices.Thorlabs.KinesisMotor(sernumber) crashes with ThorlabsBackendError: backend exception: 'read returned less data than expected'.

Minimal example to reproduce:

from pylablib.devices import Thorlabs

devices = Thorlabs.list_kinesis_devices()
sernumber = devices[0][0]
print(sernumber)

Thorlabs.KinesisMotor(sernumber)
Output
26000280
---------------------------------------------------------------------------
ThorlabsBackendError                      Traceback (most recent call last)
[c:\Users\Username\Documents\prog\packagename\packagename\temp\thorlabs-stage-dev.py](file:///C:/Users/Username/Documents/prog/packagename/packagename/temp/thorlabs-stage-dev.py) in line 8
      [5](file:///c%3A/Users/Username/Documents/prog/packagename/packagename/temp/thorlabs-stage-dev.py?line=4) sernumber = devices[0][0]
      [6](file:///c%3A/Users/Username/Documents/prog/packagename/packagename/temp/thorlabs-stage-dev.py?line=5) print(sernumber)
----> [8](file:///c%3A/Users/Username/Documents/prog/packagename/packagename/temp/thorlabs-stage-dev.py?line=7) Thorlabs.KinesisMotor(sernumber)

File [c:\Users\Username\mambaforge\envs\envname\Lib\site-packages\pylablib\devices\Thorlabs\kinesis.py:1031](file:///C:/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py:1031), in KinesisMotor.__init__(self, conn, scale, default_channel, is_rack_system)
   [1029](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=1028) self._add_settings_variable("limit_switch_parameters",self.get_limit_switch_parameters,self.setup_limit_switch)
   [1030](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=1029) with self._close_on_error():
-> [1031](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=1030)     self._stage=self._get_stage(scale)
   [1032](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=1031)     self._scale,self._scale_units=self._calculate_scale(scale)
   [1033](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=1032) if self.get_device_info().model_no in ["KDC101","KST101","KBD101"]:

File [c:\Users\Username\mambaforge\envs\envname\Lib\site-packages\pylablib\devices\Thorlabs\kinesis.py:1048](file:///C:/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py:1048), in KinesisMotor._get_stage(self, scale)
   [1047](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=1046) def _get_stage(self, scale):
-> [1048](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=1047)     model=self.get_device_info().model_no
   [1049](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=1048)     if scale=="stage":
   [1050](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=1049)         return self._autodetect_stage(model)

File [c:\Users\Username\mambaforge\envs\envname\Lib\site-packages\pylablib\devices\Thorlabs\kinesis.py:201](file:///C:/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py:201), in BasicKinesisDevice.get_device_info(self, dest)
    [195](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=194) def get_device_info(self, dest="host"):
    [196](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=195)     """
    [197](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=196)     Get device info.
    [198](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/devices/Thorlabs/kinesis.py?line=197) 
...
--> [922](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/core/devio/comm_backend.py?line=921)         raise self.Error("read returned less data than expected")
    [923](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/core/devio/comm_backend.py?line=922) self.cooldown("read")
    [924](file:///c%3A/Users/Username/mambaforge/envs/envname/Lib/site-packages/pylablib/core/devio/comm_backend.py?line=923) self._log("read",result)

ThorlabsBackendError: backend exception: 'read returned less data than expected' ('read returned less data than expected')

Thorlabs KST101 connected to USB3 port via Micro Type B cable
OS: Windows 10
Python: 3.10.12, 3.11.3
Pylablib: 1.4.1
pyft232: 0.12

Full environment
# Name                    Version                   Build  Channel
appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
asciitree                 0.3.3                      py_2    conda-forge
astropy                   5.3             py311h59ca53f_0    conda-forge
asttokens                 2.2.1              pyhd8ed1ab_0    conda-forge
async_generator           1.10                       py_0    conda-forge
attrs                     23.1.0             pyh71513ae_1    conda-forge
aws-c-auth                0.6.28               habb20d3_5    conda-forge
aws-c-cal                 0.5.27               hc655790_0    conda-forge
aws-c-common              0.8.20               hcfcfb64_0    conda-forge
aws-c-compression         0.2.17               h0a579c1_0    conda-forge
aws-c-event-stream        0.3.0                h92d84d2_6    conda-forge
aws-c-http                0.7.8                haeac8d2_4    conda-forge
aws-c-io                  0.13.26              hf956cbd_0    conda-forge
aws-c-mqtt                0.8.13               h73587ab_2    conda-forge
aws-c-s3                  0.3.4                h26b4012_5    conda-forge
aws-c-sdkutils            0.1.10               h0a579c1_0    conda-forge
aws-checksums             0.1.16               h0a579c1_0    conda-forge
aws-crt-cpp               0.20.2               h0db1998_9    conda-forge
aws-sdk-cpp               1.10.57             ha442f66_14    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                pyhd8ed1ab_3    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
baselineremoval           0.1.4                    pypi_0    pypi
bcrypt                    3.2.2           py311ha68e1ae_1    conda-forge
blas                      2.117                       mkl    conda-forge
blas-devel                3.9.0              17_win64_mkl    conda-forge
bleach                    6.0.0              pyhd8ed1ab_0    conda-forge
blosc2                    2.0.0                    pypi_0    pypi
bokeh                     3.1.1              pyhd8ed1ab_0    conda-forge
bottleneck                1.3.7           py311h59ca53f_0    conda-forge
bqplot                    0.12.39            pyhd8ed1ab_0    conda-forge
brotli                    1.0.9                hcfcfb64_8    conda-forge
brotli-bin                1.0.9                hcfcfb64_8    conda-forge
bzip2                     1.0.8                h8ffe710_4    conda-forge
c-ares                    1.19.1               hcfcfb64_0    conda-forge
ca-certificates           2023.5.7             h56e8100_0    conda-forge
cached-property           1.5.2                hd8ed1ab_1    conda-forge
cached_property           1.5.2              pyha770c72_1    conda-forge
caproto                   1.1.0              pyhd8ed1ab_0    conda-forge
certifi                   2023.5.7           pyhd8ed1ab_0    conda-forge
cffi                      1.15.1          py311h7d9ee11_3    conda-forge
cftime                    1.6.2           py311h59ca53f_1    conda-forge
chardet                   5.1.0                    pypi_0    pypi
charset-normalizer        3.1.0              pyhd8ed1ab_0    conda-forge
click                     8.1.3           win_pyhd8ed1ab_2    conda-forge
cloudpickle               2.2.1              pyhd8ed1ab_0    conda-forge
clr_loader                0.2.5              pyhd8ed1ab_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
comm                      0.1.3              pyhd8ed1ab_0    conda-forge
comtypes                  1.2.0           py311h1ea47a8_0    conda-forge
contourpy                 1.1.0           py311h005e61a_0    conda-forge
cpuonly                   2.0                           0    pytorch
cryptography              41.0.1          py311h28e9c30_0    conda-forge
curio                     1.4                        py_0    conda-forge
curl                      8.1.2                h68f0423_0    conda-forge
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
cython                    0.29.35                  pypi_0    pypi
cytoolz                   0.12.0          py311ha68e1ae_1    conda-forge
dask                      2023.6.0           pyhd8ed1ab_0    conda-forge
dask-core                 2023.6.0           pyhd8ed1ab_0    conda-forge
dataproperty              0.55.1                   pypi_0    pypi
debugpy                   1.6.7           py311h12c1d0e_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
deprecation               2.1.0              pyh9f0ad1d_0    conda-forge
distlib                   0.3.6                    pypi_0    pypi
distributed               2023.6.0           pyhd8ed1ab_0    conda-forge
docutils                  0.17.1                   pypi_0    pypi
dpkt                      1.9.8              pyhd8ed1ab_0    conda-forge
easydict                  1.10                     pypi_0    pypi
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
epics-base                7.0.7.0              h63175ca_0    conda-forge
exceptiongroup            1.1.1              pyhd8ed1ab_0    conda-forge
executing                 1.2.0              pyhd8ed1ab_0    conda-forge
farama-notifications      0.0.4              pyhd8ed1ab_0    conda-forge
fasteners                 0.17.3             pyhd8ed1ab_0    conda-forge
filelock                  3.12.2             pyhd8ed1ab_0    conda-forge
fonttools                 4.40.0          py311ha68e1ae_0    conda-forge
freetype                  2.12.1               h546665d_1    conda-forge
fsspec                    2023.6.0           pyh1a96a4e_0    conda-forge
gettext                   0.21.1               h5728263_0    conda-forge
gflags                    2.2.2             ha925a31_1004    conda-forge
glib                      2.76.3               h12be248_0    conda-forge
glib-tools                2.76.3               h12be248_0    conda-forge
glog                      0.6.0                h4797de2_0    conda-forge
gst-plugins-base          1.22.4               h001b923_0    conda-forge
gstreamer                 1.22.4               hb4038d2_0    conda-forge
gymnasium                 0.28.1          py311h3810d55_0    conda-forge
h5netcdf                  1.2.0              pyhd8ed1ab_0    conda-forge
h5py                      3.8.0           nompi_py311h3a26632_100    conda-forge
hdf4                      4.2.15               h1b1b6ef_5    conda-forge
hdf5                      1.12.2          nompi_h57737ce_101    conda-forge
icu                       70.1                 h0e60522_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
importlib-metadata        6.7.0              pyha770c72_0    conda-forge
importlib_metadata        6.7.0                hd8ed1ab_0    conda-forge
iniconfig                 2.0.0              pyhd8ed1ab_0    conda-forge
intake                    0.7.0              pyhd8ed1ab_0    conda-forge
intake-xarray             0.7.0              pyhd8ed1ab_0    conda-forge
intel-openmp              2023.1.0         h57928b3_46319    conda-forge
ipykernel                 6.23.3             pyh6817e22_0    conda-forge
ipython                   8.14.0             pyh08f2357_0    conda-forge
ipython-genutils          0.2.0                    pypi_0    pypi
ipywidgets                8.0.6              pyhd8ed1ab_0    conda-forge
jax-jumpy                 1.0.0              pyhd8ed1ab_0    conda-forge
jedi                      0.18.2             pyhd8ed1ab_0    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
joblib                    1.2.0              pyhd8ed1ab_0    conda-forge
jpeg                      9e                   hcfcfb64_3    conda-forge
jsonschema                4.17.3                   pypi_0    pypi
jupyter_client            8.3.0              pyhd8ed1ab_0    conda-forge
jupyter_core              5.3.1           py311h1ea47a8_0    conda-forge
jupyterlab_widgets        3.0.7              pyhd8ed1ab_1    conda-forge
kiwisolver                1.4.4           py311h005e61a_1    conda-forge
krb5                      1.20.1               heb0366b_0    conda-forge
lcms2                     2.15                 ha5c8aab_0    conda-forge
lerc                      4.0.0                h63175ca_0    conda-forge
libabseil                 20230125.2      cxx17_h63175ca_2    conda-forge
libaec                    1.0.6                h63175ca_1    conda-forge
libarrow                  12.0.0           h5f84808_8_cpu    conda-forge
libblas                   3.9.0              17_win64_mkl    conda-forge
libbrotlicommon           1.0.9                hcfcfb64_8    conda-forge
libbrotlidec              1.0.9                hcfcfb64_8    conda-forge
libbrotlienc              1.0.9                hcfcfb64_8    conda-forge
libcblas                  3.9.0              17_win64_mkl    conda-forge
libclang                  15.0.7          default_h77d9078_2    conda-forge
libclang13                15.0.7          default_h77d9078_2    conda-forge
libcrc32c                 1.1.2                h0e60522_0    conda-forge
libcurl                   8.1.2                h68f0423_0    conda-forge
libdeflate                1.17                 hcfcfb64_0    conda-forge
libevent                  2.1.12               h3671451_1    conda-forge
libexpat                  2.5.0                h63175ca_1    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
libglib                   2.76.3               he8f3873_0    conda-forge
libgoogle-cloud           2.11.0               hec1a1f0_1    conda-forge
libgrpc                   1.55.1               h0c1e3fa_1    conda-forge
libhwloc                  2.9.1                hbb18f9a_1    conda-forge
libiconv                  1.17                 h8ffe710_0    conda-forge
liblapack                 3.9.0              17_win64_mkl    conda-forge
liblapacke                3.9.0              17_win64_mkl    conda-forge
libnetcdf                 4.9.1           nompi_hc41bf00_101    conda-forge
libogg                    1.3.4                h8ffe710_1    conda-forge
libpng                    1.6.39               h19919ed_0    conda-forge
libprotobuf               4.23.2               h1975477_5    conda-forge
libsodium                 1.0.18               h8d14728_1    conda-forge
libsqlite                 3.42.0               hcfcfb64_0    conda-forge
libssh2                   1.11.0               h7dfc565_0    conda-forge
libthrift                 0.18.1               h06f6336_2    conda-forge
libtiff                   4.5.0                hf8721a0_2    conda-forge
libusb                    1.0.26             h8ffe710_100    conda-forge
libutf8proc               2.8.0                h82a8f57_0    conda-forge
libuv                     1.44.2               h8ffe710_0    conda-forge
libvorbis                 1.3.7                h0e60522_0    conda-forge
libwebp-base              1.3.0                hcfcfb64_0    conda-forge
libxcb                    1.13              hcd874cb_1004    conda-forge
libxml2                   2.10.4               hc3477c8_0    conda-forge
libzip                    1.9.2                h519de47_1    conda-forge
libzlib                   1.2.13               hcfcfb64_5    conda-forge
linkify-it-py             2.0.0              pyhd8ed1ab_0    conda-forge
llvmlite                  0.40.0          py311h5bc0dda_0    conda-forge
locket                    1.0.0              pyhd8ed1ab_0    conda-forge
lxml                      4.9.2                    pypi_0    pypi
lz4                       4.3.2           py311haddf500_0    conda-forge
lz4-c                     1.9.4                hcfcfb64_0    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    conda-forge
m2w64-gcc-libs            5.3.0                         7    conda-forge
m2w64-gcc-libs-core       5.3.0                         7    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    conda-forge
markdown                  3.4.3              pyhd8ed1ab_0    conda-forge
markdown-it-py            2.2.0              pyhd8ed1ab_0    conda-forge
markupsafe                2.1.3           py311ha68e1ae_0    conda-forge
matplotlib-base           3.7.1           py311h6e989c2_0    conda-forge
matplotlib-inline         0.1.6              pyhd8ed1ab_0    conda-forge
mbstrdecoder              1.1.2                    pypi_0    pypi
mdit-py-plugins           0.4.0              pyhd8ed1ab_0    conda-forge
mdurl                     0.1.0              pyhd8ed1ab_0    conda-forge
mkl                       2022.1.0           h6a75c08_874    conda-forge
mkl-devel                 2022.1.0           h57928b3_875    conda-forge
mkl-include               2022.1.0           h6a75c08_874    conda-forge
mpmath                    1.3.0              pyhd8ed1ab_0    conda-forge
msgpack-python            1.0.5           py311h005e61a_0    conda-forge
msl-loadlib               0.9.0                    pypi_0    pypi
msys2-conda-epoch         20160418                      1    conda-forge
multipledispatch          0.6.0                    pypi_0    pypi
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
mypy                      1.4.0           py311ha68e1ae_0    conda-forge
mypy_extensions           1.0.0              pyha770c72_0    conda-forge
nest-asyncio              1.5.6              pyhd8ed1ab_0    conda-forge
netcdf4                   1.6.3           nompi_py311hd70422a_100    conda-forge
netifaces                 0.11.0          py311ha68e1ae_1    conda-forge
networkx                  3.1                pyhd8ed1ab_0    conda-forge
nidaqmx-python            0.7.0              pyhd8ed1ab_0    conda-forge
numba                     0.57.0          py311h2c0921f_2    conda-forge
numcodecs                 0.11.0          py311h12c1d0e_1    conda-forge
numexpr                   2.8.4                    pypi_0    pypi
numpy                     1.24.3          py311h0b4df5a_0    conda-forge
openjpeg                  2.5.0                ha2aaf27_2    conda-forge
openssl                   3.1.1                hcfcfb64_1    conda-forge
ophyd                     1.7.0              pyhd8ed1ab_0    conda-forge
orc                       1.8.4                h08d22ad_0    conda-forge
outcome                   1.2.0              pyhd8ed1ab_0    conda-forge
packaging                 23.1               pyhd8ed1ab_0    conda-forge
pandas                    2.0.2           py311hf63dbb6_0    conda-forge
panel                     1.1.1              pyhd8ed1ab_0    conda-forge
param                     1.13.0             pyh1a96a4e_0    conda-forge
paramiko                  3.2.0              pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
partd                     1.4.0              pyhd8ed1ab_0    conda-forge
pathvalidate              2.5.2                    pypi_0    pypi
patsy                     0.5.3              pyhd8ed1ab_0    conda-forge
pcre2                     10.40                h17e33f8_0    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    9.4.0           py311h76d9071_1    conda-forge
pint                      0.22               pyhd8ed1ab_1    conda-forge
pint-xarray               0.3                pyhd8ed1ab_0    conda-forge
pip                       23.1.2             pyhd8ed1ab_0    conda-forge
platformdirs              3.8.0              pyhd8ed1ab_0    conda-forge
pluggy                    1.0.0              pyhd8ed1ab_5    conda-forge
plumbum                   1.8.2              pyhd8ed1ab_0    conda-forge
ply                       3.11                       py_1    conda-forge
pooch                     1.7.0              pyha770c72_3    conda-forge
portion                   2.4.0              pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.38             pyha770c72_0    conda-forge
prompt_toolkit            3.0.38               hd8ed1ab_0    conda-forge
psutil                    5.9.5           py311ha68e1ae_0    conda-forge
pthread-stubs             0.4               hcd874cb_1001    conda-forge
pthreads-win32            2.9.1                hfa6e2cd_3    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
py-cpuinfo                9.0.0                    pypi_0    pypi
py4j                      0.10.9.7           pyhd8ed1ab_0    conda-forge
pyarrow                   12.0.0          py311h6a6099b_8_cpu    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pyepics                   3.5.0           py311h1ea47a8_3    conda-forge
pyerfa                    2.0.0.3         py311h59ca53f_0    conda-forge
pyft232                   0.12                     pypi_0    pypi
pygments                  2.15.1             pyhd8ed1ab_0    conda-forge
pylablib                  1.4.1              pyhd8ed1ab_0    conda-forge
pymeasure                 0.11.1             pyhd8ed1ab_0    conda-forge
pymodaq                   4.0.2                    pypi_0    pypi
pymodaq-plugin-manager    1.0.1                    pypi_0    pypi
pymodaq-plugins-mock      4.0.2                    pypi_0    pypi
pynacl                    1.5.0           py311hd53affc_2    conda-forge
pyparsing                 3.1.0              pyhd8ed1ab_0    conda-forge
pyqt                      5.15.7          py311h125bc19_3    conda-forge
pyqt5-sip                 12.11.0         py311h12c1d0e_3    conda-forge
pyqtgraph                 0.13.3             pyhd8ed1ab_0    conda-forge
pyrsistent                0.19.3                   pypi_0    pypi
pyserial                  3.5                pyhd8ed1ab_0    conda-forge
pysocks                   1.7.1              pyh0701188_6    conda-forge
pytablewriter             0.64.2                   pypi_0    pypi
pytest                    7.4.0              pyhd8ed1ab_0    conda-forge
python                    3.11.4          h2628c8c_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-tzdata             2023.3             pyhd8ed1ab_0    conda-forge
python_abi                3.11                    3_cp311    conda-forge
pythonnet                 3.0.1              pyhd8ed1ab_0    conda-forge
pytorch                   2.0.1              py3.11_cpu_0    pytorch
pytorch-mutex             1.0                         cpu    pytorch
pytz                      2023.3             pyhd8ed1ab_0    conda-forge
pyusb                     1.2.1              pyhd8ed1ab_0    conda-forge
pyvisa                    1.13.0          py311h1ea47a8_0    conda-forge
pyviz_comms               2.3.2              pyhd8ed1ab_0    conda-forge
pywin32                   304             py311h12c1d0e_2    conda-forge
pywin32-on-windows        0.1.0              pyh07e9846_2    conda-forge
pyyaml                    6.0             py311ha68e1ae_5    conda-forge
pyzmq                     25.1.0          py311h7b3f143_0    conda-forge
qdarkstyle                3.1                      pypi_0    pypi
qt-main                   5.15.8               h720456b_6    conda-forge
qtconsole                 5.4.3                    pypi_0    pypi
qtpy                      2.3.1                    pypi_0    pypi
re2                       2023.03.02           hd4eee63_0    conda-forge
readme-renderer           37.3                     pypi_0    pypi
requests                  2.31.0             pyhd8ed1ab_0    conda-forge
rpyc                      5.3.0              pyhd8ed1ab_0    conda-forge
scikit-learn              1.2.2           py311h142b183_2    conda-forge
scipy                     1.10.1          py311h37ff6ca_3    conda-forge
seaborn                   0.12.2               hd8ed1ab_0    conda-forge
seaborn-base              0.12.2             pyhd8ed1ab_0    conda-forge
setuptools                68.0.0             pyhd8ed1ab_0    conda-forge
simple-pid                2.0.0                    pypi_0    pypi
sip                       6.7.9           py311h12c1d0e_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
snappy                    1.1.10               hfb803bf_0    conda-forge
sniffio                   1.3.0              pyhd8ed1ab_0    conda-forge
sortedcontainers          2.4.0              pyhd8ed1ab_0    conda-forge
stack_data                0.6.2              pyhd8ed1ab_0    conda-forge
statsmodels               0.14.0          py311h59ca53f_1    conda-forge
sympy                     1.12               pyh04b8f61_3    conda-forge
tabledata                 1.3.1                    pypi_0    pypi
tables                    3.8.0                    pypi_0    pypi
tbb                       2021.9.0             h91493d7_0    conda-forge
tblib                     1.7.0              pyhd8ed1ab_0    conda-forge
tcolorpy                  0.1.3                    pypi_0    pypi
threadpoolctl             3.1.0              pyh8a188c0_0    conda-forge
tk                        8.6.12               h8ffe710_0    conda-forge
tmm                       0.1.8                    pypi_0    pypi
tmm-fast                  0.1                      pypi_0    pypi
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
toolz                     0.12.0             pyhd8ed1ab_0    conda-forge
torchaudio                2.0.2                 py311_cpu    pytorch
torchvision               0.15.2                py311_cpu    pytorch
tornado                   6.3.2           py311ha68e1ae_0    conda-forge
tqdm                      4.65.0             pyhd8ed1ab_1    conda-forge
traitlets                 5.9.0              pyhd8ed1ab_0    conda-forge
traittypes                0.2.1              pyh9f0ad1d_2    conda-forge
trio                      0.22.0          py311h1ea47a8_1    conda-forge
typepy                    1.3.0                    pypi_0    pypi
typing-extensions         4.6.3                hd8ed1ab_0    conda-forge
typing_extensions         4.6.3              pyha770c72_0    conda-forge
tzdata                    2023c                h71feb2d_0    conda-forge
uc-micro-py               1.0.1              pyhd8ed1ab_0    conda-forge
ucrt                      10.0.22621.0         h57928b3_0    conda-forge
urllib3                   2.0.3              pyhd8ed1ab_0    conda-forge
vc                        14.3                hb25d44b_16    conda-forge
vc14_runtime              14.36.32532         hfdfe4a8_16    conda-forge
vs2015_runtime            14.36.32532         h05e6639_16    conda-forge
wcwidth                   0.2.6              pyhd8ed1ab_0    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.40.0             pyhd8ed1ab_0    conda-forge
widgetsnbextension        4.0.7              pyhd8ed1ab_0    conda-forge
win_inet_pton             1.1.0              pyhd8ed1ab_6    conda-forge
xarray                    2023.5.0           pyhd8ed1ab_0    conda-forge
xorg-libxau               1.0.11               hcd874cb_0    conda-forge
xorg-libxdmcp             1.1.3                hcd874cb_0    conda-forge
xyzservices               2023.5.0           pyhd8ed1ab_1    conda-forge
xz                        5.2.6                h8d14728_0    conda-forge
yaml                      0.2.5                h8ffe710_2    conda-forge
yawrap                    0.4.10                   pypi_0    pypi
zarr                      2.15.0             pyhd8ed1ab_0    conda-forge
zeromq                    4.3.4                h0e60522_1    conda-forge
zict                      3.0.0              pyhd8ed1ab_0    conda-forge
zipp                      3.15.0             pyhd8ed1ab_0    conda-forge
zlib                      1.2.13               hcfcfb64_5    conda-forge
zstd                      1.5.2                h12be248_6    conda-forge

Thorlabs Kinesis enable_channel() Function

Alexey,

Just wanted to bring something I noticed to your attention.

The enable_channel() function which enables or disables a given channel returns an error message which I'm guessing you're aware of based on the comment '# seems not to work for most devices when tested' below;

image

However, this actually works as intended on the K-cube (KBD 101) controller (i.e it actually disables or enables the channel) even though this error message pops up. Wonder if there is a feedback on the backend (recv_comm to check whether channel is enabled or not) that is causing this error.

On my end this isn't a problem as I can ignore the error message but thought it's something worth sharing.

Thanks again for your great work.

Best Regards,
Manny

PicamLibError: Invalid Acquisition Buffer on measurements with binning != 1

Hello,

I run into issues when trying to set ROIs with x and/or y binning using the picam library and a PYLon BR Excelon camera. The trace is the following:

cam = PI.PicamCamera('555555') #With serial number for my camera
cam.set_roi(hstart=0, hend=1340, vstart=0, vend=100, hbin=2, vbin=1)
#(0, 1340, 0, 100, 2, 1)
cam.grab()
PicamLibError                             Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_5820/57262705.py in <module>
----> 1 cam.grab()

~\.conda\envs\pmd_dev\lib\site-packages\pylablib\devices\interface\camera.py in grab(self, nframes, frame_timeout, missing_frame, return_info, buff_size)
    524         acq_params=self._get_grab_acquisition_parameters(nframes,buff_size)
    525         frames,info=[],[]
--> 526         self.start_acquisition(**acq_params)
    527         try:
    528             while len(frames)<nframes:

~\.conda\envs\pmd_dev\lib\site-packages\pylablib\devices\PrincetonInstruments\picam.py in start_acquisition(self, *args, **kwargs)
    498         self._frame_counter.reset(self._acq_params["nframes"])
    499         self._commit_parameters()
--> 500         lib.Picam_StartAcquisition(self.handle)
    501     def stop_acquisition(self):
    502         if self.acquisition_in_progress():

<string> in <lambda>(camera)

~\.conda\envs\pmd_dev\lib\site-packages\pylablib\core\utils\ctypes_wrap.py in wrapped_func(*vargs, **kwargs)
    276                     return a
    277             call_args=[_to_call_arg(n,t,a) for (n,t,a) in zip(argnames,prep_argtypes,func_args)]
--> 278             retval=func(*call_args)
    279             res=self._convert_results(rvals or [None],dict(zip(argnames,func_args)),retval,kwargs,rconv)
    280             if (not self.tuple_single_retval) and len(res)==0:

~\.conda\envs\pmd_dev\lib\site-packages\pylablib\devices\PrincetonInstruments\picam_lib.py in errchecker(result, func, arguments)
     42     def errchecker(result, func, arguments):  # pylint: disable=unused-argument
     43         if result not in passing:
---> 44             raise PicamLibError(func.__name__,result,lib=lib)
     45         return result
     46     return errchecker

PicamLibError: function 'Picam_StartAcquisition' raised error 30(PicamError_InvalidAcquisitionBuffer): Invalid Acquisition Buffer

Interestingly, if I do the following I am able to grab one single frame correctly and then I get a different error.

cam = PI.PicamCamera('555555') #With serial number for my camera
cam.set_roi(hstart=0, hend=1340, vstart=0, vend=100, hbin=2, vbin=1)
#(0, 1340, 0, 100, 2, 1)
cam.start_acquisition()
cam.read_oldest_image()
# array([[ 8642,  8930,  8769, ..., 10725, 10941, 11006],
#       [ 9702,  9723,  9791, ..., 11412, 11205, 11122],
#       [10224, 10151, 10315, ..., 12148, 11835, 12082],
#       ...,
#       [59284, 58933, 58707, ..., 64423, 64048, 64103],
#       [59473, 59159, 59371, ..., 64822, 65382, 64892],
#       [57627, 57855, 57832, ..., 62657, 63563, 62808]], dtype=uint16)
_.shape 
(100, 670)
cam.read_oldest_image()
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_4736/680920542.py in <module>
----> 1 cam.read_oldest_image()

~\.conda\envs\pmd_dev\lib\site-packages\pylablib\devices\interface\camera.py in read_oldest_image(self, peek, return_info)
    474         If ``return_info==True``, return tuple ``(frame, info)``, where ``info`` is an info tuples (camera-dependent, see :meth:`read_multiple_images`).
    475         """
--> 476         rng=self.get_new_images_range()
    477         if rng is None or rng[0]==rng[1]:
    478             return None

~\.conda\envs\pmd_dev\lib\site-packages\pylablib\devices\interface\camera.py in get_new_images_range(self)
    403         If some images were in the buffer were overwritten, exclude them from the range.
    404         """
--> 405         acquired_frames=self._get_acquired_frames()
    406         if acquired_frames is None:
    407             return None

~\.conda\envs\pmd_dev\lib\site-packages\pylablib\devices\PrincetonInstruments\picam.py in _get_acquired_frames(self)
    528                     break
    529     def _get_acquired_frames(self):
--> 530         self._wait_for_acquisition_update(reps=3)
    531         return self._waited_frames
    532 

~\.conda\envs\pmd_dev\lib\site-packages\pylablib\devices\PrincetonInstruments\picam.py in _wait_for_acquisition_update(self, timeout, reps)
    521                 try:
    522                     avail,_=lib.Picam_WaitForAcquisitionUpdate(self.handle,timeout)
--> 523                     assert avail.initial_readout==ctypes.addressof(self._buffer)+(self._waited_frames%self._buffer_frames)*self._frame_bytes
    524                     self._waited_frames+=avail.readout_count
    525                 except PicamLibError as err:

AssertionError:

Any idea why it should be the case?

IMAQ superfluous copy

Hi Alexey,

First of all, wonderful work on implementing interfaces to so many varieties of instruments!

I have especially benefited a lot from the IMAQ interface for my own project, where I need to interact with an NI PCIe-1433 frame grabber. Although it has been working smoothly, I have one suggestion regarding the performance enhancement. Specifically, I am referring to this line of code in IMAQ.py. The call to numpy.ndarray.copy() looks superfluous to me, as it only increases memory footprint and execution time. For a better performance, one can just return data. At least with my unexhaustive tests, this replacement works well. On the other hand, the gain is sizable, as now I can handle more throughput.

Cheers,
Xiangcheng

Slow snap() with Thorlabs CMOS USB camera

Hi,
I'm trying to use a Thorlabs Scientific Imaging CMOS USB camera (CS505MU) with pylablib. Camera works fine with Thorcam, but frame acquisition is very slow in pylablib (takes about 300ms) while camera can go up to 50fps in principle. Do you have any idea of where could be the issue ?

Many thanks,
Jon

without“DETECTOR.INI”

I try to load dll files to initialize Python class with code
1697988119124
However, it returns 20002 which means failed.
I find that there is no “DETECTOR.INI” files in Andor SDK files which is necessary for initialize. So I learn the code of pylablib which also needs ini_path for class AndorSDK2camera. but why I run pylablib successfully eventhough there is no “DETECTOR.INI”?

Testing pylablib with Princeton Cameras

Hello,

I have started using pylablib last week and so far it's been a great experience, so I just wanted to say many thanks for your work!

I just read #2 and wanted to let you know that I have access to 2 PyLon cameras (Br_eXcelon). So far I am able to grab frames and it seems setting some basic settings. I will let you know if I encounter any problems.

But mostly, let me know if you want me to test anything in particular, I am more than happy to help

View of contributions

Hi! First of all, I'd like to thank you for making and maintaining this project. I have been automating lab equipment in Python (and sometimes Qt) for the last several years, and I was disappointed to see how little I was able to find when looking for people who have already solved this problem and published their code.

I have somehow only just now come across your project and I am very impressed. The amount of supported devices, the ease of use, and the extent of the documentation are all excellent. I wish more people did what you have done!

Which brings me to a few questions:

  1. Are you interested in contributions to the library from other people? I have successfully controlled a few devices that don't currently seem to be supported by pylablib and I could (after significantly cleaning up my lab-level just-get-it-done-ASAP code) possibly contribute some new functionality.
  2. If contributions are welcome, how do you view incomplete implementations? If I have a stage and have only implemented 20% of its capabilities, is that sufficient, or should I wait until my code can use 100% of the stage's functions?
  3. If contributions are welcome, what is the best way of going about adding some code?

Thank you again for this project and have a great day!

BSC 201 wait_move() continues non-stop

Hi Alexey,

Just wanted to point out a couple things I've noticed while using the BSC 201 Controller.

  1. There seems to be a mislabelling of the device model number. It seems to be 'SCC201' instead of 'BSC201'. Please find warning message below.
    image

  2. The wait_move() command seems not to return a response sometimes while other times it works fine i.e It keeps running even after the connected stage completes the motion. On the Kinesis Software everything seems to be okay so I don't think it's a hardware problem.

image

I also forcefully stopped the code execution and checked the motion status of the stage using is_moving() and the response from this is true as well as the get_status() showing jogging_bk and jogging_fw even though no motion is happening on the device.

image

Any pointers as to why this could be happening will be appreciated. Let me know if there's any other information needed too.

Thanks,
Manny

Async read from Bitflow board

Hi
I have a BitFlow frame grabber and 2 cameras and I am trying to read from the cameras Async at the same time.
I was wondering if this is possible.

This is how the cameras are setup:
self.cam_1.setup_acquisition(mode="sequence", nframes=4, frame_merge=1)
self.cam_2.setup_acquisition(mode="sequence", nframes=4, frame_merge=1)

and This is how they are read (Currently sequential):
self.cam_1.wait_for_frame()
self.cam_2.wait_for_frame()

Getting a 3D color image from Thorlabs scientific Zelux camera

Hi,
I'm using pylablib.devices.Thorlabs.ThorlabsTLCamera in order to sample images from my Zelux camera (using grab or snap methods).
The returned image is 2d (gray-scale).
I'm using the same DLL's provided by Thorcam, and using the Thorcam software I can indeed capture color images.
Any idea how to get 3d images?
I'm using pyLabLib 1.4.1
Thanks

BSC201 does not detect as correct model

I am attempting to control an HDR50 stage from a BSC201 it has a serial number of 40163084.

When I attempt to run Thorlabs.KinesisMotor("40163084") I get the following error:

UserWarning: model number SCC201 doesn't match the device ID prefix 40(BSC101)
  warnings.warn("model number {} doesn't match the device ID prefix {}({})".format(model_no,port,port_model_no))
UserWarning: can't recognize motor model SCC201; setting all scales to internal units
  warnings.warn("can't recognize motor model {}; setting all scales to internal units".format(model))

I suppose I could ignore this easy enough, but I'd like to have accurate scaling when controlling the stage. Is there any way I can set my device parameters manually?

Hamamatsu synchronous readout mode

Hi,
Thanks a lot for pylalib, it helped me create a software to control easily my Hamamatsu ORCA Flash (C11440-22CU). Unfortunately I cannot find either in the API and in Pylablib if the mode "synchronous readout" in trigger exists ?
I can get internal trigger or external trigger and within the latter there is only level or edge trigger but the third one, synchronous readout is, to my knowledge not accessible. The Synchronous readout mode is made to get a continuous acquisition without having a global "readout time" in rolling shutter.
Are you aware of such a mode in the API or have you developed this in pylablib and I did not noticed ?
Thank you very much
Antoine

Function serial_readline() fails with error about type mismatch

When I call the function serial_readline() to read bytes off of my camera, I get an error about mismatched types. As best as I can tell, it seems to me that the wrapper function is checking whether pv is of type c_char_p (it is not, it is c_char_Array) and then tries to convert it to a c_char_p, which fails.

My code:

from pylablib.devices import IMAQ

IMAQ.list_cameras()
cam1 = IMAQ.IMAQCamera('img0.iid')
cam1.setup_serial_params(write_term='\r', datatype='str')

msg_transmitted = '*IDN?'
error_message = cam1.serial_write(msg_transmitted,timeout=1.0, term=None)

msg_received = cam1.serial_readline(timeout=1.0, datatype=None, maxn=1024)

Error output:

Traceback (most recent call last):

File "C:\Users\admin\Desktop\my_folder\test.py", line 28, in
msg_received = cam1.serial_readline(timeout=1.0, datatype=None, maxn=1024)

File "C:\Users\admin\anaconda3\lib\site-packages\pylablib\devices\IMAQ\IMAQ.py", line 397, in serial_readline
msg,_=lib.imgSessionSerialRead(self.sid,maxn,int(timeout*1000))

File "", line 1, in

File "C:\Users\admin\anaconda3\lib\site-packages\pylablib\core\utils\ctypes_wrap.py", line 271, in wrapped_func
func_args=self._prepare_arguments(argnames,prep_argtypes,kwargs,argprep)

File "C:\Users\admin\anaconda3\lib\site-packages\pylablib\core\utils\ctypes_wrap.py", line 175, in _prepare_arguments
cv=pv if isinstance(pv,t) else t(pv)

TypeError: bytes or integer address expected instead of c_char_Array_1025 instance

Thorlabs Kinesis trigger mode out_maxvel is inconsistent

The following function setup_kcube_trigio(trig1_mode="out_maxvel", trig1_pol=1) should declare a trigger output pulse when the stage reaches its maximum velocity.

Currently, the motor sends a trigger when the stage is in motion, not necessarily when the stage is at its maximum velocity.

This comes from a mapping in the kinesis.py file:

_p_kcube_trigio_mode=interface.EnumParameterClass("kcube_trigio_mode",{"off":0x00,
    "in_gpio":0x01,"in_relmove":0x02,"in_absmove":0x03,"in_home":0x04,
    "out_gpio":0x0A,"out_maxvel":0x0B,"out_pulse_fw":0x0D,"out_pulse_bk":0x0E,"out_pulse_move":0x0F,
    "out_lim_fw":0x10,"out_lim_bk":0x11,"out_lim_both":0x12})

According to the Thorlabs Communication Protocol (Issue 37) p 141, the relevant trigger mode for "max velocity" should be 0x0C, but it is currently implemented in pylablib as 0x0B. The Thorlabs manual suggests to me that 0x0B is for "in motion", which is consistent with what I am observing.

Is the mapping implemented in pylablib a deliberate override, or is this a simple typo?

Unit: KDC101
Ref: https://www.thorlabs.com/Software/Motion%20Control/APT_Communications_Protocol.pdf

Thorlabs Kinesis Motor "Device Not Opened" Error

Hello!

I am trying to communicate with a Thorlabs stage (HDR50) with the BSC201 Stepper Motor Controller, but I keep getting the following error when calling pylablib.devices.Thorlabs.KinesisMotor("40330594"):

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2023.1\plugins\python-ce\helpers\pydev\_pydevd_bundle\pydevd_exec2.py", line 3, in Exec
    exec(exp, global_vars, local_vars)
  File "<input>", line 1, in <module>
  File "C:\Users\lab\Documents\GitLab\tetons\venv\lib\site-packages\pylablib\devices\Thorlabs\kinesis.py", line 999, in __init__
    super().__init__(conn)
  File "C:\Users\lab\Documents\GitLab\tetons\venv\lib\site-packages\pylablib\devices\Thorlabs\kinesis.py", line 246, in __init__
    super().__init__(conn,timeout=timeout,is_rack_system=is_rack_system,default_axis=default_channel)
  File "C:\Users\lab\Documents\GitLab\tetons\venv\lib\site-packages\pylablib\devices\interface\stage.py", line 34, in __init__
    super().__init__(*args,**kwargs)
  File "C:\Users\lab\Documents\GitLab\tetons\venv\lib\site-packages\pylablib\devices\Thorlabs\kinesis.py", line 45, in __init__
    instr=comm_backend.new_backend(conn,backend=("auto","ft232"),term_write=b"",term_read=b"",timeout=timeout,
  File "C:\Users\lab\Documents\GitLab\tetons\venv\lib\site-packages\pylablib\core\devio\comm_backend.py", line 1569, in new_backend
    return backend(conn,**kwargs)
  File "C:\Users\lab\Documents\GitLab\tetons\venv\lib\site-packages\pylablib\core\devio\comm_backend.py", line 813, in __init__
    raise self.Error(e) from e
pylablib.devices.Thorlabs.base.ThorlabsBackendError: backend exception: D2XXException(3) ('Device Not Opened')

I can use pylablib.devices.Thorlabs.list_kinesis_devices() or print(comm_backend.list_backend_resources("ft232")) to show the device is detected:

[('40330594', 'APT Stepper Motor Controller')]

...and I can control the device in the Kinesis software ok.

Things I've tried with no luck:

  1. Using pylablib.devices.Thorlabs.BasicKinesisMotor (encountered same error)
  2. Using Python 3.6 and 3.10 (same issue in both)
  3. Using pylablib v1.4.1 and v1.4.0 (same issue in both)
  4. Reinstalling pylablib
  5. Power cycling, checking physical connections, etc.
  6. Using thorlabs_apt module which does seem to work, but I would prefer using pylablib :)

Thanks in advance!

Specs: Windows 10 64bit, PyCharm 2023.1.4, python 3.10, pylablib v1.4.1

SiliconSoftware compatibility broken with MicroEnable V

Some attribute names have changed in the SDK from MicroEnable IV to MicroEnable V, which leads to crashes when instantiating a Camera object relying on MicroEnable V:

  • CAMERA_LINK_CAMTYP is named CAMERA_LINK_CAMTYPE in MicroEnable V SDK
  • FG_GLOBAL_ACCESS is not defined for MicroEnable V applets, only in MicroEnable IV

By surrounding the few calls to these attributes with try/catch block (using CAMERA_LINK_CAMTYPE when CAMERA_LINK_CAMTYP fails) I have managed to make my application work with MicroEnable V framegrabber as it did with MicroEnable IV

Incorrect camera attribute limits

Hello,

While using pylablib.devices.IMAQdx, I've noticed that the camera attribute limits for exposure are being read as [0.5, 250] ms rather than the actual camera limits which are [0.1, 2000] ms (determined by using the manufacturer's software). This particular camera is from AmScope and I have found online that they have some incompatibilities with IMAQdx. Is it possible to set these parameters manually? Even when I delete the icd camera file IMAQdxOpenCamera recreates the same one, so I'm assuming these values are hard-coded somewhere...

I know this is more of a particular problem with the IMAQ library and not necessarily an issue in pylablib, but thank you in advance for any help :)

Thorlabs Kinesis - MPCX20 Issues

Hello,

I'm attempting to use the kinesis package to control a Thorlabs MPC220 controller. I've been able to connect and perform basic movements for a single channel using the move_to method, but many (useful) commands return errors.

For example, the methods home, is_moving, wait_move, and wait_for_stop all return the error:
ThorlabsError: unexpected command received: expected 0x042a, got 0x0491

The get_status and get_status_n methods return the error:
ThorlabsError: unexpected command received: expected 0x042a, got 0x0491

The get_device_info() method returns the error:
ThorlabsError: unexpected command received: expected 0x0006, got 0x0491

I can provide more examples of errors, but I think the common issue might be the MPC220 and MPC320 having a different message set than the class is expecting.

Do you have any recommendations of how to accommodate these types of motors?

Thank you,
-Zac

Function 'GetPreAmpGain' raised error 20066(DRV_P1INVALID)

I'm trying to set up control of an Andor iXon Ultra 888 using this library and can't connect due to a DRV_P1INVALID error raised in the execution of this line:

preamp_gain=self.GetPreAmpGain(pa)

which was called involved in the execution of

self.init_amp_mode(mode=self._start_amp_mode)

mode=mode or self.get_all_amp_modes()[0]

return lib.get_all_amp_modes()

following the original connection attempt,

from pylablib.devices import Andor
cam = Andor.AndorSDK2Camera()

Seems like it shouldn't matter, but just to be thorough this is using a pylablib-lightweight[devio,gui-pyqt5] installation on Windows 10.

Andor IDus does not connect

Hey,

I am currently trying to set up a Spectrometer.
for that I am using an older Andor Idus 490.

If I use the function Andor.get_cameras_number_SDK2() the feedback is 1 so I guess the implimentation of the dll worked

But if I try to connect the cam via cam = Andor.AndorSDK2Camera()

I get the following Error:

AndorSDK2LibError: function 'GetFastestRecommendedVSSpeed' raised error 20991(DRV_NOT_SUPPORTED)

is there a way I can solve this error?

best regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.