mslnz / msl-equipment Goto Github PK
View Code? Open in Web Editor NEWManage and communicate with equipment in the laboratory
License: MIT License
Manage and communicate with equipment in the laboratory
License: MIT License
KCubeStepperMotor<Thorlabs|KST101|26001683 at SDK::Thorlabs.MotionControl.KCube.StepperMotor.dll> FT_DeviceNotFound: The device could not be found. This can be generated if the function MotionControl.build_device_list() has not been called
Traceback (most recent call last):
File "test1.py", line 39, in
motor = record.connect()
File "C:\Users\USUARIO\Anaconda3\lib\site-packages\msl\equipment\record_types.py", line 274, in connect
return factory.connect(self, demo)
File "C:\Users\USUARIO\Anaconda3\lib\site-packages\msl\equipment\factory.py", line 103, in connect
return _connect(record)
File "C:\Users\USUARIO\Anaconda3\lib\site-packages\msl\equipment\factory.py", line 93, in _connect
return cls(_record)
File "C:\Users\USUARIO\Anaconda3\lib\site-packages\msl\equipment\resources\thorlabs\kinesis\kcube_stepper_motor.py", line 63, in init
super(KCubeStepperMotor, self).init(record, KCube_StepperMotor_FCNS)
File "C:\Users\USUARIO\Anaconda3\lib\site-packages\msl\equipment\resources\thorlabs\kinesis\motion_control.py", line 119, in init
self.open()
File "C:\Users\USUARIO\Anaconda3\lib\site-packages\msl\equipment\resources\thorlabs\kinesis\kcube_stepper_motor.py", line 1200, in open
self.sdk.SCC_Open(self._serial)
File "C:\Users\USUARIO\Anaconda3\lib\site-packages\msl\equipment\resources\thorlabs\kinesis\motion_control.py", line 130, in errcheck_api
self.raise_exception('{}: {}'.format(err_name, err_msg))
File "C:\Users\USUARIO\Anaconda3\lib\site-packages\msl\equipment\connection.py", line 88, in raise_exception
raise self._exception_handler('{!r}\n{}'.format(self, msg))
msl.equipment.exceptions.ThorlabsError: KCubeStepperMotor<Thorlabs|KST101|26001683 at SDK::Thorlabs.MotionControl.KCube.StepperMotor.dll>
FT_DeviceNotFound: The device could not be found. This can be generated if the function MotionControl.build_device_list() has not been called
I found the following error when using the function get_version_info()
from Avantes with Python 3.8.5 on Spyder:
Traceback (most recent call last):
File "C:\spas\Programs\Python\test_ava.py", line 17, in <module>
print(ava.get_version_info())
File "C:\Users\user1\Anaconda3\envs\env2\lib\site-packages\msl\equipment\resources\avantes\avaspec.py", line 631, in get_version_info
self.sdk.AVS_GetVersionInfo(self._handle, fpga, fm, dll)
ArgumentError: argument 2: <class 'TypeError'>: wrong type
I'm using the following code to test this error:
from msl.equipment import EquipmentRecord, ConnectionRecord, Backend
from msl.equipment.resources.avantes import MeasureCallback
from msl.equipment.resources.avantes.avaspec import SmoothingType, TriggerType, DarkCorrectionType, ControlSettingsType
record = EquipmentRecord(
manufacturer='Avantes',
model='AvaSpec-UCLS2048BCL-EVO-RS', # update for your device
serial='2011126U1', # update for your device
connection=ConnectionRecord(
# only specify the SDK filename and add the root directory to sys.path (see above)
address='SDK::./lib/avaspec3/avaspecx64.dll',
backend=Backend.MSL,
)
)
ava = record.connect()
print(ava.get_version_info())
ava.disconnect()
I have been using msl-equipment
for a few months, especially the Avantes subpackage. I recently had to reinstall my working environment and I decided to use a Miniconda virtual environment.
I am installing msl-equipment with pip
directly from github using the following command:
pip install msl-equipment@git+https://github.com/MSLNZ/msl-equipment.git
When I try to import a few modules using from msl.equipment import EquipmentRecord, ConnectionRecord, Backend
, I get the following error:
from msl.equipment import EquipmentRecord, ConnectionRecord, Backend
Traceback (most recent call last):
File "<ipython-input-3-08110628f66d>", line 1, in <module>
from msl.equipment import EquipmentRecord, ConnectionRecord, Backend
File "C:\Users\<user>\Miniconda3\envs\spas\lib\site-packages\msl\equipment\__init__.py", line 8, in <module>
from msl.equipment.record_types import (
File "C:\Users\<user>\Miniconda3\envs\spas\lib\site-packages\msl\equipment\record_types.py", line 30, in <module>
from .factory import (
File "C:\Users\<user>\Miniconda3\envs\spas\lib\site-packages\msl\equipment\factory.py", line 11, in <module>
from .resources import find_resource_class
File "C:\Users\<user>\Miniconda3\envs\spas\lib\site-packages\msl\equipment\resources\__init__.py", line 83, in <module>
importlib.import_module(root_pkg + '.' + filename[:-3])
File "C:\Users\<user>\Miniconda3\envs\spas\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\<user>\Miniconda3\envs\spas\lib\site-packages\msl\equipment\resources\dataray\datarayocx_32.py", line 75, in <module>
if Server32.is_interpreter():
AttributeError: type object 'Server32' has no attribute 'is_interpreter'
I am getting the following error when using function disconnect()
from Avantes with two devices. The error occurs only when two devices are used.
I'm using Python 3.8.1 with Sublime Text 3
Avantes<Avantes|AvaSpec-2048CL-EVO|1911274U1 at SDK::C:/AvaSpecX64-DLL_9.10.1.0/
avaspecx64.dll> The <_FuncPtr object at 0x000000563E61AEE0> function returned Fa
lse
Traceback (most recent call last):
File "junk/msl-test.py", line 92, in <module>
while time.time()-start_time < total_time:
KeyboardInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "junk/msl-test.py", line 110, in <module>
device.deactivate()
File "C:\Users\Marc\AppData\Local\Programs\Python\Python38\lib\site-packages\m
sl\equipment\resources\avantes\avaspec.py", line 230, in deactivate
self.sdk.AVS_Deactivate(self._handle)
File "C:\Users\Marc\AppData\Local\Programs\Python\Python38\lib\site-packages\m
sl\equipment\resources\avantes\avaspec.py", line 207, in _check_bool
self.raise_exception('The {} function returned False'.format(func))
File "C:\Users\Marc\AppData\Local\Programs\Python\Python38\lib\site-packages\m
sl\equipment\connection.py", line 85, in raise_exception
raise self._exception_handler('{!r}\n{}'.format(self, msg))
msl.equipment.exceptions.AvantesError: Avantes<Avantes|AvaSpec-2048CL-EVO|191127
4U1 at SDK::C:/AvaSpecX64-DLL_9.10.1.0/avaspecx64.dll>
The <_FuncPtr object at 0x000000563E61AEE0> function returned False
Avantes<Avantes|AvaSpec-2048CL-EVO|1911274U1 at SDK::C:/AvaSpecX64-DLL_9.10.1.0/
avaspecx64.dll> The <_FuncPtr object at 0x000000563E61AEE0> function returned Fa
lse
Exception ignored in: <function Connection.__del__ at 0x000000562DF218B0>
Traceback (most recent call last):
File "C:\Users\Marc\AppData\Local\Programs\Python\Python38\lib\site-packages\m
sl\equipment\connection.py", line 74, in __del__
File "C:\Users\Marc\AppData\Local\Programs\Python\Python38\lib\site-packages\m
sl\equipment\resources\avantes\avaspec.py", line 506, in disconnect
File "C:\Users\Marc\AppData\Local\Programs\Python\Python38\lib\site-packages\m
sl\equipment\resources\avantes\avaspec.py", line 230, in deactivate
File "C:\Users\Marc\AppData\Local\Programs\Python\Python38\lib\site-packages\m
sl\equipment\resources\avantes\avaspec.py", line 207, in _check_bool
File "C:\Users\Marc\AppData\Local\Programs\Python\Python38\lib\site-packages\m
sl\equipment\connection.py", line 85, in raise_exception
msl.equipment.exceptions.AvantesError: Avantes<Avantes|AvaSpec-2048CL-EVO|191127
4U1 at SDK::C:/AvaSpecX64-DLL_9.10.1.0/avaspecx64.dll>
The <_FuncPtr object at 0x000000563E61AEE0> function returned False
The following code raises this error:
import time
from msl.equipment import EquipmentRecord, ConnectionRecord, Backend
from msl.equipment.resources.avantes.avaspec import ControlSettingsType
record1 = EquipmentRecord(
manufacturer='Avantes',
model='AvaSpec-2048CL-EVO', # update for your device
serial='1911275U1', # update for your device
connection=ConnectionRecord(
address='SDK::C:/AvaSpecX64-DLL_9.10.1.0/avaspecx64.dll', # update the path to the DLL file
backend=Backend.MSL,
)
)
record2 = EquipmentRecord(
manufacturer='Avantes',
model='AvaSpec-2048CL-EVO', # update for your device
serial='1911274U1', # update for your device
connection=ConnectionRecord(
address='SDK::C:/AvaSpecX64-DLL_9.10.1.0/avaspecx64.dll', # update the path to the DLL file
backend=Backend.MSL,
)
)
# initializes the Avantes SDK and establishes the connection to the spectrometer
ava1 = record1.connect()
ava2 = record2.connect()
## 1st device
params1 = ava1.get_parameter()
# get the number of pixels that the spectrometer has
num_pixels1 = ava1.get_num_pixels()
print('The spectrometer has %d pixels' % num_pixels1)
# get the wavelength value of each pixel
wavelengths1 = ava1.get_lambda()
# enable the 16-bit AD converter
ava1.use_high_res_adc(True)
# prepare the measurement type of the spectrometer
# (the values of just a few parameters are updated here, see the manual for more details)
cfg1 = ava1.MeasConfigType()
cfg1.m_StopPixel = num_pixels1 - 1
cfg1.m_IntegrationTime = 500 # in milliseconds
cfg1.m_NrAverages = 1 # number of averages
ava1.prepare_measure(cfg1)
## 2nd device
params2 = ava2.get_parameter()
# get the number of pixels that the spectrometer has
num_pixels2 = ava2.get_num_pixels()
print('The spectrometer has %d pixels' % num_pixels2)
# get the wavelength value of each pixel
wavelengths2 = ava2.get_lambda()
# enable the 16-bit AD converter
ava2.use_high_res_adc(True)
# prepare the measurement type of the spectrometer
# (the values of just a few parameters are updated here, see the manual for more details)
cfg2 = ava2.MeasConfigType()
cfg2.m_StopPixel = num_pixels2 - 1
cfg2.m_IntegrationTime = 500 # in milliseconds
cfg2.m_NrAverages = 1 # number of averages
CST = ControlSettingsType()
CST.m_StrobeControl = 3
cfg2.m_Control = CST
ava2.prepare_measure(cfg2)
DeviceConfig = ava2.get_parameter()
SpectrumCalibration = DeviceConfig.m_Reflectance
Smoothing = SpectrumCalibration.m_Smoothing
Smoothing.m_SmoothPix = 1
print(DeviceConfig.m_Reflectance.m_Smoothing.m_SmoothPix)
ava2.set_parameter(DeviceConfig)
DeviceConfig = ava2.get_parameter()
print(DeviceConfig.m_Reflectance.m_Smoothing.m_SmoothPix)
print(len(ava2.get_lambda()))
total_time = 600
meas_interval1 = 2
start_time = time.time()
elapsed_time1 = time.time()
devices = [ava1, ava2]
try:
while time.time()-start_time < total_time:
# measurement loop
if elapsed_time1 > meas_interval1:
last_measure_time1 = time.time()
# start single measurement, wait until the measurement is finished, then get the data
for ava in devices :
ava.measure(1)
while not (ava2.poll_scan() and ava1.poll_scan()):
time.sleep(0.01)
print(ava1.poll_scan(),ava2.poll_scan())
for ava in devices:
time_count,data = ava.get_data()
print("measured {}".format(ava._handle),len(data))
elapsed_time1 = time.time() - last_measure_time1
except KeyboardInterrupt:
for device in devices:
device.deactivate()
device.disconnect()
Hi, sorry to bother again.. im running into troubles when running:
motor.load_settings()
ThorlabsError Traceback (most recent call last)
in ()
1 # load the configuration settings (so that we can use the get_real_value_from_device_unit() method)
----> 2 motory.load_settings()
C:\Users\USUARIO\Anaconda3\envs\motorcitos\lib\site-packages\msl\equipment\resources\thorlabs\kinesis\kcube_stepper_motor.py in load_settings(self)
1056 If not successful.
1057 """
-> 1058 self.sdk.SCC_LoadSettings(self._serial)
1059
1060 def load_named_settings(self, settings_name):
C:\Users\USUARIO\Anaconda3\envs\motorcitos\lib\site-packages\msl\equipment\resources\thorlabs\kinesis\motion_control.py in errcheck_true(self, result, func, args)
136 if not result:
137 msg = '{}.{}{} -> {}'.format(self.class.name, func.name, args, result)
--> 138 self.raise_exception('The function did not return True.\n' + msg)
139 return result
140
C:\Users\USUARIO\Anaconda3\envs\motorcitos\lib\site-packages\msl\equipment\connection.py in raise_exception(self, msg)
86 """
87 self.log_error('{!r} {}'.format(self, msg))
---> 88 raise self._exception_handler('{!r}\n{}'.format(self, msg))
89
90 @staticmethod
ThorlabsError: KCubeStepperMotor<Thorlabs|KST101|26001718 at SDK::Thorlabs.MotionControl.KCube.StepperMotor.dll>
The function did not return True.
KCubeStepperMotor.SCC_LoadSettings(b'26001718',) -> False
Hi,
executing the example code in
https://github.com/MSLNZ/msl-equipment/blob/main/msl/examples/equipment/thorlabs/bsc201.py
sometimes works fine - sometimes I get
OSError: [WinError -529697949] Windows Error 0xe06d7363
I have to mention that I actually got the two BSC203 (3 channel controllers)
Kinesis Verion 1.14.30
Python 3.9.7 (Anaconda)
I tried to run msl\examples\equipment\resources\kdc101.py
to control an MT550/M-Z8 with KDC101 but always get an Overload error on the display of the hardware box. I need to reboot after this. Furthermore, the sound when moving is much different than when suing the Kenesis GUI. The pitch is much higher.
This simplified script reproduces the error:
import os
import time
from msl.equipment import EquipmentRecord, ConnectionRecord, Backend
from msl.equipment.resources.thorlabs.kinesis.enums import UnitType
from msl.equipment import EquipmentRecord, ConnectionRecord, Backend
# you must update the following values
kinesis_path = 'C:/Program Files/Thorlabs/Kinesis'
serial_number = '27002488'
# the Thorlabs.MotionControl.KCube.DCServo.dll depends on other DLLs from Thorlabs
# make sure to add the Kinesis folder to the environment PATH
os.environ['PATH'] += os.pathsep + kinesis_path
record = EquipmentRecord(
manufacturer='Thorlabs',
model='KDC101',
serial=serial_number,
connection=ConnectionRecord(
backend=Backend.MSL,
address='SDK::KCubeDCServo::Thorlabs.MotionControl.KCube.DCServo.dll',
),
)
motor = record.connect()
print(motor)
motor.identify()
time.sleep(5)
motor.start_polling(250)
info = motor.get_hardware_info()
print('Found device: {}'.format(info.notes))
before = motor.get_move_relative_distance()
new = 2
motor.set_move_relative_distance(new)
time.sleep(1)
after = motor.get_move_relative_distance()
print(f'Old distance {before}, desired, {new}, got {after}')
print('Start position', motor.get_position())
motor.get_position()
time.sleep(1)
motor.move_relative_distance()
time.sleep(1)
print('End position', motor.get_position())
motor.get_position()
time.sleep(1)
motor.stop_polling()
motor.close()
produces this kind of output:
Failed to open C:\ProgramData\Thorlabs\MotionControl\ThorlabsCustomSettings.xml, error id=2, No such file or directory
XMLDocument error id=3 str1=C:\ProgramData\Thor str2=
Failed to open C:\ProgramData\Thorlabs\MotionControl\ThorlabsSettingsOverrides.xml, error id=2, No such file or directory
XMLDocument error id=3 str1=C:\ProgramData\Thor str2=
Failed to open C:\ProgramData\Thorlabs\MotionControl\ThorlabsCustomSettings.xml, error id=2, No such file or directory
XMLDocument error id=3 str1=C:\ProgramData\Thor str2=
Failed to open C:\ProgramData\Thorlabs\MotionControl\ThorlabsSettingsOverrides.xml, error id=2, No such file or directory
XMLDocument error id=3 str1=C:\ProgramData\Thor str2=
KCubeDCServo<Thorlabs|KDC101|27002488>
Found device: b'KDC101 DC Servo Drive'
Old distance 2, desired, 2, got 2
Start position 0
End position -1212
The number of the end position is always different. The use of other move functions such as move_to_position
result in the same error.
I am on Windows 10 Home 64 bit with the 64 bit DLLs and use Python 3.6
'3.6.5 | packaged by conda-forge | (default, Apr 6 2018, 16:13:55) [MSC v.1900 64 bit (AMD64)]'
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.