1

I am trying to use Thorlabs Brushed Motor Controller with Raspberry Pi 4, Model B. But its own software is Windows based and so their .dll files are Windows based too I suppose. I am trying to use some libraries like pylablib and thorpy I couln't move the stage. I am sharing the example codes that I wrote.

from thorpy.comm.discovery import *
from thorpy import *

if name == 'main':
    from thorpy.message import *

    stages = list(discover_stages())
    print(stages)

When I tried to run this code it turns me empty series. Like []

from ctypes import cdll, c_float, c_int, POINTER

# Load the Thorlabs Kinesis DLL
kinesis = cdll.LoadLibrary("Thorlabs.MotionControl.KCube.BrushlessMotor.dll")

# Connect to the Kinesis controller
serial_number = 27001111  # Replace with the serial number of your controller
kinesis.CC_Open(serial_number)

# Set the motor speed
kinesis.CC_SetVelocityParams(serial_number, 0, 100, 100)

# Move the motor forward
kinesis.CC_MoveWithVelocity(serial_number, 0, 1)

# Wait for the motor to finish moving
while kinesis.CC_CheckStatus(serial_number, 0, 0) == 3:
    pass

# Move the motor back
kinesis.CC_MoveWithVelocity(serial_number, 0, -1)

# Wait for the motor to finish moving
while kinesis.CC_CheckStatus(serial_number, 0, 0) == 3:
    pass

# Disconnect from the controller
kinesis.CC_Close(serial_number)

for example when I use this code I got invalid ELF error so... I don't know what can I do. Can you guys please help ? What can I do else can you give me any idea how to do this ?

2
  • Welcome. "Invalid ELF" implies there are binaries used that were not compiled on or for the Pi -- perhaps the .dll. Where did you get that?
    – goldilocks
    Commented Mar 17, 2023 at 15:28
  • I couln't move the stage ... what's a stage?
    – jsotola
    Commented Mar 17, 2023 at 15:49

1 Answer 1

0

I'm not sure how it's done in thorpy, but pylablib on Linux would use a standard serial port interface. Therefore, first you need to figure out which device path (e.g., dev/ttyUSB0) corresponds to the controller, e.g., by plugging and unplugging it. Then you can supply this path when opening the connection:

conn = {"port":"/dev/ttyUSB0","baudrate":115200,"rtscts":True}  # intead of ttyUSB0 use the correct path
dev = Thorlabs.KinesisMotor(("serial",conn))  # can also be, e.g., KinesisPiezoMotor, depending on the device kind

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.