-
Notifications
You must be signed in to change notification settings - Fork 0
/
kinesis.py
83 lines (65 loc) · 2.83 KB
/
kinesis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import clr
import os
import time
import sys
# Write in file paths of dlls needed.
clr.AddReference("C:\\Program Files\\Thorlabs\\Kinesis\\Thorlabs.MotionControl.DeviceManagerCLI.dll")
clr.AddReference("C:\\Program Files\\Thorlabs\\Kinesis\\Thorlabs.MotionControl.GenericMotorCLI.dll")
clr.AddReference("C:\\Program Files\\Thorlabs\\Kinesis\\ThorLabs.MotionControl.IntegratedStepperMotorsCLI.dll")
# Import functions from dlls.
from Thorlabs.MotionControl.DeviceManagerCLI import *
from Thorlabs.MotionControl.GenericMotorCLI import *
from Thorlabs.MotionControl.GenericMotorCLI.Settings import HomeSettings
from Thorlabs.MotionControl.IntegratedStepperMotorsCLI import *
from System import Decimal
def main():
"""The main entry point for the application"""
# Uncomment this line if you are using
# SimulationManager.Instance.InitializeSimulations()
try:
# Build device list.
DeviceManagerCLI.BuildDeviceList()
# create new device.
serial_no = "55342484" # Replace this line with your device's serial number.
device = CageRotator.CreateCageRotator(serial_no)
# Connect to device.
device.Connect(serial_no)
# Ensure that the device settings have been initialized.
if not device.IsSettingsInitialized():
device.WaitForSettingsInitialized(10000) # 10 second timeout.
assert device.IsSettingsInitialized() is True
# Start polling loop and enable device.
device.StartPolling(250) #250ms polling rate.
time.sleep(0.25)
device.EnableDevice()
time.sleep(0.25) # Wait for device to enable.
# set = device.GetHomingVelocity()
# print(set)
# Get Device Information and display description.
device_info = device.GetDeviceInfo()
print(device_info.Description)
# Load any configuration settings needed by the controller/stage.
device.LoadMotorConfiguration(serial_no, DeviceConfiguration.DeviceSettingsUseOptionType.UseDeviceSettings)
motor_config = device.LoadMotorConfiguration(serial_no)
# Call device methods.
print("Homing Device")
device.SetHomingVelocity(Decimal(15))
vel = device.GetHomingVelocity()
HomeSettings.HomeZeroOffset
print(vel)
# print(zero_offset)
can_home = device.CanHome
print(can_home)
device.Home(60000) # 60 second timeout.
print("Done")
# new_pos = Decimal(150.0) # Must be a .NET decimal.
# print(f'Moving to {new_pos}')
# device.MoveTo(new_pos, 60000) # 60 second timeout.
# print("Done")
# Stop polling loop and disconnect device before program finishes.
device.StopPolling()
device.Disconnect()
except Exception as e:
print(e)
if __name__ == "__main__":
main()