# Software control of a Thorlabs Nanomax stage

**URL:** <https://forum.microlist.org/t/software-control-of-a-thorlabs-nanomax-stage/1445>\
**Category:** Software\
**Created:** [June 22, 2021, 10:57am UTC](https://forum.microlist.org/t/software-control-of-a-thorlabs-nanomax-stage/1445 "2021-06-22T10:57:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![VroniPfann](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.microlist.org/vronipfann/32/804_2.png) [@VroniPfann](https://forum.microlist.org/u/VroniPfann)\
**Post date:** [June 22, 2021, 10:57am UTC](https://forum.microlist.org/t/software-control-of-a-thorlabs-nanomax-stage/1445/1 "2021-06-22T10:57:15Z")

</div>

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)
```
