Thorlabs / Motion_Control_Examples

Software examples for Thorlabs motion control products (e.g. T-Cube, K-Cube, and benchtop brushless, DC, stepper, and Piezo motor controllers)
MIT License
75 stars 31 forks source link

Motor could not correctly control the translation stage. #59

Closed hosinonisiki closed 2 months ago

hosinonisiki commented 2 months ago

Setup: BSC202 connected with an FW103 filter wheel and an NRT100 translation stage. Communication is done through USB. Using .NET control in matlab.

Phenomenon: Send the following instructions in order:

filter.Home(4000)
filter.MoveTo(180, 1000)
stage.Home(4000)
stage.Stop(1000)
stage.MoveTo(360, 1000)
stage.MoveTo(180, 1000)
stage.MoveTo(361, 1000)

The filter wheel correctly homed and then rotated for half a turn. The stage started to move in one direction and timed out, which is as expected because the distance could not be covered in 4 seconds. This was to demonstrate that the communication is going well and the homing function is working normally. The motion is terminated correctly by calling Stop. Here comes the problem. After calling MoveTo(360, 1000), the stage stayed in place, as if the motor thought it was a filter wheel (since 0 equals 360 in degree). Calling MoveTo(180, 1000) caused the stage to move a tiny distance but in a obviously larger speed then usual. Finally by calling stage.MoveTo(361, 1000) an error was returned claiming the requested position could not be reached.

Code: Based on https://github.com/Thorlabs/Motion_Control_Examples/blob/main/Matlab/Benchtop/BSC20X/BSC20X.m

devCLI = NET.addAssembly([pwd '\libs\Thorlabs.MotionControl.DeviceManagerCLI.dll']);
genCLI = NET.addAssembly([pwd '\libs\Thorlabs.MotionControl.GenericMotorCLI.dll']);
motCLI = NET.addAssembly([pwd '\libs\Thorlabs.MotionControl.Benchtop.StepperMotorCLI.dll']);
import Thorlabs.MotionControl.DeviceManagerCLI.*
import Thorlabs.MotionControl.GenericMotorCLI.*
import Thorlabs.MotionControl.Benchtop.StepperMotorCLI.*
DeviceManagerCLI.BuildDeviceList();
serial_number = '70174744';
global device;
device = BenchtopStepperMotor.CreateBenchtopStepperMotor(serial_number);
device.Connect(serial_number);
optionTypeHandle = devCLI.AssemblyHandle.GetType('Thorlabs.MotionControl.DeviceManagerCLI.DeviceSettingsSectionBase+SettingsUseOptionType');
optionTypeEnums = optionTypeHandle.GetEnumValues();
factory = ThorlabsBenchtopStepperMotorSettingsFactory();
global filter stage;
filter = device.GetChannel(2);
filter.WaitForSettingsInitialized(5000);
filter.StartPolling(250);
motorConfiguration1 = filter.LoadMotorConfiguration(filter.DeviceID);
motorConfiguration1.LoadSettingsOption = optionTypeEnums.Get(1);
motorConfiguration1.DeviceSettingsName = 'FW103';
filter.SetSettings(factory.GetSettings(motorConfiguration1), true, false);
filter.EnableDevice();
pause(1);
stage = device.GetChannel(1);
stage.WaitForSettingsInitialized(5000);
stage.StartPolling(250);
motorConfiguration2 = stage.LoadMotorConfiguration(stage.DeviceID);
motorConfiguration2.LoadSettingsOption = optionTypeEnums.Get(1);
motorConfiguration2.DeviceSettingsName = 'NRT100';
stage.SetSettings(factory.GetSettings(motorConfiguration2), true, false);
stage.EnableDevice();
pause(1);
hosinonisiki commented 2 months ago

Solved.

Solution: Set the correct actuator in Kinesis.