Hi everyone,
I would like to control a Thorlabs Nanomax stage at our light sheet microscope using python. I am having troubles with the LoadSettings method from Kinesis as it keeps working unreliably, sometimes it loads, sometimes it fails. I have put together a simple code (please see below) just to test this. Even by running that piece of software it sometimes works and sometimes doesn’t. Thus, I was wondering if anyone has had similar issues and knows how to fix it. Any help and suggestions will be very much appreciated.
Many thanks in advance,
Veronika
import sys
from ctypes import CDLL, c_char_p
sys.path.append(“C:\Program Files\Thorlabs\Kinesis”)
serial_number_b = b""
serial_number = c_char_p(serial_number_b)
SDK = CDLL(
“C:\Program Files\Thorlabs\Kinesis\Thorlabs.MotionControl.Benchtop.StepperMotor.dll”
)
TLI_BuildDeviceList = SDK[“TLI_BuildDeviceList”]
SBC_Open = SDK[“SBC_Open”]
SBC_IsChannelValid = SDK[“SBC_IsChannelValid”]
SBC_LoadSettings = SDK[“SBC_LoadSettings”]
SBC_Close = SDK[“SBC_Close”]
def test():
status = TLI_BuildDeviceList()
if status != 0:
raise Exception(“BuildDeviceList failed %d” % status)
status = SBC_Open(serial_number)
if status != 0:
raise Exception("Open failed %d" % status)
try:
for channel_nr in range(1, 4):
is_valid = SBC_IsChannelValid(serial_number, channel_nr)
print("is channel %d valid: %s" % (channel_nr, is_valid))
is_loaded = SBC_LoadSettings(serial_number, channel_nr)
if not is_loaded:
raise Exception("LoadSettings failed %d" % status)
finally:
status = SBC_Close(serial_number)
if status != 0:
print("Close failed %d" % status)