Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
dba8e9f
Add KDC101 class
adeshazer123 Nov 19, 2024
9cb8b7a
Update kdc101
adeshazer123 Nov 19, 2024
aae7bf6
Test and debug
nano713 Nov 19, 2024
a003d44
Update the initialization
adeshazer123 Nov 19, 2024
999ac9b
Comment out get_position
adeshazer123 Nov 19, 2024
3e6919a
import time
adeshazer123 Nov 19, 2024
93d898b
Update kinesis.py
nano713 Nov 19, 2024
9d86e28
Update kinesis.py
nano713 Nov 19, 2024
14ec645
Update stop and initialize methods
adeshazer123 Nov 19, 2024
26eab57
Merge branch 'dev/kc101_update' of https://github.com/adeshazer123/py…
adeshazer123 Nov 19, 2024
97f537d
Merge https://github.com/adeshazer123/pymodaq_plugins_thorlabs/tree/6…
nano713 Nov 20, 2024
257c834
Add suggestion where I tested with KDC101.
nano713 Nov 20, 2024
9358089
Merge pull request #9 from nano713/dev/kdc101_update
adeshazer123 Nov 20, 2024
0fac5ce
Add get_position and stop
adeshazer123 Nov 20, 2024
c9266b5
Merge branch 'dev/kc101_update' of https://github.com/adeshazer123/py…
adeshazer123 Nov 20, 2024
b0026ae
Add logger
adeshazer123 Nov 20, 2024
a1de23c
edit home and stop
adeshazer123 Nov 20, 2024
1cbe449
Utilize super for inheritance
adeshazer123 Nov 20, 2024
ddd1c86
Delete code
adeshazer123 Nov 20, 2024
cb330d9
Restore and update logger
adeshazer123 Nov 20, 2024
5801085
updateget_position
adeshazer123 Nov 20, 2024
7b0dda5
update move_rel
adeshazer123 Nov 20, 2024
ee5c59c
Update and add commands to daq_move
adeshazer123 Nov 21, 2024
f707133
Delete comments
adeshazer123 Nov 21, 2024
db232f6
update units
adeshazer123 Nov 21, 2024
68dfd25
update callback
adeshazer123 Nov 21, 2024
35bb5ea
test multiaxis = false
adeshazer123 Nov 21, 2024
86d046a
Remove units in params
adeshazer123 Dec 4, 2024
cb083db
Update default_units
adeshazer123 Dec 4, 2024
b1077b8
Added set_unitd and reset default_units
adeshazer123 Dec 4, 2024
0e2efdb
Update hardware
adeshazer123 Dec 4, 2024
3d9dfd9
Update units method
adeshazer123 Dec 4, 2024
514bb6f
Update set_units
adeshazer123 Dec 4, 2024
b726153
Update set_units correctly
adeshazer123 Dec 4, 2024
fddeb18
Add suggestion
nano713 Dec 5, 2024
9a3ce46
Edit comments
nano713 Dec 5, 2024
8b73ea7
Update params
adeshazer123 Dec 5, 2024
674f74b
delete comments
adeshazer123 Dec 5, 2024
22d96ec
Add suggestion in commit_settings, methods around units
nano713 Dec 5, 2024
7985ad8
delete kdc_move
adeshazer123 Dec 6, 2024
18549b2
delete kdc hardware
adeshazer123 Dec 6, 2024
2a721e0
Delete unused lines
nano713 Dec 6, 2024
2b1578a
Restore daq_move
adeshazer123 Dec 7, 2024
672337f
Restore kinesis
adeshazer123 Dec 7, 2024
f9fbf07
Merge adesha
nano713 Dec 12, 2024
a7cb24c
update params
nano713 Dec 12, 2024
c7a0ac9
Update params
nano713 Dec 12, 2024
840f056
Add suggestion in move_rel error.
nano713 Dec 16, 2024
c782772
Update move_rel
adeshazer123 Dec 17, 2024
545d736
Update README
adeshazer123 Dec 17, 2024
8de5a94
Merge https://github.com/PyMoDAQ/pymodaq_plugins_thorlabs into dev/kd…
adeshazer123 Dec 17, 2024
43704c0
Merge branch 'main' into dev/kdc101_update
nano713 Dec 17, 2024
55c931d
Merge branch 'dev/kc101_update' of https://github.com/adeshazer123/py…
nano713 Dec 17, 2024
686c3b6
Merge branch 'dev/kc101_update' of https://github.com/adeshazer123/py…
nano713 Dec 17, 2024
419e305
Delete comment
adeshazer123 Dec 17, 2024
9cfea1d
Update move_rel
nano713 Dec 17, 2024
36f4c26
Merge branch 'dev/kc101_update' of https://github.com/adeshazer123/py…
nano713 Dec 17, 2024
3bb45a5
Update class name
adeshazer123 Dec 17, 2024
9bbf20b
Merge branch 'dev/kc101_update' of https://github.com/adeshazer123/py…
nano713 Dec 17, 2024
ffe6e82
Update daq_move import
adeshazer123 Dec 17, 2024
897eb46
Update serial numbers
adeshazer123 Dec 17, 2024
253c9d2
Update serialnumbers
adeshazer123 Dec 17, 2024
bed4848
Merge branch 'dev/kc101_update' of https://github.com/adeshazer123/py…
nano713 Dec 17, 2024
c6a1c89
Add author
adeshazer123 Dec 18, 2024
7503035
Merge https://github.com/PyMoDAQ/pymodaq_plugins_thorlabs into dev/kd…
adeshazer123 Dec 21, 2024
89d74b3
Delete comments
adeshazer123 Jan 14, 2025
074f2bd
Merge branch 'main' of https://github.com/PyMoDAQ/pymodaq_plugins_tho…
adeshazer123 Jan 14, 2025
6c075f2
Merge branch 'dev/kdc101_update' of https://github.com/nano713/pymoda…
adeshazer123 Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Actuators
* **PRM1Z8_pylablib**: DC servo motorized 360° rotation mount (Thorlabs PRM1Z8) using the pylablib control module. The Thorlabs APT software should be installed: https://www.thorlabs.com/newgrouppage9.cfm?objectgroup_id=9019.
* **BrushlessDCMotor**: Kinesis control of DC Brushless Motor (tested with the BBD201 controller)
* **Kinesis_KPZ101**: Piezo Electric Stage Kinesis series (KPZ101)
* **Kinesis_KDC101**: DC Servo Motor Kinesis series (KDC101)


Viewer0D
Expand Down
130 changes: 130 additions & 0 deletions src/pymodaq_plugins_thorlabs/daq_move_plugins/daq_move_KDC101.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
from typing import Union, List, Dict
from pymodaq.control_modules.move_utility_classes import DAQ_Move_base, comon_parameters_fun, main, DataActuatorType,\
DataActuator
from pymodaq.utils.daq_utils import ThreadCommand
from pymodaq.utils.parameter import Parameter
from pymodaq_plugins_thorlabs.hardware.kinesis import serialnumbers_dcServo, DCservo as KDC101


class DAQ_Move_KDC101(DAQ_Move_base):
""" Instrument plugin class for an actuator.

This object inherits all functionalities to communicate with PyMoDAQ’s DAQ_Move module through inheritance via
DAQ_Move_base. It makes a bridge between the DAQ_Move module and the Python wrapper of a particular instrument.

Attributes:
-----------
controller: object
The particular object that allow the communication with the hardware, in general a python wrapper around the
hardware library.

"""
is_multiaxes = False
_axis_names: Union[List[str], Dict[str, int]] = {'1': 1}
_controller_units: Union[str, List[str]] = KDC101.default_units
_epsilon: Union[float, List[float]] = 0.2e-3
data_actuator_type = DataActuatorType.DataActuator

params = [
{'title': 'Serial Number:', 'name': 'serial_number', 'type': 'list',
'limits': serialnumbers_dcServo, 'value': serialnumbers_dcServo[0]},
] + comon_parameters_fun(is_multiaxes, axes_names=_axis_names, epsilon=_epsilon)

def ini_attributes(self):
self.controller: KDC101 = None


def get_actuator_value(self):
"""Get the current value from the hardware with scaling conversion.

Returns
-------
float: The position obtained after scaling conversion.
"""

pos = DataActuator(data=self.controller.get_position())
pos = self.get_position_with_scaling(pos)
return pos

def close(self):
"""Terminate the communication protocol"""
self.controller.close()

def commit_settings(self, param: Parameter):
"""Apply the consequences of a change of value in the detector settings

Parameters
----------
param: Parameter
A given parameter (within detector_settings) whose value has been changed by the user
"""
if param.name() == 'units':
self.controller.set_units(self.settings.child(('units')).value())
else:
pass

def ini_stage(self, controller=None):
"""Actuator communication initialization

Parameters
----------
controller: (object)
custom object of a PyMoDAQ plugin (Slave case). None if only one actuator by controller (Master case)

Returns
-------
info: str
initialized: bool
False if initialization failed otherwise True
"""
self.ini_stage_init(slave_controller=controller)

if self.is_master:
self.controller = KDC101()
self.controller.connect(self.settings['serial_number'])

info = "KDC101 DCServo initialized"
initialized = True
return info, initialized

def move_abs(self, value: DataActuator):
""" Move the actuator to the absolute target defined by value

Parameters
----------
value: (float) value of the absolute target positioning
"""

value = self.check_bound(value)
self.target_value = value
value = self.set_position_with_scaling(value)
self.controller.move_abs(value.value(), 60000)

def move_rel(self, value: DataActuator):
""" Move the actuator to the relative target actuator value defined by value

Parameters
----------
value: (float) value of the relative target positioning
"""
value = self.check_bound(self.current_position + value) - self.current_position
self.target_value = value + self.current_position
value = self.set_position_relative_with_scaling(value)


self.controller.move_rel(value.value(), 60000)

def move_home(self):
"""Call the reference method of the controller"""

self.controller.home(60000)

def stop_motion(self):
"""Stop the actuator and emits move_done signal"""

self.controller.stop()
self.emit_status(ThreadCommand('Update_Status', ['KDC101 DCServo stopped']))


if __name__ == '__main__':
main(__file__)
45 changes: 44 additions & 1 deletion src/pymodaq_plugins_thorlabs/hardware/kinesis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import clr
import sys
from typing import Dict
import time
import logging
logger = logging.getLogger(__name__)

from System import Decimal
from System import Action
Expand All @@ -19,13 +22,15 @@
clr.AddReference("Thorlabs.MotionControl.FilterFlipperCLI")
clr.AddReference("Thorlabs.MotionControl.Benchtop.BrushlessMotorCLI")
clr.AddReference("Thorlabs.MotionControl.KCube.PiezoCLI")
clr.AddReference("Thorlabs.MotionControl.KCube.DCServoCLI")

import Thorlabs.MotionControl.FilterFlipperCLI as FilterFlipper
import Thorlabs.MotionControl.IntegratedStepperMotorsCLI as Integrated
import Thorlabs.MotionControl.DeviceManagerCLI as Device
import Thorlabs.MotionControl.GenericMotorCLI as Generic
import Thorlabs.MotionControl.Benchtop.BrushlessMotorCLI as BrushlessMotorCLI
import Thorlabs.MotionControl.KCube.PiezoCLI as KCubePiezo
import Thorlabs.MotionControl.KCube.DCServoCLI as KCube

Device.DeviceManagerCLI.BuildDeviceList()
serialnumbers_integrated_stepper = [str(ser) for ser in
Expand All @@ -35,6 +40,7 @@
serialnumbers_brushless = [str(ser) for ser in
Device.DeviceManagerCLI.GetDeviceList(BrushlessMotorCLI.BenchtopBrushlessMotor.DevicePrefix)]
serialnumbers_piezo = [str(ser) for ser in Device.DeviceManagerCLI.GetDeviceList(KCubePiezo.KCubePiezo.DevicePrefix)]
serialnumbers_dcServo = [str(ser) for ser in Device.DeviceManagerCLI.GetDeviceList(KCube.KCubeDCServo.DevicePrefix)]


class Kinesis:
Expand Down Expand Up @@ -323,6 +329,43 @@ def get_position(self) -> float:
def stop(self):
pass

class DCservo(Kinesis):
default_units = 'mm'
def __init__(self):
self._device: KCube.KCubeDCServo = None

def connect(self, serial: int):
if serial in serialnumbers_dcServo:
self._device = KCube.KCubeDCServo.CreateKCubeDCServo(serial)
self._device.Connect(serial)
time.sleep(0.25)
self._device.StartPolling(250)
time.sleep(0.25)
self._device.EnableDevice()
time.sleep(0.25)

if not self._device.IsSettingsInitialized():
self._device.WaitForSettingsInitialized(10000)
assert self._device.IsSettingsInitialized() is True

servo_config = self._device.LoadMotorConfiguration(serial)
logger.info(f"Servo Configuration: {servo_config}")

def get_position(self):
return Decimal.ToDouble(self._device.get_DevicePosition())

def move_abs(self, position: float, callback=None):
self._device.MoveTo(Decimal(position), callback)

def move_rel(self, position: float, callback=None):
self._device.MoveRelative(Generic.MotorDirection.Forward, Decimal(position), callback)

def home(self, callback=None):
self._device.Home(callback)

def stop(self):
self._device.Stop(0)

if __name__ == '__main__':
controller = BrushlessDCMotor()
controller.connect(serialnumbers_brushless[0])
Expand All @@ -338,4 +381,4 @@ def stop(self):
print(f'Moving: {motor.is_moving}')
print(motor.get_target_position())

controller.close()
controller.close()