Filter löschen
Filter löschen

Thorlabs Linear Stage LTS150 Long Travel Stage with Matlab

21 Ansichten (letzte 30 Tage)
Raha
Raha am 8 Mai 2023
Hi,
I have some trouble getting this stage to work in Matlab.
It works using the Throlabs App---Hence hardware is ok
I am able to read the serial number of the linear stage----> The test computer does see the hardware.
But when trying to connect to the device---Matlab thinks the stage is not connected.
Anyone else may have found a solution for this issue?
Thanks,
------------------- Code for future reference --------
% Load .dll files associated with the Thorlabs motor
NET.addAssembly('C:\Program Files\Thorlabs\Kinesis\Thorlabs.MotionControl.DeviceManagerCLI.dll');
NET.addAssembly('C:\Program Files\Thorlabs\Kinesis\Thorlabs.MotionControl.GenericMotorCLI.dll');
NET.addAssembly('C:\Program Files\Thorlabs\Kinesis\Thorlabs.MotionControl.IntegratedStepperMotorsCLI.dll')
%NET.addAssembly('C:\Program Files\Thorlabs\Kinesis\ThorLabs.MotionControl.VerticalStageCLI.dll')
import Thorlabs.MotionControl.DeviceManagerCLI.*
import Thorlabs.MotionControl.GenericMotorCLI.*
import Thorlabs.MotionControl.GenericMotorCLI.ControlParameters.*
import Thorlabs.MotionControl.GenericMotorCLI.AdvancedMotor.*
import Thorlabs.MotionControl.GenericMotorCLI.Settings.*
import Thorlabs.MotionControl.IntegratedStepperMotorsCLI.*
%import ThorLabs.MotionControl.VerticalStageCLI.*
% Generate device list
Thorlabs.MotionControl.DeviceManagerCLI.DeviceManagerCLI.BuildDeviceList() % Build device list
serialNumbersNet = Thorlabs.MotionControl.DeviceManagerCLI.DeviceManagerCLI.GetDeviceList() % Get device list
serialNumbers = cell(ToArray(serialNumbersNet)) % Convert serial numbers to cell array
serial_no = serialNumbers{1} % shows correct serial number ('45357364')
device = LongTravelStage.CreateLongTravelStage(serial_no);%The output of this line must be suppressed
device.Connect(serial_no);
----------------

Antworten (2)

Garmit Pant
Garmit Pant am 25 Sep. 2023
Hello Raha
I understand that you are trying to connect a Thorlabs LTS150 to MATLAB using .NET functions but you are unable to establish the connection.
You can use the complete name of the module you want to use, i.e. ‘Thorlabs.MotionControl.IntegratedStepperMotorsCLI.LongTravelStage’, to call its functions. Please refer to the following code snippet:
clc;
clear all;
%Set up paths of the dll files required
MOTORPATHDEFAULT = 'C:\Program Files\Thorlabs\Kinesis\';
DEVICEMANAGERDLL= 'Thorlabs.MotionControl.DeviceManagerCLI.dll';
GENERICMOTORDLL= 'Thorlabs.MotionControl.GenericMotorCLI.dll';
INTSTEPPERMOTORDLL= 'Thorlabs.MotionControl.IntegratedStepperMotorsCLI.dll';
%Load .dll files associated with the Thorlabs motor
asm_dev = NET.addAssembly([MOTORPATHDEFAULT, DEVICEMANAGERDLL]);
asm_gen = NET.addAssembly([MOTORPATHDEFAULT, GENERICMOTORDLL]);
asmInfo = NET.addAssembly([MOTORPATHDEFAULT, INTSTEPPERMOTORDLL]);
% Generate device list
Thorlabs.MotionControl.DeviceManagerCLI.DeviceManagerCLI.BuildDeviceList(); % Build device list
serialNumbers =Thorlabs.MotionControl.DeviceManagerCLI.DeviceManagerCLI.GetDeviceList(); % Get device list
serialNumbers = cell(ToArray(serialNumbers)); % Convert serial numbers to cell array
if isempty(serialNumbers)
short_warn('No Thorlabs stages found!');
return;
end
defaultSerialNr = '45357364'; % Correct Serial Number
deviceFound = any(strcmp(serialNumbers,defaultSerialNr)); %Try to check if the device is found
if deviceFound
DeviceNet = Thorlabs.MotionControl.IntegratedStepperMotorsCLI.LongTravelStage.CreateLongTravelStage(defaultSerialNr); %Create the .NET object
fprintf('Device found...');
else
short_warn('Device not found!');
fprintf('Devices available:\n');
fprintf('%s\n',serialNumbers{:});
fprintf('Expected: \n');
fprintf('%s\n',defaultSerialNr);
return;
end
fprintf('connecting...');
DeviceNet.ClearDeviceExceptions();
% Clears the the last device exceptions if any.
DeviceNet.ConnectDevice(defaultSerialNr);
DeviceNet.Connect(defaultSerialNr);
% Connects to the device with the supplied serial number.
For further understanding, you can also refer to ‘Thorlabs.MotionControl.DotNet_API.chm’ at ‘C:\Program Files\Thorlabs\Kinesis’
I hope this helps!
Best Regards
Garmit
  2 Kommentare
james ingham
james ingham am 11 Dez. 2023
Hi,
I hope you can help! I am trying to use the same stage as above but I get the following error when I try your code:
Message: Could not load file or assembly 'file:///C:\Program Files
(x86)\Thorlabs\Kinesis\Thorlabs.MotionControl.DeviceManagerCLI.dll' or one of its dependencies. An attempt was made to load a
program with an incorrect format.
Source: mscorlib
HelpLink: None
Am i doing something stupid? Any help would be much appriacted! The stage works in kensis so I know everything is working on that front.
James
james ingham
james ingham am 11 Dez. 2023
Sorry I figured this out as I had the wrong drivers. I redownloaded the correct thorlabs drivers and I get past this issue now. I still havent worked out how to acutally set and control the stage but I can connect to it at least thanks for your previous answers.

Melden Sie sich an, um zu kommentieren.


thaipadath johnson
thaipadath johnson am 21 Mai 2024
Bearbeitet: thaipadath johnson am 21 Mai 2024
im new to this. i am trying to figure the code and the way to connect the Thorlabs LTs300/M , .can anyone help me with this .

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by